Skip to content

Commit 5057318

Browse files
Merge pull request #23 from Sightem/test-clean-v17
Fix regression test crashes and fix GlobalISel unit tests
2 parents 4b56c30 + 5685f33 commit 5057318

6 files changed

Lines changed: 83 additions & 78 deletions

File tree

llvm/lib/Target/Z80/GISel/Z80LegalizerInfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ Z80LegalizerInfo::Z80LegalizerInfo(const Z80Subtarget &STI,
148148

149149
getActionDefinitionsBuilder({G_ZEXT, G_ANYEXT})
150150
.legalForCartesianProduct(LegalScalars, NotMaxWithOne)
151-
.widenScalarToNextPow2(0, 8)
152-
.widenScalarToNextPow2(1, 1)
153151
.clampScalar(0, *LegalScalars.begin(), *std::prev(LegalScalars.end()))
154152
.clampScalar(1, *NotMaxWithOne.begin(), *std::prev(NotMaxWithOne.end()));
155153

@@ -198,8 +196,6 @@ Z80LegalizerInfo::Z80LegalizerInfo(const Z80Subtarget &STI,
198196

199197
getActionDefinitionsBuilder(G_TRUNC)
200198
.legalForCartesianProduct(NotMaxWithOne, LegalScalars)
201-
.widenScalarToNextPow2(0, 1)
202-
.widenScalarToNextPow2(1, 8)
203199
.clampScalar(1, *LegalScalars.begin(), *std::prev(LegalScalars.end()))
204200
.clampScalar(0, *NotMaxWithOne.begin(), *std::prev(NotMaxWithOne.end()));
205201

llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,69 +24,92 @@ static cl::opt<bool> EscapeNonPrint(
2424
"Avoid outputting non-printable ascii characters to assembly files."),
2525
cl::Hidden);
2626

27+
cl::opt<bool> Z80GasStyle(
28+
"z80-gas-style",
29+
cl::desc("Use GAS style assembly syntax instead of FASMG style."),
30+
cl::NotHidden);
31+
2732
void Z80MCAsmInfoELF::anchor() { }
2833

2934
Z80MCAsmInfoELF::Z80MCAsmInfoELF(const Triple &T) {
3035
bool Is16Bit = T.isArch16Bit() || T.getEnvironment() == Triple::CODE16;
3136
CodePointerSize = CalleeSaveStackSlotSize = Is16Bit ? 2 : 3;
3237
MaxInstLength = 6;
33-
DollarIsPC = true;
34-
SeparatorString = nullptr;
38+
39+
// Common to both GAS and fasmg
3540
CommentString = ";";
36-
PrivateGlobalPrefix = PrivateLabelPrefix = "";
37-
Code16Directive = "assume\tadl = 0";
38-
Code24Directive = "assume\tadl = 1";
41+
AscizDirective = nullptr;
3942
Code32Directive = Code64Directive = nullptr;
43+
UseIntegratedAssembler = false;
4044
AssemblerDialect = !Is16Bit;
41-
SupportsQuotedNames = false;
42-
ZeroDirective = AscizDirective = nullptr;
43-
BlockSeparator = " dup ";
44-
AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
45-
NumberLiteralSyntax = ANLS_PlainDecimal;
46-
CharacterLiteralSyntax = ACLS_SingleQuotes;
47-
HasPairedDoubleQuoteStringConstants = true;
48-
HasBackslashEscapesInStringConstants = false;
49-
StringConstantsEscapeNonPrint = EscapeNonPrint;
50-
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
51-
Data16bitsDirective = "\tdw\t";
52-
Data24bitsDirective = "\tdl\t";
53-
Data32bitsDirective = "\tdd\t";
54-
Data64bitsDirective = "\tdq\t";
55-
DataULEB128Directive = "\tuleb128\t";
56-
DataSLEB128Directive = "\tsleb128\t";
57-
SectionDirective = "\tsection\t";
58-
AlwaysChangeSection = true;
59-
GlobalDirective = "\tpublic\t";
60-
LGloblDirective = "\tprivate\t";
61-
SetDirective = "\tlabel\t";
62-
SetSeparator = " at ";
6345
HasFunctionAlignment = false;
64-
HasDotTypeDotSizeDirective = false;
65-
IdentDirective = "\tident\t";
66-
WeakDirective = "\tweak\t";
67-
UseIntegratedAssembler = false;
68-
UseLogicalShr = false;
69-
HasSingleParameterDotFile = false;
70-
SupportsDebugInformation = SupportsCFI = true;
7146
ExceptionsType = ExceptionHandling::SjLj;
72-
DwarfFileDirective = "\tfile\t";
73-
DwarfLocDirective = "\tloc\t";
74-
DwarfCFIDirectivePrefix = "\tcfi_";
47+
48+
if (Z80GasStyle) {
49+
Code16Directive = ".assume\tADL = 0";
50+
Code24Directive = ".assume\tADL = 1";
51+
AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
52+
Data16bitsDirective = "\tdw\t";
53+
Data24bitsDirective = "\td24\t";
54+
Data32bitsDirective = "\td32\t";
55+
StringConstantsEscapeNonPrint = true;
56+
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
57+
} else {
58+
Code16Directive = "assume\tadl = 0";
59+
Code24Directive = "assume\tadl = 1";
60+
DollarIsPC = true;
61+
SeparatorString = nullptr;
62+
PrivateGlobalPrefix = PrivateLabelPrefix = "";
63+
SupportsQuotedNames = false;
64+
ZeroDirective = nullptr;
65+
BlockSeparator = " dup ";
66+
AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
67+
NumberLiteralSyntax = ANLS_PlainDecimal;
68+
CharacterLiteralSyntax = ACLS_SingleQuotes;
69+
HasPairedDoubleQuoteStringConstants = true;
70+
HasBackslashEscapesInStringConstants = false;
71+
StringConstantsEscapeNonPrint = EscapeNonPrint;
72+
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
73+
Data16bitsDirective = "\tdw\t";
74+
Data24bitsDirective = "\tdl\t";
75+
Data32bitsDirective = "\tdd\t";
76+
Data64bitsDirective = "\tdq\t";
77+
DataULEB128Directive = "\tuleb128\t";
78+
DataSLEB128Directive = "\tsleb128\t";
79+
SectionDirective = "\tsection\t";
80+
AlwaysChangeSection = true;
81+
GlobalDirective = "\tpublic\t";
82+
LGloblDirective = "\tprivate\t";
83+
SetDirective = "\tlabel\t";
84+
SetSeparator = " at ";
85+
HasDotTypeDotSizeDirective = false;
86+
IdentDirective = "\tident\t";
87+
WeakDirective = "\tweak\t";
88+
UseLogicalShr = false;
89+
HasSingleParameterDotFile = false;
90+
SupportsDebugInformation = SupportsCFI = true;
91+
DwarfFileDirective = "\tfile\t";
92+
DwarfLocDirective = "\tloc\t";
93+
DwarfCFIDirectivePrefix = "\tcfi_";
94+
}
7595
}
7696

7797
MCSection *Z80MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const {
7898
return nullptr;
7999
}
80100

81101
bool Z80MCAsmInfoELF::isAcceptableChar(char C) const {
82-
return MCAsmInfo::isAcceptableChar(C) || C == '%' || C == '^';
102+
return Z80GasStyle ? MCAsmInfo::isAcceptableChar(C) : (MCAsmInfo::isAcceptableChar(C) || C == '%' || C == '^');
83103
}
84104

85105
bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
86106
return false;
87107
}
88108

89109
const char *Z80MCAsmInfoELF::getBlockDirective(int64_t Size) const {
110+
if (Z80GasStyle) {
111+
return MCAsmInfoELF::getBlockDirective(Size);
112+
}
90113
switch (Size) {
91114
default: return nullptr;
92115
case 1: return "\tdb\t";
@@ -97,6 +120,9 @@ const char *Z80MCAsmInfoELF::getBlockDirective(int64_t Size) const {
97120
}
98121

99122
const char *Z80MCAsmInfoELF::getUnaryOperator(unsigned Opc) const {
123+
if (Z80GasStyle) {
124+
return MCAsmInfoELF::getUnaryOperator(Opc);
125+
}
100126
switch (Opc) {
101127
default: llvm_unreachable("unknown opcode");
102128
case MCUnaryExpr::LNot: return "~";
@@ -107,6 +133,9 @@ const char *Z80MCAsmInfoELF::getUnaryOperator(unsigned Opc) const {
107133
}
108134

109135
const char *Z80MCAsmInfoELF::getBinaryOperator(unsigned Opc) const {
136+
if (Z80GasStyle) {
137+
return MCAsmInfoELF::getBinaryOperator(Opc);
138+
}
110139
switch (Opc) {
111140
default: llvm_unreachable("unknown opcode");
112141
case MCBinaryExpr::Add: return "+";

llvm/test/CodeGen/Z80/intrinsics.ll

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ define i8 @abs.i8(i8) {
2020
; Z80-NEXT: ld a, l
2121
; Z80-NEXT: xor a, e
2222
; Z80-NEXT: ld l, a
23-
; Z80-NEXT: ld a, l
2423
; Z80-NEXT: ret
2524
;
2625
; EZ80-CODE16-LABEL: abs.i8:
@@ -38,7 +37,6 @@ define i8 @abs.i8(i8) {
3837
; EZ80-CODE16-NEXT: ld a, l
3938
; EZ80-CODE16-NEXT: xor a, e
4039
; EZ80-CODE16-NEXT: ld l, a
41-
; EZ80-CODE16-NEXT: ld a, l
4240
; EZ80-CODE16-NEXT: ret
4341
;
4442
; EZ80-LABEL: abs.i8:
@@ -56,7 +54,6 @@ define i8 @abs.i8(i8) {
5654
; EZ80-NEXT: ld a, l
5755
; EZ80-NEXT: xor a, e
5856
; EZ80-NEXT: ld l, a
59-
; EZ80-NEXT: ld a, l
6057
; EZ80-NEXT: ret
6158
call i8 @llvm.abs.i8(i8 %0, i1 false)
6259
ret i8 %2
@@ -3281,7 +3278,6 @@ define i8 @fshl.i8(i8, i8, i8) {
32813278
; Z80-NEXT: ld a, e
32823279
; Z80-NEXT: or a, l
32833280
; Z80-NEXT: ld l, a
3284-
; Z80-NEXT: ld a, l
32853281
; Z80-NEXT: ret
32863282
;
32873283
; EZ80-CODE16-LABEL: fshl.i8:
@@ -3309,7 +3305,6 @@ define i8 @fshl.i8(i8, i8, i8) {
33093305
; EZ80-CODE16-NEXT: ld a, e
33103306
; EZ80-CODE16-NEXT: or a, l
33113307
; EZ80-CODE16-NEXT: ld l, a
3312-
; EZ80-CODE16-NEXT: ld a, l
33133308
; EZ80-CODE16-NEXT: ret
33143309
;
33153310
; EZ80-LABEL: fshl.i8:
@@ -3337,7 +3332,6 @@ define i8 @fshl.i8(i8, i8, i8) {
33373332
; EZ80-NEXT: ld a, e
33383333
; EZ80-NEXT: or a, l
33393334
; EZ80-NEXT: ld l, a
3340-
; EZ80-NEXT: ld a, l
33413335
; EZ80-NEXT: ret
33423336
call i8 @llvm.fshl.i8(i8 %0, i8 %1, i8 %2)
33433337
ret i8 %4
@@ -3901,7 +3895,6 @@ define i8 @fshr.i8(i8, i8, i8) {
39013895
; Z80-NEXT: ld a, e
39023896
; Z80-NEXT: or a, l
39033897
; Z80-NEXT: ld l, a
3904-
; Z80-NEXT: ld a, l
39053898
; Z80-NEXT: ret
39063899
;
39073900
; EZ80-CODE16-LABEL: fshr.i8:
@@ -3929,7 +3922,6 @@ define i8 @fshr.i8(i8, i8, i8) {
39293922
; EZ80-CODE16-NEXT: ld a, e
39303923
; EZ80-CODE16-NEXT: or a, l
39313924
; EZ80-CODE16-NEXT: ld l, a
3932-
; EZ80-CODE16-NEXT: ld a, l
39333925
; EZ80-CODE16-NEXT: ret
39343926
;
39353927
; EZ80-LABEL: fshr.i8:
@@ -3957,7 +3949,6 @@ define i8 @fshr.i8(i8, i8, i8) {
39573949
; EZ80-NEXT: ld a, e
39583950
; EZ80-NEXT: or a, l
39593951
; EZ80-NEXT: ld l, a
3960-
; EZ80-NEXT: ld a, l
39613952
; EZ80-NEXT: ret
39623953
call i8 @llvm.fshr.i8(i8 %0, i8 %1, i8 %2)
39633954
ret i8 %4
@@ -5598,7 +5589,6 @@ define i1 @smul.with.overflow.i8(i8, i8) {
55985589
; Z80-NEXT: ld a, l
55995590
; Z80-NEXT: or a, e
56005591
; Z80-NEXT: ld l, a
5601-
; Z80-NEXT: ld a, l
56025592
; Z80-NEXT: or a, a
56035593
; Z80-NEXT: jr z, BB63_6
56045594
; Z80-NEXT: ; %bb.5:
@@ -5702,7 +5692,6 @@ define i1 @smul.with.overflow.i8(i8, i8) {
57025692
; EZ80-CODE16-NEXT: ld a, l
57035693
; EZ80-CODE16-NEXT: or a, e
57045694
; EZ80-CODE16-NEXT: ld l, a
5705-
; EZ80-CODE16-NEXT: ld a, l
57065695
; EZ80-CODE16-NEXT: or a, a
57075696
; EZ80-CODE16-NEXT: jr z, BB63_6
57085697
; EZ80-CODE16-NEXT: ; %bb.5:
@@ -5793,7 +5782,6 @@ define i1 @smul.with.overflow.i8(i8, i8) {
57935782
; EZ80-NEXT: ld a, l
57945783
; EZ80-NEXT: or a, e
57955784
; EZ80-NEXT: ld l, a
5796-
; EZ80-NEXT: ld a, l
57975785
; EZ80-NEXT: or a, a
57985786
; EZ80-NEXT: jr z, BB63_6
57995787
; EZ80-NEXT: ; %bb.5:
@@ -5916,7 +5904,6 @@ define i1 @smul.with.overflow.i16(i16, i16) {
59165904
; Z80-NEXT: ld a, l
59175905
; Z80-NEXT: or a, e
59185906
; Z80-NEXT: ld l, a
5919-
; Z80-NEXT: ld a, l
59205907
; Z80-NEXT: or a, a
59215908
; Z80-NEXT: jr z, BB64_6
59225909
; Z80-NEXT: ; %bb.5:
@@ -6005,7 +5992,6 @@ define i1 @smul.with.overflow.i16(i16, i16) {
60055992
; EZ80-CODE16-NEXT: ld a, l
60065993
; EZ80-CODE16-NEXT: or a, e
60075994
; EZ80-CODE16-NEXT: ld l, a
6008-
; EZ80-CODE16-NEXT: ld a, l
60095995
; EZ80-CODE16-NEXT: or a, a
60105996
; EZ80-CODE16-NEXT: jr z, BB64_6
60115997
; EZ80-CODE16-NEXT: ; %bb.5:
@@ -6102,7 +6088,6 @@ define i1 @smul.with.overflow.i16(i16, i16) {
61026088
; EZ80-NEXT: ld a, l
61036089
; EZ80-NEXT: or a, e
61046090
; EZ80-NEXT: ld l, a
6105-
; EZ80-NEXT: ld a, l
61066091
; EZ80-NEXT: or a, a
61076092
; EZ80-NEXT: jr z, BB64_6
61086093
; EZ80-NEXT: ; %bb.5:

llvm/test/CodeGen/Z80/operations.ll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ define i8 @and.i8(i8, i8) {
599599
; EZ80-NEXT: ld l, (iy + 6)
600600
; EZ80-NEXT: and a, l
601601
; EZ80-NEXT: ld l, a
602-
; EZ80-NEXT: ld a, l
603602
; EZ80-NEXT: ret
604603
and i8 %0, %1
605604
ret i8 %3
@@ -826,7 +825,6 @@ define i8 @or.i8(i8, i8) {
826825
; EZ80-NEXT: ld l, (iy + 6)
827826
; EZ80-NEXT: or a, l
828827
; EZ80-NEXT: ld l, a
829-
; EZ80-NEXT: ld a, l
830828
; EZ80-NEXT: ret
831829
or i8 %0, %1
832830
ret i8 %3
@@ -1053,7 +1051,6 @@ define i8 @xor.i8(i8, i8) {
10531051
; EZ80-NEXT: ld l, (iy + 6)
10541052
; EZ80-NEXT: xor a, l
10551053
; EZ80-NEXT: ld l, a
1056-
; EZ80-NEXT: ld a, l
10571054
; EZ80-NEXT: ret
10581055
xor i8 %0, %1
10591056
ret i8 %3
@@ -1280,7 +1277,6 @@ define i8 @add.i8(i8, i8) {
12801277
; EZ80-NEXT: ld l, (iy + 6)
12811278
; EZ80-NEXT: add a, l
12821279
; EZ80-NEXT: ld l, a
1283-
; EZ80-NEXT: ld a, l
12841280
; EZ80-NEXT: ret
12851281
add i8 %0, %1
12861282
ret i8 %3
@@ -1563,7 +1559,6 @@ define i8 @sub.i8(i8, i8) {
15631559
; EZ80-NEXT: ld l, (iy + 6)
15641560
; EZ80-NEXT: sub a, l
15651561
; EZ80-NEXT: ld l, a
1566-
; EZ80-NEXT: ld a, l
15671562
; EZ80-NEXT: ret
15681563
sub i8 %0, %1
15691564
ret i8 %3

0 commit comments

Comments
 (0)