diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def b/clang/include/clang/Basic/BuiltinsRISCV.def --- a/clang/include/clang/Basic/BuiltinsRISCV.def +++ b/clang/include/clang/Basic/BuiltinsRISCV.def @@ -20,6 +20,21 @@ TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit") TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb") TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_andn_32, "ZiZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_andn_64, "WiWiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_clzw_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_cpop_32, "ZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_cpop_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_cpopw_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_ctzw_64, "WiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_max_32, "ZiZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_max_64, "WiWiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_maxu_32, "ZiZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_maxu_64, "WiWiWi", "nc", "zbb,64bit") +TARGET_BUILTIN(__builtin_riscv_orn_32, "ZiZiZi", "nc", "zbb") +TARGET_BUILTIN(__builtin_riscv_orn_64, "WiWiWi", "nc", "zbb,64bit") // Zbc or Zbkc extension TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc") diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18994,6 +18994,20 @@ case RISCV::BI__builtin_riscv_orc_b_64: case RISCV::BI__builtin_riscv_clz_32: case RISCV::BI__builtin_riscv_clz_64: + case RISCV::BI__builtin_riscv_andn_32: + case RISCV::BI__builtin_riscv_andn_64: + case RISCV::BI__builtin_riscv_clzw_64: + case RISCV::BI__builtin_riscv_cpop_32: + case RISCV::BI__builtin_riscv_cpop_64: + case RISCV::BI__builtin_riscv_cpopw_64: + case RISCV::BI__builtin_riscv_ctz_32: + case RISCV::BI__builtin_riscv_ctz_64: + case RISCV::BI__builtin_riscv_max_32: + case RISCV::BI__builtin_riscv_max_64: + case RISCV::BI__builtin_riscv_maxu_32: + case RISCV::BI__builtin_riscv_maxu_64: + case RISCV::BI__builtin_riscv_orn_32: + case RISCV::BI__builtin_riscv_orn_64: case RISCV::BI__builtin_riscv_clmul: case RISCV::BI__builtin_riscv_clmulh: case RISCV::BI__builtin_riscv_clmulr: @@ -19044,6 +19058,36 @@ Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType()); return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)}); } + case RISCV::BI__builtin_riscv_andn_32: + case RISCV::BI__builtin_riscv_andn_64: + ID = Intrinsic::riscv_andn; + break; + case RISCV::BI__builtin_riscv_clzw_64: + ID = Intrinsic::riscv_clzw; + break; + case RISCV::BI__builtin_riscv_cpop_32: + case RISCV::BI__builtin_riscv_cpop_64: + ID = Intrinsic::riscv_cpop; + break; + case RISCV::BI__builtin_riscv_cpopw_64: + ID = Intrinsic::riscv_cpopw; + break; + case RISCV::BI__builtin_riscv_ctz_32: + case RISCV::BI__builtin_riscv_ctz_64: + ID = Intrinsic::riscv_ctz; + break; + case RISCV::BI__builtin_riscv_max_32: + case RISCV::BI__builtin_riscv_max_64: + ID = Intrinsic::riscv_max; + break; + case RISCV::BI__builtin_riscv_maxu_32: + case RISCV::BI__builtin_riscv_maxu_64: + ID = Intrinsic::riscv_maxu; + break; + case RISCV::BI__builtin_riscv_orn_32: + case RISCV::BI__builtin_riscv_orn_64: + ID = Intrinsic::riscv_orn; + break; // Zbc case RISCV::BI__builtin_riscv_clmul: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -87,6 +87,14 @@ // Zbb def int_riscv_orc_b : BitManipGPRIntrinsics; + def int_riscv_andn : BitManipGPRGPRGRIntrinsics; + def int_riscv_clzw : BitManipGPRIntrinsics; + def int_riscv_cpop : BitManipGPRIntrinsics; + def int_riscv_cpopw : BitManipGPRIntrinsics; + def int_riscv_ctz : BitManipGPRIntrinsics; + def int_riscv_max : BitManipGPRGPRIntrinsics; + def int_riscv_maxu : BitManipGPRGPRIntrinsics; + def int_riscv_orn : BitManipGPRGPRIntrinsics; // Zbc or Zbkc def int_riscv_clmul : BitManipGPRGPRIntrinsics;