Clean up a lot of the code I added yesterday by exposing the IntrinsicLowering

implementation from the TargetMachine directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-12-28 21:23:38 +00:00
parent 27490a6fcc
commit f70e0c216c
21 changed files with 76 additions and 107 deletions

View File

@ -22,7 +22,6 @@ class Function;
class FunctionPass; class FunctionPass;
class InstrForest; class InstrForest;
class InstructionNode; class InstructionNode;
class IntrinsicLowering;
class MachineCodeForInstruction; class MachineCodeForInstruction;
class MachineInstr; class MachineInstr;
class TargetMachine; class TargetMachine;
@ -40,8 +39,6 @@ extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
extern bool ThisIsAChainRule (int eruleno); extern bool ThisIsAChainRule (int eruleno);
//************************ Exported Functions ******************************/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Function: createInstructionSelectionPass // Function: createInstructionSelectionPass
@ -51,12 +48,9 @@ extern bool ThisIsAChainRule (int eruleno);
// Return a pass that performs machine dependent instruction selection. // Return a pass that performs machine dependent instruction selection.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
FunctionPass *createInstructionSelectionPass(TargetMachine &Target, FunctionPass *createInstructionSelectionPass(TargetMachine &Target);
IntrinsicLowering &IL);
//************************ Exported Data Types *****************************/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// class TmpInstruction // class TmpInstruction

View File

@ -33,6 +33,8 @@
#ifndef LLVM_INTRINSICLOWERING_H #ifndef LLVM_INTRINSICLOWERING_H
#define LLVM_INTRINSICLOWERING_H #define LLVM_INTRINSICLOWERING_H
#include "llvm/Intrinsics.h"
namespace llvm { namespace llvm {
class CallInst; class CallInst;

View File

@ -33,6 +33,8 @@
#ifndef LLVM_INTRINSICLOWERING_H #ifndef LLVM_INTRINSICLOWERING_H
#define LLVM_INTRINSICLOWERING_H #define LLVM_INTRINSICLOWERING_H
#include "llvm/Intrinsics.h"
namespace llvm { namespace llvm {
class CallInst; class CallInst;

View File

@ -31,6 +31,7 @@ class MRegisterInfo;
class FunctionPassManager; class FunctionPassManager;
class PassManager; class PassManager;
class Pass; class Pass;
class IntrinsicLowering;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// ///
@ -40,24 +41,27 @@ class Pass;
/// ///
class TargetMachine { class TargetMachine {
const std::string Name; const std::string Name;
const TargetData DataLayout; // Calculates type size & alignment const TargetData DataLayout; // Calculates type size & alignment
IntrinsicLowering *IL; // Specifies how to lower intrinsic calls
TargetMachine(const TargetMachine&); // DO NOT IMPLEMENT TargetMachine(const TargetMachine&); // DO NOT IMPLEMENT
void operator=(const TargetMachine&); // DO NOT IMPLEMENT void operator=(const TargetMachine&); // DO NOT IMPLEMENT
protected: protected: // Can only create subclasses...
TargetMachine(const std::string &name, // Can only create subclasses... TargetMachine(const std::string &name, IntrinsicLowering *IL,
bool LittleEndian = false, bool LittleEndian = false,
unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char PtrSize = 8, unsigned char PtrAl = 8,
unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
unsigned char LongAl = 8, unsigned char IntAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4,
unsigned char ShortAl = 2, unsigned char ByteAl = 1) unsigned char ShortAl = 2, unsigned char ByteAl = 1);
: Name(name), DataLayout(name, LittleEndian,
PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
IntAl, ShortAl, ByteAl) {}
public: public:
virtual ~TargetMachine() {} virtual ~TargetMachine();
const std::string &getName() const { return Name; } const std::string &getName() const { return Name; }
// getIntrinsicLowering - This method returns a reference to an
// IntrinsicLowering instance which should be used by the code generator to
// lower unknown intrinsic functions to the equivalent LLVM expansion.
IntrinsicLowering &getIntrinsicLowering() const { return *IL; }
// Interfaces to the major aspects of target machine information: // Interfaces to the major aspects of target machine information:
// -- Instruction opcode and operand information // -- Instruction opcode and operand information

View File

@ -16,7 +16,6 @@
#include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelection.h"
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/iPHINode.h" #include "llvm/iPHINode.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
@ -68,7 +67,6 @@ namespace {
// //
class InstructionSelection : public FunctionPass { class InstructionSelection : public FunctionPass {
TargetMachine &Target; TargetMachine &Target;
IntrinsicLowering &IL;
void InsertCodeForPhis(Function &F); void InsertCodeForPhis(Function &F);
void InsertPhiElimInstructions(BasicBlock *BB, void InsertPhiElimInstructions(BasicBlock *BB,
const std::vector<MachineInstr*>& CpVec); const std::vector<MachineInstr*>& CpVec);
@ -76,8 +74,7 @@ namespace {
void PostprocessMachineCodeForTree(InstructionNode* instrNode, void PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode, short* nts); int ruleForNode, short* nts);
public: public:
InstructionSelection(TargetMachine &TM, IntrinsicLowering &il) InstructionSelection(TargetMachine &TM) : Target(TM) {}
: Target(TM), IL(il) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG(); AU.setPreservesCFG();
@ -145,7 +142,7 @@ bool InstructionSelection::runOnFunction(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = CI->getPrev(); Instruction *Before = CI->getPrev();
IL.LowerIntrinsicCall(CI); Target.getIntrinsicLowering().LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
} else { } else {
@ -415,7 +412,6 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode,
// createInstructionSelectionPass - Public entrypoint for instruction selection // createInstructionSelectionPass - Public entrypoint for instruction selection
// and this file as a whole... // and this file as a whole...
// //
FunctionPass *llvm::createInstructionSelectionPass(TargetMachine &T, FunctionPass *llvm::createInstructionSelectionPass(TargetMachine &TM) {
IntrinsicLowering &IL) { return new InstructionSelection(TM);
return new InstructionSelection(T, IL);
} }

View File

@ -13,7 +13,6 @@
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/Constant.h" #include "llvm/Constant.h"
#include "llvm/Intrinsics.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"

View File

@ -17,7 +17,6 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/Intrinsics.h"
#include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/GetElementPtrTypeIterator.h"
#include "Support/Statistic.h" #include "Support/Statistic.h"
#include "Support/Debug.h" #include "Support/Debug.h"

View File

@ -16,7 +16,6 @@
#include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelection.h"
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/iPHINode.h" #include "llvm/iPHINode.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
@ -68,7 +67,6 @@ namespace {
// //
class InstructionSelection : public FunctionPass { class InstructionSelection : public FunctionPass {
TargetMachine &Target; TargetMachine &Target;
IntrinsicLowering &IL;
void InsertCodeForPhis(Function &F); void InsertCodeForPhis(Function &F);
void InsertPhiElimInstructions(BasicBlock *BB, void InsertPhiElimInstructions(BasicBlock *BB,
const std::vector<MachineInstr*>& CpVec); const std::vector<MachineInstr*>& CpVec);
@ -76,8 +74,7 @@ namespace {
void PostprocessMachineCodeForTree(InstructionNode* instrNode, void PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode, short* nts); int ruleForNode, short* nts);
public: public:
InstructionSelection(TargetMachine &TM, IntrinsicLowering &il) InstructionSelection(TargetMachine &TM) : Target(TM) {}
: Target(TM), IL(il) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG(); AU.setPreservesCFG();
@ -145,7 +142,7 @@ bool InstructionSelection::runOnFunction(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = CI->getPrev(); Instruction *Before = CI->getPrev();
IL.LowerIntrinsicCall(CI); Target.getIntrinsicLowering().LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
} else { } else {
@ -415,7 +412,6 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode,
// createInstructionSelectionPass - Public entrypoint for instruction selection // createInstructionSelectionPass - Public entrypoint for instruction selection
// and this file as a whole... // and this file as a whole...
// //
FunctionPass *llvm::createInstructionSelectionPass(TargetMachine &T, FunctionPass *llvm::createInstructionSelectionPass(TargetMachine &TM) {
IntrinsicLowering &IL) { return new InstructionSelection(TM);
return new InstructionSelection(T, IL);
} }

View File

@ -18,13 +18,11 @@
namespace llvm { namespace llvm {
class TargetMachine; class TargetMachine;
class IntrinsicLowering;
class SparcJITInfo : public TargetJITInfo { class SparcJITInfo : public TargetJITInfo {
TargetMachine &TM; TargetMachine &TM;
IntrinsicLowering &IL;
public: public:
SparcJITInfo(TargetMachine &tm, IntrinsicLowering &il) : TM(tm), IL(il) {} SparcJITInfo(TargetMachine &tm) : TM(tm) {}
/// addPassesToJITCompile - Add passes to the specified pass manager to /// addPassesToJITCompile - Add passes to the specified pass manager to
/// implement a fast dynamic compiler for this target. Return true if this /// implement a fast dynamic compiler for this target. Return true if this

View File

@ -116,17 +116,12 @@ FunctionPass *llvm::createSparcMachineCodeDestructionPass() {
SparcTargetMachine::SparcTargetMachine(IntrinsicLowering *il) SparcTargetMachine::SparcTargetMachine(IntrinsicLowering *il)
: TargetMachine("UltraSparc-Native", false), : TargetMachine("UltraSparc-Native", il, false),
IL(il ? il : new DefaultIntrinsicLowering()),
schedInfo(*this), schedInfo(*this),
regInfo(*this), regInfo(*this),
frameInfo(*this), frameInfo(*this),
cacheInfo(*this), cacheInfo(*this),
jitInfo(*this, *IL) { jitInfo(*this) {
}
SparcTargetMachine::~SparcTargetMachine() {
delete IL;
} }
// addPassesToEmitAssembly - This method controls the entire code generation // addPassesToEmitAssembly - This method controls the entire code generation
@ -171,7 +166,7 @@ SparcTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
PM.add(new PrintFunctionPass("Input code to instr. selection:\n", PM.add(new PrintFunctionPass("Input code to instr. selection:\n",
&std::cerr)); &std::cerr));
PM.add(createInstructionSelectionPass(*this, *IL)); PM.add(createInstructionSelectionPass(*this));
if (!DisableSched) if (!DisableSched)
PM.add(createInstructionSchedulingWithSSAPass(*this)); PM.add(createInstructionSchedulingWithSSAPass(*this));
@ -238,7 +233,7 @@ void SparcJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
//PM.add(createLICMPass()); //PM.add(createLICMPass());
//PM.add(createGCSEPass()); //PM.add(createGCSEPass());
PM.add(createInstructionSelectionPass(TM, IL)); PM.add(createInstructionSelectionPass(TM));
PM.add(getRegisterAllocator(TM)); PM.add(getRegisterAllocator(TM));
PM.add(createPrologEpilogInsertionPass()); PM.add(createPrologEpilogInsertionPass());

View File

@ -24,10 +24,8 @@
namespace llvm { namespace llvm {
class PassManager; class PassManager;
class IntrinsicLowering;
class SparcTargetMachine : public TargetMachine { class SparcTargetMachine : public TargetMachine {
IntrinsicLowering *IL;
SparcInstrInfo instrInfo; SparcInstrInfo instrInfo;
SparcSchedInfo schedInfo; SparcSchedInfo schedInfo;
SparcRegInfo regInfo; SparcRegInfo regInfo;
@ -36,7 +34,6 @@ class SparcTargetMachine : public TargetMachine {
SparcJITInfo jitInfo; SparcJITInfo jitInfo;
public: public:
SparcTargetMachine(IntrinsicLowering *IL); SparcTargetMachine(IntrinsicLowering *IL);
~SparcTargetMachine();
virtual const TargetInstrInfo &getInstrInfo() const { return instrInfo; } virtual const TargetInstrInfo &getInstrInfo() const { return instrInfo; }
virtual const TargetSchedInfo &getSchedInfo() const { return schedInfo; } virtual const TargetSchedInfo &getSchedInfo() const { return schedInfo; }

View File

@ -15,20 +15,33 @@
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetCacheInfo.h" #include "llvm/Target/TargetCacheInfo.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/IntrinsicLowering.h"
namespace llvm { using namespace llvm;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// class TargetMachine // TargetMachine Class
// //
// Purpose: TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
// Machine description. bool LittleEndian,
// unsigned char PtrSize, unsigned char PtrAl,
//--------------------------------------------------------------------------- unsigned char DoubleAl, unsigned char FloatAl,
unsigned char LongAl, unsigned char IntAl,
unsigned char ShortAl, unsigned char ByteAl)
: Name(name), DataLayout(name, LittleEndian,
PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
IntAl, ShortAl, ByteAl) {
IL = il ? il : new DefaultIntrinsicLowering();
}
TargetMachine::~TargetMachine() {
delete IL;
}
// function TargetMachine::findOptimalStorageSize
//
unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const { unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
// All integer types smaller than ints promote to 4 byte integers. // All integer types smaller than ints promote to 4 byte integers.
if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4) if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
@ -39,11 +52,8 @@ unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// class TargetCacheInfo // TargetCacheInfo Class
// //
// Purpose:
// Describes properties of the target cache architecture.
//---------------------------------------------------------------------------
void TargetCacheInfo::Initialize() { void TargetCacheInfo::Initialize() {
numLevels = 2; numLevels = 2;
@ -51,5 +61,3 @@ void TargetCacheInfo::Initialize() {
cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20); cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
cacheAssoc.push_back(1); cacheAssoc.push_back(4); cacheAssoc.push_back(1); cacheAssoc.push_back(4);
} }
} // End llvm namespace

View File

@ -119,7 +119,6 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) {
/// into a machine code representation using pattern matching and a machine /// into a machine code representation using pattern matching and a machine
/// description file. /// description file.
/// ///
FunctionPass *llvm::createX86PatternInstructionSelector(TargetMachine &TM, FunctionPass *llvm::createX86PatternInstructionSelector(TargetMachine &TM) {
IntrinsicLowering &IL) {
return new ISel(TM); return new ISel(TM);
} }

View File

@ -18,7 +18,6 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineConstantPool.h"
@ -59,7 +58,6 @@ inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB,
namespace { namespace {
struct ISel : public FunctionPass, InstVisitor<ISel> { struct ISel : public FunctionPass, InstVisitor<ISel> {
TargetMachine &TM; TargetMachine &TM;
IntrinsicLowering &IL;
MachineFunction *F; // The function we are compiling into MachineFunction *F; // The function we are compiling into
MachineBasicBlock *BB; // The current MBB we are compiling MachineBasicBlock *BB; // The current MBB we are compiling
int VarArgsFrameIndex; // FrameIndex for start of varargs area int VarArgsFrameIndex; // FrameIndex for start of varargs area
@ -69,8 +67,7 @@ namespace {
// MBBMap - Mapping between LLVM BB -> Machine BB // MBBMap - Mapping between LLVM BB -> Machine BB
std::map<const BasicBlock*, MachineBasicBlock*> MBBMap; std::map<const BasicBlock*, MachineBasicBlock*> MBBMap;
ISel(TargetMachine &tm, IntrinsicLowering &il) ISel(TargetMachine &tm) : TM(tm), F(0), BB(0) {}
: TM(tm), IL(il), F(0), BB(0) {}
/// runOnFunction - Top level implementation of instruction selection for /// runOnFunction - Top level implementation of instruction selection for
/// the entire function. /// the entire function.
@ -1116,7 +1113,7 @@ void ISel::LowerUnknownIntrinsicFunctionCalls(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = CI->getPrev(); Instruction *Before = CI->getPrev();
IL.LowerIntrinsicCall(CI); TM.getIntrinsicLowering().LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
} else { } else {
@ -2196,7 +2193,6 @@ void ISel::visitFreeInst(FreeInst &I) {
/// into a machine code representation is a very simple peep-hole fashion. The /// into a machine code representation is a very simple peep-hole fashion. The
/// generated code sucks but the implementation is nice and simple. /// generated code sucks but the implementation is nice and simple.
/// ///
FunctionPass *llvm::createX86SimpleInstructionSelector(TargetMachine &TM, FunctionPass *llvm::createX86SimpleInstructionSelector(TargetMachine &TM) {
IntrinsicLowering &IL) { return new ISel(TM);
return new ISel(TM, IL);
} }

View File

@ -27,15 +27,13 @@ class IntrinsicLowering;
/// into a machine code representation in a very simple peep-hole fashion. The /// into a machine code representation in a very simple peep-hole fashion. The
/// generated code sucks but the implementation is nice and simple. /// generated code sucks but the implementation is nice and simple.
/// ///
FunctionPass *createX86SimpleInstructionSelector(TargetMachine &TM, FunctionPass *createX86SimpleInstructionSelector(TargetMachine &TM);
IntrinsicLowering &IL);
/// createX86PatternInstructionSelector - This pass converts an LLVM function /// createX86PatternInstructionSelector - This pass converts an LLVM function
/// into a machine code representation using pattern matching and a machine /// into a machine code representation using pattern matching and a machine
/// description file. /// description file.
/// ///
FunctionPass *createX86PatternInstructionSelector(TargetMachine &TM, FunctionPass *createX86PatternInstructionSelector(TargetMachine &TM);
IntrinsicLowering &IL);
/// createX86SSAPeepholeOptimizerPass - Create a pass to perform SSA-based X86 /// createX86SSAPeepholeOptimizerPass - Create a pass to perform SSA-based X86
/// specific peephole optimizations. /// specific peephole optimizations.

View File

@ -119,7 +119,6 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) {
/// into a machine code representation using pattern matching and a machine /// into a machine code representation using pattern matching and a machine
/// description file. /// description file.
/// ///
FunctionPass *llvm::createX86PatternInstructionSelector(TargetMachine &TM, FunctionPass *llvm::createX86PatternInstructionSelector(TargetMachine &TM) {
IntrinsicLowering &IL) {
return new ISel(TM); return new ISel(TM);
} }

View File

@ -18,7 +18,6 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineConstantPool.h"
@ -59,7 +58,6 @@ inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB,
namespace { namespace {
struct ISel : public FunctionPass, InstVisitor<ISel> { struct ISel : public FunctionPass, InstVisitor<ISel> {
TargetMachine &TM; TargetMachine &TM;
IntrinsicLowering &IL;
MachineFunction *F; // The function we are compiling into MachineFunction *F; // The function we are compiling into
MachineBasicBlock *BB; // The current MBB we are compiling MachineBasicBlock *BB; // The current MBB we are compiling
int VarArgsFrameIndex; // FrameIndex for start of varargs area int VarArgsFrameIndex; // FrameIndex for start of varargs area
@ -69,8 +67,7 @@ namespace {
// MBBMap - Mapping between LLVM BB -> Machine BB // MBBMap - Mapping between LLVM BB -> Machine BB
std::map<const BasicBlock*, MachineBasicBlock*> MBBMap; std::map<const BasicBlock*, MachineBasicBlock*> MBBMap;
ISel(TargetMachine &tm, IntrinsicLowering &il) ISel(TargetMachine &tm) : TM(tm), F(0), BB(0) {}
: TM(tm), IL(il), F(0), BB(0) {}
/// runOnFunction - Top level implementation of instruction selection for /// runOnFunction - Top level implementation of instruction selection for
/// the entire function. /// the entire function.
@ -1116,7 +1113,7 @@ void ISel::LowerUnknownIntrinsicFunctionCalls(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = CI->getPrev(); Instruction *Before = CI->getPrev();
IL.LowerIntrinsicCall(CI); TM.getIntrinsicLowering().LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
} else { } else {
@ -2196,7 +2193,6 @@ void ISel::visitFreeInst(FreeInst &I) {
/// into a machine code representation is a very simple peep-hole fashion. The /// into a machine code representation is a very simple peep-hole fashion. The
/// generated code sucks but the implementation is nice and simple. /// generated code sucks but the implementation is nice and simple.
/// ///
FunctionPass *llvm::createX86SimpleInstructionSelector(TargetMachine &TM, FunctionPass *llvm::createX86SimpleInstructionSelector(TargetMachine &TM) {
IntrinsicLowering &IL) { return new ISel(TM);
return new ISel(TM, IL);
} }

View File

@ -22,9 +22,8 @@ namespace llvm {
class X86JITInfo : public TargetJITInfo { class X86JITInfo : public TargetJITInfo {
TargetMachine &TM; TargetMachine &TM;
IntrinsicLowering &IL;
public: public:
X86JITInfo(TargetMachine &tm, IntrinsicLowering &il) : TM(tm), IL(il) {} X86JITInfo(TargetMachine &tm) : TM(tm) {}
/// addPassesToJITCompile - Add passes to the specified pass manager to /// addPassesToJITCompile - Add passes to the specified pass manager to
/// implement a fast dynamic compiler for this target. Return true if this /// implement a fast dynamic compiler for this target. Return true if this
@ -37,7 +36,7 @@ namespace llvm {
/// overwriting OLD with a branch to NEW. This is used for self-modifying /// overwriting OLD with a branch to NEW. This is used for self-modifying
/// code. /// code.
/// ///
virtual void replaceMachineCodeForFunction (void *Old, void *New); virtual void replaceMachineCodeForFunction(void *Old, void *New);
/// getJITStubForFunction - Create or return a stub for the specified /// getJITStubForFunction - Create or return a stub for the specified
/// function. This stub acts just like the specified function, except that /// function. This stub acts just like the specified function, except that

View File

@ -45,15 +45,10 @@ TargetMachine *llvm::allocateX86TargetMachine(const Module &M,
/// X86TargetMachine ctor - Create an ILP32 architecture model /// X86TargetMachine ctor - Create an ILP32 architecture model
/// ///
X86TargetMachine::X86TargetMachine(const Module &M, IntrinsicLowering *il) X86TargetMachine::X86TargetMachine(const Module &M, IntrinsicLowering *IL)
: TargetMachine("X86", true, 4, 4, 4, 4, 4), : TargetMachine("X86", IL, true, 4, 4, 4, 4, 4),
IL(il ? il : new DefaultIntrinsicLowering()),
FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4), FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4),
JITInfo(*this, *IL) { JITInfo(*this) {
}
X86TargetMachine::~X86TargetMachine() {
delete IL;
} }
@ -72,9 +67,9 @@ bool X86TargetMachine::addPassesToEmitAssembly(PassManager &PM,
PM.add(createCFGSimplificationPass()); PM.add(createCFGSimplificationPass());
if (NoPatternISel) if (NoPatternISel)
PM.add(createX86SimpleInstructionSelector(*this, *IL)); PM.add(createX86SimpleInstructionSelector(*this));
else else
PM.add(createX86PatternInstructionSelector(*this, *IL)); PM.add(createX86PatternInstructionSelector(*this));
// Run optional SSA-based machine code optimizations next... // Run optional SSA-based machine code optimizations next...
if (!NoSSAPeephole) if (!NoSSAPeephole)
@ -127,9 +122,9 @@ void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
PM.add(createCFGSimplificationPass()); PM.add(createCFGSimplificationPass());
if (NoPatternISel) if (NoPatternISel)
PM.add(createX86SimpleInstructionSelector(TM, IL)); PM.add(createX86SimpleInstructionSelector(TM));
else else
PM.add(createX86PatternInstructionSelector(TM, IL)); PM.add(createX86PatternInstructionSelector(TM));
// Run optional SSA-based machine code optimizations next... // Run optional SSA-based machine code optimizations next...
if (!NoSSAPeephole) if (!NoSSAPeephole)

View File

@ -24,13 +24,11 @@ namespace llvm {
class IntrinsicLowering; class IntrinsicLowering;
class X86TargetMachine : public TargetMachine { class X86TargetMachine : public TargetMachine {
IntrinsicLowering *IL;
X86InstrInfo InstrInfo; X86InstrInfo InstrInfo;
TargetFrameInfo FrameInfo; TargetFrameInfo FrameInfo;
X86JITInfo JITInfo; X86JITInfo JITInfo;
public: public:
X86TargetMachine(const Module &M, IntrinsicLowering *IL); X86TargetMachine(const Module &M, IntrinsicLowering *IL);
~X86TargetMachine();
virtual const X86InstrInfo &getInstrInfo() const { return InstrInfo; } virtual const X86InstrInfo &getInstrInfo() const { return InstrInfo; }
virtual const TargetFrameInfo &getFrameInfo() const { return FrameInfo; } virtual const TargetFrameInfo &getFrameInfo() const { return FrameInfo; }

View File

@ -13,7 +13,6 @@
#include "llvm/IntrinsicLowering.h" #include "llvm/IntrinsicLowering.h"
#include "llvm/Constant.h" #include "llvm/Constant.h"
#include "llvm/Intrinsics.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"