mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-25 03:30:37 +00:00
break coff symbol definition stuff out into proper MCStreamer callbacks,
patch by Nathan Jeffords! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103346 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
369252db2e
commit
b54b9ddaaf
@ -27,7 +27,7 @@ namespace llvm {
|
|||||||
class MCSection;
|
class MCSection;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
class TargetAsmBackend;
|
class TargetAsmBackend;
|
||||||
class Twine;
|
class Twine;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class formatted_raw_ostream;
|
class formatted_raw_ostream;
|
||||||
@ -138,7 +138,24 @@ class TargetAsmBackend;
|
|||||||
/// @param DescValue - The value to set into the n_desc field.
|
/// @param DescValue - The value to set into the n_desc field.
|
||||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
|
||||||
|
|
||||||
|
/// BeginCOFFSymbolDef - Start emitting COFF symbol definition
|
||||||
|
///
|
||||||
|
/// @param Symbol - The symbol to have its External & Type fields set.
|
||||||
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0;
|
||||||
|
|
||||||
|
/// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol.
|
||||||
|
///
|
||||||
|
/// @param StorageClass - The storage class the symbol should have.
|
||||||
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0;
|
||||||
|
|
||||||
|
/// EmitCOFFSymbolType - Emit the type of the symbol.
|
||||||
|
///
|
||||||
|
/// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
|
||||||
|
virtual void EmitCOFFSymbolType(int Type) = 0;
|
||||||
|
|
||||||
|
/// EndCOFFSymbolDef - Marks the end of the symbol definition.
|
||||||
|
virtual void EndCOFFSymbolDef() = 0;
|
||||||
|
|
||||||
/// EmitELFSize - Emit an ELF .size directive.
|
/// EmitELFSize - Emit an ELF .size directive.
|
||||||
///
|
///
|
||||||
/// This corresponds to an assembler statement such as:
|
/// This corresponds to an assembler statement such as:
|
||||||
|
@ -109,7 +109,10 @@ public:
|
|||||||
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
|
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
|
||||||
|
|
||||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
||||||
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
|
||||||
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass);
|
||||||
|
virtual void EmitCOFFSymbolType(int Type);
|
||||||
|
virtual void EndCOFFSymbolDef();
|
||||||
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
|
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
|
||||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment);
|
unsigned ByteAlignment);
|
||||||
@ -293,6 +296,26 @@ void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
|||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
||||||
|
OS << "\t.def\t " << *Symbol << ';';
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitCOFFSymbolStorageClass (int StorageClass) {
|
||||||
|
OS << "\t.scl\t" << StorageClass << ';';
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitCOFFSymbolType (int Type) {
|
||||||
|
OS << "\t.type\t" << Type << ';';
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EndCOFFSymbolDef() {
|
||||||
|
OS << "\t.endef";
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
void MCAsmStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
||||||
assert(MAI.hasDotTypeDotSizeDirective());
|
assert(MAI.hasDotTypeDotSizeDirective());
|
||||||
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
||||||
|
@ -96,6 +96,18 @@ public:
|
|||||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
||||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment);
|
unsigned ByteAlignment);
|
||||||
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
||||||
|
assert(0 && "macho doesn't support this directive");
|
||||||
|
}
|
||||||
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass) {
|
||||||
|
assert(0 && "macho doesn't support this directive");
|
||||||
|
}
|
||||||
|
virtual void EmitCOFFSymbolType(int Type) {
|
||||||
|
assert(0 && "macho doesn't support this directive");
|
||||||
|
}
|
||||||
|
virtual void EndCOFFSymbolDef() {
|
||||||
|
assert(0 && "macho doesn't support this directive");
|
||||||
|
}
|
||||||
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
||||||
assert(0 && "macho doesn't support this directive");
|
assert(0 && "macho doesn't support this directive");
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,12 @@ namespace {
|
|||||||
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){}
|
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){}
|
||||||
|
|
||||||
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
|
||||||
|
|
||||||
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
|
||||||
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
|
||||||
|
virtual void EmitCOFFSymbolType(int Type) {}
|
||||||
|
virtual void EndCOFFSymbolDef() {}
|
||||||
|
|
||||||
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
|
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
|
||||||
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) {}
|
unsigned ByteAlignment) {}
|
||||||
|
@ -58,12 +58,11 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
SetupMachineFunction(MF);
|
SetupMachineFunction(MF);
|
||||||
|
|
||||||
if (Subtarget->isTargetCOFF()) {
|
if (Subtarget->isTargetCOFF()) {
|
||||||
const Function *F = MF.getFunction();
|
bool Intrn = MF.getFunction()->hasInternalLinkage();
|
||||||
OutStreamer.EmitRawText("\t.def\t " + Twine(CurrentFnSym->getName()) +
|
OutStreamer.BeginCOFFSymbolDef(CurrentFnSym);
|
||||||
";\t.scl\t" +
|
OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::C_STAT : COFF::C_EXT);
|
||||||
Twine(F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) +
|
OutStreamer.EmitCOFFSymbolType(COFF::DT_FCN << COFF::N_BTSHFT);
|
||||||
";\t.type\t" + Twine(COFF::DT_FCN << COFF::N_BTSHFT)
|
OutStreamer.EndCOFFSymbolDef();
|
||||||
+ ";\t.endef");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have common code print out the function header with linkage info etc.
|
// Have common code print out the function header with linkage info etc.
|
||||||
@ -571,13 +570,14 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
|||||||
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
||||||
|
|
||||||
// Emit type information for external functions
|
// Emit type information for external functions
|
||||||
for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
|
typedef X86COFFMachineModuleInfo::externals_iterator externals_iterator;
|
||||||
E = COFFMMI.stub_end(); I != E; ++I) {
|
for (externals_iterator I = COFFMMI.externals_begin(),
|
||||||
OutStreamer.EmitRawText("\t.def\t " + Twine(I->getKeyData()) +
|
E = COFFMMI.externals_end();
|
||||||
";\t.scl\t" + Twine(COFF::C_EXT) +
|
I != E; ++I) {
|
||||||
";\t.type\t" +
|
OutStreamer.BeginCOFFSymbolDef(CurrentFnSym);
|
||||||
Twine(COFF::DT_FCN << COFF::N_BTSHFT) +
|
OutStreamer.EmitCOFFSymbolStorageClass(COFF::C_EXT);
|
||||||
";\t.endef");
|
OutStreamer.EmitCOFFSymbolType(COFF::DT_FCN << COFF::N_BTSHFT);
|
||||||
|
OutStreamer.EndCOFFSymbolDef();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Subtarget->isTargetCygMing()) {
|
if (Subtarget->isTargetCygMing()) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#define X86COFF_MACHINEMODULEINFO_H
|
#define X86COFF_MACHINEMODULEINFO_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/ADT/StringSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include "X86MachineFunctionInfo.h"
|
#include "X86MachineFunctionInfo.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -25,18 +25,18 @@ namespace llvm {
|
|||||||
/// X86COFFMachineModuleInfo - This is a MachineModuleInfoImpl implementation
|
/// X86COFFMachineModuleInfo - This is a MachineModuleInfoImpl implementation
|
||||||
/// for X86 COFF targets.
|
/// for X86 COFF targets.
|
||||||
class X86COFFMachineModuleInfo : public MachineModuleInfoImpl {
|
class X86COFFMachineModuleInfo : public MachineModuleInfoImpl {
|
||||||
StringSet<> CygMingStubs;
|
DenseSet<MCSymbol const *> Externals;
|
||||||
public:
|
public:
|
||||||
X86COFFMachineModuleInfo(const MachineModuleInfo &) {}
|
X86COFFMachineModuleInfo(const MachineModuleInfo &) {}
|
||||||
virtual ~X86COFFMachineModuleInfo();
|
virtual ~X86COFFMachineModuleInfo();
|
||||||
|
|
||||||
void addExternalFunction(StringRef Name) {
|
void addExternalFunction(MCSymbol* Symbol) {
|
||||||
CygMingStubs.insert(Name);
|
Externals.insert(Symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef StringSet<>::const_iterator stub_iterator;
|
typedef DenseSet<MCSymbol const *>::const_iterator externals_iterator;
|
||||||
stub_iterator stub_begin() const { return CygMingStubs.begin(); }
|
externals_iterator externals_begin() const { return Externals.begin(); }
|
||||||
stub_iterator stub_end() const { return CygMingStubs.end(); }
|
externals_iterator externals_end() const { return Externals.end(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user