mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Add ConstantExpr::getSizeOf(Type*).
llvm-svn: 17196
This commit is contained in:
parent
f8bd6fc901
commit
a893aad8fb
@ -557,6 +557,10 @@ public:
|
|||||||
return getSelectTy(V1->getType(), C, V1, V2);
|
return getSelectTy(V1->getType(), C, V1, V2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getSizeOf constant expr - computes the size of a type in a
|
||||||
|
/// target independent way
|
||||||
|
///
|
||||||
|
static Constant *getSizeOf(const Type *Ty);
|
||||||
|
|
||||||
/// ConstantExpr::get - Return a binary or shift operator constant expression,
|
/// ConstantExpr::get - Return a binary or shift operator constant expression,
|
||||||
/// folding if possible.
|
/// folding if possible.
|
||||||
|
@ -1244,6 +1244,15 @@ Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
|
|||||||
return ConstantExpr::getCast(C, 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 *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
|
||||||
Constant *C1, Constant *C2) {
|
Constant *C1, Constant *C2) {
|
||||||
if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)
|
if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)
|
||||||
|
Loading…
Reference in New Issue
Block a user