[llvm-commits] CVS: llvm/lib/VMCore/ConstantHandling.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Aug 13 10:53:01 PDT 2003
Changes in directory llvm/lib/VMCore:
ConstantHandling.cpp updated: 1.32 -> 1.33
---
Log message:
Implement constant folding of casts from boolean constants to other values
---
Diffs of the changes:
Index: llvm/lib/VMCore/ConstantHandling.cpp
diff -u llvm/lib/VMCore/ConstantHandling.cpp:1.32 llvm/lib/VMCore/ConstantHandling.cpp:1.33
--- llvm/lib/VMCore/ConstantHandling.cpp:1.32 Thu Jun 26 00:22:45 2003
+++ llvm/lib/VMCore/ConstantHandling.cpp Wed Aug 13 10:52:25 2003
@@ -344,6 +344,25 @@
static Constant *Xor(const ConstantBool *V1, const ConstantBool *V2) {
return ConstantBool::get(V1->getValue() ^ V2->getValue());
}
+
+ // Casting operators. ick
+#define DEF_CAST(TYPE, CLASS, CTYPE) \
+ static CLASS *CastTo##TYPE (const ConstantBool *V) { \
+ return CLASS::get(Type::TYPE##Ty, (CTYPE)(bool)V->getValue()); \
+ }
+
+ DEF_CAST(Bool , ConstantBool, bool)
+ DEF_CAST(SByte , ConstantSInt, signed char)
+ DEF_CAST(UByte , ConstantUInt, unsigned char)
+ DEF_CAST(Short , ConstantSInt, signed short)
+ DEF_CAST(UShort, ConstantUInt, unsigned short)
+ DEF_CAST(Int , ConstantSInt, signed int)
+ DEF_CAST(UInt , ConstantUInt, unsigned int)
+ DEF_CAST(Long , ConstantSInt, int64_t)
+ DEF_CAST(ULong , ConstantUInt, uint64_t)
+ DEF_CAST(Float , ConstantFP , float)
+ DEF_CAST(Double, ConstantFP , double)
+#undef DEF_CAST
};
More information about the llvm-commits
mailing list