mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
move .set generation out of DwarfPrinter into AsmPrinter and
MCize it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5196018d9c
commit
0d50c7620d
@ -136,6 +136,7 @@ namespace llvm {
|
|||||||
mutable const MachineInstr *LastMI;
|
mutable const MachineInstr *LastMI;
|
||||||
mutable const Function *LastFn;
|
mutable const Function *LastFn;
|
||||||
mutable unsigned Counter;
|
mutable unsigned Counter;
|
||||||
|
mutable unsigned SetCounter;
|
||||||
|
|
||||||
// Private state for processDebugLoc()
|
// Private state for processDebugLoc()
|
||||||
mutable const MDNode *PrevDLT;
|
mutable const MDNode *PrevDLT;
|
||||||
@ -275,6 +276,13 @@ namespace llvm {
|
|||||||
/// EmitInt64 - Emit a long long directive and value.
|
/// EmitInt64 - Emit a long long directive and value.
|
||||||
///
|
///
|
||||||
void EmitInt64(uint64_t Value) const;
|
void EmitInt64(uint64_t Value) const;
|
||||||
|
|
||||||
|
|
||||||
|
/// EmitLabelDifference - Emit something like ".long Hi-Lo" where the size
|
||||||
|
/// in bytes of the directive is specified by Size and Hi/Lo specify the
|
||||||
|
/// labels. This implicitly uses .set if it is available.
|
||||||
|
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
|
||||||
|
unsigned Size) const;
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
|||||||
: MachineFunctionPass(&ID), O(o),
|
: MachineFunctionPass(&ID), O(o),
|
||||||
TM(tm), MAI(T), TRI(tm.getRegisterInfo()),
|
TM(tm), MAI(T), TRI(tm.getRegisterInfo()),
|
||||||
OutContext(Ctx), OutStreamer(Streamer),
|
OutContext(Ctx), OutStreamer(Streamer),
|
||||||
LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) {
|
LastMI(0), LastFn(0), Counter(~0U), SetCounter(0), PrevDLT(NULL) {
|
||||||
DW = 0; MMI = 0;
|
DW = 0; MMI = 0;
|
||||||
VerboseAsm = Streamer.isVerboseAsm();
|
VerboseAsm = Streamer.isVerboseAsm();
|
||||||
}
|
}
|
||||||
@ -893,6 +893,33 @@ void AsmPrinter::EmitInt64(uint64_t Value) const {
|
|||||||
OutStreamer.EmitIntValue(Value, 8, 0/*addrspace*/);
|
OutStreamer.EmitIntValue(Value, 8, 0/*addrspace*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// EmitLabelDifference - Emit something like ".long Hi-Lo" where the size
|
||||||
|
/// in bytes of the directive is specified by Size and Hi/Lo specify the
|
||||||
|
/// labels. This implicitly uses .set if it is available.
|
||||||
|
void AsmPrinter::EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
|
||||||
|
unsigned Size) const {
|
||||||
|
// Get the Hi-Lo expression.
|
||||||
|
const MCExpr *Diff =
|
||||||
|
MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(Hi, OutContext),
|
||||||
|
MCSymbolRefExpr::Create(Lo, OutContext),
|
||||||
|
OutContext);
|
||||||
|
|
||||||
|
if (!MAI->hasSetDirective()) {
|
||||||
|
OutStreamer.EmitValue(Diff, Size, 0/*AddrSpace*/);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, emit with .set (aka assignment).
|
||||||
|
MCSymbol *SetLabel =
|
||||||
|
OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "set" +
|
||||||
|
Twine(SetCounter++));
|
||||||
|
OutStreamer.EmitAssignment(SetLabel, Diff);
|
||||||
|
|
||||||
|
OutStreamer.EmitValue(MCSymbolRefExpr::Create(SetLabel, OutContext),
|
||||||
|
Size, 0/*AddrSpace*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// EmitAlignment - Emit an alignment directive to the specified power of
|
// EmitAlignment - Emit an alignment directive to the specified power of
|
||||||
|
@ -35,7 +35,7 @@ DwarfPrinter::DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
|||||||
const char *flavor)
|
const char *flavor)
|
||||||
: O(OS), Asm(A), MAI(T), TD(Asm->TM.getTargetData()),
|
: O(OS), Asm(A), MAI(T), TD(Asm->TM.getTargetData()),
|
||||||
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
|
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
|
||||||
SubprogramCount(0), Flavor(flavor), SetCounter(1) {}
|
SubprogramCount(0), Flavor(flavor) {}
|
||||||
|
|
||||||
|
|
||||||
/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
|
/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
|
||||||
@ -243,7 +243,7 @@ void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
|
|||||||
O << *TLOF.getSymbolForDwarfReference(Sym, Asm->MMI, Encoding);;
|
O << *TLOF.getSymbolForDwarfReference(Sym, Asm->MMI, Encoding);;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const {
|
void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{
|
||||||
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
|
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
|
||||||
|
|
||||||
PrintRelDirective(Encoding);
|
PrintRelDirective(Encoding);
|
||||||
@ -255,25 +255,8 @@ void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const
|
|||||||
/// supports .set, we emit a .set of a temporary and then use it in the .word.
|
/// supports .set, we emit a .set of a temporary and then use it in the .word.
|
||||||
void DwarfPrinter::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo,
|
void DwarfPrinter::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo,
|
||||||
bool IsSmall) {
|
bool IsSmall) {
|
||||||
if (MAI->hasSetDirective()) {
|
unsigned Size = IsSmall ? 4 : TD->getPointerSize();
|
||||||
// FIXME: switch to OutStreamer.EmitAssignment.
|
Asm->EmitLabelDifference(TagHi, TagLo, Size);
|
||||||
O << "\t.set\t";
|
|
||||||
PrintLabelName("set", SetCounter, Flavor);
|
|
||||||
O << ",";
|
|
||||||
PrintLabelName(TagHi);
|
|
||||||
O << "-";
|
|
||||||
PrintLabelName(TagLo);
|
|
||||||
O << "\n";
|
|
||||||
|
|
||||||
PrintRelDirective(IsSmall);
|
|
||||||
PrintLabelName("set", SetCounter, Flavor);
|
|
||||||
++SetCounter;
|
|
||||||
} else {
|
|
||||||
PrintRelDirective(IsSmall);
|
|
||||||
PrintLabelName(TagHi);
|
|
||||||
O << "-";
|
|
||||||
PrintLabelName(TagLo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
|
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
|
||||||
|
@ -70,9 +70,6 @@ protected:
|
|||||||
/// unique labels.
|
/// unique labels.
|
||||||
const char * const Flavor;
|
const char * const Flavor;
|
||||||
|
|
||||||
/// SetCounter - A unique number for each '.set' directive.
|
|
||||||
unsigned SetCounter;
|
|
||||||
|
|
||||||
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
||||||
const char *flavor);
|
const char *flavor);
|
||||||
public:
|
public:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
|
; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
|
||||||
; RUN: grep { = } %t | count 7
|
; RUN: grep { = } %t | count 16
|
||||||
; RUN: grep set %t | count 18
|
; RUN: grep set %t | count 18
|
||||||
; RUN: grep globl %t | count 6
|
; RUN: grep globl %t | count 6
|
||||||
; RUN: grep weak %t | count 1
|
; RUN: grep weak %t | count 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user