diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-29 22:37:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-29 22:37:54 +0000 |
commit | b4f68ed32ede4cf7d31ce9e516e4074dad0a24ee (patch) | |
tree | bb4d2d8830f9cb5d0904e93950221dbce528b873 /lib/Target/X86/InstSelectSimple.cpp | |
parent | c66583ef3b08abf73cd527d299d978e38a5254ef (diff) |
Convert backend to use passes, implement X86TargetMachine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstSelectSimple.cpp')
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 4491fdf792..4659bea907 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -10,28 +10,32 @@ #include "llvm/iTerminators.h" #include "llvm/Type.h" #include "llvm/Constants.h" +#include "llvm/Pass.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Support/InstVisitor.h" #include <map> namespace { - struct ISel : public InstVisitor<ISel> { // eventually will be a FunctionPass + struct ISel : public FunctionPass, InstVisitor<ISel> { + TargetMachine &TM; MachineFunction *F; // The function we are compiling into MachineBasicBlock *BB; // The current MBB we are compiling unsigned CurReg; std::map<Value*, unsigned> RegMap; // Mapping between Val's and SSA Regs - ISel(MachineFunction *f) - : F(f), BB(0), CurReg(MRegisterInfo::FirstVirtualRegister) {} + ISel(TargetMachine &tm) + : TM(tm), F(0), BB(0), CurReg(MRegisterInfo::FirstVirtualRegister) {} /// runOnFunction - Top level implementation of instruction selection for /// the entire function. /// - bool runOnFunction(Function &F) { - visit(F); + bool runOnFunction(Function &Fn) { + F = new MachineFunction(&Fn, TM); + visit(Fn); RegMap.clear(); + F = 0; return false; // We never modify the LLVM itself. } @@ -161,14 +165,10 @@ void ISel::visitAdd(BinaryOperator &B) { } } - - -/// X86SimpleInstructionSelection - This function converts an LLVM function into -/// a machine code representation is a very simple peep-hole fashion. The +/// createSimpleX86InstructionSelector - This pass converts an LLVM function +/// into a machine code representation is a very simple peep-hole fashion. The /// generated code sucks but the implementation is nice and simple. /// -MachineFunction *X86SimpleInstructionSelection(Function &F, TargetMachine &TM) { - MachineFunction *Result = new MachineFunction(&F, TM); - ISel(Result).runOnFunction(F); - return Result; +Pass *createSimpleX86InstructionSelector(TargetMachine &TM) { + return new ISel(TM); } |