Skip to content

Commit 44b8574

Browse files
authored
[AArch64] Fix movk parsing with an .equ operand (#124428)
Prior to 5da8013, this code worked: .equ p4_low_b0, 0x0000 movk x1, p4_low_b0, lsl 16 (The code above is from the isa-l project - I discovered this issue while trying to compile it with clang 19 on MacOS on aarch64) That commit fixed a different bug, but accidentally broke the case where the second operand to movk is not a literal. In 442f066, a fix was applied to handle the case where the second operand is a value like "(Val) >> 16". However, that didn't appear to fix the test case in this commit. In this commit, we extend the change to handle the case where the second operand is a identifier defined by .equ. Fixes #124427
1 parent 6bb70a9 commit 44b8574

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -5017,7 +5017,9 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
50175017
return true;
50185018
E = SMLoc::getFromPointer(getLoc().getPointer() - 1);
50195019
Operands.push_back(AArch64Operand::CreateImm(IdVal, S, E, getContext()));
5020-
return false;
5020+
5021+
// Parse an optional shift/extend modifier.
5022+
return parseOptionalShiftExtend(getTok());
50215023
}
50225024
case AsmToken::Integer:
50235025
case AsmToken::Real:

llvm/test/MC/AArch64/basic-a64-instructions.s

+5
Original file line numberDiff line numberDiff line change
@@ -3347,6 +3347,11 @@ _func:
33473347
// CHECK: mov x2, #5299989643264 // encoding: [0x42,0x9a,0xc0,0xd2]
33483348
// CHECK: movk xzr, #{{4321|0x10e1}}, lsl #48 // encoding: [0x3f,0x1c,0xe2,0xf2]
33493349

3350+
.equ equvalue, 0x0001
3351+
movk x1, equvalue, lsl 16
3352+
// CHECK: .set equvalue, 1
3353+
// CHECK-NEXT: movk x1, #1, lsl #16 // encoding: [0x21,0x00,0xa0,0xf2]
3354+
33503355
movz x2, #:abs_g0:sym
33513356
movk w3, #:abs_g0_nc:sym
33523357

0 commit comments

Comments
 (0)