================
@@ -1875,8 +1930,29 @@ emitTargetArchBuiltinExpr(CIRGenFunction *cgf, unsigned 
builtinID,
     return std::nullopt;
 
   case llvm::Triple::x86:
-  case llvm::Triple::x86_64:
-    return cgf->emitX86BuiltinExpr(builtinID, e);
+  case llvm::Triple::x86_64: {
+    // Try the target-specific emitter first. If it doesn't handle the
+    // builtin, fall back to the generic builtin->intrinsic emitter so target
+    // files don't have to call it themselves.
+    if (std::optional<mlir::Value> res = cgf->emitX86BuiltinExpr(builtinID, e))
+      return *res;
+
+    // Build the operand list
+    llvm::SmallVector<mlir::Value> ops;
+    unsigned iceArguments = 0;
+    ASTContext::GetBuiltinTypeError error;
+    cgf->getContext().GetBuiltinType(builtinID, error, &iceArguments);
+    assert(error == ASTContext::GE_None && "Error while getting builtin 
type.");
+
+    for (auto [idx, arg] : llvm::enumerate(e->arguments()))
+      ops.push_back(cgf->emitScalarOrConstFoldImmArg(iceArguments, idx, arg));
+
+    if (std::optional<mlir::Value> maybeRes =
+            cgf->emitGenericBuiltinIntrinsic(builtinID, e, ops))
----------------
Priyanshu3820 wrote:

that indeed makes more sense given that similar builtins are handled there only 
but the problem is that even classic codegen doesn't handle rdpmc in the 
specific target file

https://github.com/llvm/llvm-project/pull/177639
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to