diff --git a/llvm/include/llvm/AsmParser/LLToken.h b/llvm/include/llvm/AsmParser/LLToken.h --- a/llvm/include/llvm/AsmParser/LLToken.h +++ b/llvm/include/llvm/AsmParser/LLToken.h @@ -252,6 +252,7 @@ kw_immarg, kw_byref, kw_mustprogress, + kw_amxpreserve, kw_type, kw_opaque, diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -672,6 +672,7 @@ ATTR_KIND_NO_SANITIZE_COVERAGE = 76, ATTR_KIND_ELEMENTTYPE = 77, ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION = 78, + ATTR_KIND_AMXPRESERVE = 79, }; enum ComdatSelectionKindCodes { diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -290,6 +290,9 @@ /// Function is required to make Forward Progress. def MustProgress : EnumAttr<"mustprogress", [FnAttr]>; +/// Preserve AMX state across function call. +def AMXPreserve: EnumAttr<"amxpreserve", [FnAttr]>; + /// Target-independent string attributes. def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -708,6 +708,7 @@ KEYWORD(immarg); KEYWORD(byref); KEYWORD(mustprogress); + KEYWORD(amxpreserve); KEYWORD(type); KEYWORD(opaque); diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1511,6 +1511,8 @@ return Attribute::WillReturn; case bitc::ATTR_KIND_WRITEONLY: return Attribute::WriteOnly; + case bitc::ATTR_KIND_AMXPRESERVE: + return Attribute::AMXPreserve; case bitc::ATTR_KIND_Z_EXT: return Attribute::ZExt; case bitc::ATTR_KIND_IMMARG: diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -748,6 +748,8 @@ return bitc::ATTR_KIND_VSCALE_RANGE; case Attribute::WillReturn: return bitc::ATTR_KIND_WILLRETURN; + case Attribute::AMXPreserve: + return bitc::ATTR_KIND_AMXPRESERVE; case Attribute::WriteOnly: return bitc::ATTR_KIND_WRITEONLY; case Attribute::ZExt: diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -933,6 +933,7 @@ case Attribute::SwiftSelf: case Attribute::SwiftAsync: case Attribute::WillReturn: + case Attribute::AMXPreserve: case Attribute::WriteOnly: case Attribute::ZExt: case Attribute::ImmArg: diff --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll --- a/llvm/test/Bitcode/attributes.ll +++ b/llvm/test/Bitcode/attributes.ll @@ -478,6 +478,12 @@ ret void; } +; CHECK: define void @f81() #51 +define void @f81() amxpreserve +{ + ret void +} + ; CHECK: attributes #0 = { noreturn } ; CHECK: attributes #1 = { nounwind } ; CHECK: attributes #2 = { readnone } @@ -529,4 +535,5 @@ ; CHECK: attributes #48 = { nosanitize_coverage } ; CHECK: attributes #49 = { noprofile } ; CHECK: attributes #50 = { disable_sanitizer_instrumentation } +; CHECK: attributes #51 = { amxpreserve } ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }