aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/RISCV/RISCVGISelShift.rccdesc
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-16 20:13:50 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-16 20:13:50 +0800
commitbebaa1737200e4944be71bcab4137a3774c2d07e (patch)
tree16a4c1307722f0e894385bc90736abec31b6b511 /backend/lib/Target/RISCV/RISCVGISelShift.rccdesc
parent2d05768bedb7f4209038330bebab270a7f1b558d (diff)
downloadrcc-project-bebaa1737200e4944be71bcab4137a3774c2d07e.tar.gz
rcc-project-bebaa1737200e4944be71bcab4137a3774c2d07e.tar.xz
[RISCV][GlobalISel] Generate shift selections
Diffstat (limited to 'backend/lib/Target/RISCV/RISCVGISelShift.rccdesc')
-rw-r--r--backend/lib/Target/RISCV/RISCVGISelShift.rccdesc198
1 files changed, 198 insertions, 0 deletions
diff --git a/backend/lib/Target/RISCV/RISCVGISelShift.rccdesc b/backend/lib/Target/RISCV/RISCVGISelShift.rccdesc
new file mode 100644
index 0000000..bf9bf71
--- /dev/null
+++ b/backend/lib/Target/RISCV/RISCVGISelShift.rccdesc
@@ -0,0 +1,198 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+selection_rules:
+ -
+ id: select_g_lshr_s64_word_immediate
+ priority: 500
+ match:
+ opcode: G_LSHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 0, max: 31 }]
+ def_use:
+ - operand: 1
+ opcode: G_AND
+ captures:
+ - { id: source, operand: 1 }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 4294967295, max: 4294967295 }]
+ apply:
+ instructions:
+ - opcode: SRLIW
+ root: true
+ operands:
+ - { operand: 0 }
+ - { captured_operand: source }
+ - { captured_immediate: 2 }
+ erase_operand_definitions: [1, 2]
+ -
+ id: select_g_ashr_s64_word_immediate
+ priority: 500
+ match:
+ opcode: G_ASHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 0, max: 31 }]
+ def_use:
+ - operand: 1
+ opcode: G_SEXT_INREG
+ captures:
+ - { id: source, operand: 1 }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 32, max: 32 }]
+ apply:
+ instructions:
+ - opcode: SRAIW
+ root: true
+ operands:
+ - { operand: 0 }
+ - { captured_operand: source }
+ - { captured_immediate: 2 }
+ erase_operand_definitions: [1, 2]
+ -
+ id: select_g_shl_s64_immediate
+ priority: 400
+ match:
+ opcode: G_SHL
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 0, max: 63 }]
+ apply:
+ instructions:
+ - opcode: SLLI
+ root: true
+ operands: [{ operand: 0 }, { operand: 1 }, { captured_immediate: 2 }]
+ erase_operand_definitions: [2]
+ -
+ id: select_g_lshr_s64_immediate
+ priority: 400
+ match:
+ opcode: G_LSHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 0, max: 63 }]
+ apply:
+ instructions:
+ - opcode: SRLI
+ root: true
+ operands: [{ operand: 0 }, { operand: 1 }, { captured_immediate: 2 }]
+ erase_operand_definitions: [2]
+ -
+ id: select_g_ashr_s64_immediate
+ priority: 400
+ match:
+ opcode: G_ASHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, bits: 64 }
+ - { index: 2, kind: scalar, bits: 64 }
+ operand_banks:
+ - { index: 0, bank: GPR }
+ - { index: 1, bank: GPR }
+ - { index: 2, bank: GPR }
+ operand_def_constants:
+ - index: 2
+ ranges: [{ min: 0, max: 63 }]
+ apply:
+ instructions:
+ - opcode: SRAI
+ root: true
+ operands: [{ operand: 0 }, { operand: 1 }, { captured_immediate: 2 }]
+ erase_operand_definitions: [2]
+ -
+ id: select_g_shl_s64_register
+ priority: 100
+ match:
+ opcode: G_SHL
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, 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: SLL
+ root: true
+ operands:
+ - { operand: 0 }
+ - { operand: 1 }
+ - { complex: shift_mask_xlen, operand: 2 }
+ -
+ id: select_g_lshr_s64_register
+ priority: 100
+ match:
+ opcode: G_LSHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, 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: SRL
+ root: true
+ operands:
+ - { operand: 0 }
+ - { operand: 1 }
+ - { complex: shift_mask_xlen, operand: 2 }
+ -
+ id: select_g_ashr_s64_register
+ priority: 100
+ match:
+ opcode: G_ASHR
+ result_type: { kind: scalar, bits: 64 }
+ operand_types:
+ - { index: 1, kind: scalar, 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: SRA
+ root: true
+ operands:
+ - { operand: 0 }
+ - { operand: 1 }
+ - { complex: shift_mask_xlen, operand: 2 }