@@ -24,62 +24,74 @@ 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+
2732void Z80MCAsmInfoELF::anchor () { }
2833
2934Z80MCAsmInfoELF::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 ;
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_" ;
38+
39+ if (!Z80GasStyle) {
40+ DollarIsPC = true ;
41+ SeparatorString = nullptr ;
42+ CommentString = " ;" ;
43+ PrivateGlobalPrefix = PrivateLabelPrefix = " " ;
44+ Code16Directive = " assume\t adl = 0" ;
45+ Code24Directive = " assume\t adl = 1" ;
46+ Code32Directive = Code64Directive = nullptr ;
47+ AssemblerDialect = !Is16Bit;
48+ SupportsQuotedNames = false ;
49+ ZeroDirective = AscizDirective = nullptr ;
50+ BlockSeparator = " dup " ;
51+ AsciiDirective = ByteListDirective = Data8bitsDirective = " \t db\t " ;
52+ NumberLiteralSyntax = ANLS_PlainDecimal;
53+ CharacterLiteralSyntax = ACLS_SingleQuotes;
54+ HasPairedDoubleQuoteStringConstants = true ;
55+ HasBackslashEscapesInStringConstants = false ;
56+ StringConstantsEscapeNonPrint = EscapeNonPrint;
57+ StringConstantsRequiredEscapes = {" \n\r\32 " , 4 }; // include null
58+ Data16bitsDirective = " \t dw\t " ;
59+ Data24bitsDirective = " \t dl\t " ;
60+ Data32bitsDirective = " \t dd\t " ;
61+ Data64bitsDirective = " \t dq\t " ;
62+ DataULEB128Directive = " \t uleb128\t " ;
63+ DataSLEB128Directive = " \t sleb128\t " ;
64+ SectionDirective = " \t section\t " ;
65+ AlwaysChangeSection = true ;
66+ GlobalDirective = " \t public\t " ;
67+ LGloblDirective = " \t private\t " ;
68+ SetDirective = " \t label\t " ;
69+ SetSeparator = " at " ;
70+ HasFunctionAlignment = false ;
71+ HasDotTypeDotSizeDirective = false ;
72+ IdentDirective = " \t ident\t " ;
73+ WeakDirective = " \t weak\t " ;
74+ UseIntegratedAssembler = false ;
75+ UseLogicalShr = false ;
76+ HasSingleParameterDotFile = false ;
77+ SupportsDebugInformation = SupportsCFI = true ;
78+ ExceptionsType = ExceptionHandling::SjLj;
79+ DwarfFileDirective = " \t file\t " ;
80+ DwarfLocDirective = " \t loc\t " ;
81+ DwarfCFIDirectivePrefix = " \t cfi_" ;
82+ } else {
83+ CommentString = " ;" ;
84+ Code16Directive = Code24Directive = Code32Directive = Code64Directive = nullptr ;
85+ UseIntegratedAssembler = false ;
86+ }
7587}
7688
7789MCSection *Z80MCAsmInfoELF::getNonexecutableStackSection (MCContext &Ctx) const {
7890 return nullptr ;
7991}
8092
8193bool Z80MCAsmInfoELF::isAcceptableChar (char C) const {
82- return MCAsmInfo::isAcceptableChar (C) || C == ' %' || C == ' ^' ;
94+ return Z80GasStyle ? MCAsmInfo::isAcceptableChar (C) : ( MCAsmInfo::isAcceptableChar (C) || C == ' %' || C == ' ^' ) ;
8395}
8496
8597bool Z80MCAsmInfoELF::shouldOmitSectionDirective (StringRef SectionName) const {
@@ -89,10 +101,10 @@ bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
89101const char *Z80MCAsmInfoELF::getBlockDirective (int64_t Size) const {
90102 switch (Size) {
91103 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 " ;
104+ case 1 : return Z80GasStyle ? " \t .byte " : " \t db\t " ;
105+ case 2 : return Z80GasStyle ? " \t .short " : " \t dw\t " ;
106+ case 3 : return Z80GasStyle ? " \t .long " : " \t dl\t " ;
107+ case 4 : return Z80GasStyle ? " \t .quad " : " \t dd\t " ;
96108 }
97109}
98110
0 commit comments