[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
|
|
|
|
; RUN: | FileCheck %s -check-prefix=RV32I
|
|
|
|
|
|
|
|
define void @jt(i32 %in, i32* %out) {
|
|
|
|
; RV32I-LABEL: jt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; RV32I: # %bb.0: # %entry
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; RV32I-NEXT: addi a2, zero, 2
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: blt a2, a0, .LBB0_4
|
|
|
|
; RV32I-NEXT: # %bb.1: # %entry
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: addi a2, zero, 1
|
|
|
|
; RV32I-NEXT: beq a0, a2, .LBB0_7
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: # %bb.2: # %entry
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: addi a2, zero, 2
|
|
|
|
; RV32I-NEXT: bne a0, a2, .LBB0_10
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: # %bb.3: # %bb2
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; RV32I-NEXT: addi a0, zero, 3
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: j .LBB0_9
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; RV32I-NEXT: .LBB0_4: # %entry
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: addi a2, zero, 3
|
|
|
|
; RV32I-NEXT: beq a0, a2, .LBB0_8
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: # %bb.5: # %entry
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; RV32I-NEXT: addi a2, zero, 4
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: bne a0, a2, .LBB0_10
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: # %bb.6: # %bb4
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
; RV32I-NEXT: addi a0, zero, 1
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: j .LBB0_9
|
2018-01-11 05:05:07 +08:00
|
|
|
; RV32I-NEXT: .LBB0_7: # %bb1
|
2018-01-11 04:47:00 +08:00
|
|
|
; RV32I-NEXT: addi a0, zero, 4
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: j .LBB0_9
|
2018-01-11 05:05:07 +08:00
|
|
|
; RV32I-NEXT: .LBB0_8: # %bb3
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: addi a0, zero, 2
|
2018-01-11 05:05:07 +08:00
|
|
|
; RV32I-NEXT: .LBB0_9: # %exit
|
2019-01-26 04:22:49 +08:00
|
|
|
; RV32I-NEXT: sw a0, 0(a1)
|
|
|
|
; RV32I-NEXT: .LBB0_10: # %exit
|
2017-12-15 17:47:01 +08:00
|
|
|
; RV32I-NEXT: ret
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
entry:
|
|
|
|
switch i32 %in, label %exit [
|
|
|
|
i32 1, label %bb1
|
|
|
|
i32 2, label %bb2
|
|
|
|
i32 3, label %bb3
|
|
|
|
i32 4, label %bb4
|
|
|
|
]
|
|
|
|
bb1:
|
|
|
|
store i32 4, i32* %out
|
|
|
|
br label %exit
|
|
|
|
bb2:
|
|
|
|
store i32 3, i32* %out
|
|
|
|
br label %exit
|
|
|
|
bb3:
|
|
|
|
store i32 2, i32* %out
|
|
|
|
br label %exit
|
|
|
|
bb4:
|
|
|
|
store i32 1, i32* %out
|
|
|
|
br label %exit
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|