summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-04 23:32:23 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-04 23:32:23 +0000
commitf9271ea159b97e2febedcf095c3c4122cb24d077 (patch)
tree3c039e9f6223cafc13bb494584f6e434858fe6de /lib/Bitcode/Reader
parent638c63ccf74807bbbff444d527a0acad592b3802 (diff)
downloadllvm-f9271ea159b97e2febedcf095c3c4122cb24d077.tar.gz
llvm-f9271ea159b97e2febedcf095c3c4122cb24d077.tar.bz2
llvm-f9271ea159b97e2febedcf095c3c4122cb24d077.tar.xz
Initial cleanups of the param-attribute code in the bitcode reader/writer.
Rename the PARAMATTR_CODE_ENTRY to PARAMATTR_CODE_ENTRY_OLD. It will be replaced by another encoding. Keep around the current LLVM attribute encoder/decoder code, but move it to the bitcode directories so that no one's tempted to use them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174335 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index ca299c007c..6ab7011187 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -428,6 +428,26 @@ Type *BitcodeReader::getTypeByID(unsigned ID) {
// Functions for parsing blocks from the bitcode file
//===----------------------------------------------------------------------===//
+
+/// \brief This fills an AttrBuilder object with the LLVM attributes that have
+/// been decoded from the given integer. This function must stay in sync with
+/// 'encodeLLVMAttributesForBitcode'.
+static void decodeLLVMAttributesForBitcode(AttrBuilder &B,
+ uint64_t EncodedAttrs) {
+ // FIXME: Remove in 4.0.
+
+ // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
+ // the bits above 31 down by 11 bits.
+ unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
+ assert((!Alignment || isPowerOf2_32(Alignment)) &&
+ "Alignment must be a power of two.");
+
+ if (Alignment)
+ B.addAlignmentAttr(Alignment);
+ B.addRawValue(((EncodedAttrs & (0xffffULL << 32)) >> 11) |
+ (EncodedAttrs & 0xffff));
+}
+
bool BitcodeReader::ParseAttributeBlock() {
if (Stream.EnterSubBlock(bitc::PARAMATTR_BLOCK_ID))
return Error("Malformed block record");
@@ -459,14 +479,14 @@ bool BitcodeReader::ParseAttributeBlock() {
switch (Stream.readRecord(Entry.ID, Record)) {
default: // Default behavior: ignore.
break;
- case bitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [paramidx0, attr0, ...]
+ case bitc::PARAMATTR_CODE_ENTRY_OLD: { // ENTRY: [paramidx0, attr0, ...]
+ // FIXME: Remove in 4.0.
if (Record.size() & 1)
return Error("Invalid ENTRY record");
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
AttrBuilder B;
- AttributeFuncs::decodeLLVMAttributesForBitcode(Context, B,
- Record[i+1]);
+ decodeLLVMAttributesForBitcode(B, Record[i+1]);
Attrs.push_back(AttributeSet::get(Context, Record[i], B));
}