Skip to content

Commit 2cacf71

Browse files
authored
[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.
1 parent 368d599 commit 2cacf71

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20428,9 +20428,9 @@ void ARMTargetLowering::LowerAsmOperandForConstraint(SDValue Op,
2042820428
if (CVal >= -255 && CVal <= -1)
2042920429
break;
2043020430
} else {
20431-
// This must be a constant between -4095 and 4095. It is not clear
20432-
// what this constraint is intended for. Implemented for
20433-
// compatibility with GCC.
20431+
// This must be a constant between -4095 and 4095. This is suitable
20432+
// for use as the immediate offset field in LDR and STR instructions
20433+
// such as LDR r0,[r1,#offset].
2043420434
if (CVal >= -4095 && CVal <= 4095)
2043520435
break;
2043620436
}

0 commit comments

Comments
 (0)