[clang] [Clang][ExprConstant] Normalize aux target builtin IDs before dispatch (PR #201805)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 20:13:04 PDT 2026


================
@@ -78,6 +79,21 @@ void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
 CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E,
                          UnaryExprOrTypeTrait ExprKind);
 
+/// Return the (normalized) builtin ID to dispatch on in the constant
+/// evaluators' target-specific cases, or 0 if the builtin is not one those
+/// cases should handle. Translates an auxiliary target builtin ID back to its
+/// canonical value and only returns IDs for architectures the constant
+/// evaluators can fold (currently x86/x86_64).
+///
+/// The ID-based overload performs no work beyond a single comparison for
+/// target-independent builtins, so it is suitable for hot paths (e.g. the
+/// bytecode interpreter's builtin dispatch) where re-deriving the ID from the
+/// call expression would be wasteful.
+unsigned getConstantEvaluatedBuiltinID(const ASTContext &Ctx,
+                                       unsigned BuiltinID);
----------------
yaohuihan-iluvatar wrote:

done:rename the function to ConvertBuiltinIDToX86BuiltinID
And limit its use to the x86 target-specific dispatch sites.

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


More information about the cfe-commits mailing list