Skip to content

Commit 93ec649

Browse files
committed
[AArch64] Refactor move_vec_shift operand def and update operand type handling and testcase
1 parent 2d7fc2f commit 93ec649

File tree

5 files changed

+14
-44
lines changed

5 files changed

+14
-44
lines changed

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,17 +1238,6 @@ def timm32_0_255 : Operand<i32>, TImmLeaf<i32, [{
12381238

12391239
} // let OperandType = "OPERAND_IMMEDIATE"
12401240

1241-
let OperandType = "OPERAND_MSL_SHIFT" in {
1242-
// A vector move shifter operand:
1243-
// {0} - imm1: #8 or #16
1244-
def move_vec_shift : Operand<i32> {
1245-
let PrintMethod = "printShifter";
1246-
let OperandNamespace = "AArch64";
1247-
let EncoderMethod = "getMoveVecShifterOpValue";
1248-
let ParserMatchClass = MoveVecShifterOperand;
1249-
}
1250-
} // let OperandType = "OPERAND_MSL_SHIFT"
1251-
12521241
// An arithmetic shifter operand:
12531242
// {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr
12541243
// {5-0} - imm6
@@ -1327,6 +1316,16 @@ def logical_vec_hw_shift : Operand<i32> {
13271316
let ParserMatchClass = LogicalVecHalfWordShifterOperand;
13281317
}
13291318

1319+
// A vector move shifter operand:
1320+
// {0} - imm1: #8 or #16
1321+
def move_vec_shift : Operand<i32> {
1322+
let PrintMethod = "printShifter";
1323+
let EncoderMethod = "getMoveVecShifterOpValue";
1324+
let ParserMatchClass = MoveVecShifterOperand;
1325+
let OperandType = "OPERAND_SHIFT_MSL";
1326+
let OperandNamespace = "AArch64";
1327+
}
1328+
13301329
let DiagnosticType = "AddSubSecondSource" in {
13311330
def AddSubImmOperand : AsmOperandClass {
13321331
let Name = "AddSubImm";

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool isFpOrNEON(const MCInst &MI, const MCInstrInfo *MCII);
7070
namespace AArch64 {
7171
enum OperandType {
7272
OPERAND_IMPLICIT_IMM_0 = MCOI::OPERAND_FIRST_TARGET,
73-
OPERAND_MSL_SHIFT
73+
OPERAND_SHIFT_MSL,
7474
};
7575
} // namespace AArch64
7676

llvm/test/tools/llvm-exegesis/AArch64/error-resolution.s

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,6 @@
22

33

44

5-
// Test for omitting OperandType::OPERAND_UNKNOWN
6-
7-
// ADDXri: ADD Xd, Xn, #imm{, shift}
8-
# RUN: llvm-exegesis --mtriple=aarch64 --mcpu=neoverse-v2 --mode=latency --benchmark-phase=prepare-and-assemble-snippet --opcode-name=ADDXri 2>&1 | FileCheck %s --check-prefix=ADDXri_latency
9-
# ADDXri_latency-NOT: Not all operands were initialized by the snippet generator for ADDXri opcode
10-
# ADDXri_latency: ---
11-
# ADDXri_latency-NEXT: mode: latency
12-
# ADDXri_latency-NEXT: key:
13-
# ADDXri_latency-NEXT: instructions:
14-
# ADDXri_latency-NEXT: ADDXri [[REG1:X[0-9]+|LR]] [[REG2:X[0-9]+|LR]] i_0x0 i_0x0
15-
# ADDXri_latency: ...
16-
17-
# RUN: llvm-exegesis --mtriple=aarch64 --mcpu=neoverse-v2 --mode=inverse_throughput --benchmark-phase=prepare-and-assemble-snippet --opcode-name=ADDXri 2>&1 | FileCheck %s --check-prefix=ADDXri_throughput
18-
# ADDXri_throughput-NOT: Not all operands were initialized by the snippet generator for ADDXri opcode
19-
# ADDXri_throughput: ---
20-
# ADDXri_throughput-NEXT: mode: inverse_throughput
21-
# ADDXri_throughput-NEXT: key:
22-
# ADDXri_throughput-NEXT: instructions:
23-
# ADDXri_throughput-NEXT: ADDXri [[REG1:X[0-9]+|LR]] [[REG2:X[0-9]+|LR]] i_0x0 i_0x0
24-
# ADDXri_throughput: ...
25-
26-
27-
285
// Test for omitting OperandType::OPERAND_MSL_SHIFT_4S
296

307
// MOVIv2s_msl: MOVI vd, #imm{, shift}

llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,9 @@ Error ExegesisAArch64Target::randomizeTargetMCOperand(
173173
// encodings or unreliable benchmark results for these system-level
174174
// instructions.
175175
switch (OperandType) {
176-
case MCOI::OperandType::OPERAND_UNKNOWN: {
177-
AssignedValue = MCOperand::createImm(0);
178-
return Error::success();
179-
}
180176
// MSL (Masking Shift Left) imm operand for 32-bit splatted SIMD constants
181177
// Correspond to AArch64InstructionSelector::tryAdvSIMDModImm321s()
182-
case llvm::AArch64::OPERAND_MSL_SHIFT: {
178+
case llvm::AArch64::OPERAND_SHIFT_MSL: {
183179
// There are two valid encodings:
184180
// - Type 7: imm at [15:8], [47:40], shift = 264 (0x108) → msl #8
185181
// - Type 8: imm at [23:16], [55:48], shift = 272 (0x110) → msl #16
@@ -189,8 +185,8 @@ Error ExegesisAArch64Target::randomizeTargetMCOperand(
189185
AssignedValue = MCOperand::createImm(264);
190186
return Error::success();
191187
}
188+
case llvm::AArch64::OPERAND_IMPLICIT_IMM_0:
192189
case MCOI::OperandType::OPERAND_PCREL:
193-
case MCOI::OperandType::OPERAND_FIRST_TARGET:
194190
AssignedValue = MCOperand::createImm(0);
195191
return Error::success();
196192
default:

llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ static Error randomizeMCOperand(const LLVMState &State,
276276
AssignedValue = MCOperand::createReg(randomBit(AllowedRegs));
277277
break;
278278
}
279-
/// Omit unknown and pc-relative operands to imm value based on the
280-
/// instruction
281-
case MCOI::OperandType::OPERAND_UNKNOWN:
279+
/// Omit pc-relative operands to imm value based on the instruction
282280
case MCOI::OperandType::OPERAND_PCREL:
283281
return State.getExegesisTarget().randomizeTargetMCOperand(
284282
Instr, Var, AssignedValue, ForbiddenRegs);

0 commit comments

Comments
 (0)