llvm.org GIT mirror llvm / aba9bcb
switch GC_LABEL to use an MCSymbol operand instead of a label ID operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98474 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
7 changed file(s) with 43 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
3737 #include "llvm/ADT/StringMap.h"
3838
3939 namespace llvm {
40
4140 class AsmPrinter;
4241 class GCStrategy;
4342 class Constant;
44 class MCAsmInfo;
45
43 class MCSymbol;
4644
4745 namespace GC {
4846 /// PointKind - The type of a collector-safe point.
5957 ///
6058 struct GCPoint {
6159 GC::PointKind Kind; //< The kind of the safe point.
62 unsigned Num; //< Usually a label.
60 MCSymbol *Label; //< A label.
6361
64 GCPoint(GC::PointKind K, unsigned N) : Kind(K), Num(N) {}
62 GCPoint(GC::PointKind K, MCSymbol *L) : Kind(K), Label(L) {}
6563 };
6664
6765 /// GCRoot - Metadata for a pointer to an object managed by the garbage
122120 /// addSafePoint - Notes the existence of a safe point. Num is the ID of the
123121 /// label just prior to the safe point (if the code generator is using
124122 /// MachineModuleInfo).
125 void addSafePoint(GC::PointKind Kind, unsigned Num) {
126 SafePoints.push_back(GCPoint(Kind, Num));
123 void addSafePoint(GC::PointKind Kind, MCSymbol *Label) {
124 SafePoints.push_back(GCPoint(Kind, Label));
127125 }
128126
129127 /// getFrameSize/setFrameSize - Records the function's frame size.
2727
2828 class GCMetadataPrinter;
2929 class raw_ostream;
30 class MCAsmInfo;
3031
3132 /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
3233 /// defaults from Registry.
15571557 if (MI->getOperand(0).isMCSymbol())
15581558 Sym = MI->getOperand(0).getMCSymbol();
15591559 else
1560 Sym =
1561 OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
1562 "label" + Twine(MI->getOperand(0).getImm()));
1560 Sym = MMI->getLabelSym(MI->getOperand(0).getImm());
15631561 OutStreamer.EmitLabel(Sym);
15641562 }
15651563
1616 #include "llvm/Pass.h"
1717 #include "llvm/CodeGen/Passes.h"
1818 #include "llvm/Function.h"
19 #include "llvm/MC/MCSymbol.h"
1920 #include "llvm/Support/Debug.h"
2021 #include "llvm/Support/ErrorHandling.h"
2122 #include "llvm/Support/raw_ostream.h"
149150 }
150151
151152 bool Printer::runOnFunction(Function &F) {
152 if (!F.hasGC()) {
153 GCFunctionInfo *FD = &getAnalysis().getFunctionInfo(F);
154
155 OS << "GC roots for " << FD->getFunction().getNameStr() << ":\n";
156 for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(),
157 RE = FD->roots_end(); RI != RE; ++RI)
158 OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n";
159
160 OS << "GC safe points for " << FD->getFunction().getNameStr() << ":\n";
161 for (GCFunctionInfo::iterator PI = FD->begin(),
162 PE = FD->end(); PI != PE; ++PI) {
163
164 OS << "\tlabel " << PI->Num << ": " << DescKind(PI->Kind) << ", live = {";
165
166 for (GCFunctionInfo::live_iterator RI = FD->live_begin(PI),
167 RE = FD->live_end(PI);;) {
168 OS << " " << RI->Num;
169 if (++RI == RE)
170 break;
171 OS << ",";
172 }
173
174 OS << " }\n";
153 if (F.hasGC()) return false;
154
155 GCFunctionInfo *FD = &getAnalysis().getFunctionInfo(F);
156
157 OS << "GC roots for " << FD->getFunction().getNameStr() << ":\n";
158 for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(),
159 RE = FD->roots_end(); RI != RE; ++RI)
160 OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n";
161
162 OS << "GC safe points for " << FD->getFunction().getNameStr() << ":\n";
163 for (GCFunctionInfo::iterator PI = FD->begin(),
164 PE = FD->end(); PI != PE; ++PI) {
165
166 OS << "\t" << PI->Label->getName() << ": "
167 << DescKind(PI->Kind) << ", live = {";
168
169 for (GCFunctionInfo::live_iterator RI = FD->live_begin(PI),
170 RE = FD->live_end(PI);;) {
171 OS << " " << RI->Num;
172 if (++RI == RE)
173 break;
174 OS << ",";
175175 }
176
177 OS << " }\n";
176178 }
177179
178180 return false;
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/CodeGen/GCMetadataPrinter.h"
14
14 class MCAsmInfo;
1515 using namespace llvm;
1616
1717 GCMetadataPrinter::GCMetadataPrinter() { }
7070
7171 void FindSafePoints(MachineFunction &MF);
7272 void VisitCallPoint(MachineBasicBlock::iterator MI);
73 unsigned InsertLabel(MachineBasicBlock &MBB,
74 MachineBasicBlock::iterator MI,
75 DebugLoc DL) const;
73 MCSymbol *InsertLabel(MachineBasicBlock &MBB,
74 MachineBasicBlock::iterator MI,
75 DebugLoc DL) const;
7676
7777 void FindStackOffsets(MachineFunction &MF);
7878
328328 AU.addRequired();
329329 }
330330
331 unsigned MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
332 MachineBasicBlock::iterator MI,
333 DebugLoc DL) const {
334 unsigned Label = MMI->NextLabelID();
335
336 BuildMI(MBB, MI, DL,
337 TII->get(TargetOpcode::GC_LABEL)).addImm(Label);
338
331 MCSymbol *MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
332 MachineBasicBlock::iterator MI,
333 DebugLoc DL) const {
334 MCSymbol *Label = MMI->getLabelSym(MMI->NextLabelID());
335 BuildMI(MBB, MI, DL, TII->get(TargetOpcode::GC_LABEL)).addSym(Label);
339336 return Label;
340337 }
341338
602602 llvm_report_error("JIT does not support inline asm!");
603603 break;
604604 case TargetOpcode::DBG_LABEL:
605 MCE.emitLabel(MMI->getLabelSym(MI.getOperand(0).getImm()));
606 break;
605607 case TargetOpcode::GC_LABEL:
606 MCE.emitLabel(MMI->getLabelSym(MI.getOperand(0).getImm()));
607 break;
608608 case TargetOpcode::EH_LABEL:
609609 MCE.emitLabel(MI.getOperand(0).getMCSymbol());
610610 break;