summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-12-11 08:59:05 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-12-11 08:59:05 +0000
commit54dd24c2a723be37f032567bfc41a4b4307bd4a0 (patch)
tree71609a83b2d8f992701ce17da00735dab7065794 /llvm/lib/Bitcode/Writer
parent8975f49065992ea2da7e5bdc117befc12615be58 (diff)
downloadbcm5719-llvm-54dd24c2a723be37f032567bfc41a4b4307bd4a0.tar.gz
bcm5719-llvm-54dd24c2a723be37f032567bfc41a4b4307bd4a0.zip
Implement address space attribute for LLVM pointer types. Address spaces are
regions of memory that have a target specific relationship, as described in the Embedded C Technical Report. This also implements the 2007-12-11-AddressSpaces test, which demonstrates how address space attributes can be used in LLVM IR. In addition, this patch changes the bitcode signature for stores (in a backwards compatible manner), such that the pointer type, rather than the pointee type, is encoded. This permits type information in the pointer (e.g. address space) to be preserved for stores. LangRef updates are forthcoming. llvm-svn: 44858
Diffstat (limited to 'llvm/lib/Bitcode/Writer')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 612d89338b7..c58d23ada21 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -197,10 +197,14 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
TypeVals.push_back(cast<IntegerType>(T)->getBitWidth());
break;
case Type::PointerTyID:
- // POINTER: [pointee type]
+ const PointerType *PTy = cast<PointerType>(T);
+ // POINTER: [pointee type] or [pointee type, address space]
Code = bitc::TYPE_CODE_POINTER;
- TypeVals.push_back(VE.getTypeID(cast<PointerType>(T)->getElementType()));
- AbbrevToUse = PtrAbbrev;
+ TypeVals.push_back(VE.getTypeID(PTy->getElementType()));
+ if (unsigned AddressSpace = PTy->getAddressSpace())
+ TypeVals.push_back(AddressSpace);
+ else
+ AbbrevToUse = PtrAbbrev;
break;
case Type::FunctionTyID: {
@@ -829,9 +833,9 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Vals.push_back(cast<LoadInst>(I).isVolatile());
break;
case Instruction::Store:
- Code = bitc::FUNC_CODE_INST_STORE;
- PushValueAndType(I.getOperand(0), InstID, Vals, VE); // val.
- Vals.push_back(VE.getValueID(I.getOperand(1))); // ptr.
+ Code = bitc::FUNC_CODE_INST_STORE2;
+ PushValueAndType(I.getOperand(1), InstID, Vals, VE); // ptrty + ptr
+ Vals.push_back(VE.getValueID(I.getOperand(0))); // val.
Vals.push_back(Log2_32(cast<StoreInst>(I).getAlignment())+1);
Vals.push_back(cast<StoreInst>(I).isVolatile());
break;
OpenPOWER on IntegriCloud