Factor out the code for sign-extending/truncating gep indices
[oota-llvm.git] / include / llvm / CodeGen / FastISel.h
index 9d33340de7805fc521a30af796489d655cd1d198..1cc83106052e3168e59e1255df081f5e08c1dc7b 100644 (file)
 
 #include "llvm/BasicBlock.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/CodeGen/SelectionDAGNodes.h"
 
 namespace llvm {
 
 class AllocaInst;
 class ConstantFP;
+class Instruction;
 class MachineBasicBlock;
 class MachineConstantPool;
 class MachineFunction;
@@ -44,6 +46,9 @@ protected:
   DenseMap<const Value *, unsigned> &ValueMap;
   DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap;
   DenseMap<const AllocaInst *, int> &StaticAllocaMap;
+#ifndef NDEBUG
+  SmallSet<Instruction*, 8> &CatchInfoLost;
+#endif
   MachineFunction &MF;
   MachineModuleInfo *MMI;
   MachineRegisterInfo &MRI;
@@ -55,12 +60,20 @@ protected:
   const TargetLowering &TLI;
 
 public:
+  /// startNewBlock - Set the current block, to which generated
+  /// machine instructions will be appended, and clear the local
+  /// CSE map.
+  ///
+  void startNewBlock(MachineBasicBlock *mbb) {
+    setCurrentBlock(mbb);
+    LocalValueMap.clear();
+  }
+
   /// setCurrentBlock - Set the current block, to which generated
   /// machine instructions will be appended.
   ///
   void setCurrentBlock(MachineBasicBlock *mbb) {
     MBB = mbb;
-    LocalValueMap.clear();
   }
 
   /// SelectInstruction - Do "fast" instruction selection for the given
@@ -93,6 +106,11 @@ public:
   /// defined locally.
   unsigned lookUpRegForValue(Value *V);
 
+  /// getRegForGEPIndex - This is a wrapper around getRegForValue that also
+  /// takes care of truncating or sign-extending the given getelementptr
+  /// index value.
+  unsigned getRegForGEPIndex(Value *V);
+
   virtual ~FastISel();
 
 protected:
@@ -100,7 +118,11 @@ protected:
            MachineModuleInfo *mmi,
            DenseMap<const Value *, unsigned> &vm,
            DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,
-           DenseMap<const AllocaInst *, int> &am);
+           DenseMap<const AllocaInst *, int> &am
+#ifndef NDEBUG
+           , SmallSet<Instruction*, 8> &cil
+#endif
+           );
 
   /// FastEmit_r - This method is called by target-independent code
   /// to request that an instruction with the given type and opcode
@@ -238,6 +260,11 @@ protected:
   /// from a specified index of a superregister.
   unsigned FastEmitInst_extractsubreg(unsigned Op0, uint32_t Idx);
 
+  /// FastEmitBranch - Emit an unconditional branch to the given block,
+  /// unless it is the immediate (fall-through) successor, and update
+  /// the CFG.
+  void FastEmitBranch(MachineBasicBlock *MBB);
+
   void UpdateValueMap(Value* I, unsigned Reg);
 
   unsigned createResultReg(const TargetRegisterClass *RC);