[clang] [CIR][X86] Implement generic fallback for x86 builtins (PR #177639)

Priyanshu Kumar via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 23 19:56:06 PST 2026


================
@@ -33,6 +33,27 @@ CIRGenFunction::CIRGenFunction(CIRGenModule &cgm, CIRGenBuilderTy &builder,
 
 CIRGenFunction::~CIRGenFunction() {}
 
+std::optional<std::string>
+CIRGenFunction::getIntrinsicNameForBuiltin(unsigned builtinID) {
+  // First try explicit mappings for known builtins.
+  switch (builtinID) {
+  case X86::BI__builtin_ia32_rdpmc:
+    return std::string("x86.rdpmc");
+  default:
+    break;
+  }
+
+  // As a fallback, match common builtin names to avoid depending on the exact
+  // enum variant emitted by TableGen (e.g., "rdpmc" vs "__builtin_ia32_rdpmc").
+  std::string name = getContext().BuiltinInfo.getName(builtinID);
+
+  if (name.size() >= 5 && name.compare(name.size() - 5, 5, "rdpmc") == 0) {
----------------
Priyanshu3820 wrote:

For x86, it is the only case that was not handled in the specific target file

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


More information about the cfe-commits mailing list