Factor out FastISel's code for materializing constants and other values
authorDan Gohman <gohman@apple.com>
Mon, 3 May 2010 23:36:34 +0000 (23:36 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 3 May 2010 23:36:34 +0000 (23:36 +0000)
in registers into a separate function to de-couple it from the
top-down-specific logic in getRegForValue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102975 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/FastISel.h
lib/CodeGen/SelectionDAG/FastISel.cpp

index 2eb2df2f60176eff9005d8c6c277c91c37bb2f4b..5a2b0e7c765f211074e4defe0c8eec336064d7fc 100644 (file)
@@ -311,6 +311,11 @@ private:
   /// might result in multiple MBB's for one BB.  As such, the start of the
   /// BB might correspond to a different MBB than the end.
   bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
+
+  /// materializeRegForValue - Helper for getRegForVale. This function is
+  /// called when the value isn't already available in a register and must
+  /// be materialized with new instructions.
+  unsigned materializeRegForValue(const Value *V, MVT VT);
 };
 
 }
index 49bfbffa623c13bc56418f98b1c7a75e4e96949c..b4c38332691c79c1d9ecda4d6261430e4794fe6a 100644 (file)
@@ -84,6 +84,15 @@ unsigned FastISel::getRegForValue(const Value *V) {
   if (Reg != 0)
     return Reg;
 
+  return materializeRegForValue(V, VT);
+}
+
+/// materializeRegForValue - Helper for getRegForVale. This function is
+/// called when the value isn't already available in a register and must
+/// be materialized with new instructions.
+unsigned FastISel::materializeRegForValue(const Value *V, MVT VT) {
+  unsigned Reg = 0;
+
   if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
     if (CI->getValue().getActiveBits() <= 64)
       Reg = FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
@@ -141,7 +150,7 @@ unsigned FastISel::lookUpRegForValue(const Value *V) {
   // Look up the value to see if we already have a register for it. We
   // cache values defined by Instructions across blocks, and other values
   // only locally. This is because Instructions already have the SSA
-  // def-dominatess-use requirement enforced.
+  // def-dominates-use requirement enforced.
   if (ValueMap.count(V))
     return ValueMap[V];
   return LocalValueMap[V];