[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Sat Jan 28 21:17:33 PST 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.155 -> 1.156
---
Log message:

make the casts actually cast to the variable type

---
Diffs of the changes:  (+10 -7)

 DAGISelEmitter.cpp |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.155 llvm/utils/TableGen/DAGISelEmitter.cpp:1.156
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.155	Sat Jan 28 23:07:04 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Sat Jan 28 23:17:22 2006
@@ -2069,18 +2069,21 @@
       unsigned ResNo = TmpNo++;
       unsigned NumRes = 1;
       if (!N->isLeaf() && N->getOperator()->getName() == "imm") {
+        const char* CastType;
         assert(N->getExtTypes().size() == 1 && "Multiple types not handled!");
         const char *Code;
         switch (N->getTypeNum(0)) {
         default: assert(0 && "Unknown type for constant node!");
-        case MVT::i1:  Code = "bool Tmp"; break;
-        case MVT::i8:  Code = "unsigned char Tmp"; break;
-        case MVT::i16: Code = "unsigned short Tmp"; break;
-        case MVT::i32: Code = "unsigned Tmp"; break;
-        case MVT::i64: Code = "uint64_t Tmp"; break;
+        case MVT::i1:  CastType = "bool"; Code = "bool Tmp"; break;
+        case MVT::i8: 
+          CastType = "unsigned char"; Code = "unsigned char Tmp"; break;
+        case MVT::i16:
+          CastType = "unsigned short"; Code = "unsigned short Tmp"; break;
+        case MVT::i32: CastType = "unsigned"; Code = "unsigned Tmp"; break;
+        case MVT::i64: CastType = "uint64_t"; Code = "uint64_t Tmp"; break;
         }
-        emitCode(Code + utostr(ResNo) + "C = (uint64_t)cast<ConstantSDNode>(" +
-                 Val + ")->getValue();");
+        emitCode(Code + utostr(ResNo) + "C = (" + CastType + 
+                 ")cast<ConstantSDNode>(" + Val + ")->getValue();");
         emitCode("SDOperand Tmp" + utostr(ResNo) + 
                  " = CurDAG->getTargetConstant(Tmp" + utostr(ResNo) + 
                  "C, MVT::" + getEnumName(N->getTypeNum(0)) + ");");






More information about the llvm-commits mailing list