llvm.org GIT mirror llvm / c5b19b2
Revert r77654, it appears to be causing llvm-gcc bootstrap failures, and many failures when building assorted projects with clang. --- Reverse-merging r77654 into '.': U include/llvm/CodeGen/Passes.h U include/llvm/CodeGen/MachineFunctionPass.h U include/llvm/CodeGen/MachineFunction.h U include/llvm/CodeGen/LazyLiveness.h U include/llvm/CodeGen/SelectionDAGISel.h D include/llvm/CodeGen/MachineFunctionAnalysis.h U include/llvm/Function.h U lib/Target/CellSPU/SPUISelDAGToDAG.cpp U lib/Target/PowerPC/PPCISelDAGToDAG.cpp U lib/CodeGen/LLVMTargetMachine.cpp U lib/CodeGen/MachineVerifier.cpp U lib/CodeGen/MachineFunction.cpp U lib/CodeGen/PrologEpilogInserter.cpp U lib/CodeGen/MachineLoopInfo.cpp U lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp D lib/CodeGen/MachineFunctionAnalysis.cpp D lib/CodeGen/MachineFunctionPass.cpp U lib/CodeGen/LiveVariables.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77661 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
18 changed file(s) with 139 addition(s) and 190 deletion(s). Raw diff Collapse all Expand all
3333 void getAnalysisUsage(AnalysisUsage &AU) const {
3434 AU.setPreservesAll();
3535 AU.addRequired();
36 MachineFunctionPass::getAnalysisUsage(AU);
3736 }
3837
3938 bool runOnMachineFunction(MachineFunction &mf);
6666 };
6767
6868 class MachineFunction : private Annotation {
69 Function *Fn;
69 const Function *Fn;
7070 const TargetMachine &Target;
7171
7272 // RegInfo - Information about each register in use in the function.
114114 unsigned Alignment;
115115
116116 public:
117 MachineFunction(Function *Fn, const TargetMachine &TM);
117 MachineFunction(const Function *Fn, const TargetMachine &TM);
118118 ~MachineFunction();
119119
120120 /// getFunction - Return the LLVM function that this machine code represents
121121 ///
122 Function *getFunction() const { return Fn; }
122 const Function *getFunction() const { return Fn; }
123123
124124 /// getTarget - Return the target machine this machine code is compiled with
125125 ///
228228 ///
229229 void dump() const;
230230
231 /// construct - Allocate and initialize a MachineFunction for a given Function
232 /// and Target
233 ///
234 static MachineFunction& construct(const Function *F, const TargetMachine &TM);
235
236 /// destruct - Destroy the MachineFunction corresponding to a given Function
237 ///
238 static void destruct(const Function *F);
239
240 /// get - Return a handle to a MachineFunction corresponding to the given
241 /// Function. This should not be called before "construct()" for a given
242 /// Function.
243 ///
244 static MachineFunction& get(const Function *F);
245
231246 // Provide accessors for the MachineBasicBlock list...
232247 typedef BasicBlockListType::iterator iterator;
233248 typedef BasicBlockListType::const_iterator const_iterator;
+0
-49
include/llvm/CodeGen/MachineFunctionAnalysis.h less more
None //===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the MachineFunctionAnalysis class.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
14 #define LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
15
16 #include "llvm/Pass.h"
17 #include "llvm/Target/TargetMachine.h"
18
19 namespace llvm {
20
21 class MachineFunction;
22
23 /// MachineFunctionAnalysis - This class is a Pass that manages a
24 /// MachineFunction object.
25 struct MachineFunctionAnalysis : public FunctionPass {
26 private:
27 const TargetMachine &TM;
28 CodeGenOpt::Level OptLevel;
29 MachineFunction *MF;
30
31 public:
32 static char ID;
33 explicit MachineFunctionAnalysis(TargetMachine &tm,
34 CodeGenOpt::Level OL = CodeGenOpt::Default);
35
36
37 MachineFunction &getMF() const { return *MF; }
38 CodeGenOpt::Level getOptLevel() const { return OptLevel; }
39
40 private:
41 virtual bool runOnFunction(Function &F);
42 virtual void releaseMemory();
43 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
44 };
45
46 } // End llvm namespace
47
48 #endif
2323
2424 namespace llvm {
2525
26 /// MachineFunctionPass - This class adapts the FunctionPass interface to
27 /// allow convenient creation of passes that operate on the MachineFunction
28 /// representation. Instead of overriding runOnFunction, subclasses
29 /// override runOnMachineFunction.
30 class MachineFunctionPass : public FunctionPass {
31 protected:
26 // FIXME: This pass should declare that the pass does not invalidate any LLVM
27 // passes.
28 struct MachineFunctionPass : public FunctionPass {
3229 explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
3330 explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
3431
32 protected:
3533 /// runOnMachineFunction - This method must be overloaded to perform the
3634 /// desired machine code transformation or analysis.
3735 ///
3836 virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
3937
40 /// getAnalysisUsage - Subclasses that override getAnalysisUsage
41 /// must call this.
42 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
43
44 private:
38 public:
4539 bool runOnFunction(Function &F);
4640 };
4741
145145 /// by seeing if the labels map to the same reduced label.
146146 FunctionPass *createDebugLabelFoldingPass();
147147
148 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
149 /// the current function, which should happen after the function has been
150 /// emitted to a .s file or to memory.
151 FunctionPass *createMachineCodeDeleter();
152
148153 /// getRegisterAllocator - This creates an instance of the register allocator
149154 /// for the Sparc.
150155 FunctionPass *getRegisterAllocator(TargetMachine &T);
1818 #include "llvm/Pass.h"
1919 #include "llvm/Constant.h"
2020 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/CodeGen/MachineFunctionPass.h"
2221
2322 namespace llvm {
2423 class FastISel;
3938
4039 /// SelectionDAGISel - This is the common base class used for SelectionDAG-based
4140 /// pattern-matching instruction selectors.
42 class SelectionDAGISel : public MachineFunctionPass {
41 class SelectionDAGISel : public FunctionPass {
4342 public:
4443 const TargetMachine &TM;
4544 TargetLowering &TLI;
6261
6362 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
6463
65 virtual bool runOnMachineFunction(MachineFunction &MF);
64 virtual bool runOnFunction(Function &Fn);
6665
6766 unsigned MakeReg(MVT VT);
6867
2020 #include "llvm/GlobalValue.h"
2121 #include "llvm/BasicBlock.h"
2222 #include "llvm/Argument.h"
23 #include "llvm/Support/Annotation.h"
2324 #include "llvm/Attributes.h"
2425
2526 namespace llvm {
6465 mutable ilist_node Sentinel;
6566 };
6667
67 class Function : public GlobalValue,
68 class Function : public GlobalValue, public Annotable,
6869 public ilist_node {
6970 public:
7071 typedef iplist ArgumentListType;
1717 #include "llvm/Analysis/LoopPass.h"
1818 #include "llvm/CodeGen/Passes.h"
1919 #include "llvm/CodeGen/GCStrategy.h"
20 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
2120 #include "llvm/Target/TargetOptions.h"
2221 #include "llvm/Target/TargetAsmInfo.h"
2322 #include "llvm/Target/TargetRegistry.h"
118117
119118 PM.add(createGCInfoDeleter());
120119
120 // Delete machine code for this function
121 PM.add(createMachineCodeDeleter());
122
121123 return false; // success!
122124 }
123125
134136
135137 PM.add(createGCInfoDeleter());
136138
139 // Delete machine code for this function
140 PM.add(createMachineCodeDeleter());
141
137142 return false; // success!
138143 }
139144
149154 addAssemblyEmitter(PM, OptLevel, true, ferrs());
150155
151156 PM.add(createGCInfoDeleter());
157
158 // Delete machine code for this function
159 PM.add(createMachineCodeDeleter());
152160
153161 return false; // success!
154162 }
175183
176184 PM.add(createGCInfoDeleter());
177185
186 // Delete machine code for this function
187 PM.add(createMachineCodeDeleter());
188
178189 return false; // success!
179190 }
180191
200211
201212 PM.add(createGCInfoDeleter());
202213
214 // Delete machine code for this function
215 PM.add(createMachineCodeDeleter());
216
203217 return false; // success!
204218 }
205219
250264
251265 // Standard Lower-Level Passes.
252266
253 // Set up a MachineFunction for the rest of CodeGen to work on.
254 PM.add(new MachineFunctionAnalysis(*this, OptLevel));
255
256267 // Enable FastISel with -fast, but allow that to be overridden.
257268 if (EnableFastISelOption == cl::BOU_TRUE ||
258269 (OptLevel == CodeGenOpt::None && EnableFastISelOption != cl::BOU_FALSE))
4747 void LiveVariables::getAnalysisUsage(AnalysisUsage &AU) const {
4848 AU.addRequiredID(UnreachableMachineBlockElimID);
4949 AU.setPreservesAll();
50 MachineFunctionPass::getAnalysisUsage(AU);
5150 }
5251
5352 void LiveVariables::VarInfo::dump() const {
3535 #include
3636 using namespace llvm;
3737
38 bool MachineFunctionPass::runOnFunction(Function &F) {
39 // Do not codegen any 'available_externally' functions at all, they have
40 // definitions outside the translation unit.
41 if (F.hasAvailableExternallyLinkage())
42 return false;
43
44 return runOnMachineFunction(MachineFunction::get(&F));
45 }
46
3847 namespace {
3948 struct VISIBILITY_HIDDEN Printer : public MachineFunctionPass {
4049 static char ID;
4958
5059 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5160 AU.setPreservesAll();
52 MachineFunctionPass::getAnalysisUsage(AU);
5361 }
5462
5563 bool runOnMachineFunction(MachineFunction &MF) {
6977 return new Printer(OS, Banner);
7078 }
7179
80 namespace {
81 struct VISIBILITY_HIDDEN Deleter : public MachineFunctionPass {
82 static char ID;
83 Deleter() : MachineFunctionPass(&ID) {}
84
85 const char *getPassName() const { return "Machine Code Deleter"; }
86
87 bool runOnMachineFunction(MachineFunction &MF) {
88 // Delete the annotation from the function now.
89 MachineFunction::destruct(MF.getFunction());
90 return true;
91 }
92 };
93 char Deleter::ID = 0;
94 }
95
96 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
97 /// the current function, which should happen after the function has been
98 /// emitted to a .s file or to memory.
99 FunctionPass *llvm::createMachineCodeDeleter() {
100 return new Deleter();
101 }
102
103
104
72105 //===---------------------------------------------------------------------===//
73106 // MachineFunction implementation
74107 //===---------------------------------------------------------------------===//
77110 MBB->getParent()->DeleteMachineBasicBlock(MBB);
78111 }
79112
80 MachineFunction::MachineFunction(Function *F,
113 MachineFunction::MachineFunction(const Function *F,
81114 const TargetMachine &TM)
82115 : Annotation(AnnotationManager::getID("CodeGen::MachineCodeForFunction")),
83116 Fn(F), Target(TM) {
320353 cerr << "SelectionDAG::viewGraph is only available in debug builds on "
321354 << "systems with Graphviz or gv!\n";
322355 #endif // NDEBUG
356 }
357
358 // The next two methods are used to construct and to retrieve
359 // the MachineCodeForFunction object for the given function.
360 // construct() -- Allocates and initializes for a given function and target
361 // get() -- Returns a handle to the object.
362 // This should not be called before "construct()"
363 // for a given Function.
364 //
365 MachineFunction&
366 MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
367 {
368 AnnotationID MF_AID =
369 AnnotationManager::getID("CodeGen::MachineCodeForFunction");
370 assert(Fn->getAnnotation(MF_AID) == 0 &&
371 "Object already exists for this function!");
372 MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
373 Fn->addAnnotation(mcInfo);
374 return *mcInfo;
375 }
376
377 void MachineFunction::destruct(const Function *Fn) {
378 AnnotationID MF_AID =
379 AnnotationManager::getID("CodeGen::MachineCodeForFunction");
380 bool Deleted = Fn->deleteAnnotation(MF_AID);
381 assert(Deleted && "Machine code did not exist for function!");
382 Deleted = Deleted; // silence warning when no assertions.
383 }
384
385 MachineFunction& MachineFunction::get(const Function *F)
386 {
387 AnnotationID MF_AID =
388 AnnotationManager::getID("CodeGen::MachineCodeForFunction");
389 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID);
390 assert(mc && "Call construct() method first to allocate the object");
391 return *mc;
323392 }
324393
325394 /// addLiveIn - Add the specified physical register as a live-in value and
+0
-45
lib/CodeGen/MachineFunctionAnalysis.cpp less more
None //===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the definitions of the MachineFunctionAnalysis members.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
14 #include "llvm/CodeGen/MachineFunction.h"
15 using namespace llvm;
16
17 // Register this pass with PassInfo directly to avoid having to define
18 // a default constructor.
19 static PassInfo
20 X("Machine Function Analysis", "machine-function-analysis",
21 intptr_t(&MachineFunctionAnalysis::ID), 0,
22 /*CFGOnly=*/false, /*is_analysis=*/true);
23
24 char MachineFunctionAnalysis::ID = 0;
25
26 MachineFunctionAnalysis::MachineFunctionAnalysis(TargetMachine &tm,
27 CodeGenOpt::Level OL) :
28 FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) {
29 }
30
31 bool MachineFunctionAnalysis::runOnFunction(Function &F) {
32 assert(!MF && "MachineFunctionAnalysis already initialized!");
33 MF = new MachineFunction(&F, TM);
34 return false;
35 }
36
37 void MachineFunctionAnalysis::releaseMemory() {
38 delete MF;
39 MF = 0;
40 }
41
42 void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
43 AU.setPreservesAll();
44 }
+0
-50
lib/CodeGen/MachineFunctionPass.cpp less more
None //===-- MachineFunctionPass.cpp -------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the definitions of the MachineFunctionPass members.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/Analysis/AliasAnalysis.h"
14 #include "llvm/Analysis/ScalarEvolution.h"
15 #include "llvm/Analysis/IVUsers.h"
16 #include "llvm/Analysis/LiveValues.h"
17 #include "llvm/Analysis/LoopDependenceAnalysis.h"
18 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
19 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
20 #include "llvm/CodeGen/MachineFunctionPass.h"
21 using namespace llvm;
22
23 bool MachineFunctionPass::runOnFunction(Function &F) {
24 // Do not codegen any 'available_externally' functions at all, they have
25 // definitions outside the translation unit.
26 if (F.hasAvailableExternallyLinkage())
27 return false;
28
29 MachineFunction &MF = getAnalysis().getMF();
30 return runOnMachineFunction(MF);
31 }
32
33 void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
34 AU.addRequired();
35
36 // MachineFunctionPass preserves all LLVM IR passes, but there's no
37 // high-level way to express this. Instead, just list a bunch of
38 // passes explicitly.
39 AU.addPreserved();
40 AU.addPreserved();
41 AU.addPreserved();
42 AU.addPreserved();
43 AU.addPreserved();
44 AU.addPreserved();
45 AU.addPreserved();
46 AU.setPreservesCFG();
47
48 FunctionPass::getAnalysisUsage(AU);
49 }
4040 void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
4141 AU.setPreservesAll();
4242 AU.addRequired();
43 MachineFunctionPass::getAnalysisUsage(AU);
4443 }
5454
5555 void getAnalysisUsage(AnalysisUsage &AU) const {
5656 AU.setPreservesAll();
57 MachineFunctionPass::getAnalysisUsage(AU);
5857 }
5958
6059 bool runOnMachineFunction(MachineFunction &MF);
110110
111111 #if 0
112112 void PEI::getAnalysisUsage(AnalysisUsage &AU) const {
113 AU.setPreservesCFG();
113114 if (ShrinkWrapping || ShrinkWrapFunc != "") {
114115 AU.addRequired();
115116 AU.addRequired();
2828 #include "llvm/CodeGen/GCStrategy.h"
2929 #include "llvm/CodeGen/GCMetadata.h"
3030 #include "llvm/CodeGen/MachineFunction.h"
31 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
3231 #include "llvm/CodeGen/MachineFrameInfo.h"
3332 #include "llvm/CodeGen/MachineInstrBuilder.h"
3433 #include "llvm/CodeGen/MachineJumpTableInfo.h"
267266 //===----------------------------------------------------------------------===//
268267
269268 SelectionDAGISel::SelectionDAGISel(TargetMachine &tm, CodeGenOpt::Level OL) :
270 MachineFunctionPass(&ID), TM(tm), TLI(*tm.getTargetLowering()),
269 FunctionPass(&ID), TM(tm), TLI(*tm.getTargetLowering()),
271270 FuncInfo(new FunctionLoweringInfo(TLI)),
272271 CurDAG(new SelectionDAG(TLI, *FuncInfo)),
273272 SDL(new SelectionDAGLowering(*CurDAG, TLI, *FuncInfo, OL)),
291290 AU.addRequired();
292291 AU.addRequired();
293292 AU.setPreservesAll();
294 MachineFunctionPass::getAnalysisUsage(AU);
295 }
296
297 bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
298 Function &Fn = *mf.getFunction();
299
293 }
294
295 bool SelectionDAGISel::runOnFunction(Function &Fn) {
300296 // Do some sanity-checking on the command-line options.
301297 assert((!EnableFastISelVerbose || EnableFastISel) &&
302298 "-fast-isel-verbose requires -fast-isel");
308304 if (Fn.hasAvailableExternallyLinkage())
309305 return false;
310306
307
311308 // Get alias analysis for load/store combining.
312309 AA = &getAnalysis();
313310
314311 TargetMachine &TM = TLI.getTargetMachine();
315 MF = &mf;
312 MF = &MachineFunction::construct(&Fn, TM);
316313 const TargetInstrInfo &TII = *TM.getInstrInfo();
317314 const TargetRegisterInfo &TRI = *TM.getRegisterInfo();
318315
252252 SPUtli(*tm.getTargetLowering())
253253 { }
254254
255 virtual bool runOnMachineFunction(MachineFunction &MF) {
255 virtual bool runOnFunction(Function &Fn) {
256256 // Make sure we re-emit a set of the global base reg if necessary
257257 GlobalBaseReg = 0;
258 SelectionDAGISel::runOnMachineFunction(MF);
258 SelectionDAGISel::runOnFunction(Fn);
259259 return true;
260260 }
261261
1919 #include "PPCHazardRecognizers.h"
2020 #include "llvm/CodeGen/MachineInstrBuilder.h"
2121 #include "llvm/CodeGen/MachineFunction.h"
22 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
2322 #include "llvm/CodeGen/MachineRegisterInfo.h"
2423 #include "llvm/CodeGen/SelectionDAG.h"
2524 #include "llvm/CodeGen/SelectionDAGISel.h"
5150 PPCLowering(*TM.getTargetLowering()),
5251 PPCSubTarget(*TM.getSubtargetImpl()) {}
5352
54 virtual bool runOnMachineFunction(MachineFunction &MF) {
53 virtual bool runOnFunction(Function &Fn) {
54 // Do not codegen any 'available_externally' functions at all, they have
55 // definitions outside the translation unit.
56 if (Fn.hasAvailableExternallyLinkage())
57 return false;
58
5559 // Make sure we re-emit a set of the global base reg if necessary
5660 GlobalBaseReg = 0;
57 SelectionDAGISel::runOnMachineFunction(MF);
58
59 InsertVRSaveCode(MF);
61 SelectionDAGISel::runOnFunction(Fn);
62
63 InsertVRSaveCode(Fn);
6064 return true;
6165 }
6266
176180 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
177181 virtual void InstructionSelect();
178182
179 void InsertVRSaveCode(MachineFunction &MF);
183 void InsertVRSaveCode(Function &Fn);
180184
181185 virtual const char *getPassName() const {
182186 return "PowerPC DAG->DAG Pattern Instruction Selection";
213217 /// InsertVRSaveCode - Once the entire function has been instruction selected,
214218 /// all virtual registers are created and all machine instructions are built,
215219 /// check to see if we need to save/restore VRSAVE. If so, do it.
216 void PPCDAGToDAGISel::InsertVRSaveCode(MachineFunction &Fn) {
220 void PPCDAGToDAGISel::InsertVRSaveCode(Function &F) {
217221 // Check to see if this function uses vector registers, which means we have to
218222 // save and restore the VRSAVE register and update it with the regs we use.
219223 //
220224 // In this case, there will be virtual registers of vector type type created
221225 // by the scheduler. Detect them now.
226 MachineFunction &Fn = MachineFunction::get(&F);
222227 bool HasVectorVReg = false;
223228 for (unsigned i = TargetRegisterInfo::FirstVirtualRegister,
224229 e = RegInfo->getLastVirtReg()+1; i != e; ++i)