Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ TargetInfo::BuiltinVaListKind AArch64TargetInfo::getBuiltinVaListKind() const {
}

const char *const AArch64TargetInfo::GCCRegNames[] = {
// clang-format off

// 32-bit Integer registers
"w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11",
"w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22",
Expand Down Expand Up @@ -1200,7 +1202,12 @@ const char *const AArch64TargetInfo::GCCRegNames[] = {

// SVE predicate-as-counter registers
"pn0", "pn1", "pn2", "pn3", "pn4", "pn5", "pn6", "pn7", "pn8",
"pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
"pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15",

// SME registers
"za", "zt0",

// clang-format on
};

ArrayRef<const char *> AArch64TargetInfo::getGCCRegNames() const {
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CodeGen/aarch64-inline-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ void test_reduced_gpr_constraints(int var32, long var64) {
// CHECK: [[ARG2:%.+]] = load i64, ptr
// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Ucj,~{x0}"(i64 [[ARG2]])
}

void test_sme_constraints(){
asm("movt zt0[3, mul vl], z0" : : : "za");
// CHECK: call void asm sideeffect "movt zt0[3, mul vl], z0", "~{za}"()

asm("movt zt0[3, mul vl], z0" : : : "zt0");
// CHECK: call void asm sideeffect "movt zt0[3, mul vl], z0", "~{zt0}"()
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10702,6 +10702,14 @@ AArch64TargetLowering::getRegForInlineAsmConstraint(
parseConstraintCode(Constraint) != AArch64CC::Invalid)
return std::make_pair(unsigned(AArch64::NZCV), &AArch64::CCRRegClass);

if (StringRef("{za}").equals_insensitive(Constraint)) {
Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (StringRef("{za}").equals_insensitive(Constraint)) {
if (Constraint == "{za}") {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return std::make_pair(unsigned(AArch64::ZA), &AArch64::MPRRegClass);
}

if (StringRef("{zt0}").equals_insensitive(Constraint)) {
Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (StringRef("{zt0}").equals_insensitive(Constraint)) {
if (Constraint == "{zt0}") {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return std::make_pair(unsigned(AArch64::ZT0), &AArch64::ZTRRegClass);
}

// Use the default implementation in TargetLowering to convert the register
// constraint into a member of a register class.
std::pair<unsigned, const TargetRegisterClass *> Res;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ bool AArch64RegisterInfo::isAsmClobberable(const MachineFunction &MF,
MCRegisterInfo::regsOverlap(PhysReg, AArch64::X16))
return true;

// ZA/ZT0 registers are reserved but may be permitted in the clobber list.
if (PhysReg.id() == AArch64::ZA || PhysReg.id() == AArch64::ZT0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (PhysReg.id() == AArch64::ZA || PhysReg.id() == AArch64::ZT0)
if (PhysReg == AArch64::ZA || PhysReg == AArch64::ZT0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return true;

return !isReservedReg(MF, PhysReg);
}

Expand Down
16 changes: 16 additions & 0 deletions llvm/test/CodeGen/AArch64/aarch64-za-clobber.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=aarch64-none-linux-gnu -stop-after=aarch64-isel < %s -o - | FileCheck %s

define void @alpha(<vscale x 4 x i32> %x) local_unnamed_addr {
entry:
; CHECK: INLINEASM &"movt zt0[3, mul vl], z0", 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def early-clobber $za
tail call void asm sideeffect "movt zt0[3, mul vl], z0", "~{za}"()
ret void
}

define void @beta(<vscale x 4 x i32> %x) local_unnamed_addr {
entry:
; CHECK: INLINEASM &"movt zt0[3, mul vl], z0", 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def early-clobber $zt0
tail call void asm sideeffect "movt zt0[3, mul vl], z0", "~{zt0}"()
ret void
}