Skip to content

Commit 49f8da5

Browse files
[Z80] improve gas syntax
1 parent 73b8fcf commit 49f8da5

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

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

+20-13
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ Z80MCAsmInfoELF::Z80MCAsmInfoELF(const Triple &T) {
3636
CodePointerSize = CalleeSaveStackSlotSize = Is16Bit ? 2 : 3;
3737
MaxInstLength = 6;
3838

39+
CommentString = ";";
40+
Code16Directive = ".assume\tadl = 0";
41+
Code24Directive = ".assume\tadl = 1";
42+
Code32Directive = Code64Directive = nullptr;
43+
UseIntegratedAssembler = false;
44+
AssemblerDialect = !Is16Bit;
45+
3946
if (!Z80GasStyle) {
4047
DollarIsPC = true;
4148
SeparatorString = nullptr;
42-
CommentString = ";";
4349
PrivateGlobalPrefix = PrivateLabelPrefix = "";
44-
Code16Directive = "assume\tadl = 0";
45-
Code24Directive = "assume\tadl = 1";
46-
Code32Directive = Code64Directive = nullptr;
47-
AssemblerDialect = !Is16Bit;
4850
SupportsQuotedNames = false;
4951
ZeroDirective = AscizDirective = nullptr;
5052
BlockSeparator = " dup ";
@@ -79,10 +81,6 @@ Z80MCAsmInfoELF::Z80MCAsmInfoELF(const Triple &T) {
7981
DwarfFileDirective = "\tfile\t";
8082
DwarfLocDirective = "\tloc\t";
8183
DwarfCFIDirectivePrefix = "\tcfi_";
82-
} else {
83-
CommentString = ";";
84-
Code16Directive = Code24Directive = Code32Directive = Code64Directive = nullptr;
85-
UseIntegratedAssembler = false;
8684
}
8785
}
8886

@@ -99,16 +97,22 @@ bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
9997
}
10098

10199
const char *Z80MCAsmInfoELF::getBlockDirective(int64_t Size) const {
100+
if (Z80GasStyle) {
101+
return MCAsmInfoELF::getBlockDirective(Size);
102+
}
102103
switch (Size) {
103104
default: return nullptr;
104-
case 1: return Z80GasStyle ? "\t.byte" : "\tdb\t";
105-
case 2: return Z80GasStyle ? "\t.short" : "\tdw\t";
106-
case 3: return Z80GasStyle ? "\t.long" : "\tdl\t";
107-
case 4: return Z80GasStyle ? "\t.quad" : "\tdd\t";
105+
case 1: return "\tdb\t";
106+
case 2: return "\tdw\t";
107+
case 3: return "\tdl\t";
108+
case 4: return "\tdd\t";
108109
}
109110
}
110111

111112
const char *Z80MCAsmInfoELF::getUnaryOperator(unsigned Opc) const {
113+
if (Z80GasStyle) {
114+
return MCAsmInfoELF::getUnaryOperator(Opc);
115+
}
112116
switch (Opc) {
113117
default: llvm_unreachable("unknown opcode");
114118
case MCUnaryExpr::LNot: return "~";
@@ -119,6 +123,9 @@ const char *Z80MCAsmInfoELF::getUnaryOperator(unsigned Opc) const {
119123
}
120124

121125
const char *Z80MCAsmInfoELF::getBinaryOperator(unsigned Opc) const {
126+
if (Z80GasStyle) {
127+
return MCAsmInfoELF::getBinaryOperator(Opc);
128+
}
122129
switch (Opc) {
123130
default: llvm_unreachable("unknown opcode");
124131
case MCBinaryExpr::Add: return "+";

0 commit comments

Comments
 (0)