aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-10-24 01:41:10 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-10-24 01:41:10 +0000
commit60ab1402981a757c5ee785de540a5d0f85839c5d (patch)
tree8774ccdcd5a4dad2a12b0145803a9b2925910953 /lib
parentd4b4a99587a0856473b9334455f6cebcb4fe2583 (diff)
downloadexternal_llvm-60ab1402981a757c5ee785de540a5d0f85839c5d.zip
external_llvm-60ab1402981a757c5ee785de540a5d0f85839c5d.tar.gz
external_llvm-60ab1402981a757c5ee785de540a5d0f85839c5d.tar.bz2
Add ConstantExpr::getSizeOf(Type*).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17196 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Constants.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 77aa231..3d2e658 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1244,6 +1244,15 @@ Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
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)