diff --git a/clang/include/clang/Basic/BuiltinsRISCVCOREV.def b/clang/include/clang/Basic/BuiltinsRISCVCOREV.def index 7d79ae426e69..b285e04f6aaf 100644 --- a/clang/include/clang/Basic/BuiltinsRISCVCOREV.def +++ b/clang/include/clang/Basic/BuiltinsRISCVCOREV.def @@ -177,6 +177,48 @@ TARGET_BUILTIN(bitmanip_cnt, "UZiUZi", "nc", "xcvbitmanip") TARGET_BUILTIN(bitmanip_ror, "UZiUZiUZi", "nc", "xcvbitmanip") TARGET_BUILTIN(bitmanip_bitrev, "UZiUZiIUcIUc", "nc", "xcvbitmanip") +TARGET_BUILTIN(alu_slet, +"ZiZiZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_sletu, +"ZiUZiUZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_min, +"ZiZiZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_minu, +"UZiUZiUZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_max, +"ZiZiZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_maxu, +"UZiUZiUZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_exths, +"Zis", "nc", "xcvalu") +TARGET_BUILTIN(alu_exthz, +"UZiUs", "nc", "xcvalu") +TARGET_BUILTIN(alu_extbs, +"Zic", "nc", "xcvalu") +TARGET_BUILTIN(alu_extbz, +"UZiUc", "nc", "xcvalu") + +TARGET_BUILTIN(alu_clip, +"ZiZiUZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_clipu, +"UZiUZiUZi", "nc", "xcvalu") +TARGET_BUILTIN(alu_addN, +"ZiZiUZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_adduN, +"UZiUZiUZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_addRN, +"ZiZiZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_adduRN, +"UZiUZiUZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_subN, +"ZiZiUZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_subuN, +"UZiUZiUZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_subRN, +"ZiZiZiUc", "nc", "xcvalu") +TARGET_BUILTIN(alu_subuRN, +"UZiUZiUZiUc", "nc", "xcvalu") + #undef BUILTIN #undef TARGET_BUILTIN #undef PSEUDO_BUILTIN diff --git a/clang/test/CodeGen/RISCV/corev-intrinsics/alu.c b/clang/test/CodeGen/RISCV/corev-intrinsics/alu.c new file mode 100644 index 000000000000..39941ad0b8be --- /dev/null +++ b/clang/test/CodeGen/RISCV/corev-intrinsics/alu.c @@ -0,0 +1,305 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -triple riscv32 -target-feature +xcvalu -emit-llvm %s -o - \ +// RUN: | FileCheck %s + +#include + +// CHECK-LABEL: @test_abs( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[TMP0]] +// CHECK-NEXT: [[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0 +// CHECK-NEXT: [[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]] +// CHECK-NEXT: ret i32 [[ABS]] +// +int test_abs(int a) { + return __builtin_abs(a); +} + +// CHECK-LABEL: @test_alu_slet( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.slet(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_slet(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_slet(a, b); +} + +// CHECK-LABEL: @test_alu_sletu( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.sletu(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_sletu(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_sletu(a, b); +} + +// CHECK-LABEL: @test_alu_min( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.min(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_min(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_min(a, b); +} + +// CHECK-LABEL: @test_alu_minu( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.minu(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_minu(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_minu(a, b); +} + +// CHECK-LABEL: @test_alu_max( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.max(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_max(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_max(a, b); +} + +// CHECK-LABEL: @test_alu_maxu( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.maxu(i32 [[TMP0]], i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_maxu(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_maxu(a, b); +} + +// CHECK-LABEL: @test_alu_exths( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i16, align 2 +// CHECK-NEXT: store i16 [[A:%.*]], ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[TMP0]] to i32 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.exths(i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_exths(int16_t a) { + return __builtin_riscv_cv_alu_exths(a); +} + +// CHECK-LABEL: @test_alu_exthz( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i16, align 2 +// CHECK-NEXT: store i16 [[A:%.*]], ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[TMP0]] to i32 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.exthz(i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_exthz(uint16_t a) { + return __builtin_riscv_cv_alu_exthz(a); +} + +// CHECK-LABEL: @test_alu_extbs( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i8, align 1 +// CHECK-NEXT: store i8 [[A:%.*]], ptr [[A_ADDR]], align 1 +// CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[A_ADDR]], align 1 +// CHECK-NEXT: [[TMP1:%.*]] = sext i8 [[TMP0]] to i32 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.extbs(i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_extbs(int8_t a) { + return __builtin_riscv_cv_alu_extbs(a); +} + +// CHECK-LABEL: @test_alu_extbz( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i8, align 1 +// CHECK-NEXT: store i8 [[A:%.*]], ptr [[A_ADDR]], align 1 +// CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[A_ADDR]], align 1 +// CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[TMP0]] to i32 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.extbz(i32 [[TMP1]]) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_extbz(uint8_t a) { + return __builtin_riscv_cv_alu_extbz(a); +} + +// CHECK-LABEL: @test_alu_clip( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.alu.clip(i32 [[TMP0]], i32 15) +// CHECK-NEXT: ret i32 [[TMP1]] +// +int test_alu_clip(int32_t a) { + return __builtin_riscv_cv_alu_clip(a, 15); +} + +// CHECK-LABEL: @test_alu_clipu( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.alu.clipu(i32 [[TMP0]], i32 15) +// CHECK-NEXT: ret i32 [[TMP1]] +// +int test_alu_clipu(uint32_t a) { + return __builtin_riscv_cv_alu_clipu(a, 15); +} + +// CHECK-LABEL: @test_alu_addN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.addN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_addN(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_addN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_adduN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.adduN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_adduN(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_adduN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_addRN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.addRN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_addRN(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_addRN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_adduRN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.adduRN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_adduRN(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_adduRN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_subN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.subN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_subN(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_subN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_subuN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.subuN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_subuN(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_subuN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_subRN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.subRN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_subRN(int32_t a, int32_t b) { + return __builtin_riscv_cv_alu_subRN(a, b, 0); +} + +// CHECK-LABEL: @test_alu_subuRN( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.cv.alu.subuRN(i32 [[TMP0]], i32 [[TMP1]], i32 0) +// CHECK-NEXT: ret i32 [[TMP2]] +// +int test_alu_subuRN(uint32_t a, uint32_t b) { + return __builtin_riscv_cv_alu_subuRN(a, b, 0); +} diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index caf5f1b67855..7b593e224131 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -1781,7 +1781,7 @@ class ScalarCoreVAluGprGprIntrinsic class ScalarCoreVAluGprGprGprIntrinsic : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem, IntrWillReturn, IntrSpeculatable]>; -def int_riscv_cv_alu_abs : ScalarCoreVAluGprIntrinsic; + def int_riscv_cv_alu_slet : ScalarCoreVAluGprGprIntrinsic; def int_riscv_cv_alu_sletu : ScalarCoreVAluGprGprIntrinsic; def int_riscv_cv_alu_min : ScalarCoreVAluGprGprIntrinsic; @@ -1795,12 +1795,12 @@ def int_riscv_cv_alu_extbz : ScalarCoreVAluGprIntrinsic; def int_riscv_cv_alu_clip : ScalarCoreVAluGprGprIntrinsic; def int_riscv_cv_alu_clipu : ScalarCoreVAluGprGprIntrinsic; -def int_riscv_cv_alu_addn : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_addun : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_addrn : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_addurn : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_subn : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_subun : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_subrn : ScalarCoreVAluGprGprGprIntrinsic; -def int_riscv_cv_alu_suburn : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_addN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_adduN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_addRN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_adduRN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_subN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_subuN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_subRN : ScalarCoreVAluGprGprGprIntrinsic; +def int_riscv_cv_alu_subuRN : ScalarCoreVAluGprGprGprIntrinsic; } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td index e9213df1c005..a14d81f29b63 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td @@ -882,7 +882,6 @@ let Predicates = [HasExtXcvalu] in { def : Pat<(srl (add (sub GPR:$rd, GPR:$rs1), (roundBit GPR:$rs2)), GPR:$rs2), (CV_SUBURNR GPR:$rd, GPR:$rs1, GPR:$rs2)>; - def : PatCoreVAluGpr<"abs", "ABS">; def : PatCoreVAluGprGpr<"slet", "SLET">; def : PatCoreVAluGprGpr<"sletu", "SLETU">; def : PatCoreVAluGprGpr<"min", "MIN">; @@ -896,14 +895,14 @@ let Predicates = [HasExtXcvalu] in { defm CLIP : PatCoreVAluGprImm; defm CLIPU : PatCoreVAluGprImm; - defm ADDN : PatCoreVAluGprGprImm; - defm ADDUN : PatCoreVAluGprGprImm; - defm ADDRN : PatCoreVAluGprGprImm; - defm ADDURN : PatCoreVAluGprGprImm; - defm SUBN : PatCoreVAluGprGprImm; - defm SUBUN : PatCoreVAluGprGprImm; - defm SUBRN : PatCoreVAluGprGprImm; - defm SUBURN : PatCoreVAluGprGprImm; + defm ADDN : PatCoreVAluGprGprImm; + defm ADDUN : PatCoreVAluGprGprImm; + defm ADDRN : PatCoreVAluGprGprImm; + defm ADDURN : PatCoreVAluGprGprImm; + defm SUBN : PatCoreVAluGprGprImm; + defm SUBUN : PatCoreVAluGprGprImm; + defm SUBRN : PatCoreVAluGprGprImm; + defm SUBURN : PatCoreVAluGprGprImm; } //===----------------------------------------------------------------------===// diff --git a/llvm/test/CodeGen/RISCV/corev/alu.ll b/llvm/test/CodeGen/RISCV/corev/alu.ll index 01aec1732f85..a6b80744c082 100644 --- a/llvm/test/CodeGen/RISCV/corev/alu.ll +++ b/llvm/test/CodeGen/RISCV/corev/alu.ll @@ -328,17 +328,6 @@ define i32 @subuRNr(i32 %a, i32 %b, i32 %c) { ret i32 %5 } -declare i32 @llvm.riscv.cv.alu.abs(i32) - -define i32 @test.cv.alu.abs(i32 %a) { -; CHECK-LABEL: test.cv.alu.abs: -; CHECK: # %bb.0: -; CHECK-NEXT: cv.abs a0, a0 -; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.abs(i32 %a) - ret i32 %1 -} - declare i32 @llvm.riscv.cv.alu.slet(i32, i32) define i32 @test.cv.alu.slet(i32 %a, i32 %b) { @@ -491,66 +480,66 @@ define i32 @test.cv.alu.clipu.case.b(i32 %a) { ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.addn(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.addN(i32, i32, i32) -define i32 @test.cv.alu.addn.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addn.case.a: +define i32 @test.cv.alu.addN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.addN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.addn a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addn(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.addN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.addn.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addn.case.b: +define i32 @test.cv.alu.addN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.addN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.addnr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addn(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.addN(i32 %a, i32 %b, i32 32) ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.addun(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.adduN(i32, i32, i32) -define i32 @test.cv.alu.addun.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addun.case.a: +define i32 @test.cv.alu.adduN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.adduN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.addun a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addun(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.adduN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.addun.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addun.case.b: +define i32 @test.cv.alu.adduN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.adduN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.addunr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addun(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.adduN(i32 %a, i32 %b, i32 32) ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.addrn(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.addRN(i32, i32, i32) -define i32 @test.cv.alu.addrn.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addrn.case.a: +define i32 @test.cv.alu.addRN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.addRN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.addrn a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addrn(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.addRN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.addrn.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.addrn.case.b: +define i32 @test.cv.alu.addRN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.addRN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.addrnr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.addrn(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.addRN(i32 %a, i32 %b, i32 32) ret i32 %1 } @@ -588,86 +577,86 @@ define i32 @test.cv.alu.adurn.case.b(i32 %a, i32 %b) { ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.subn(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.subN(i32, i32, i32) -define i32 @test.cv.alu.subn.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subn.case.a: +define i32 @test.cv.alu.subN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.subn a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subn(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.subN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.subn.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subn.case.b: +define i32 @test.cv.alu.subN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.subnr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subn(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.subN(i32 %a, i32 %b, i32 32) ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.subun(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.subuN(i32, i32, i32) -define i32 @test.cv.alu.subun.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subun.case.a: +define i32 @test.cv.alu.subuN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subuN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.subun a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subun(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.subuN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.subun.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subun.case.b: +define i32 @test.cv.alu.subuN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subuN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.subunr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subun(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.subuN(i32 %a, i32 %b, i32 32) ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.subrn(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.subRN(i32, i32, i32) -define i32 @test.cv.alu.subrn.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subrn.case.a: +define i32 @test.cv.alu.subRN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subRN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.subrn a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subrn(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.subRN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.subrn.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.subrn.case.b: +define i32 @test.cv.alu.subRN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subRN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.subrnr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.subrn(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.subRN(i32 %a, i32 %b, i32 32) ret i32 %1 } -declare i32 @llvm.riscv.cv.alu.suburn(i32, i32, i32) +declare i32 @llvm.riscv.cv.alu.subuRN(i32, i32, i32) -define i32 @test.cv.alu.suburn.case.a(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.suburn.case.a: +define i32 @test.cv.alu.subuRN.case.a(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subuRN.case.a: ; CHECK: # %bb.0: ; CHECK-NEXT: cv.suburn a0, a0, a1, 15 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.suburn(i32 %a, i32 %b, i32 15) + %1 = call i32 @llvm.riscv.cv.alu.subuRN(i32 %a, i32 %b, i32 15) ret i32 %1 } -define i32 @test.cv.alu.suburn.case.b(i32 %a, i32 %b) { -; CHECK-LABEL: test.cv.alu.suburn.case.b: +define i32 @test.cv.alu.subuRN.case.b(i32 %a, i32 %b) { +; CHECK-LABEL: test.cv.alu.subuRN.case.b: ; CHECK: # %bb.0: ; CHECK-NEXT: li a2, 32 ; CHECK-NEXT: cv.suburnr a0, a1, a2 ; CHECK-NEXT: ret - %1 = call i32 @llvm.riscv.cv.alu.suburn(i32 %a, i32 %b, i32 32) + %1 = call i32 @llvm.riscv.cv.alu.subuRN(i32 %a, i32 %b, i32 32) ret i32 %1 }