aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorJim Lin <jim@andestech.com>2025-07-16 16:13:31 +0800
committerGitHub <noreply@github.com>2025-07-16 16:13:31 +0800
commit3e4153c97b54d456cfaf6ae21391122582b0ab28 (patch)
tree5933f0c87efa3a8057ca09e5e89a5881ad1205ba /clang/lib/CodeGen
parentd7f6660c34b84c0e04843ba29cfc60b4aacd870c (diff)
downloadllvm-3e4153c97b54d456cfaf6ae21391122582b0ab28.zip
llvm-3e4153c97b54d456cfaf6ae21391122582b0ab28.tar.gz
llvm-3e4153c97b54d456cfaf6ae21391122582b0ab28.tar.bz2
[RISCV] Implement Builtins for XAndesBFHCvt extension. (#148804)
XAndesBFHCvt provides two builtins functions for converting between float and bf16. Users can use them to convert bf16 values loaded from memory to float, perform arithmetic operations, then convert them back to bf16 and store them to memory. The load/store and move operations for bf16 will be handled in a later patch.
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/TargetBuiltins/RISCV.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
index 89e3f6f..b08a058 100644
--- a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
@@ -413,6 +413,12 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
ID = Intrinsic::riscv_cv_alu_subuRN;
break;
+ // XAndesBFHCvt
+ case RISCV::BI__builtin_riscv_nds_fcvt_s_bf16:
+ return Builder.CreateFPExt(Ops[0], FloatTy);
+ case RISCV::BI__builtin_riscv_nds_fcvt_bf16_s:
+ return Builder.CreateFPTrunc(Ops[0], BFloatTy);
+
// Vector builtins are handled from here.
#include "clang/Basic/riscv_vector_builtin_cg.inc"