diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2007-02-28 19:50:21 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2007-02-28 19:50:21 +0000 |
| commit | 8774fe816a2132e3c3f82a94461d02b13f8a57c6 (patch) | |
| tree | d8f8293b46cbd6a300e0fbfbf1c96bd302f9b745 | |
| parent | 56f784d12d00a0a9d93c9ef860141e0595d31828 (diff) | |
| download | bcm5719-llvm-8774fe816a2132e3c3f82a94461d02b13f8a57c6.tar.gz bcm5719-llvm-8774fe816a2132e3c3f82a94461d02b13f8a57c6.zip | |
Implement a convenience method to construct a ConstantInt directly from an
APInt. The implied type is the integer type that corresponds to the bit
width of the APInt.
llvm-svn: 34757
| -rw-r--r-- | llvm/include/llvm/Constants.h | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h index 6ae7a528710..dd8343d6b38 100644 --- a/llvm/include/llvm/Constants.h +++ b/llvm/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/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 37e0abec988..29f096364f4 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/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 //===----------------------------------------------------------------------===// |

