[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Constants.cpp Type.cpp ValueTypes.cpp

Reid Spencer reid at x10sys.com
Fri Jan 19 13:14:33 PST 2007



Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.132 -> 1.133
Constants.cpp updated: 1.201 -> 1.202
Type.cpp updated: 1.163 -> 1.164
ValueTypes.cpp updated: 1.10 -> 1.11
---
Log message:

For PR1043: http://llvm.org/PR1043 :
This is the final patch for this PR. It implements some minor cleanup 
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*

This also fixes PR1120: http://llvm.org/PR1120 .

Patch by Sheng Zhou.



---
Diffs of the changes:  (+14 -9)

 ConstantFolding.cpp |    7 +------
 Constants.cpp       |    4 ++--
 Type.cpp            |   11 ++++++++++-
 ValueTypes.cpp      |    1 +
 4 files changed, 14 insertions(+), 9 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.132 llvm/lib/VMCore/ConstantFolding.cpp:1.133
--- llvm/lib/VMCore/ConstantFolding.cpp:1.132	Sun Jan 14 20:27:26 2007
+++ llvm/lib/VMCore/ConstantFolding.cpp	Fri Jan 19 15:13:56 2007
@@ -295,13 +295,8 @@
     // Handle ConstantFP input.
     if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
       // FP -> Integral.
-      if (DestTy->isInteger()) {
-        if (DestTy == Type::Int32Ty)
-          return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
-        assert(DestTy == Type::Int64Ty && 
-               "Incorrect integer type for bitcast!");
+      if (DestTy->isInteger())
         return ConstantInt::get(DestTy, DoubleToBits(FP->getValue()));
-      }
     }
     return 0;
   default:


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.201 llvm/lib/VMCore/Constants.cpp:1.202
--- llvm/lib/VMCore/Constants.cpp:1.201	Sun Jan 14 20:27:26 2007
+++ llvm/lib/VMCore/Constants.cpp	Fri Jan 19 15:13:56 2007
@@ -568,7 +568,7 @@
   unsigned NumBits = cast<IntegerType>(Ty)->getBitWidth(); // assert okay
   assert(NumBits <= 64 && "Not implemented: integers > 64-bits");
   if (Ty == Type::Int1Ty)
-    return Val == 0 || Val == 1;
+    return Val == 0 || Val == 1 || Val == -1;
   if (NumBits == 64)
     return true; // always true, has to fit in largest type
   int64_t Min = -(1ll << (NumBits-1));
@@ -849,7 +849,7 @@
       return getTrue();
     else
       return getFalse();
-  return IntConstants->getOrCreate(Ty, V & Ty->getIntegerTypeMask());
+  return IntConstants->getOrCreate(Ty, V & cast<IntegerType>(Ty)->getBitMask());
 }
 
 //---- ConstantFP::get() implementation...


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.163 llvm/lib/VMCore/Type.cpp:1.164
--- llvm/lib/VMCore/Type.cpp:1.163	Thu Jan 18 12:14:49 2007
+++ llvm/lib/VMCore/Type.cpp	Fri Jan 19 15:13:56 2007
@@ -81,6 +81,15 @@
   }
 }
 
+const Type *Type::getVAArgsPromotedType() const {
+  if (ID == IntegerTyID && getSubclassData() < 32)
+    return Type::Int32Ty;
+  else if (ID == FloatTyID)
+    return Type::DoubleTy;
+  else
+    return this;
+}
+
 /// isFPOrFPVector - Return true if this is a FP type or a vector of FP types.
 ///
 bool Type::isFPOrFPVector() const {
@@ -352,7 +361,7 @@
     };                                                       \
   }                                                          \
   static ManagedStatic<TY##Type> The##TY##Ty;                \
-  const Type *Type::TY##Ty = &*The##TY##Ty
+  const IntegerType *Type::TY##Ty = &*The##TY##Ty
 
 DeclarePrimType(Void,   "void");
 DeclarePrimType(Float,  "float");


Index: llvm/lib/VMCore/ValueTypes.cpp
diff -u llvm/lib/VMCore/ValueTypes.cpp:1.10 llvm/lib/VMCore/ValueTypes.cpp:1.11
--- llvm/lib/VMCore/ValueTypes.cpp:1.10	Thu Jan 11 12:21:29 2007
+++ llvm/lib/VMCore/ValueTypes.cpp	Fri Jan 19 15:13:56 2007
@@ -13,6 +13,7 @@
 
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/Type.h"
+#include "llvm/DerivedTypes.h"
 using namespace llvm;
 
 /// MVT::getValueTypeString - This function returns value type as a string,






More information about the llvm-commits mailing list