Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Add IR intrinsic for Zbb extension
Header files are included in a separate patch in case the name needs to be changed. RV32 / 64: orc.b
- Loading branch information
Showing
11 changed files
with
153 additions
and
27 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,15 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s -check-prefix=RV32ZBB | ||
|
||
// RV32ZBB-LABEL: @orcb32( | ||
// RV32ZBB-NEXT: entry: | ||
// RV32ZBB-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 | ||
// RV32ZBB-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 | ||
// RV32ZBB-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 | ||
// RV32ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]]) | ||
// RV32ZBB-NEXT: ret i32 [[TMP1]] | ||
// | ||
int orcb32(int a) { | ||
return __builtin_riscv_orc_b_32(a); | ||
} |
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,27 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zbb -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s -check-prefix=RV64ZBB | ||
|
||
// RV64ZBB-LABEL: @orcb32( | ||
// RV64ZBB-NEXT: entry: | ||
// RV64ZBB-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 | ||
// RV64ZBB-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 | ||
// RV64ZBB-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 | ||
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]]) | ||
// RV64ZBB-NEXT: ret i32 [[TMP1]] | ||
// | ||
int orcb32(int a) { | ||
return __builtin_riscv_orc_b_32(a); | ||
} | ||
|
||
// RV64ZBB-LABEL: @orcb64( | ||
// RV64ZBB-NEXT: entry: | ||
// RV64ZBB-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8 | ||
// RV64ZBB-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 | ||
// RV64ZBB-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8 | ||
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]]) | ||
// RV64ZBB-NEXT: ret i64 [[TMP1]] | ||
// | ||
long orcb64(long a) { | ||
return __builtin_riscv_orc_b_64(a); | ||
} |
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,21 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck %s -check-prefix=RV32IB | ||
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck %s -check-prefix=RV32IBB | ||
|
||
declare i32 @llvm.riscv.orc.b.i32(i32) | ||
|
||
define i32 @orcb(i32 %a) nounwind { | ||
; RV32IB-LABEL: orcb: | ||
; RV32IB: # %bb.0: | ||
; RV32IB-NEXT: orc.b a0, a0 | ||
; RV32IB-NEXT: ret | ||
; | ||
; RV32IBB-LABEL: orcb: | ||
; RV32IBB: # %bb.0: | ||
; RV32IBB-NEXT: orc.b a0, a0 | ||
; RV32IBB-NEXT: ret | ||
%tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a) | ||
ret i32 %tmp | ||
} |
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,37 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck %s -check-prefix=RV64IB | ||
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbb -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck %s -check-prefix=RV64IBB | ||
|
||
declare i32 @llvm.riscv.orc.b.i32(i32) | ||
|
||
define i32 @orcb32(i32 %a) nounwind { | ||
; RV64IB-LABEL: orcb32: | ||
; RV64IB: # %bb.0: | ||
; RV64IB-NEXT: orc.b a0, a0 | ||
; RV64IB-NEXT: ret | ||
; | ||
; RV64IBB-LABEL: orcb32: | ||
; RV64IBB: # %bb.0: | ||
; RV64IBB-NEXT: orc.b a0, a0 | ||
; RV64IBB-NEXT: ret | ||
%tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a) | ||
ret i32 %tmp | ||
} | ||
|
||
declare i64 @llvm.riscv.orc.b.i64(i64) | ||
|
||
define i64 @orcb64(i64 %a) nounwind { | ||
; RV64IB-LABEL: orcb64: | ||
; RV64IB: # %bb.0: | ||
; RV64IB-NEXT: orc.b a0, a0 | ||
; RV64IB-NEXT: ret | ||
; | ||
; RV64IBB-LABEL: orcb64: | ||
; RV64IBB: # %bb.0: | ||
; RV64IBB-NEXT: orc.b a0, a0 | ||
; RV64IBB-NEXT: ret | ||
%tmp = call i64 @llvm.riscv.orc.b.i64(i64 %a) | ||
ret i64 %tmp | ||
} |