mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
mcize lcomm, simplify .comm, extend both to support 64-bit sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f9f93e4388
commit
9eb158d5b4
@ -191,15 +191,10 @@ namespace llvm {
|
||||
/// the assembler to set the value of a variable to some expression.
|
||||
const char *SetDirective; // Defaults to null.
|
||||
|
||||
/// LCOMMDirective - This is the name of a directive (if supported) that can
|
||||
/// be used to efficiently declare a local (internal) block of zero
|
||||
/// initialized data in the .bss/.data section. The syntax expected is:
|
||||
/// @verbatim <LCOMMDirective> SYMBOLNAME LENGTHINBYTES
|
||||
/// @endverbatim
|
||||
const char *LCOMMDirective; // Defaults to null.
|
||||
/// HasLCOMMDirective - This is true if the target supports the .lcomm
|
||||
/// directive.
|
||||
bool HasLCOMMDirective; // Defaults to false.
|
||||
|
||||
const char *COMMDirective; // Defaults to "\t.comm\t".
|
||||
|
||||
/// COMMDirectiveTakesAlignment - True if COMMDirective take a third
|
||||
/// argument that specifies the alignment of the declaration.
|
||||
bool COMMDirectiveTakesAlignment; // Defaults to true.
|
||||
@ -404,12 +399,7 @@ namespace llvm {
|
||||
const char *getSetDirective() const {
|
||||
return SetDirective;
|
||||
}
|
||||
const char *getLCOMMDirective() const {
|
||||
return LCOMMDirective;
|
||||
}
|
||||
const char *getCOMMDirective() const {
|
||||
return COMMDirective;
|
||||
}
|
||||
bool hasLCOMMDirective() const { return HasLCOMMDirective; }
|
||||
bool getCOMMDirectiveTakesAlignment() const {
|
||||
return COMMDirectiveTakesAlignment;
|
||||
}
|
||||
|
@ -129,15 +129,21 @@ namespace llvm {
|
||||
/// @param DescValue - The value to set into the n_desc field.
|
||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
|
||||
|
||||
/// EmitCommonSymbol - Emit a common or local common symbol.
|
||||
/// EmitCommonSymbol - Emit a common symbol.
|
||||
///
|
||||
/// @param Symbol - The common symbol to emit.
|
||||
/// @param Size - The size of the common symbol.
|
||||
/// @param ByteAlignment - The alignment of the symbol if
|
||||
/// non-zero. This must be a power of 2 on some targets.
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
/// non-zero. This must be a power of 2.
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) = 0;
|
||||
|
||||
/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
|
||||
///
|
||||
/// @param Symbol - The common symbol to emit.
|
||||
/// @param Size - The size of the common symbol.
|
||||
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) = 0;
|
||||
|
||||
/// EmitZerofill - Emit a the zerofill section and an option symbol.
|
||||
///
|
||||
/// @param Section - The zerofill section to create and or to put the symbol
|
||||
|
@ -196,9 +196,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (const char *LComm = MAI->getLCOMMDirective()) {
|
||||
if (MAI->hasLCOMMDirective()) {
|
||||
// .lcomm _foo, 42
|
||||
O << LComm << *GVSym << ',' << Size << '\n';
|
||||
OutStreamer.EmitLocalCommonSymbol(GVSym, Size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,7 @@ MCAsmInfo::MCAsmInfo() {
|
||||
PICJumpTableDirective = 0;
|
||||
GlobalDirective = "\t.globl\t";
|
||||
SetDirective = 0;
|
||||
LCOMMDirective = 0;
|
||||
COMMDirective = "\t.comm\t";
|
||||
HasLCOMMDirective = false;
|
||||
COMMDirectiveTakesAlignment = true;
|
||||
HasDotTypeDotSizeDirective = true;
|
||||
HasSingleParameterDotFile = true;
|
||||
|
@ -18,7 +18,7 @@ using namespace llvm;
|
||||
|
||||
MCAsmInfoCOFF::MCAsmInfoCOFF() {
|
||||
GlobalPrefix = "_";
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
HasLCOMMDirective = true;
|
||||
COMMDirectiveTakesAlignment = false;
|
||||
HasDotTypeDotSizeDirective = false;
|
||||
HasSingleParameterDotFile = false;
|
||||
|
@ -93,9 +93,15 @@ public:
|
||||
|
||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
||||
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment);
|
||||
|
||||
/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
|
||||
///
|
||||
/// @param Symbol - The common symbol to emit.
|
||||
/// @param Size - The size of the common symbol.
|
||||
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size);
|
||||
|
||||
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
|
||||
unsigned Size = 0, unsigned ByteAlignment = 0);
|
||||
|
||||
@ -245,9 +251,9 @@ void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) {
|
||||
OS << MAI.getCOMMDirective() << *Symbol << ',' << Size;
|
||||
OS << "\t.comm\t" << *Symbol << ',' << Size;
|
||||
if (ByteAlignment != 0 && MAI.getCOMMDirectiveTakesAlignment()) {
|
||||
if (MAI.getAlignmentIsInBytes())
|
||||
OS << ',' << ByteAlignment;
|
||||
@ -257,6 +263,16 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
|
||||
///
|
||||
/// @param Symbol - The common symbol to emit.
|
||||
/// @param Size - The size of the common symbol.
|
||||
void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {
|
||||
assert(MAI.hasLCOMMDirective() && "Doesn't have .lcomm, can't emit it!");
|
||||
OS << "\t.lcomm\t" << *Symbol << ',' << Size;
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
|
||||
unsigned Size, unsigned ByteAlignment) {
|
||||
// Note: a .zerofill directive does not switch sections.
|
||||
|
@ -122,8 +122,11 @@ public:
|
||||
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
|
||||
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
|
||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment);
|
||||
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {
|
||||
assert(0 && "macho doesn't support this directive");
|
||||
}
|
||||
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
|
||||
unsigned Size = 0, unsigned ByteAlignment = 0);
|
||||
virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
|
||||
@ -270,7 +273,7 @@ void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||
getSymbolData(*Symbol).setFlags(DescValue & SF_DescFlagsMask);
|
||||
}
|
||||
|
||||
void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) {
|
||||
// FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
|
||||
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
||||
|
@ -39,8 +39,9 @@ namespace {
|
||||
|
||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
|
||||
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
|
||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment) {}
|
||||
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {}
|
||||
|
||||
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
|
||||
unsigned Size = 0, unsigned ByteAlignment = 0) {}
|
||||
|
@ -64,7 +64,7 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
|
||||
PrivateGlobalPrefix = ".L";
|
||||
WeakRefDirective = "\t.weak\t";
|
||||
SetDirective = "\t.set\t";
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
HasLCOMMDirective = true;
|
||||
|
||||
DwarfRequiresFrameSection = false;
|
||||
|
||||
|
@ -19,7 +19,7 @@ SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, const StringRef &TT) {
|
||||
SetDirective = "\t.set";
|
||||
Data64bitsDirective = "\t.quad\t";
|
||||
AlignmentIsInBytes = false;
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
HasLCOMMDirective = true;
|
||||
|
||||
PCSymbol = ".";
|
||||
CommentString = "#";
|
||||
|
@ -52,7 +52,7 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
|
||||
SetDirective = "\t.set";
|
||||
Data64bitsDirective = is64Bit ? "\t.quad\t" : 0;
|
||||
AlignmentIsInBytes = false;
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
HasLCOMMDirective = true;
|
||||
AssemblerDialect = 0; // Old-Style mnemonics.
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user