[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Aug 24 21:47:30 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelDAGToDAG.cpp updated: 1.27 -> 1.28
---
Log message:

Add support for FP constants, fixing UnitTests/2004-02-02-NegativeZero


---
Diffs of the changes:  (+25 -6)

 PPC32ISelDAGToDAG.cpp |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.27 llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.28
--- llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.27	Wed Aug 24 19:45:43 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp	Wed Aug 24 23:47:18 2005
@@ -15,6 +15,7 @@
 #include "PowerPC.h"
 #include "PPC32TargetMachine.h"
 #include "PPC32ISelLowering.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/SSARegMap.h"
@@ -22,6 +23,7 @@
 #include "llvm/CodeGen/SelectionDAGISel.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Constants.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
@@ -141,12 +143,15 @@
     // look for the first zero bit after the run of ones
     ME = CountLeadingZeros_32((Val - 1) ^ Val);
     return true;
-  } else if (isShiftedMask_32(Val = ~Val)) { // invert mask
-                                             // effectively look for the first zero bit
-    ME = CountLeadingZeros_32(Val) - 1;
-    // effectively look for the first one bit after the run of zeros
-    MB = CountLeadingZeros_32((Val - 1) ^ Val) + 1;
-    return true;
+  } else {
+    Val = ~Val; // invert mask
+    if (isShiftedMask_32(Val)) {
+      // effectively look for the first zero bit
+      ME = CountLeadingZeros_32(Val) - 1;
+      // effectively look for the first one bit after the run of zeros
+      MB = CountLeadingZeros_32((Val - 1) ^ Val) + 1;
+      return true;
+    }
   }
   // no run present
   return false;
@@ -525,6 +530,20 @@
     }
     break;
   }
+  case ISD::ConstantFP: {  // FIXME: this should get sucked into the legalizer
+    MachineConstantPool *CP = CurDAG->getMachineFunction().getConstantPool();
+    Constant *CFP = ConstantFP::get(Type::FloatTy,
+                                    cast<ConstantFPSDNode>(N)->getValue());
+    SDOperand CPN = CurDAG->getConstantPool(CP->getConstantPoolIndex(CFP),
+                                            MVT::i32);
+    SDOperand Tmp;
+    if (PICEnabled)
+      Tmp = CurDAG->getTargetNode(PPC::ADDIS, MVT::i32, getGlobalBaseReg(),CPN);
+    else
+      Tmp = CurDAG->getTargetNode(PPC::LIS, MVT::i32, CPN);
+    CurDAG->SelectNodeTo(N, N->getValueType(0), PPC::LFS, CPN, Tmp);
+    break;
+  }
   case ISD::UNDEF:
     if (N->getValueType(0) == MVT::i32)
       CurDAG->SelectNodeTo(N, MVT::i32, PPC::IMPLICIT_DEF_GPR);






More information about the llvm-commits mailing list