mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Add code for emitting the attribute groups.
This is some initial code for emitting the attribute groups into the bitcode. NOTE: This format *may* change! Do not rely upon the attribute groups' bitcode not changing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174845 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -185,6 +185,54 @@ static uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs,
|
||||
return EncodedAttrs;
|
||||
}
|
||||
|
||||
static void WriteAttributeGroupTable(const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream) {
|
||||
const std::vector<AttributeSet> &Attrs = VE.getAttributeSets();
|
||||
if (Attrs.empty()) return;
|
||||
|
||||
Stream.EnterSubblock(bitc::PARAMATTR_GROUP_BLOCK_ID, 3);
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
||||
AttributeSet AS = Attrs[i];
|
||||
for (unsigned i = 0, e = AS.getNumSlots(); i != e; ++i) {
|
||||
AttributeSet A = AS.getSlotAttributes(i);
|
||||
|
||||
Record.push_back(VE.getAttributeSetID(A));
|
||||
Record.push_back(AS.getSlotIndex(i));
|
||||
|
||||
for (AttributeSet::iterator I = AS.begin(0), E = AS.end(0);
|
||||
I != E; ++I) {
|
||||
Attribute Attr = *I;
|
||||
if (Attr.isEnumAttribute()) {
|
||||
Record.push_back(0);
|
||||
Record.push_back(Attr.getKindAsEnum());
|
||||
} else if (Attr.isAlignAttribute()) {
|
||||
Record.push_back(1);
|
||||
Record.push_back(Attr.getKindAsEnum());
|
||||
Record.push_back(Attr.getValueAsInt());
|
||||
} else {
|
||||
StringRef Kind = Attr.getKindAsString();
|
||||
StringRef Val = Attr.getValueAsString();
|
||||
|
||||
Record.push_back(Val.empty() ? 3 : 4);
|
||||
Record.append(Kind.begin(), Kind.end());
|
||||
Record.push_back(0);
|
||||
if (!Val.empty()) {
|
||||
Record.append(Val.begin(), Val.end());
|
||||
Record.push_back(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stream.EmitRecord(bitc::PARAMATTR_GRP_CODE_ENTRY, Record);
|
||||
Record.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Stream.ExitBlock();
|
||||
}
|
||||
|
||||
static void WriteAttributeTable(const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream) {
|
||||
const std::vector<AttributeSet> &Attrs = VE.getAttributes();
|
||||
@ -192,6 +240,8 @@ static void WriteAttributeTable(const ValueEnumerator &VE,
|
||||
|
||||
Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
|
||||
|
||||
// FIXME: Remove this! It no longer works with the current attributes classes.
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
||||
const AttributeSet &A = Attrs[i];
|
||||
@ -1854,6 +1904,9 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) {
|
||||
// Emit blockinfo, which defines the standard abbreviations etc.
|
||||
WriteBlockInfo(VE, Stream);
|
||||
|
||||
// Emit information about attribute groups.
|
||||
WriteAttributeGroupTable(VE, Stream);
|
||||
|
||||
// Emit information about parameter attributes.
|
||||
WriteAttributeTable(VE, Stream);
|
||||
|
||||
|
Reference in New Issue
Block a user