[Attributes] Make type attribute handling more generic (NFCI)

Followup to D105658 to make AttrBuilder automatically work with
new type attributes. TableGen is tweaked to emit First/LastTypeAttr
markers, based on which we can handle type attributes
programmatically.

Differential Revision: https://reviews.llvm.org/D105763
This commit is contained in:
Nikita Popov
2021-07-10 18:36:00 +02:00
parent 6ebbf755b6
commit 5d1464cbfe
4 changed files with 53 additions and 61 deletions

View File

@@ -1642,17 +1642,10 @@ Error BitcodeReader::parseAttributeGroupBlock() {
Attribute::AttrKind Kind;
if (Error Err = parseAttrKind(Record[++i], &Kind))
return Err;
if (Kind == Attribute::ByVal) {
B.addByValAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
} else if (Kind == Attribute::StructRet) {
B.addStructRetAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
} else if (Kind == Attribute::ByRef) {
B.addByRefAttr(getTypeByID(Record[++i]));
} else if (Kind == Attribute::Preallocated) {
B.addPreallocatedAttr(getTypeByID(Record[++i]));
} else if (Kind == Attribute::InAlloca) {
B.addInAllocaAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
}
if (!Attribute::isTypeAttrKind(Kind))
return error("Not a type attribute");
B.addTypeAttr(Kind, HasType ? getTypeByID(Record[++i]) : nullptr);
}
}