-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Re-define sha256, Zksed, and Zksh intrinsics to use i32 types.
Previously we returned i32 on RV32 and i64 on RV64. The instructions only consume 32 bits and only produce 32 bits. For RV64, the result is sign extended to 64 bits like *W instructions. This patch removes this detail from the interface to improve portability and consistency. This matches the proposal for scalar intrinsics here riscv-non-isa/riscv-c-api-doc#44 I've included IR autoupgrade support as well. I'll be doing this for other builtins/intrinsics that currently use 'long' in other patches. Reviewed By: VincentWu Differential Revision: https://reviews.llvm.org/D154647
- Loading branch information
Showing
25 changed files
with
544 additions
and
281 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv32 -target-feature +zksed -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s -check-prefix=RV32ZKSED | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +zksed -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s -check-prefix=RV64ZKSED | ||
|
||
#include <stdint.h> | ||
|
||
// RV32ZKSED-LABEL: @sm4ks( | ||
// RV32ZKSED-NEXT: entry: | ||
// RV32ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4 | ||
// RV32ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4 | ||
// RV32ZKSED-NEXT: store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ks(i32 [[TMP0]], i32 [[TMP1]], i32 0) | ||
// RV32ZKSED-NEXT: ret i32 [[TMP2]] | ||
// | ||
// RV64ZKSED-LABEL: @sm4ks( | ||
// RV64ZKSED-NEXT: entry: | ||
// RV64ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4 | ||
// RV64ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4 | ||
// RV64ZKSED-NEXT: store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ks(i32 [[TMP0]], i32 [[TMP1]], i32 0) | ||
// RV64ZKSED-NEXT: ret i32 [[TMP2]] | ||
// | ||
uint32_t sm4ks(uint32_t rs1, uint32_t rs2) { | ||
return __builtin_riscv_sm4ks(rs1, rs2, 0); | ||
} | ||
|
||
// RV32ZKSED-LABEL: @sm4ed( | ||
// RV32ZKSED-NEXT: entry: | ||
// RV32ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4 | ||
// RV32ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4 | ||
// RV32ZKSED-NEXT: store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4 | ||
// RV32ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ed(i32 [[TMP0]], i32 [[TMP1]], i32 0) | ||
// RV32ZKSED-NEXT: ret i32 [[TMP2]] | ||
// | ||
// RV64ZKSED-LABEL: @sm4ed( | ||
// RV64ZKSED-NEXT: entry: | ||
// RV64ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4 | ||
// RV64ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4 | ||
// RV64ZKSED-NEXT: store i32 [[RS1:%.*]], ptr [[RS1_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: store i32 [[RS2:%.*]], ptr [[RS2_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP0:%.*]] = load i32, ptr [[RS1_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP1:%.*]] = load i32, ptr [[RS2_ADDR]], align 4 | ||
// RV64ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ed(i32 [[TMP0]], i32 [[TMP1]], i32 0) | ||
// RV64ZKSED-NEXT: ret i32 [[TMP2]] | ||
// | ||
uint32_t sm4ed(uint32_t rs1, uint32_t rs2) { | ||
return __builtin_riscv_sm4ed(rs1, rs2, 0); | ||
} |
Oops, something went wrong.