diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-07 09:35:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-07 09:35:34 +0000 |
commit | ece4180609c6ec2e21dfef5f27eb9bf7b65351e4 (patch) | |
tree | b4060f4e83c931aae54651d9b65823fb445422ec /include/llvm/Target | |
parent | 683309f29784560cf55826b443f44503318876f1 (diff) | |
download | external_llvm-ece4180609c6ec2e21dfef5f27eb9bf7b65351e4.zip external_llvm-ece4180609c6ec2e21dfef5f27eb9bf7b65351e4.tar.gz external_llvm-ece4180609c6ec2e21dfef5f27eb9bf7b65351e4.tar.bz2 |
add the ability for TargetData to return information about legal integer
datatypes on a given CPU. This is intended to allow instcombine and other
transformations to avoid converting big sequences of operations to an
inconvenient width, and will help clean up after SRoA. See also "Adding
legal integer sizes to TargetData" on Feb 1, 2009 on llvmdev, and PR3451.
Comments welcome.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86370 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Target')
-rw-r--r-- | include/llvm/Target/TargetData.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index 1ad058c..9630877 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -70,6 +70,8 @@ private: unsigned char PointerABIAlign; ///< Pointer ABI alignment unsigned char PointerPrefAlign; ///< Pointer preferred alignment + SmallVector<unsigned char, 8> LegalIntWidths; ///< Legal Integers. + /// Alignments- Where the primitive type alignment data is stored. /// /// @sa init(). @@ -78,12 +80,8 @@ private: /// we don't. SmallVector<TargetAlignElem, 16> Alignments; - - - /*! - This member is a signal that a requested alignment type and bit width were - not found in the SmallVector. - */ + /// InvalidAlignmentElem - This member is a signal that a requested alignment + /// type and bit width were not found in the SmallVector. static const TargetAlignElem InvalidAlignmentElem; // Opaque pointer for the StructType -> StructLayout map. @@ -127,6 +125,7 @@ public: PointerMemSize(TD.PointerMemSize), PointerABIAlign(TD.PointerABIAlign), PointerPrefAlign(TD.PointerPrefAlign), + LegalIntWidths(TD.LegalIntWidths), Alignments(TD.Alignments), LayoutMap(0) { } @@ -137,13 +136,33 @@ public: void init(StringRef TargetDescription); /// Target endianness... - bool isLittleEndian() const { return LittleEndian; } - bool isBigEndian() const { return !LittleEndian; } + bool isLittleEndian() const { return LittleEndian; } + bool isBigEndian() const { return !LittleEndian; } /// getStringRepresentation - Return the string representation of the /// TargetData. This representation is in the same format accepted by the /// string constructor above. std::string getStringRepresentation() const; + + + /// isIllegalInteger - This function returns true if the specified type is + /// known to not be a native integer type supported by the CPU. For example, + /// i64 is not native on most 32-bit CPUs and i37 is not native on any known + /// one. This returns false if the integer width is legal or we don't know. + /// + /// The width is specified in bits. + /// + bool isIllegalInteger(unsigned Width) const { + // If we don't have information about legal integer types, don't claim the + // type is illegal. + if (LegalIntWidths.empty()) return false; + + for (unsigned i = 0, e = LegalIntWidths.size(); i != e; ++i) + if (LegalIntWidths[i] == Width) + return false; + return true; + } + /// Target pointer alignment unsigned char getPointerABIAlignment() const { return PointerABIAlign; } /// Return target's alignment for stack-based pointers |