[llvm] [GISel][Inlineasm] Support inlineasm i constraint for symbols (PR #170094)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 08:05:09 PST 2025
https://github.com/KRM7 updated https://github.com/llvm/llvm-project/pull/170094
>From 364c04daaab2c5180d6d5be2454871084855e69b Mon Sep 17 00:00:00 2001
From: Krisztian Rugasi <Krisztian.Rugasi at hightec-rt.com>
Date: Mon, 1 Dec 2025 16:19:53 +0100
Subject: [PATCH] [GISel][Inlineasm] Support inlineasm i constraint for symbols
and s constraint
---
.../CodeGen/GlobalISel/InlineAsmLowering.cpp | 11 +++++++++++
.../GlobalISel/irtranslator-inline-asm.ll | 19 +++++++++++++++++++
2 files changed, 30 insertions(+)
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..bbf1a7b9d5d6e 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 nonnull @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 nonnull @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