[clang] [AMDGPU][clang] provide device implementation for __builtin_logb and … (PR #129347)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 07:58:40 PDT 2025


================
@@ -43,6 +43,33 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm;
 
+/// Some builtins do not have library implementation on some targets and
+/// are instead emitted as LLVM IRs by some target builtin emitters.
+/// FIXME: Remove this when library support is added
+static bool shouldEmitBuiltinAsIR(unsigned BuiltinID,
+                                  const Builtin::Context &BI,
+                                  const CodeGenFunction &CGF) {
+  if (!CGF.CGM.getLangOpts().MathErrno &&
+      CGF.CurFPFeatures.getExceptionMode() ==
+          LangOptions::FPExceptionModeKind::FPE_Ignore &&
+      CGF.getTarget().getTriple().isAMDGCN()) {
----------------
yxsamliu wrote:

Instead of checking triple, you can add a virtual function TargetCodeGenInfo::supportsLibCall(), by default it returns true. For AMDGPU, it returns false.

https://github.com/llvm/llvm-project/pull/129347


More information about the cfe-commits mailing list