Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/lib/Target/Z80/GISel/Z80CallLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
using namespace llvm;
using namespace MIPatternMatch;

cl::opt<bool> ReturnSRet("z80-return-sret", cl::desc("Return sret pointers"),
cl::init(true), cl::Hidden);
static cl::opt<bool> ReturnSRet("z80-return-sret", cl::desc("Return sret pointers"),
cl::init(true), cl::Hidden);

#define DEBUG_TYPE "z80-call-lowering"

Expand Down
106 changes: 59 additions & 47 deletions llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,74 @@ static cl::opt<bool> EscapeNonPrint(
"Avoid outputting non-printable ascii characters to assembly files."),
cl::Hidden);

cl::opt<bool> Z80GasStyle(
"z80-gas-style",
cl::desc("Use GAS style assembly syntax instead of FASMG style."),
cl::NotHidden);

void Z80MCAsmInfoELF::anchor() { }

Z80MCAsmInfoELF::Z80MCAsmInfoELF(const Triple &T) {
bool Is16Bit = T.isArch16Bit() || T.getEnvironment() == Triple::CODE16;
CodePointerSize = CalleeSaveStackSlotSize = Is16Bit ? 2 : 3;
MaxInstLength = 6;
DollarIsPC = true;
SeparatorString = nullptr;
CommentString = ";";
PrivateGlobalPrefix = PrivateLabelPrefix = "";
Code16Directive = "assume\tadl = 0";
Code24Directive = "assume\tadl = 1";
Code32Directive = Code64Directive = nullptr;
AssemblerDialect = !Is16Bit;
SupportsQuotedNames = false;
ZeroDirective = AscizDirective = nullptr;
BlockSeparator = " dup ";
AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
NumberLiteralSyntax = ANLS_PlainDecimal;
CharacterLiteralSyntax = ACLS_SingleQuotes;
HasPairedDoubleQuoteStringConstants = true;
HasBackslashEscapesInStringConstants = false;
StringConstantsEscapeNonPrint = EscapeNonPrint;
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
Data16bitsDirective = "\tdw\t";
Data24bitsDirective = "\tdl\t";
Data32bitsDirective = "\tdd\t";
Data64bitsDirective = "\tdq\t";
DataULEB128Directive = "\tuleb128\t";
DataSLEB128Directive = "\tsleb128\t";
SectionDirective = "\tsection\t";
AlwaysChangeSection = true;
GlobalDirective = "\tpublic\t";
LGloblDirective = "\tprivate\t";
SetDirective = "\tlabel\t";
SetSeparator = " at ";
HasFunctionAlignment = false;
HasDotTypeDotSizeDirective = false;
IdentDirective = "\tident\t";
WeakDirective = "\tweak\t";
UseIntegratedAssembler = false;
UseLogicalShr = false;
HasSingleParameterDotFile = false;
SupportsDebugInformation = SupportsCFI = true;
ExceptionsType = ExceptionHandling::SjLj;
DwarfFileDirective = "\tfile\t";
DwarfLocDirective = "\tloc\t";
DwarfCFIDirectivePrefix = "\tcfi_";

if (!Z80GasStyle) {
DollarIsPC = true;
SeparatorString = nullptr;
CommentString = ";";
PrivateGlobalPrefix = PrivateLabelPrefix = "";
Code16Directive = "assume\tadl = 0";
Code24Directive = "assume\tadl = 1";
Code32Directive = Code64Directive = nullptr;
AssemblerDialect = !Is16Bit;
SupportsQuotedNames = false;
ZeroDirective = AscizDirective = nullptr;
BlockSeparator = " dup ";
AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
NumberLiteralSyntax = ANLS_PlainDecimal;
CharacterLiteralSyntax = ACLS_SingleQuotes;
HasPairedDoubleQuoteStringConstants = true;
HasBackslashEscapesInStringConstants = false;
StringConstantsEscapeNonPrint = EscapeNonPrint;
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
Data16bitsDirective = "\tdw\t";
Data24bitsDirective = "\tdl\t";
Data32bitsDirective = "\tdd\t";
Data64bitsDirective = "\tdq\t";
DataULEB128Directive = "\tuleb128\t";
DataSLEB128Directive = "\tsleb128\t";
SectionDirective = "\tsection\t";
AlwaysChangeSection = true;
GlobalDirective = "\tpublic\t";
LGloblDirective = "\tprivate\t";
SetDirective = "\tlabel\t";
SetSeparator = " at ";
HasFunctionAlignment = false;
HasDotTypeDotSizeDirective = false;
IdentDirective = "\tident\t";
WeakDirective = "\tweak\t";
UseIntegratedAssembler = false;
UseLogicalShr = false;
HasSingleParameterDotFile = false;
SupportsDebugInformation = SupportsCFI = true;
ExceptionsType = ExceptionHandling::SjLj;
DwarfFileDirective = "\tfile\t";
DwarfLocDirective = "\tloc\t";
DwarfCFIDirectivePrefix = "\tcfi_";
} else {
CommentString = ";";
Code16Directive = Code24Directive = Code32Directive = Code64Directive = nullptr;
UseIntegratedAssembler = false;
}
}

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

bool Z80MCAsmInfoELF::isAcceptableChar(char C) const {
return MCAsmInfo::isAcceptableChar(C) || C == '%' || C == '^';
return Z80GasStyle ? MCAsmInfo::isAcceptableChar(C) : (MCAsmInfo::isAcceptableChar(C) || C == '%' || C == '^');
}

bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
Expand All @@ -89,10 +101,10 @@ bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
const char *Z80MCAsmInfoELF::getBlockDirective(int64_t Size) const {
switch (Size) {
default: return nullptr;
case 1: return "\tdb\t";
case 2: return "\tdw\t";
case 3: return "\tdl\t";
case 4: return "\tdd\t";
case 1: return Z80GasStyle ? "\t.byte" : "\tdb\t";
case 2: return Z80GasStyle ? "\t.short" : "\tdw\t";
case 3: return Z80GasStyle ? "\t.long" : "\tdl\t";
case 4: return Z80GasStyle ? "\t.quad" : "\tdd\t";
}
}

Expand Down
15 changes: 9 additions & 6 deletions llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
#include "Z80TargetStreamer.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"

using namespace llvm;

extern cl::opt<bool> Z80GasStyle;

Z80TargetStreamer::Z80TargetStreamer(MCStreamer &S)
: MCTargetStreamer(S) {}

Expand All @@ -32,34 +35,34 @@ void Z80TargetAsmStreamer::emitLabel(MCSymbol *Symbol) {

void Z80TargetAsmStreamer::emitAlign(Align Alignment) {
if (auto Mask = Alignment.value() - 1)
OS << "\trb\t($$ - $) and " << Mask << '\n';
Z80GasStyle ? OS << "\t.skip\t($$ - $) and " << Mask << '\n' : OS << "\trb\t($$ - $) and " << Mask << '\n';
}

void Z80TargetAsmStreamer::emitBlock(uint64_t NumBytes) {
if (NumBytes)
OS << "\trb\t" << NumBytes << '\n';
Z80GasStyle ? OS << "\t.skip\t" << NumBytes << '\n' : OS << "\trb\t" << NumBytes << '\n';
}

void Z80TargetAsmStreamer::emitLocal(MCSymbol *Symbol) {
OS << "\tprivate\t";
Z80GasStyle ? OS << "\t.local\t" : OS << "\tprivate\t";
Symbol->print(OS, MAI);
OS << '\n';
}

void Z80TargetAsmStreamer::emitWeakGlobal(MCSymbol *Symbol) {
OS << "\tweak\t";
Z80GasStyle ? OS << "\t.weak\t" : OS << "\tweak\t";
Symbol->print(OS, MAI);
OS << '\n';
}

void Z80TargetAsmStreamer::emitGlobal(MCSymbol *Symbol) {
OS << "\tpublic\t";
Z80GasStyle ? OS << "\t.global\t" : OS << "\tpublic\t";
Symbol->print(OS, MAI);
OS << '\n';
}

void Z80TargetAsmStreamer::emitExtern(MCSymbol *Symbol) {
OS << "\textern\t";
Z80GasStyle ? OS << "\t.extern\t" : OS << "\textern\t";
Symbol->print(OS, MAI);
OS << '\n';
}