[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Sat Oct 23 18:41:21 PDT 2004
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.108 -> 1.109
---
Log message:
Add ConstantExpr::getSizeOf(Type*).
---
Diffs of the changes: (+9 -0)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.108 llvm/lib/VMCore/Constants.cpp:1.109
--- llvm/lib/VMCore/Constants.cpp:1.108 Sat Oct 16 13:07:16 2004
+++ llvm/lib/VMCore/Constants.cpp Sat Oct 23 20:41:10 2004
@@ -1244,6 +1244,15 @@
return ConstantExpr::getCast(C, Ty);
}
+Constant *ConstantExpr::getSizeOf(const Type *Ty) {
+ // sizeof is implemented as: (unsigned) gep (Ty)null, 1
+ return getCast(
+ getGetElementPtr(
+ getNullValue(Ty),
+ std::vector<Constant*>(1, ConstantInt::get(Type::UByteTy, 1))),
+ Type::UIntTy);
+}
+
Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
Constant *C1, Constant *C2) {
if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)
More information about the llvm-commits
mailing list