[llvm-commits] [SignlessTypes] CVS: llvm/lib/CodeGen/AsmPrinter.cpp IntrinsicLowering.cpp MachineDebugInfo.cpp

Reid Spencer reid at x10sys.com
Wed Oct 18 20:59:01 PDT 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.111 -> 1.111.2.1
IntrinsicLowering.cpp updated: 1.43 -> 1.43.6.1
MachineDebugInfo.cpp updated: 1.50 -> 1.50.2.1
---
Log message:

For PR950: http://llvm.org/PR950 :
This commit (on SignlessTypes branch) provides the first Iteration for 
moving LLVM away from Signed types. This patch removes the ConstantSInt
and ConstantUInt classes from Type.h and makes all necessary changes in
LLVM to compensate.


---
Diffs of the changes:  (+50 -39)

 AsmPrinter.cpp        |   17 +++++++++--------
 IntrinsicLowering.cpp |   43 ++++++++++++++++++++++++++-----------------
 MachineDebugInfo.cpp  |   29 +++++++++++++++--------------
 3 files changed, 50 insertions(+), 39 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.111 llvm/lib/CodeGen/AsmPrinter.cpp:1.111.2.1
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.111	Tue Oct 17 12:17:24 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Wed Oct 18 22:57:55 2006
@@ -393,14 +393,15 @@
   else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
     assert(CB->getValue());
     O << "1";
-  } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
-    if (((CI->getValue() << 32) >> 32) == CI->getValue())
-      O << CI->getValue();
-    else
-      O << (uint64_t)CI->getValue();
-  else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
-    O << CI->getValue();
-  else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
+  } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
+    if (CI->getType()->isSigned()) {
+      if (((CI->getSExtValue() << 32) >> 32) == CI->getSExtValue())
+        O << CI->getSExtValue();
+      else
+        O << (uint64_t)CI->getSExtValue();
+    } else 
+      O << CI->getZExtValue();
+  } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
     // This is a constant address for a global variable or function. Use the
     // name of the variable or function as the address value, possibly
     // decorating it with GlobalVarAddrPrefix/Suffix or


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43.6.1
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43	Thu Mar 23 12:06:46 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp	Wed Oct 18 22:57:55 2006
@@ -166,10 +166,12 @@
     Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
                               ConstantInt::get(Type::UByteTy,24),"bswap.1", IP);
     Tmp3 = BinaryOperator::createAnd(Tmp3, 
-                                     ConstantUInt::get(Type::UIntTy, 0xFF0000),
+                                     ConstantInt::get(Type::UIntTy, 
+                                       uint32_t(0xFF0000)),
                                      "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2, 
-                                     ConstantUInt::get(Type::UIntTy, 0xFF00),
+                                     ConstantInt::get(Type::UIntTy, 
+                                       uint32_t(0xFF00)),
                                      "bswap.and2", IP);
     Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP);
     Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP);
@@ -194,23 +196,29 @@
     Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
                               ConstantInt::get(Type::UByteTy,56),"bswap.1", IP);
     Tmp7 = BinaryOperator::createAnd(Tmp7,
-                          ConstantUInt::get(Type::ULongTy, 0xFF000000000000ULL),
-                          "bswap.and7", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF000000000000ULL)),
+                             "bswap.and7", IP);
     Tmp6 = BinaryOperator::createAnd(Tmp6,
-                            ConstantUInt::get(Type::ULongTy, 0xFF0000000000ULL),
-                            "bswap.and6", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF0000000000ULL)),
+                             "bswap.and6", IP);
     Tmp5 = BinaryOperator::createAnd(Tmp5,
-                              ConstantUInt::get(Type::ULongTy, 0xFF00000000ULL),
-                              "bswap.and5", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF00000000ULL)),
+                             "bswap.and5", IP);
     Tmp4 = BinaryOperator::createAnd(Tmp4,
-                                ConstantUInt::get(Type::ULongTy, 0xFF000000ULL),
-                                "bswap.and4", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF000000ULL)),
+                             "bswap.and4", IP);
     Tmp3 = BinaryOperator::createAnd(Tmp3,
-                                  ConstantUInt::get(Type::ULongTy, 0xFF0000ULL),
-                                  "bswap.and3", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF0000ULL)),
+                             "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2,
-                                    ConstantUInt::get(Type::ULongTy, 0xFF00ULL),
-                                    "bswap.and2", IP);
+                             ConstantInt::get(Type::ULongTy, 
+                               uint64_t(0xFF00ULL)),
+                             "bswap.and2", IP);
     Tmp8 = BinaryOperator::createOr(Tmp8, Tmp7, "bswap.or1", IP);
     Tmp6 = BinaryOperator::createOr(Tmp6, Tmp5, "bswap.or2", IP);
     Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or3", IP);
@@ -247,8 +255,9 @@
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   for (unsigned i = 1, ct = 0; i != BitSize; i <<= 1, ++ct) {
     Value *MaskCst =
-      ConstantExpr::getCast(ConstantUInt::get(Type::ULongTy,
-                                              MaskValues[ct]), V->getType());
+      ConstantExpr::getCast(ConstantInt::get(Type::ULongTy, 
+                                             uint64_t(MaskValues[ct])),
+                                             V->getType());
     Value *LHS = BinaryOperator::createAnd(V, MaskCst, "cppop.and1", IP);
     Value *VShift = new ShiftInst(Instruction::Shr, V,
                       ConstantInt::get(Type::UByteTy, i), "ctpop.sh", IP);
@@ -395,7 +404,7 @@
   case Intrinsic::readcyclecounter: {
     std::cerr << "WARNING: this target does not support the llvm.readcyclecoun"
               << "ter intrinsic.  It is being lowered to a constant 0\n";
-    CI->replaceAllUsesWith(ConstantUInt::get(Type::ULongTy, 0));
+    CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, uint32_t(0)));
     break;
   }
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.50 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.50.2.1
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.50	Tue Oct 17 18:16:42 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Wed Oct 18 22:57:55 2006
@@ -120,7 +120,7 @@
 
 /// getUIntOperand - Return ith operand if it is an unsigned integer.
 ///
-static ConstantUInt *getUIntOperand(GlobalVariable *GV, unsigned i) {
+static ConstantInt *getUIntOperand(GlobalVariable *GV, unsigned i) {
   // Make sure the GlobalVariable has an initializer.
   if (!GV->hasInitializer()) return NULL;
   
@@ -133,8 +133,9 @@
   if (i >= N) return NULL;
 
   // Check constant.
-  return dyn_cast<ConstantUInt>(CI->getOperand(i));
+  return dyn_cast<ConstantInt>(CI->getOperand(i));
 }
+
 //===----------------------------------------------------------------------===//
 
 /// ApplyToFields - Target the visitor to each field of the debug information
@@ -192,19 +193,19 @@
   ///
   virtual void Apply(int &Field) {
     Constant *C = CI->getOperand(I++);
-    Field = cast<ConstantSInt>(C)->getValue();
+    Field = cast<ConstantInt>(C)->getSExtValue();
   }
   virtual void Apply(unsigned &Field) {
     Constant *C = CI->getOperand(I++);
-    Field = cast<ConstantUInt>(C)->getValue();
+    Field = cast<ConstantInt>(C)->getZExtValue();
   }
   virtual void Apply(int64_t &Field) {
     Constant *C = CI->getOperand(I++);
-    Field = cast<ConstantSInt>(C)->getValue();
+    Field = cast<ConstantInt>(C)->getSExtValue();
   }
   virtual void Apply(uint64_t &Field) {
     Constant *C = CI->getOperand(I++);
-    Field = cast<ConstantUInt>(C)->getValue();
+    Field = cast<ConstantInt>(C)->getZExtValue();
   }
   virtual void Apply(bool &Field) {
     Constant *C = CI->getOperand(I++);
@@ -261,16 +262,16 @@
   /// Apply - Set the value of each of the fields.
   ///
   virtual void Apply(int &Field) {
-    Elements.push_back(ConstantSInt::get(Type::IntTy, Field));
+    Elements.push_back(ConstantInt::get(Type::IntTy, int32_t(Field)));
   }
   virtual void Apply(unsigned &Field) {
-    Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
+    Elements.push_back(ConstantInt::get(Type::UIntTy, uint32_t(Field)));
   }
   virtual void Apply(int64_t &Field) {
-    Elements.push_back(ConstantSInt::get(Type::LongTy, Field));
+    Elements.push_back(ConstantInt::get(Type::LongTy, int64_t(Field)));
   }
   virtual void Apply(uint64_t &Field) {
-    Elements.push_back(ConstantUInt::get(Type::ULongTy, Field));
+    Elements.push_back(ConstantInt::get(Type::ULongTy, uint64_t(Field)));
   }
   virtual void Apply(bool &Field) {
     Elements.push_back(ConstantBool::get(Field));
@@ -467,8 +468,8 @@
 /// TagFromGlobal - Returns the tag number from a debug info descriptor
 /// GlobalVariable.   Return DIIValid if operand is not an unsigned int. 
 unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
-  ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? ((unsigned)C->getValue() & ~LLVMDebugVersionMask) :
+  ConstantInt *C = getUIntOperand(GV, 0);
+  return C ? ((unsigned)C->getZExtValue() & ~LLVMDebugVersionMask) :
              (unsigned)DW_TAG_invalid;
 }
 
@@ -476,8 +477,8 @@
 /// descriptor GlobalVariable.  Return DIIValid if operand is not an unsigned
 /// int.
 unsigned  DebugInfoDesc::VersionFromGlobal(GlobalVariable *GV) {
-  ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? ((unsigned)C->getValue() & LLVMDebugVersionMask) :
+  ConstantInt *C = getUIntOperand(GV, 0);
+  return C ? ((unsigned)C->getZExtValue() & LLVMDebugVersionMask) :
              (unsigned)DW_TAG_invalid;
 }
 






More information about the llvm-commits mailing list