[llvm] 2cacf71 - [ARM] Improve comment on the 'J' inline asm modifier. (#160712)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 01:19:02 PDT 2025


Author: Simon Tatham
Date: 2025-09-26T09:18:59+01:00
New Revision: 2cacf7117ba0fb7c134413a1a51302f8d6649052

URL: https://github.com/llvm/llvm-project/commit/2cacf7117ba0fb7c134413a1a51302f8d6649052
DIFF: https://github.com/llvm/llvm-project/commit/2cacf7117ba0fb7c134413a1a51302f8d6649052.diff

LOG: [ARM] Improve comment on the 'J' inline asm modifier. (#160712)

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.

Added: 
    

Modified: 
    llvm/lib/Target/ARM/ARMISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 78b706625a178..f4ac6bb76b3fe 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;
         }


        


More information about the llvm-commits mailing list