Skip to content

Commit 7238353

Browse files
committed
[AArch64][MC] Reject "add x0, x1, w2, lsl #1" etc.
Looks like just a minor oversight in the parsing code. Fixes https://bugs.llvm.org/show_bug.cgi?id=41504. Differential Revision: https://reviews.llvm.org/D60840 llvm-svn: 359855
1 parent 5e32805 commit 7238353

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,11 @@ class AArch64Operand : public MCParsedAsmOperand {
12701270
bool isExtend64() const {
12711271
if (!isExtend())
12721272
return false;
1273-
// UXTX and SXTX require a 64-bit source register (the ExtendLSL64 class).
1273+
// Make sure the extend expects a 32-bit source register.
12741274
AArch64_AM::ShiftExtendType ET = getShiftExtendType();
1275-
return ET != AArch64_AM::UXTX && ET != AArch64_AM::SXTX;
1275+
return ET == AArch64_AM::UXTB || ET == AArch64_AM::SXTB ||
1276+
ET == AArch64_AM::UXTH || ET == AArch64_AM::SXTH ||
1277+
ET == AArch64_AM::UXTW || ET == AArch64_AM::SXTW;
12761278
}
12771279

12781280
bool isExtendLSL64() const {
@@ -4189,7 +4191,7 @@ bool AArch64AsmParser::showMatchError(SMLoc Loc, unsigned ErrCode,
41894191
return Error(Loc, "expected AArch64 condition code");
41904192
case Match_AddSubRegExtendSmall:
41914193
return Error(Loc,
4192-
"expected '[su]xt[bhw]' or 'lsl' with optional integer in range [0, 4]");
4194+
"expected '[su]xt[bhw]' with optional integer in range [0, 4]");
41934195
case Match_AddSubRegExtendLarge:
41944196
return Error(Loc,
41954197
"expected 'sxtx' 'uxtx' or 'lsl' with optional integer in range [0, 4]");

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
// Mismatched final register and extend
99
add x2, x3, x5, sxtb
1010
add x2, x4, w2, uxtx
11+
add x2, x4, w2, lsl #3
1112
add w5, w7, x9, sxtx
1213
// CHECK-ERROR: error: expected 'sxtx' 'uxtx' or 'lsl' with optional integer in range [0, 4]
1314
// CHECK-ERROR: add x2, x3, x5, sxtb
1415
// CHECK-ERROR: ^
15-
// CHECK-ERROR: error: expected '[su]xt[bhw]' or 'lsl' with optional integer in range [0, 4]
16+
// CHECK-ERROR: error: expected '[su]xt[bhw]' with optional integer in range [0, 4]
1617
// CHECK-ERROR: add x2, x4, w2, uxtx
1718
// CHECK-ERROR: ^
19+
// CHECK-ERROR: error: expected '[su]xt[bhw]' with optional integer in range [0, 4]
20+
// CHECK-ERROR: add x2, x4, w2, lsl #3
21+
// CHECK-ERROR: ^
1822
// CHECK-ERROR: error: expected compatible register, symbol or integer in range [0, 4095]
1923
// CHECK-ERROR: add w5, w7, x9, sxtx
2024
// CHECK-ERROR: ^
@@ -26,7 +30,7 @@
2630
// CHECK-ERROR: error: expected integer shift amount
2731
// CHECK-ERROR: add x9, x10, w11, uxtb #-1
2832
// CHECK-ERROR: ^
29-
// CHECK-ERROR: error: expected '[su]xt[bhw]' or 'lsl' with optional integer in range [0, 4]
33+
// CHECK-ERROR: error: expected '[su]xt[bhw]' with optional integer in range [0, 4]
3034
// CHECK-ERROR: add x3, x5, w7, uxtb #5
3135
// CHECK-ERROR: ^
3236
// CHECK-ERROR: error: expected 'sxtx' 'uxtx' or 'lsl' with optional integer in range [0, 4]

0 commit comments

Comments
 (0)