From 25d7c8c35e155cbf5256ffeba9211b539c92ba60 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 25 Sep 2025 15:07:21 +0100 Subject: [PATCH] [ARM] Improve comment on the 'J' inline asm modifier. An inline asm constraint "Jr", in AArch32, means that if the input value is a compile-time constant in the range -4095 to +4095, then it can be inserted into the assembly language as an immediate operand, and otherwise it will be placed in a register. The comment in the Arm backend said "It is not clear what this constraint is intended for". I believe the answer is that that range of immediate values are the ones you can use in a LDR or STR instruction. So it's suitable for cases like this: asm("str %0,[%1,%2]" : : "r"(data), "r"(base), "Jr"(offset) : "memory"); in the same way that the "Ir" constraint is suitable for the immediate in a data-processing instruction such as ADD or EOR. --- llvm/lib/Target/ARM/ARMISelLowering.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 9a247bb5a83d9..c283b0c77872e 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -20428,9 +20428,9 @@ void ARMTargetLowering::LowerAsmOperandForConstraint(SDValue Op, if (CVal >= -255 && CVal <= -1) break; } else { - // This must be a constant between -4095 and 4095. It is not clear - // what this constraint is intended for. Implemented for - // compatibility with GCC. + // This must be a constant between -4095 and 4095. This is suitable + // for use as the immediate offset field in LDR and STR instructions + // such as LDR r0,[r1,#offset]. if (CVal >= -4095 && CVal <= 4095) break; }