aboutsummaryrefslogtreecommitdiff
path: root/backend/lib
diff options
context:
space:
mode:
Diffstat (limited to 'backend/lib')
-rw-r--r--backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp9
-rw-r--r--backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc84
2 files changed, 84 insertions, 9 deletions
diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index edf0b40..08e9f6c 100644
--- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -203,8 +203,6 @@ public:
case GenericOpcode::G_SHL:
case GenericOpcode::G_LSHR:
case GenericOpcode::G_ASHR:
- case GenericOpcode::G_PTR_ADD:
- case GenericOpcode::G_PTRMASK:
case GenericOpcode::G_CONSTANT:
if (!Integer())
return makeUnexpected(ErrorCode::Unsupported,
@@ -311,9 +309,6 @@ public:
const GenericOpcode Generic = static_cast<GenericOpcode>(Instruction.opcode().value());
const std::optional<LowLevelType> Type = resultType(Function, Instruction);
- const auto SelectDirect = [&Instruction](InstructionOpcode Selected) {
- return Instruction.setOpcode(instructionOpcode(Selected));
- };
switch (Generic) {
case GenericOpcode::G_ADD:
return selectIntegerBinary(Instruction, Function, Type, InstructionOpcode::ADD,
@@ -379,10 +374,6 @@ public:
return selectNormalizedIntegerBinary(
Instruction, Function, Target, Type, InstructionOpcode::SRA, InstructionOpcode::SRAW,
true, false, InstructionOpcode::SRAI, InstructionOpcode::SRAIW, false, 6, 5);
- case GenericOpcode::G_PTR_ADD:
- return SelectDirect(InstructionOpcode::ADD);
- case GenericOpcode::G_PTRMASK:
- return SelectDirect(InstructionOpcode::AND);
case GenericOpcode::G_LOAD:
return selectLoad(Instruction, Function, Type);
case GenericOpcode::G_SEXTLOAD:
diff --git a/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc b/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
index d8b0a42..9e32842 100644
--- a/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
+++ b/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
@@ -1,5 +1,89 @@
selection_rules:
-
+ id: select_g_ptr_add_immediate
+ priority: 400
+ match:
+ opcode: G_PTR_ADD
+ result_type: { kind: pointer, bits: 64 }
+ operand_types:
+ - { index: 1, kind: pointer, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: -2048, max: 2047 }]
+ apply:
+ instructions:
+ - opcode: ADDI
+ root: true
+ operands:
+ - { operand: 0 }
+ - { operand: 1 }
+ - { captured_immediate: 2 }
+ erase_operand_definitions: [2]
+ -
+ id: select_g_ptrmask_immediate
+ priority: 400
+ match:
+ opcode: G_PTRMASK
+ result_type: { kind: pointer, bits: 64 }
+ operand_types:
+ - { index: 1, kind: pointer, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: -2048, max: 2047 }]
+ apply:
+ instructions:
+ - opcode: ANDI
+ root: true
+ operands:
+ - { operand: 0 }
+ - { operand: 1 }
+ - { captured_immediate: 2 }
+ erase_operand_definitions: [2]
+ -
+ id: select_g_ptr_add_register
+ priority: 100
+ match:
+ opcode: G_PTR_ADD
+ result_type: { kind: pointer, bits: 64 }
+ operand_types:
+ - { index: 1, kind: pointer, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ apply:
+ instructions:
+ - opcode: ADD
+ root: true
+ operands: [{ operand: 0 }, { operand: 1 }, { operand: 2 }]
+ -
+ id: select_g_ptrmask_register
+ priority: 100
+ match:
+ opcode: G_PTRMASK
+ result_type: { kind: pointer, bits: 64 }
+ operand_types:
+ - { index: 1, kind: pointer, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ apply:
+ instructions:
+ - opcode: AND
+ root: true
+ operands: [{ operand: 0 }, { operand: 1 }, { operand: 2 }]
+ -
id: select_g_sllw
priority: 100
match: