Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
17 changed files
with
1,566 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck -check-prefix=RV32I %s | ||
|
||
; Ensure that the ISDOpcodes ADDC, ADDE, SUBC, SUBE are handled correctly | ||
|
||
define i64 @addc_adde(i64 %a, i64 %b) { | ||
; RV32I-LABEL: addc_adde: | ||
; RV32I: # BB#0: | ||
; RV32I-NEXT: add a1, a1, a3 | ||
; RV32I-NEXT: add a2, a0, a2 | ||
; RV32I-NEXT: sltu a0, a2, a0 | ||
; RV32I-NEXT: add a1, a1, a0 | ||
; RV32I-NEXT: addi a0, a2, 0 | ||
; RV32I-NEXT: jalr zero, ra, 0 | ||
%1 = add i64 %a, %b | ||
ret i64 %1 | ||
} | ||
|
||
define i64 @subc_sube(i64 %a, i64 %b) { | ||
; RV32I-LABEL: subc_sube: | ||
; RV32I: # BB#0: | ||
; RV32I-NEXT: sub a1, a1, a3 | ||
; RV32I-NEXT: sltu a3, a0, a2 | ||
; RV32I-NEXT: sub a1, a1, a3 | ||
; RV32I-NEXT: sub a0, a0, a2 | ||
; RV32I-NEXT: jalr zero, ra, 0 | ||
%1 = sub i64 %a, %b | ||
ret i64 %1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; 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 | ||
|
||
@addr = global i8* null | ||
|
||
define void @test_blockaddress() nounwind { | ||
; RV32I-LABEL: test_blockaddress: | ||
; RV32I: # BB#0: | ||
; RV32I-NEXT: sw ra, 0(s0) | ||
; RV32I-NEXT: lui a0, %hi(addr) | ||
; RV32I-NEXT: addi a0, a0, %lo(addr) | ||
; RV32I-NEXT: lui a1, %hi(.Ltmp0) | ||
; RV32I-NEXT: addi a1, a1, %lo(.Ltmp0) | ||
; RV32I-NEXT: sw a1, 0(a0) | ||
; RV32I-NEXT: lw a0, 0(a0) | ||
; RV32I-NEXT: jalr zero, a0, 0 | ||
; RV32I-NEXT: .Ltmp0: # Block address taken | ||
; RV32I-NEXT: .LBB0_1: # %block | ||
; RV32I-NEXT: lw ra, 0(s0) | ||
; RV32I-NEXT: jalr zero, ra, 0 | ||
store volatile i8* blockaddress(@test_blockaddress, %block), i8** @addr | ||
%val = load volatile i8*, i8** @addr | ||
indirectbr i8* %val, [label %block] | ||
|
||
block: | ||
ret void | ||
} |
Oops, something went wrong.