Skip to content

Commit c5437ea

Browse files
committed
Overhaul my earlier submission due to feedback. It's a large patch, but most of
them are generic changes. - Use the "fast" flag that's already being passed into the asm printers instead of shoving it into the DwarfWriter. - Instead of calling "MI->getParent()->getParent()" for every MI, set the machine function when calling "runOnMachineFunction" in the asm printers. llvm-svn: 65379
1 parent 0b0dcd9 commit c5437ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+174
-139
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ namespace llvm {
6565
// Necessary for external weak linkage support
6666
std::set<const GlobalValue*> ExtWeakSymbols;
6767

68+
/// Fast - Generating code via fast instruction selection.
69+
bool Fast;
6870
public:
6971
/// Output stream on which we're printing assembly code.
7072
///
@@ -82,6 +84,9 @@ namespace llvm {
8284
///
8385
const TargetRegisterInfo *TRI;
8486

87+
/// The current machine function.
88+
const MachineFunction *MF;
89+
8590
/// Name-mangler for global names.
8691
///
8792
Mangler *Mang;
@@ -101,7 +106,8 @@ namespace llvm {
101106
bool IsInTextSection;
102107

103108
protected:
104-
AsmPrinter(raw_ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
109+
AsmPrinter(raw_ostream &o, TargetMachine &TM,
110+
const TargetAsmInfo *T, bool F);
105111

106112
public:
107113
virtual ~AsmPrinter();

llvm/include/llvm/CodeGen/DwarfWriter.h

-6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ class DwarfWriter : public ImmutablePass {
4949
///
5050
DwarfException *DE;
5151

52-
/// FastCodeGen - True if generating code via the "fast" isel.
53-
///
54-
bool FastCodeGen;
5552
public:
5653
static char ID; // Pass identification, replacement for typeid
5754

@@ -107,9 +104,6 @@ class DwarfWriter : public ImmutablePass {
107104
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
108105
/// be emitted.
109106
bool ShouldEmitDwarfDebug() const;
110-
111-
bool getFastCodeGen() const { return FastCodeGen; }
112-
void setFastCodeGen(bool Fast) { FastCodeGen = Fast; }
113107
};
114108

115109

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ using namespace llvm;
3737

3838
char AsmPrinter::ID = 0;
3939
AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
40-
const TargetAsmInfo *T)
41-
: MachineFunctionPass(&ID), FunctionNumber(0), O(o),
40+
const TargetAsmInfo *T, bool F)
41+
: MachineFunctionPass(&ID), FunctionNumber(0), Fast(F), O(o),
4242
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
4343
IsInTextSection(false)
4444
{}

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ bool FastISel::SelectCall(User *I) {
370370
unsigned Line = Subprogram.getLineNumber();
371371
unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile);
372372
setCurDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(SrcFile, Line, 0)));
373-
DW->setFastCodeGen(true);
374373

375374
if (DW->getRecordSourceLineCount() != 1) {
376375
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3915,7 +3915,6 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
39153915
if (Fast)
39163916
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
39173917
getRoot(), LabelID));
3918-
DW->setFastCodeGen(Fast);
39193918
}
39203919

39213920
return 0;

llvm/lib/Target/ARM/ARM.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) {
8989
}
9090

9191
FunctionPass *createARMISelDag(ARMTargetMachine &TM);
92-
FunctionPass *createARMCodePrinterPass(raw_ostream &O, ARMTargetMachine &TM);
92+
FunctionPass *createARMCodePrinterPass(raw_ostream &O,
93+
ARMTargetMachine &TM,
94+
bool Fast);
9395
FunctionPass *createARMCodeEmitterPass(ARMTargetMachine &TM,
9496
MachineCodeEmitter &MCE);
9597
FunctionPass *createARMLoadStoreOptimizationPass();

llvm/lib/Target/ARM/ARMTargetMachine.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
157157
// Output assembly language.
158158
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
159159
if (AsmPrinterCtor)
160-
PM.add(AsmPrinterCtor(Out, *this));
160+
PM.add(AsmPrinterCtor(Out, *this, Fast));
161161

162162
return false;
163163
}
@@ -174,7 +174,7 @@ bool ARMTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
174174
if (DumpAsm) {
175175
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
176176
if (AsmPrinterCtor)
177-
PM.add(AsmPrinterCtor(errs(), *this));
177+
PM.add(AsmPrinterCtor(errs(), *this, Fast));
178178
}
179179

180180
return false;
@@ -187,7 +187,7 @@ bool ARMTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
187187
if (DumpAsm) {
188188
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
189189
if (AsmPrinterCtor)
190-
PM.add(AsmPrinterCtor(errs(), *this));
190+
PM.add(AsmPrinterCtor(errs(), *this, Fast));
191191
}
192192

193193
return false;

llvm/lib/Target/ARM/ARMTargetMachine.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class ARMTargetMachine : public LLVMTargetMachine {
4040
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
4141
// set this functions to ctor pointer at startup time if they are linked in.
4242
typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
43-
ARMTargetMachine &tm);
43+
ARMTargetMachine &tm,
44+
bool fast);
4445
static AsmPrinterCtorFn AsmPrinterCtor;
4546

4647
public:

llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,7 @@ using namespace llvm;
4242
STATISTIC(EmittedInsts, "Number of machine instrs printed");
4343

4444
namespace {
45-
struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
46-
ARMAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
47-
: AsmPrinter(O, TM, T), DW(0), MMI(NULL), AFI(NULL), MCP(NULL),
48-
InCPMode(false) {
49-
Subtarget = &TM.getSubtarget<ARMSubtarget>();
50-
}
51-
45+
class VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
5246
DwarfWriter *DW;
5347
MachineModuleInfo *MMI;
5448

@@ -85,7 +79,14 @@ namespace {
8579

8680
/// True if asm printer is printing a series of CONSTPOOL_ENTRY.
8781
bool InCPMode;
88-
82+
public:
83+
ARMAsmPrinter(raw_ostream &O, TargetMachine &TM,
84+
const TargetAsmInfo *T, bool F)
85+
: AsmPrinter(O, TM, T, F), DW(0), MMI(NULL), AFI(NULL), MCP(NULL),
86+
InCPMode(false) {
87+
Subtarget = &TM.getSubtarget<ARMSubtarget>();
88+
}
89+
8990
virtual const char *getPassName() const {
9091
return "ARM Assembly Printer";
9192
}
@@ -183,6 +184,8 @@ namespace {
183184
/// method to print assembly for each instruction.
184185
///
185186
bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
187+
this->MF = &MF;
188+
186189
AFI = MF.getInfo<ARMFunctionInfo>();
187190
MCP = MF.getConstantPool();
188191

@@ -1039,8 +1042,9 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
10391042
/// regardless of whether the function is in SSA form.
10401043
///
10411044
FunctionPass *llvm::createARMCodePrinterPass(raw_ostream &o,
1042-
ARMTargetMachine &tm) {
1043-
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
1045+
ARMTargetMachine &tm,
1046+
bool fast) {
1047+
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), fast);
10441048
}
10451049

10461050
namespace {

llvm/lib/Target/Alpha/Alpha.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace llvm {
2525

2626
FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
2727
FunctionPass *createAlphaCodePrinterPass(raw_ostream &OS,
28-
TargetMachine &TM);
28+
TargetMachine &TM,
29+
bool Fast);
2930
FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
3031
FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM,
3132
MachineCodeEmitter &MCE);

llvm/lib/Target/Alpha/AlphaTargetMachine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
8888
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
8989
raw_ostream &Out) {
9090
PM.add(createAlphaLLRPPass(*this));
91-
PM.add(createAlphaCodePrinterPass(Out, *this));
91+
PM.add(createAlphaCodePrinterPass(Out, *this, Fast));
9292
return false;
9393
}
9494
bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
9595
bool DumpAsm, MachineCodeEmitter &MCE) {
9696
PM.add(createAlphaCodeEmitterPass(*this, MCE));
9797
if (DumpAsm)
98-
PM.add(createAlphaCodePrinterPass(errs(), *this));
98+
PM.add(createAlphaCodePrinterPass(errs(), *this, Fast));
9999
return false;
100100
}
101101
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,

llvm/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
3333

3434
namespace {
3535
struct VISIBILITY_HIDDEN AlphaAsmPrinter : public AsmPrinter {
36-
3736
/// Unique incrementer for label values for referencing Global values.
3837
///
3938

40-
AlphaAsmPrinter(raw_ostream &o, TargetMachine &tm, const TargetAsmInfo *T)
41-
: AsmPrinter(o, tm, T) {
42-
}
39+
AlphaAsmPrinter(raw_ostream &o, TargetMachine &tm,
40+
const TargetAsmInfo *T, bool F)
41+
: AsmPrinter(o, tm, T, F) {}
4342

4443
virtual const char *getPassName() const {
4544
return "Alpha Assembly Printer";
@@ -68,8 +67,9 @@ namespace {
6867
/// regardless of whether the function is in SSA form.
6968
///
7069
FunctionPass *llvm::createAlphaCodePrinterPass(raw_ostream &o,
71-
TargetMachine &tm) {
72-
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo());
70+
TargetMachine &tm,
71+
bool fast) {
72+
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo(), fast);
7373
}
7474

7575
#include "AlphaGenAsmWriter.inc"
@@ -139,6 +139,8 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
139139
/// method to print assembly for each instruction.
140140
///
141141
bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
142+
this->MF = &MF;
143+
142144
SetupMachineFunction(MF);
143145
O << "\n\n";
144146

llvm/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ namespace {
4545

4646
const std::string bss_section(".bss");
4747

48-
struct VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
48+
class VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
4949
std::set<std::string> FnStubs, GVStubs;
50-
51-
SPUAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T) :
52-
AsmPrinter(O, TM, T)
53-
{
54-
}
50+
public:
51+
SPUAsmPrinter(raw_ostream &O, TargetMachine &TM,
52+
const TargetAsmInfo *T, bool F) :
53+
AsmPrinter(O, TM, T, F) {}
5554

5655
virtual const char *getPassName() const {
5756
return "STI CBEA SPU Assembly Printer";
@@ -285,17 +284,13 @@ namespace {
285284
};
286285

287286
/// LinuxAsmPrinter - SPU assembly printer, customized for Linux
288-
struct VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
289-
287+
class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
290288
DwarfWriter *DW;
291289
MachineModuleInfo *MMI;
292-
290+
public:
293291
LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM,
294-
const TargetAsmInfo *T) :
295-
SPUAsmPrinter(O, TM, T),
296-
DW(0),
297-
MMI(0)
298-
{ }
292+
const TargetAsmInfo *T, bool F)
293+
: SPUAsmPrinter(O, TM, T, F), DW(0), MMI(0) {}
299294

300295
virtual const char *getPassName() const {
301296
return "STI CBEA SPU Assembly Printer";
@@ -427,6 +422,8 @@ void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
427422
bool
428423
LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF)
429424
{
425+
this->MF = &MF;
426+
430427
SetupMachineFunction(MF);
431428
O << "\n\n";
432429

@@ -613,6 +610,7 @@ bool LinuxAsmPrinter::doFinalization(Module &M) {
613610
/// that the Linux SPU assembler can deal with.
614611
///
615612
FunctionPass *llvm::createSPUAsmPrinterPass(raw_ostream &o,
616-
SPUTargetMachine &tm) {
617-
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
613+
SPUTargetMachine &tm,
614+
bool fast) {
615+
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), fast);
618616
}

llvm/lib/Target/CellSPU/SPU.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ namespace llvm {
2323
class raw_ostream;
2424

2525
FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
26-
FunctionPass *createSPUAsmPrinterPass(raw_ostream &o, SPUTargetMachine &tm);
26+
FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
27+
SPUTargetMachine &tm,
28+
bool fast);
2729

2830
/*--== Utility functions/predicates/etc used all over the place: --==*/
2931
//! Predicate test for a signed 10-bit value

llvm/lib/Target/CellSPU/SPUTargetMachine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ SPUTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast)
9090

9191
bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
9292
raw_ostream &Out) {
93-
PM.add(createSPUAsmPrinterPass(Out, *this));
93+
PM.add(createSPUAsmPrinterPass(Out, *this, Fast));
9494
return false;
9595
}

llvm/lib/Target/IA64/IA64.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ FunctionPass *createIA64BundlingPass(IA64TargetMachine &TM);
3535
/// using the given target machine description. This should work
3636
/// regardless of whether the function is in SSA form.
3737
///
38-
FunctionPass *createIA64CodePrinterPass(raw_ostream &o, IA64TargetMachine &tm);
38+
FunctionPass *createIA64CodePrinterPass(raw_ostream &o,
39+
IA64TargetMachine &tm,
40+
bool fast);
3941

4042
} // End llvm namespace
4143

llvm/lib/Target/IA64/IA64AsmPrinter.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ using namespace llvm;
3434
STATISTIC(EmittedInsts, "Number of machine instrs printed");
3535

3636
namespace {
37-
struct IA64AsmPrinter : public AsmPrinter {
37+
class IA64AsmPrinter : public AsmPrinter {
3838
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
39-
40-
IA64AsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
41-
: AsmPrinter(O, TM, T) {
42-
}
39+
public:
40+
IA64AsmPrinter(raw_ostream &O, TargetMachine &TM,
41+
const TargetAsmInfo *T, bool F)
42+
: AsmPrinter(O, TM, T, F) {}
4343

4444
virtual const char *getPassName() const {
4545
return "IA64 Assembly Printer";
@@ -124,6 +124,8 @@ namespace {
124124
/// method to print assembly for each instruction.
125125
///
126126
bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
127+
this->MF = &MF;
128+
127129
SetupMachineFunction(MF);
128130
O << "\n\n";
129131

@@ -365,6 +367,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
365367
/// the given target machine description.
366368
///
367369
FunctionPass *llvm::createIA64CodePrinterPass(raw_ostream &o,
368-
IA64TargetMachine &tm) {
369-
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
370+
IA64TargetMachine &tm,
371+
bool fast) {
372+
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), fast);
370373
}

llvm/lib/Target/IA64/IA64TargetMachine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
8484
}
8585
bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
8686
raw_ostream &Out) {
87-
PM.add(createIA64CodePrinterPass(Out, *this));
87+
PM.add(createIA64CodePrinterPass(Out, *this, Fast));
8888
return false;
8989
}
9090

llvm/lib/Target/Mips/Mips.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace llvm {
2424
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
2525
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
2626
FunctionPass *createMipsCodePrinterPass(raw_ostream &OS,
27-
MipsTargetMachine &TM);
27+
MipsTargetMachine &TM,
28+
bool Fast);
2829
} // end namespace llvm;
2930

3031
// Defines symbolic names for Mips registers. This defines a mapping from

0 commit comments

Comments
 (0)