From 49c04575298af970b94f62f34888970a152de613 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 Feb 2006 02:05:45 +0000 Subject: [PATCH] Add some happy helper methods. llvm-svn: 26046 --- llvm/include/llvm/CodeGen/ValueTypes.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/CodeGen/ValueTypes.h b/llvm/include/llvm/CodeGen/ValueTypes.h index f0ee31a10811..28c3ab26bbb7 100644 --- a/llvm/include/llvm/CodeGen/ValueTypes.h +++ b/llvm/include/llvm/CodeGen/ValueTypes.h @@ -17,6 +17,7 @@ #define LLVM_CODEGEN_VALUETYPES_H #include +#include "llvm/Support/DataTypes.h" namespace llvm { class Type; @@ -67,7 +68,7 @@ namespace MVT { // MVT = Machine Value Types static inline bool isVector(ValueType VT) { return (VT >= v16i8 && VT <= v2f64); } - + /// getVectorType - Returns the ValueType that represents a vector NumElements /// in length, where each element is of type VT. If there is no ValueType /// that represents this vector, a ValueType of Other is returned. @@ -107,6 +108,19 @@ namespace MVT { // MVT = Machine Value Types case MVT::v2f64: return 128; } } + + /// getIntVTBitMask - Return an integer with 1's every place there are bits + /// in the specified integer value type. + static inline uint64_t getIntVTBitMask(ValueType VT) { + assert(isInteger(VT) && !isVector(VT) && "Only applies to int scalars!"); + return ~0ULL >> (64-getSizeInBits(VT)); + } + /// getIntVTSignBit - Return an integer with a 1 in the position of the sign + /// bit for the specified integer value type. + static inline uint64_t getIntVTSignBit(ValueType VT) { + assert(isInteger(VT) && !isVector(VT) && "Only applies to int scalars!"); + return 1ULL << (getSizeInBits(VT)-1); + } /// MVT::getValueTypeString - This function returns value type as a string, /// e.g. "i32".