@@ -24,54 +24,67 @@ static cl::opt<bool> EscapeNonPrint(
24
24
" Avoid outputting non-printable ascii characters to assembly files." ),
25
25
cl::Hidden);
26
26
27
+ // TODO: Put this somewhere more appropriate for a global
28
+ cl::opt<bool > GasStyle (
29
+ " z80-gas-style" ,
30
+ cl::desc (" Use GAS style assembly syntax instead of FASMG style." ),
31
+ cl::NotHidden);
32
+
27
33
void Z80MCAsmInfoELF::anchor () { }
28
34
29
35
Z80MCAsmInfoELF::Z80MCAsmInfoELF (const Triple &T) {
30
36
bool Is16Bit = T.isArch16Bit () || T.getEnvironment () == Triple::CODE16;
31
37
CodePointerSize = CalleeSaveStackSlotSize = Is16Bit ? 2 : 3 ;
32
38
MaxInstLength = 6 ;
33
- DollarIsPC = true ;
34
- SeparatorString = nullptr ;
35
- CommentString = " ;" ;
36
- PrivateGlobalPrefix = PrivateLabelPrefix = " " ;
37
- Code16Directive = " assume\t adl = 0" ;
38
- Code24Directive = " assume\t adl = 1" ;
39
- Code32Directive = Code64Directive = nullptr ;
40
- AssemblerDialect = !Is16Bit;
41
- SupportsQuotedNames = false ;
42
- ZeroDirective = AscizDirective = nullptr ;
43
- BlockSeparator = " dup " ;
44
- AsciiDirective = ByteListDirective = Data8bitsDirective = " \t db\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 = " \t dw\t " ;
52
- Data24bitsDirective = " \t dl\t " ;
53
- Data32bitsDirective = " \t dd\t " ;
54
- Data64bitsDirective = " \t dq\t " ;
55
- DataULEB128Directive = " \t uleb128\t " ;
56
- DataSLEB128Directive = " \t sleb128\t " ;
57
- SectionDirective = " \t section\t " ;
58
- AlwaysChangeSection = true ;
59
- GlobalDirective = " \t public\t " ;
60
- LGloblDirective = " \t private\t " ;
61
- SetDirective = " \t label\t " ;
62
- SetSeparator = " at " ;
63
- HasFunctionAlignment = false ;
64
- HasDotTypeDotSizeDirective = false ;
65
- IdentDirective = " \t ident\t " ;
66
- WeakDirective = " \t weak\t " ;
67
- UseIntegratedAssembler = false ;
68
- UseLogicalShr = false ;
69
- HasSingleParameterDotFile = false ;
70
- SupportsDebugInformation = SupportsCFI = true ;
71
- ExceptionsType = ExceptionHandling::SjLj;
72
- DwarfFileDirective = " \t file\t " ;
73
- DwarfLocDirective = " \t loc\t " ;
74
- DwarfCFIDirectivePrefix = " \t cfi_" ;
39
+
40
+ if (!GasStyle) {
41
+ DollarIsPC = true ;
42
+ SeparatorString = nullptr ;
43
+ CommentString = " ;" ;
44
+ PrivateGlobalPrefix = PrivateLabelPrefix = " " ;
45
+ Code16Directive = " assume\t adl = 0" ;
46
+ Code24Directive = " assume\t adl = 1" ;
47
+ Code32Directive = Code64Directive = nullptr ;
48
+ AssemblerDialect = !Is16Bit;
49
+ SupportsQuotedNames = false ;
50
+ ZeroDirective = AscizDirective = nullptr ;
51
+ BlockSeparator = " dup " ;
52
+ AsciiDirective = ByteListDirective = Data8bitsDirective = " \t db\t " ;
53
+ NumberLiteralSyntax = ANLS_PlainDecimal;
54
+ CharacterLiteralSyntax = ACLS_SingleQuotes;
55
+ HasPairedDoubleQuoteStringConstants = true ;
56
+ HasBackslashEscapesInStringConstants = false ;
57
+ StringConstantsEscapeNonPrint = EscapeNonPrint;
58
+ StringConstantsRequiredEscapes = {" \n\r\32 " , 4 }; // include null
59
+ Data16bitsDirective = " \t dw\t " ;
60
+ Data24bitsDirective = " \t dl\t " ;
61
+ Data32bitsDirective = " \t dd\t " ;
62
+ Data64bitsDirective = " \t dq\t " ;
63
+ DataULEB128Directive = " \t uleb128\t " ;
64
+ DataSLEB128Directive = " \t sleb128\t " ;
65
+ SectionDirective = " \t section\t " ;
66
+ AlwaysChangeSection = true ;
67
+ GlobalDirective = " \t public\t " ;
68
+ LGloblDirective = " \t private\t " ;
69
+ SetDirective = " \t label\t " ;
70
+ SetSeparator = " at " ;
71
+ HasFunctionAlignment = false ;
72
+ HasDotTypeDotSizeDirective = false ;
73
+ IdentDirective = " \t ident\t " ;
74
+ WeakDirective = " \t weak\t " ;
75
+ UseIntegratedAssembler = false ;
76
+ UseLogicalShr = false ;
77
+ HasSingleParameterDotFile = false ;
78
+ SupportsDebugInformation = SupportsCFI = true ;
79
+ ExceptionsType = ExceptionHandling::SjLj;
80
+ DwarfFileDirective = " \t file\t " ;
81
+ DwarfLocDirective = " \t loc\t " ;
82
+ DwarfCFIDirectivePrefix = " \t cfi_" ;
83
+ } else {
84
+ CommentString = " ;" ;
85
+ Code16Directive = Code24Directive = Code32Directive = Code64Directive = nullptr ;
86
+ UseIntegratedAssembler = false ;
87
+ }
75
88
}
76
89
77
90
MCSection *Z80MCAsmInfoELF::getNonexecutableStackSection (MCContext &Ctx) const {
@@ -89,10 +102,10 @@ bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
89
102
const char *Z80MCAsmInfoELF::getBlockDirective (int64_t Size) const {
90
103
switch (Size) {
91
104
default : return nullptr ;
92
- case 1 : return " \t db\t " ;
93
- case 2 : return " \t dw\t " ;
94
- case 3 : return " \t dl\t " ;
95
- case 4 : return " \t dd\t " ;
105
+ case 1 : return GasStyle ? " \t .byte " : " \t db\t " ;
106
+ case 2 : return GasStyle ? " \t .short " : " \t dw\t " ;
107
+ case 3 : return GasStyle ? " \t .long " : " \t dl\t " ;
108
+ case 4 : return GasStyle ? " \t .quad " : " \t dd\t " ;
96
109
}
97
110
}
98
111
0 commit comments