diff options
author | Ken Dyck <ken.dyck@onsemi.com> | 2009-12-17 20:09:43 +0000 |
---|---|---|
committer | Ken Dyck <ken.dyck@onsemi.com> | 2009-12-17 20:09:43 +0000 |
commit | bceddbdc919fc2ca7bc8c3911586ba93367686f0 (patch) | |
tree | d75c3219a254bd51439b8485d7e17ef93faeabf3 /include/llvm/CodeGen/ValueTypes.h | |
parent | 551dec592f602258e3ff64cb613f23312e0f7610 (diff) | |
download | external_llvm-bceddbdc919fc2ca7bc8c3911586ba93367686f0.zip external_llvm-bceddbdc919fc2ca7bc8c3911586ba93367686f0.tar.gz external_llvm-bceddbdc919fc2ca7bc8c3911586ba93367686f0.tar.bz2 |
Introduce EVT::getHalfSizedIntegerVT() for use in ExpandUnalignedStore() in
LegalizeDAG.cpp. Unlike the code it replaces, which simply decrements the simple
type by one, getHalfSizedIntegerVT() searches for the smallest simple integer
type that is at least half the size of the type it is called on. This approach
has the advantage that it will continue working if a new value type (such as
i24) is added to MVT.
Also, in preparation for new value types, remove the assertions that
non-power-of-2 8-bit-mutiple types are Extended when legalizing extload and
truncstore operations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/ValueTypes.h')
-rw-r--r-- | include/llvm/CodeGen/ValueTypes.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 06e07f3..9dc4c7b 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -589,7 +589,25 @@ namespace llvm { return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth)); } - /// isPow2VectorType - Retuns true if the given vector is a power of 2. + /// getHalfSizedIntegerVT - Finds the smallest simple value type that is + /// greater than or equal to half the width of this EVT. If no simple + /// value type can be found, an extended integer value type of half the + /// size (rounded up) is returned. + EVT getHalfSizedIntegerVT(LLVMContext &Context) const { + assert(isInteger() && !isVector() && "Invalid integer type!"); + unsigned EVTSize = getSizeInBits(); + for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE; + IntVT <= MVT::LAST_INTEGER_VALUETYPE; + ++IntVT) { + EVT HalfVT = EVT((MVT::SimpleValueType)IntVT); + if(HalfVT.getSizeInBits() * 2 >= EVTSize) { + return HalfVT; + } + } + return getIntegerVT(Context, (EVTSize + 1) / 2); + } + + /// isPow2VectorType - Returns true if the given vector is a power of 2. bool isPow2VectorType() const { unsigned NElts = getVectorNumElements(); return !(NElts & (NElts - 1)); |