Skip to content

Commit

Permalink
[AArch64] Mark some operands as OPERAND_IMMEDIATE.
Browse files Browse the repository at this point in the history
This allows llvm-exegesis to generate them as constants.
  • Loading branch information
davemgreen committed Jul 14, 2023
1 parent 76f2009 commit 1ae4726
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ let DiagnosticType = "LogicalSecondSource" in {
let RenderMethod = "addLogicalImmNotOperands<int64_t>";
}
}

def Imm0_127Operand : AsmImmRange<0, 127>;

let OperandType = "OPERAND_IMMEDIATE" in {

def logical_imm32 : Operand<i32>, IntImmLeaf<i32, [{
return AArch64_AM::isLogicalImmediate(Imm.getZExtValue(), 32);
}], logical_imm32_XFORM> {
Expand Down Expand Up @@ -893,7 +898,7 @@ def timm64_0_65535 : Operand<i64>, TImmLeaf<i64, [{
def imm64_0_65535 : Operand<i64>, ImmLeaf<i64, [{
return ((uint64_t)Imm) < 65536;
}]>;
}
} // ParserMatchClass

def imm0_255 : Operand<i32>, ImmLeaf<i32, [{
return ((uint32_t)Imm) < 256;
Expand All @@ -903,7 +908,6 @@ def imm0_255 : Operand<i32>, ImmLeaf<i32, [{
}

// imm0_127 predicate - True if the immediate is in the range [0,127]
def Imm0_127Operand : AsmImmRange<0, 127>;
def imm0_127 : Operand<i32>, ImmLeaf<i32, [{
return ((uint32_t)Imm) < 128;
}]> {
Expand Down Expand Up @@ -1040,6 +1044,8 @@ def timm32_0_255 : Operand<i32>, TImmLeaf<i32, [{
let ParserMatchClass = Imm0_255Operand;
}

} // let OperandType = "OPERAND_IMMEDIATE"

// An arithmetic shifter operand:
// {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr
// {5-0} - imm6
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/llvm-exegesis/AArch64/immediates.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: llvm-exegesis --mtriple=aarch64 --mcpu=neoverse-v2 --mode=latency --opcode-name=EXTRWrri --benchmark-phase=prepare-and-assemble-snippet | FileCheck %s

# CHECK: 'EXTRWrri {{W.*}} {{W.*}} {{W.*}} i_0x1'
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-exegesis/AArch64/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ if not ("AArch64" in config.root.targets):
# We need support for AArch64.
config.unsupported = True
elif not ("aarch64" in config.root.host_triple):
# We need to be running on an PPC host.
# We need to be running on an AArch64 host.
config.unsupported = True

0 comments on commit 1ae4726

Please sign in to comment.