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
70 lines
2.9 KiB
YAML
70 lines
2.9 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: 3RI2
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ---------------------------------------------+-----+--------------+--------------+---------------
|
|
# 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 |imm2 | rk | rj | rd
|
|
# ---------------------------------------------+-----+--------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_ALSL_W:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: alsl.w $a0, $a1, $a2, 4
|
|
name: test_ALSL_W
|
|
body: |
|
|
bb.0:
|
|
$r4 = ALSL_W $r5, $r6, 4
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_ALSL_WU:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: alsl.wu $a0, $a1, $a2, 2
|
|
name: test_ALSL_WU
|
|
body: |
|
|
bb.0:
|
|
$r4 = ALSL_WU $r5, $r6, 2
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_ALSL_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: alsl.d $a0, $a1, $a2, 4
|
|
name: test_ALSL_D
|
|
body: |
|
|
bb.0:
|
|
$r4 = ALSL_D $r5, $r6, 4
|
|
...
|
|
---
|
|
# CHECK-LABEL: test_BYTEPICK_W:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bytepick.w $a0, $a1, $a2, 0
|
|
name: test_BYTEPICK_W
|
|
body: |
|
|
bb.0:
|
|
$r4 = BYTEPICK_W $r5, $r6, 0
|
|
...
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
# Encoding format: 3RI3
|
|
# -------------------------------------------------------------------------------------------------
|
|
# ------------------------------------------+--------+--------------+--------------+---------------
|
|
# 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 | imm3 | rk | rj | rd
|
|
# ------------------------------------------+--------+--------------+--------------+---------------
|
|
|
|
---
|
|
# CHECK-LABEL: test_BYTEPICK_D:
|
|
# CHECK-ENC: 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0
|
|
# CHECK-ASM: bytepick.d $a0, $a1, $a2, 4
|
|
name: test_BYTEPICK_D
|
|
body: |
|
|
bb.0:
|
|
$r4 = BYTEPICK_D $r5, $r6, 4
|