This is a split patch of D120476 and thanks to myhsu. 'Transformed' means the encoding of an immediate is not the same as its binary representation. For example, the `bl` instruction requires a signed 28-bits integer as its operand and the low 2 bits must be 0. So only the upper 26 bits are needed to get encoded into the instruction. Based on the above reason this kind of immediate needs a customed `EncoderMethod` to get the real value getting encoded into the instruction. Currently these immediate includes: ``` uimm2_plus1 simm14_lsl2 simm16_lsl2 simm21_lsl2 simm26_lsl2 ``` This patch adds those `EncoderMethod`s and revises related .mir test in previous patch. Reviewed By: xen0n, MaskRay Differential Revision: https://reviews.llvm.org/D120545
201 lines
8.2 KiB
YAML
201 lines
8.2 KiB
YAML
# RUN: llc %s -mtriple=loongarch64 -start-after=prologepilog -O0 -filetype=obj -o - \
|
|
# RUN: | extract-section .text \
|
|
# RUN: | FileCheck %s -check-prefix=CHECK-ENC
|
|
# RUN: llc %s -mtriple=loongarch64 -start-after=prologepilog -O0 -filetype=asm -o - \
|
|
# RUN: | FileCheck %s -check-prefix=CHECK-ASM
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: I15
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ---------------------------------------------------+---------------------------------------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ---------------------------------------------------+---------------------------------------------
|
|
# opcode | imm15
|
|
# ---------------------------------------------------+---------------------------------------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_DBAR:
|
|
# CHECK-ENC: 0 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
# CHECK-ASM: dbar 0
|
|
name: test_DBAR
|
|
body: |
|
|
bb.0:
|
|
DBAR 0
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_IBAR:
|
|
# CHECK-ENC: 0 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
# CHECK-ASM: ibar 0
|
|
name: test_IBAR
|
|
body: |
|
|
bb.0:
|
|
IBAR 0
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_SYSCALL:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0
|
|
# CHECK-ASM: syscall 100
|
|
name: test_SYSCALL
|
|
body: |
|
|
bb.0:
|
|
SYSCALL 100
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_BREAK:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1
|
|
# CHECK-ASM: break 199
|
|
name: test_BREAK
|
|
body: |
|
|
bb.0:
|
|
BREAK 199
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: I26
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ------------------+-----------------------------------------------+------------------------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ------------------+-----------------------------------------------+------------------------------
|
|
# opcode | imm26{15-0} | imm26{25-16}
|
|
# ------------------+-----------------------------------------------+------------------------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_B:
|
|
# CHECK-ENC: 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0
|
|
# CHECK-ASM: b 80
|
|
name: test_B
|
|
body: |
|
|
bb.0:
|
|
B 80
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_BL:
|
|
# CHECK-ENC: 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
|
|
# CHECK-ASM: bl 136
|
|
name: test_BL
|
|
body: |
|
|
bb.0:
|
|
BL 136
|
|
...
|
|
|
|
# --------------------------------------------------------------------------------------------------------
|
|
# Encoding format: BSTR_W
|
|
# --------------------------------------------------------------------------------------------------------
|
|
# ---------------------------------+--------------+---------+--------------+--------------+---------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ---------------------------------+--------------+---------+--------------+--------------+---------------
|
|
# opcode{11-1} | msb |opcode{0}| lsb | rj | rd
|
|
# ---------------------------------+--------------+---------+--------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_BSTRINS_W:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bstrins.w $a0, $a1, 7, 2
|
|
name: test_BSTRINS_W
|
|
body: |
|
|
bb.0:
|
|
$r4 = BSTRINS_W $r4, $r5, 7, 2
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_BSTRPICK_W:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bstrpick.w $a0, $a1, 10, 4
|
|
name: test_BSTRPICK_W
|
|
body: |
|
|
bb.0:
|
|
$r4 = BSTRPICK_W $r5, 10, 4
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: BSTR_D
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ------------------------------+-----------------+-----------------+--------------+---------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ------------------------------+-----------------+-----------------+--------------+---------------
|
|
# opcode | msb | lsb | rj | rd
|
|
# ------------------------------+-----------------+-----------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_BSTRINS_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bstrins.d $a0, $a1, 7, 2
|
|
name: test_BSTRINS_D
|
|
body: |
|
|
bb.0:
|
|
$r4 = BSTRINS_D $r4, $r5, 7, 2
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_BSTRPICK_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bstrpick.d $a0, $a1, 39, 22
|
|
name: test_BSTRPICK_D
|
|
body: |
|
|
bb.0:
|
|
$r4 = BSTRPICK_D $r5, 39, 22
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: ASRT
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
# opcode | rk | rj | 0x0
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_ASRTLE_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0
|
|
# CHECK-ASM: asrtle.d $a0, $a1
|
|
name: test_ASRTLE_D
|
|
body: |
|
|
bb.0:
|
|
ASRTLE_D $r4, $r5
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_ASRTGT_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0
|
|
# CHECK-ASM: asrtgt.d $a0, $a1
|
|
name: test_ASRTGT_D
|
|
body: |
|
|
bb.0:
|
|
ASRTGT_D $r4, $r5
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: PRELD
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ------------------------------+-----------------------------------+--------------+---------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ------------------------------+-----------------------------------+--------------+---------------
|
|
# opcode | imm12 | rj | imm5
|
|
# ------------------------------+-----------------------------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_PRELD:
|
|
# CHECK-ENC: 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 0 1 1 1 1
|
|
# CHECK-ASM: preld 15, $a0, 21
|
|
name: test_PRELD
|
|
body: |
|
|
bb.0:
|
|
PRELD 15, $r4, 21
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: PRELDX
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
# 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
# opcode | rk | rj | imm5
|
|
# ---------------------------------------------------+--------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_PRELDX:
|
|
# CHECK-ENC: 0 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1
|
|
# CHECK-ASM: preldx 11, $a0, $a1
|
|
name: test_PRELDX
|
|
body: |
|
|
bb.0:
|
|
PRELDX 11, $r4, $r5
|