mutable const MachineInstr *LastMI;
mutable const Function *LastFn;
mutable unsigned Counter;
+ mutable unsigned SetCounter;
// Private state for processDebugLoc()
mutable const MDNode *PrevDLT;
/// EmitInt64 - Emit a long long directive and value.
///
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;
//===------------------------------------------------------------------===//
: MachineFunctionPass(&ID), O(o),
TM(tm), MAI(T), TRI(tm.getRegisterInfo()),
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;
VerboseAsm = Streamer.isVerboseAsm();
}
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
const char *flavor)
: O(OS), Asm(A), MAI(T), TD(Asm->TM.getTargetData()),
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
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();
PrintRelDirective(Encoding);
/// 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,
bool IsSmall) {
- if (MAI->hasSetDirective()) {
- // FIXME: switch to OutStreamer.EmitAssignment.
- 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);
- }
+ unsigned Size = IsSmall ? 4 : TD->getPointerSize();
+ Asm->EmitLabelDifference(TagHi, TagLo, Size);
}
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
/// unique labels.
const char * const Flavor;
- /// SetCounter - A unique number for each '.set' directive.
- unsigned SetCounter;
-
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
const char *flavor);
public:
; 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 globl %t | count 6
; RUN: grep weak %t | count 1