[llvm] e0e5b6e - [GISel][Inlineasm] Support inlineasm i/s constraint for symbols (#170094)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 11:16:21 PST 2025
Author: KRM7
Date: 2025-12-12T20:16:17+01:00
New Revision: e0e5b6e1f72ed1935f111fa013e2bbecda96df50
URL: https://github.com/llvm/llvm-project/commit/e0e5b6e1f72ed1935f111fa013e2bbecda96df50
DIFF: https://github.com/llvm/llvm-project/commit/e0e5b6e1f72ed1935f111fa013e2bbecda96df50.diff
LOG: [GISel][Inlineasm] Support inlineasm i/s constraint for symbols (#170094)
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp b/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
index f695a2daf6b2c..2927b075fc360 100644
--- a/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
@@ -657,7 +657,18 @@ bool InlineAsmLowering::lowerAsmOperandForConstraint(
switch (ConstraintLetter) {
default:
return false;
+ case 's': // Integer immediate not known at compile time
+ if (const auto *GV = dyn_cast<GlobalValue>(Val)) {
+ Ops.push_back(MachineOperand::CreateGA(GV, /*Offset=*/0));
+ return true;
+ }
+ return false;
case 'i': // Simple Integer or Relocatable Constant
+ if (const auto *GV = dyn_cast<GlobalValue>(Val)) {
+ Ops.push_back(MachineOperand::CreateGA(GV, /*Offset=*/0));
+ return true;
+ }
+ [[fallthrough]];
case 'n': // immediate integer with a known value.
if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
assert(CI->getBitWidth() <= 64 &&
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll
index 8597ceb9ed87a..2a490bc7d3d1c 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll
@@ -183,6 +183,25 @@ define void @test_input_imm() {
ret void
}
+ at var = global i64 0, align 8
+define void @test_immediate_constraint_sym() {
+ ; CHECK-LABEL: name: test_immediate_constraint_sym
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: INLINEASM &"#TEST $0", 9 /* sideeffect mayload attdialect */, 13 /* imm */, @var
+ ; CHECK-NEXT: RET_ReallyLR
+ call void asm sideeffect "#TEST $0", "i"(ptr @var)
+ ret void
+}
+
+define void @test_s_constraint() {
+ ; CHECK-LABEL: name: test_s_constraint
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: INLINEASM &"#TEST $0", 9 /* sideeffect mayload attdialect */, 13 /* imm */, @var
+ ; CHECK-NEXT: RET_ReallyLR
+ call void asm sideeffect "#TEST $0", "s"(ptr @var)
+ ret void
+}
+
define zeroext i8 @test_input_register(ptr %src) nounwind {
; CHECK-LABEL: name: test_input_register
; CHECK: bb.1.entry:
More information about the llvm-commits
mailing list