diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-09-26 14:01:53 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-09-26 14:01:53 +0000 |
commit | 50b7d70707960155ad28ff23d7622009b7b97eb3 (patch) | |
tree | 4dc660eff70445606f083e346473a825126d190f /include | |
parent | 565df79b74126e1f2a2be8e2c55c5bb506270f26 (diff) | |
download | llvm-50b7d70707960155ad28ff23d7622009b7b97eb3.tar.gz llvm-50b7d70707960155ad28ff23d7622009b7b97eb3.tar.bz2 llvm-50b7d70707960155ad28ff23d7622009b7b97eb3.tar.xz |
Address Duncan's comments on r164684:
- Put statistics in alphabetical order
- Don't use getZextValue when building TableInt, just use APInts
- Introduce Create{Z,S}ExtOrTrunc in IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IRBuilder.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/llvm/IRBuilder.h b/include/llvm/IRBuilder.h index ff64660a42..f9d219f3a0 100644 --- a/include/llvm/IRBuilder.h +++ b/include/llvm/IRBuilder.h @@ -995,6 +995,30 @@ public: Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") { return CreateCast(Instruction::SExt, V, DestTy, Name); } + /// CreateZExtOrTrunc - Create a ZExt or Trunc from the integer value V to + /// DestTy. Return the value untouched if the type of V is already DestTy. + Value *CreateZExtOrTrunc(Value *V, IntegerType *DestTy, + const Twine &Name = "") { + assert(isa<IntegerType>(V->getType()) && "Can only zero extend integers!"); + IntegerType *IntTy = cast<IntegerType>(V->getType()); + if (IntTy->getBitWidth() < DestTy->getBitWidth()) + return CreateZExt(V, DestTy, Name); + if (IntTy->getBitWidth() > DestTy->getBitWidth()) + return CreateTrunc(V, DestTy, Name); + return V; + } + /// CreateSExtOrTrunc - Create a SExt or Trunc from the integer value V to + /// DestTy. Return the value untouched if the type of V is already DestTy. + Value *CreateSExtOrTrunc(Value *V, IntegerType *DestTy, + const Twine &Name = "") { + assert(isa<IntegerType>(V->getType()) && "Can only sign extend integers!"); + IntegerType *IntTy = cast<IntegerType>(V->getType()); + if (IntTy->getBitWidth() < DestTy->getBitWidth()) + return CreateSExt(V, DestTy, Name); + if (IntTy->getBitWidth() > DestTy->getBitWidth()) + return CreateTrunc(V, DestTy, Name); + return V; + } Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = ""){ return CreateCast(Instruction::FPToUI, V, DestTy, Name); } |