LLVM API Documentation
00001 //===-- llvm/CodeGen/SelectionDAGISel.h - Common Base Class------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the SelectionDAGISel class, which is used as the common 00011 // base class for SelectionDAG-based instruction selectors. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CODEGEN_SELECTIONDAG_ISEL_H 00016 #define LLVM_CODEGEN_SELECTIONDAG_ISEL_H 00017 00018 #include "llvm/BasicBlock.h" 00019 #include "llvm/Pass.h" 00020 #include "llvm/Constant.h" 00021 #include "llvm/CodeGen/SelectionDAG.h" 00022 00023 namespace llvm { 00024 class FastISel; 00025 class SelectionDAGLowering; 00026 class SDValue; 00027 class MachineRegisterInfo; 00028 class MachineBasicBlock; 00029 class MachineFunction; 00030 class MachineInstr; 00031 class MachineModuleInfo; 00032 class TargetLowering; 00033 class TargetInstrInfo; 00034 class FunctionLoweringInfo; 00035 class HazardRecognizer; 00036 class GCFunctionInfo; 00037 class ScheduleDAG; 00038 00039 /// SelectionDAGISel - This is the common base class used for SelectionDAG-based 00040 /// pattern-matching instruction selectors. 00041 class SelectionDAGISel : public FunctionPass { 00042 public: 00043 TargetLowering &TLI; 00044 MachineRegisterInfo *RegInfo; 00045 FunctionLoweringInfo *FuncInfo; 00046 SelectionDAG *CurDAG; 00047 SelectionDAGLowering *SDL; 00048 MachineBasicBlock *BB; 00049 AliasAnalysis *AA; 00050 GCFunctionInfo *GFI; 00051 bool Fast; 00052 static char ID; 00053 00054 explicit SelectionDAGISel(TargetLowering &tli, bool fast = false); 00055 virtual ~SelectionDAGISel(); 00056 00057 TargetLowering &getTargetLowering() { return TLI; } 00058 00059 virtual void getAnalysisUsage(AnalysisUsage &AU) const; 00060 00061 virtual bool runOnFunction(Function &Fn); 00062 00063 unsigned MakeReg(MVT VT); 00064 00065 virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {} 00066 virtual void InstructionSelect() = 0; 00067 00068 void SelectRootInit() { 00069 DAGSize = CurDAG->AssignTopologicalOrder(); 00070 } 00071 00072 /// SelectInlineAsmMemoryOperand - Select the specified address as a target 00073 /// addressing mode, according to the specified constraint code. If this does 00074 /// not match or is not implemented, return true. The resultant operands 00075 /// (which will appear in the machine instruction) should be added to the 00076 /// OutOps vector. 00077 virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, 00078 char ConstraintCode, 00079 std::vector<SDValue> &OutOps) { 00080 return true; 00081 } 00082 00083 /// IsLegalAndProfitableToFold - Returns true if the specific operand node N of 00084 /// U can be folded during instruction selection that starts at Root and 00085 /// folding N is profitable. 00086 virtual 00087 bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U, SDNode *Root) const { 00088 return true; 00089 } 00090 00091 /// CreateTargetHazardRecognizer - Return a newly allocated hazard recognizer 00092 /// to use for this target when scheduling the DAG. 00093 virtual HazardRecognizer *CreateTargetHazardRecognizer(); 00094 00095 protected: 00096 /// DAGSize - Size of DAG being instruction selected. 00097 /// 00098 unsigned DAGSize; 00099 00100 /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated 00101 /// by tblgen. Others should not call it. 00102 void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops); 00103 00104 // Calls to these predicates are generated by tblgen. 00105 bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, 00106 int64_t DesiredMaskS) const; 00107 bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, 00108 int64_t DesiredMaskS) const; 00109 00110 private: 00111 void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, 00112 MachineModuleInfo *MMI, 00113 const TargetInstrInfo &TII); 00114 void FinishBasicBlock(); 00115 00116 void SelectBasicBlock(BasicBlock *LLVMBB, 00117 BasicBlock::iterator Begin, 00118 BasicBlock::iterator End); 00119 void CodeGenAndEmitDAG(); 00120 void LowerArguments(BasicBlock *BB); 00121 00122 void ComputeLiveOutVRegInfo(); 00123 00124 void HandlePHINodesInSuccessorBlocks(BasicBlock *LLVMBB); 00125 00126 bool HandlePHINodesInSuccessorBlocksFast(BasicBlock *LLVMBB, FastISel *F); 00127 00128 /// Pick a safe ordering for instructions for each target node in the 00129 /// graph. 00130 ScheduleDAG *Schedule(); 00131 }; 00132 00133 } 00134 00135 #endif /* LLVM_CODEGEN_SELECTIONDAG_ISEL_H */
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.