diff options
-rw-r--r-- | include/llvm/Constants.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 6ae7a52..dd8343d 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -97,6 +97,10 @@ public: static ConstantInt *get(const Type *Ty, int64_t V); static ConstantInt *get(const Type *Ty, const APInt& V); + /// Return a ConstantInt with the specified value and an implied Type. The + /// type is the integer type that corresponds to the bit width of the value. + static ConstantInt *get(const APInt &V); + /// getType - Specialize the getType() method to always return an IntegerType, /// which reduces the amount of casting needed in parts of the compiler. /// diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 37e0abe..29f0963 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -216,6 +216,10 @@ ConstantInt *ConstantInt::get(const Type *Ty, const APInt& V) { return Slot = new ConstantInt(ITy, V); } +ConstantInt *ConstantInt::get(const APInt &V) { + return ConstantInt::get(IntegerType::get(V.getBitWidth()), V); +} + //===----------------------------------------------------------------------===// // ConstantFP //===----------------------------------------------------------------------===// |