Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit a6b7c20

Browse files
committed
Add 'swiftisa' argument attribute
1 parent 266994f commit a6b7c20

27 files changed

+74
-9
lines changed

include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ enum AttributeKindCodes {
558558
ATTR_KIND_INACCESSIBLEMEM_OR_ARGMEMONLY = 50,
559559
ATTR_KIND_ALLOC_SIZE = 51,
560560
ATTR_KIND_WRITEONLY = 52,
561-
ATTR_KIND_SPECULATABLE = 53
561+
ATTR_KIND_SPECULATABLE = 53,
562+
ATTR_KIND_SWIFT_ISA = 54,
562563
};
563564

564565
enum ComdatSelectionKindCodes {

include/llvm/IR/Argument.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class Argument final : public Value {
6969
/// Return true if this argument has the swiftself attribute.
7070
bool hasSwiftSelfAttr() const;
7171

72+
/// Return true if this argument has the swiftisa attribute.
73+
bool hasSwiftIsaAttr() const;
74+
7275
/// Return true if this argument has the swifterror attribute.
7376
bool hasSwiftErrorAttr() const;
7477

include/llvm/IR/Attributes.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ def SwiftError : EnumAttr<"swifterror">;
167167
/// Argument is swift self/context.
168168
def SwiftSelf : EnumAttr<"swiftself">;
169169

170+
/// Argument is swift isa pointer.
171+
def SwiftIsa : EnumAttr<"swiftisa">;
172+
170173
/// Function must be in a unwind table.
171174
def UWTable : EnumAttr<"uwtable">;
172175

include/llvm/Target/TargetCallingConv.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace ISD {
3838
unsigned IsSplitEnd : 1; ///< Last part of a split
3939
unsigned IsSwiftSelf : 1; ///< Swift self parameter
4040
unsigned IsSwiftError : 1; ///< Swift error parameter
41+
unsigned IsSwiftIsa : 1; ///< Swift isa parameter
4142
unsigned IsHva : 1; ///< HVA field for
4243
unsigned IsHvaStart : 1; ///< HVA structure start
4344
unsigned IsSecArgPass : 1; ///< Second argument
@@ -53,7 +54,7 @@ namespace ISD {
5354
ArgFlagsTy()
5455
: IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsNest(0),
5556
IsReturned(0), IsSplit(0), IsInAlloca(0), IsSplitEnd(0),
56-
IsSwiftSelf(0), IsSwiftError(0), IsHva(0), IsHvaStart(0),
57+
IsSwiftSelf(0), IsSwiftError(0), IsSwiftIsa(0), IsHva(0), IsHvaStart(0),
5758
IsSecArgPass(0), ByValAlign(0), OrigAlign(0),
5859
IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
5960
IsCopyElisionCandidate(0), ByValSize(0) {
@@ -84,6 +85,9 @@ namespace ISD {
8485
bool isSwiftError() const { return IsSwiftError; }
8586
void setSwiftError() { IsSwiftError = 1; }
8687

88+
bool isSwiftIsa() const { return IsSwiftIsa; }
89+
void setSwiftIsa() { IsSwiftIsa = 1; }
90+
8791
bool isHva() const { return IsHva; }
8892
void setHva() { IsHva = 1; }
8993

include/llvm/Target/TargetCallingConv.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
4747
class CCIfSwiftSelf<CCAction A> : CCIf<"ArgFlags.isSwiftSelf()", A> {
4848
}
4949

50+
/// CCIfSwiftIsa - If the current argument has swiftisa parameter attribute,
51+
/// apply Action A.
52+
class CCIfSwiftIsa<CCAction A> : CCIf<"ArgFlags.isSwiftIsa()", A> {
53+
}
54+
5055
/// CCIfSwiftError - If the current argument has swifterror parameter attribute,
5156
/// apply Action A.
5257
class CCIfSwiftError<CCAction A> : CCIf<"ArgFlags.isSwiftError()", A> {

include/llvm/Target/TargetLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,13 @@ class TargetLoweringBase {
186186
bool IsReturned : 1;
187187
bool IsSwiftSelf : 1;
188188
bool IsSwiftError : 1;
189+
bool IsSwiftIsa : 1;
189190
uint16_t Alignment = 0;
190191

191192
ArgListEntry()
192193
: IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
193194
IsNest(false), IsByVal(false), IsInAlloca(false), IsReturned(false),
194-
IsSwiftSelf(false), IsSwiftError(false) {}
195+
IsSwiftSelf(false), IsSwiftError(false), IsSwiftIsa(false) {}
195196

196197
void setAttributes(ImmutableCallSite *CS, unsigned ArgIdx);
197198
};

lib/AsmParser/LLLexer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ lltok::Kind LLLexer::LexIdentifier() {
660660
KEYWORD(sanitize_memory);
661661
KEYWORD(swifterror);
662662
KEYWORD(swiftself);
663+
KEYWORD(swiftisa);
663664
KEYWORD(uwtable);
664665
KEYWORD(writeonly);
665666
KEYWORD(zeroext);

lib/AsmParser/LLParser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
11521152
case lltok::kw_sret:
11531153
case lltok::kw_swifterror:
11541154
case lltok::kw_swiftself:
1155+
case lltok::kw_swiftisa:
11551156
HaveError |=
11561157
Error(Lex.getLoc(),
11571158
"invalid use of parameter-only attribute on a function");
@@ -1425,6 +1426,7 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) {
14251426
case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break;
14261427
case lltok::kw_swifterror: B.addAttribute(Attribute::SwiftError); break;
14271428
case lltok::kw_swiftself: B.addAttribute(Attribute::SwiftSelf); break;
1429+
case lltok::kw_swiftisa: B.addAttribute(Attribute::SwiftIsa); break;
14281430
case lltok::kw_writeonly: B.addAttribute(Attribute::WriteOnly); break;
14291431
case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
14301432

@@ -1515,6 +1517,7 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) {
15151517
case lltok::kw_sret:
15161518
case lltok::kw_swifterror:
15171519
case lltok::kw_swiftself:
1520+
case lltok::kw_swiftisa:
15181521
HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute");
15191522
break;
15201523

lib/AsmParser/LLToken.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ enum Kind {
209209
kw_sanitize_memory,
210210
kw_swifterror,
211211
kw_swiftself,
212+
kw_swiftisa,
212213
kw_uwtable,
213214
kw_writeonly,
214215
kw_zeroext,

lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ static uint64_t getRawAttributeMask(Attribute::AttrKind Val) {
11281128
case Attribute::SwiftError: return 1ULL << 52;
11291129
case Attribute::WriteOnly: return 1ULL << 53;
11301130
case Attribute::Speculatable: return 1ULL << 54;
1131+
case Attribute::SwiftIsa: return 1ULL << 55;
11311132
case Attribute::Dereferenceable:
11321133
llvm_unreachable("dereferenceable attribute not supported in raw format");
11331134
break;
@@ -1348,6 +1349,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
13481349
return Attribute::SwiftError;
13491350
case bitc::ATTR_KIND_SWIFT_SELF:
13501351
return Attribute::SwiftSelf;
1352+
case bitc::ATTR_KIND_SWIFT_ISA:
1353+
return Attribute::SwiftIsa;
13511354
case bitc::ATTR_KIND_UW_TABLE:
13521355
return Attribute::UWTable;
13531356
case bitc::ATTR_KIND_WRITEONLY:

0 commit comments

Comments
 (0)