[llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp TransformInternals.cpp

Reid Spencer reid at x10sys.com
Sat Dec 30 21:49:03 PST 2006



Changes in directory llvm/lib/Transforms:

ExprTypeConvert.cpp updated: 1.118 -> 1.119
LevelRaise.cpp updated: 1.117 -> 1.118
TransformInternals.cpp updated: 1.51 -> 1.52
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int   -> Int32
4. [U]Long  -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
   and other methods related to signedness. In a few places this warranted
   identifying the signedness information from other sources.



---
Diffs of the changes:  (+15 -16)

 ExprTypeConvert.cpp    |   19 +++++++++----------
 LevelRaise.cpp         |    4 ++--
 TransformInternals.cpp |    8 ++++----
 3 files changed, 15 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/ExprTypeConvert.cpp
diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.118 llvm/lib/Transforms/ExprTypeConvert.cpp:1.119
--- llvm/lib/Transforms/ExprTypeConvert.cpp:1.118	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/ExprTypeConvert.cpp	Sat Dec 30 23:48:39 2006
@@ -210,8 +210,9 @@
     Constant *CPV = cast<Constant>(V);
     // Constants are converted by constant folding the cast that is required.
     // We assume here that all casts are implemented for constant prop.
-    Instruction::CastOps opcode = CastInst::getCastOpcode(CPV,
-        CPV->getType()->isSigned(), Ty, Ty->isSigned());
+    // FIXME: This seems to work, but it is unclear why ZEXT is always the
+    // right choice here.
+    Instruction::CastOps opcode = CastInst::getCastOpcode(CPV, false, Ty,false);
     Value *Result = ConstantExpr::getCast(opcode, CPV, Ty);
     // Add the instruction to the expression map
     //VMC.ExprMap[V] = Result;
@@ -231,7 +232,7 @@
   case Instruction::BitCast: {
     assert(VMC.NewCasts.count(ValueHandle(VMC, I)) == 0);
     Instruction::CastOps opcode = CastInst::getCastOpcode(I->getOperand(0),
-        I->getOperand(0)->getType()->isSigned(), Ty, Ty->isSigned());
+        false, Ty, false);
     Res = CastInst::create(opcode, I->getOperand(0), Ty, Name);
     VMC.NewCasts.insert(ValueHandle(VMC, Res));
     break;
@@ -473,8 +474,6 @@
   }
   case Instruction::LShr:
   case Instruction::AShr:
-    if (Ty->isSigned() != V->getType()->isSigned()) return false;
-    // FALL THROUGH
   case Instruction::Shl:
     if (I->getOperand(1) == V) return false;  // Cannot change shift amount type
     if (!Ty->isInteger()) return false;
@@ -713,8 +712,8 @@
 
   switch (I->getOpcode()) {
   case Instruction::BitCast: {
-    Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal,
-        NewVal->getType()->isSigned(), I->getType(), I->getType()->isSigned());
+    Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal, false, 
+                                                          I->getType(), false);
     Res = CastInst::create(opcode, NewVal, I->getType(), Name);
     break;
   }
@@ -768,7 +767,7 @@
 
     if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
       std::vector<Value*> Indices;
-      Indices.push_back(Constant::getNullValue(Type::UIntTy));
+      Indices.push_back(Constant::getNullValue(Type::Int32Ty));
 
       unsigned Offset = 0;   // No offset, get first leaf.
       LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false);
@@ -801,7 +800,7 @@
 
         if (ElTy != NewTy) {
           std::vector<Value*> Indices;
-          Indices.push_back(Constant::getNullValue(Type::UIntTy));
+          Indices.push_back(Constant::getNullValue(Type::Int32Ty));
 
           unsigned Offset = 0;
           const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false);
@@ -830,7 +829,7 @@
 
       if (isa<StructType>(ValTy)) {
         std::vector<Value*> Indices;
-        Indices.push_back(Constant::getNullValue(Type::UIntTy));
+        Indices.push_back(Constant::getNullValue(Type::Int32Ty));
 
         unsigned Offset = 0;
         ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false);


Index: llvm/lib/Transforms/LevelRaise.cpp
diff -u llvm/lib/Transforms/LevelRaise.cpp:1.117 llvm/lib/Transforms/LevelRaise.cpp:1.118
--- llvm/lib/Transforms/LevelRaise.cpp:1.117	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/LevelRaise.cpp	Sat Dec 30 23:48:39 2006
@@ -206,7 +206,7 @@
           // Build the index vector, full of all zeros
           std::vector<Value*> Indices;
 
-          Indices.push_back(Constant::getNullValue(Type::UIntTy));
+          Indices.push_back(Constant::getNullValue(Type::Int32Ty));
           while (CurCTy && !isa<PointerType>(CurCTy)) {
             if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
               // Check for a zero element struct type... if we have one, bail.
@@ -221,7 +221,7 @@
             }
 
             // Insert a zero to index through this type...
-            Indices.push_back(Constant::getNullValue(Type::UIntTy));
+            Indices.push_back(Constant::getNullValue(Type::Int32Ty));
 
             // Did we find what we're looking for?
             if (ElTy->canLosslesslyBitCastTo(DestPointedTy)) break;


Index: llvm/lib/Transforms/TransformInternals.cpp
diff -u llvm/lib/Transforms/TransformInternals.cpp:1.51 llvm/lib/Transforms/TransformInternals.cpp:1.52
--- llvm/lib/Transforms/TransformInternals.cpp:1.51	Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/TransformInternals.cpp	Sat Dec 30 23:48:39 2006
@@ -34,7 +34,7 @@
          (i == SL->MemberOffsets.size()-1 || Offset < SL->MemberOffsets[i+1]));
 
   // Make sure to save the current index...
-  Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+  Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
   Offset = SL->MemberOffsets[i];
   return STy->getContainedType(i);
 }
@@ -73,11 +73,11 @@
 
     NextType = ATy->getElementType();
     unsigned ChildSize = (unsigned)TD.getTypeSize(NextType);
-    if (ConstantInt::isValueValidForType(Type::IntTy, 
+    if (ConstantInt::isValueValidForType(Type::Int32Ty, 
                                          uint64_t(Offset/ChildSize)))
-      Indices.push_back(ConstantInt::get(Type::IntTy, Offset/ChildSize));
+      Indices.push_back(ConstantInt::get(Type::Int32Ty, Offset/ChildSize));
     else
-      Indices.push_back(ConstantInt::get(Type::LongTy, Offset/ChildSize));
+      Indices.push_back(ConstantInt::get(Type::Int64Ty, Offset/ChildSize));
     ThisOffset = (Offset/ChildSize)*ChildSize;
   } else {
     Offset = 0;   // Return the offset that we were able to achieve






More information about the llvm-commits mailing list