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

Reid Spencer reid at x10sys.com
Fri Oct 20 00:08:34 PDT 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.111 -> 1.112
IntrinsicLowering.cpp updated: 1.43 -> 1.44
MachineDebugInfo.cpp updated: 1.50 -> 1.51
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


---
Diffs of the changes:  (+45 -42)

 AsmPrinter.cpp        |   23 ++++++++++++-----------
 IntrinsicLowering.cpp |   35 ++++++++++++++++++-----------------
 MachineDebugInfo.cpp  |   29 +++++++++++++++--------------
 3 files changed, 45 insertions(+), 42 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.111 llvm/lib/CodeGen/AsmPrinter.cpp:1.112
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.111	Tue Oct 17 12:17:24 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Fri Oct 20 02:07:24 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
@@ -492,7 +493,7 @@
   O << "\"";
   for (unsigned i = 0; i != LastElt; ++i) {
     unsigned char C =
-        (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
+        (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getZExtValue();
 
     if (C == '"') {
       O << "\\\"";
@@ -524,7 +525,7 @@
 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
   unsigned NumElts = CVA->getNumOperands();
   if (TAI->getAscizDirective() && NumElts && 
-      cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
+      cast<ConstantInt>(CVA->getOperand(NumElts-1))->getZExtValue() == 0) {
     O << TAI->getAscizDirective();
     printAsCString(O, CVA, NumElts-1);
   } else {
@@ -604,7 +605,7 @@
     }
   } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
     if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
-      uint64_t Val = CI->getRawValue();
+      uint64_t Val = CI->getZExtValue();
 
       if (TAI->getData64bitsDirective())
         O << TAI->getData64bitsDirective() << Val << "\n";


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.44
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43	Thu Mar 23 12:06:46 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp	Fri Oct 20 02:07:24 2006
@@ -166,10 +166,10 @@
     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, 0xFF0000),
                                      "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2, 
-                                     ConstantUInt::get(Type::UIntTy, 0xFF00),
+                                     ConstantInt::get(Type::UIntTy, 0xFF00),
                                      "bswap.and2", IP);
     Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP);
     Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP);
@@ -194,23 +194,24 @@
     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, 
+                               0xFF000000000000ULL),
+                             "bswap.and7", IP);
     Tmp6 = BinaryOperator::createAnd(Tmp6,
-                            ConstantUInt::get(Type::ULongTy, 0xFF0000000000ULL),
-                            "bswap.and6", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF0000000000ULL),
+                             "bswap.and6", IP);
     Tmp5 = BinaryOperator::createAnd(Tmp5,
-                              ConstantUInt::get(Type::ULongTy, 0xFF00000000ULL),
-                              "bswap.and5", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF00000000ULL),
+                             "bswap.and5", IP);
     Tmp4 = BinaryOperator::createAnd(Tmp4,
-                                ConstantUInt::get(Type::ULongTy, 0xFF000000ULL),
-                                "bswap.and4", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF000000ULL),
+                             "bswap.and4", IP);
     Tmp3 = BinaryOperator::createAnd(Tmp3,
-                                  ConstantUInt::get(Type::ULongTy, 0xFF0000ULL),
-                                  "bswap.and3", IP);
+                             ConstantInt::get(Type::ULongTy, 0xFF0000ULL),
+                             "bswap.and3", IP);
     Tmp2 = BinaryOperator::createAnd(Tmp2,
-                                    ConstantUInt::get(Type::ULongTy, 0xFF00ULL),
-                                    "bswap.and2", IP);
+                             ConstantInt::get(Type::ULongTy, 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 +248,8 @@
   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, 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 +396,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, 0));
     break;
   }
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.50 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.51
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.50	Tue Oct 17 18:16:42 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Fri Oct 20 02:07:24 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