[clang] [CIR][X86] Add support for `cpuid`/`cpuidex` (PR #173197)

Roberto Turrado Camblor via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 9 07:13:33 PST 2026


================
@@ -3565,6 +3565,31 @@ cir::EhTypeIdOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
   return success();
 }
 
+//===----------------------------------------------------------------------===//
+// CpuIdOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult cir::CpuIdOp::verify() {
+  auto basePtrTy = mlir::dyn_cast<cir::PointerType>(getBasePtr().getType());
+  if (!basePtrTy)
+    return mlir::failure();
+
+  mlir::Type type = basePtrTy.getPointee();
+
+  // basePtr points to an array of size at least 4
+  auto arrayTy = mlir::dyn_cast<cir::ArrayType>(type);
+  if (arrayTy && (arrayTy.getSize() < 4))
----------------
rturrado wrote:

I think you are right, yes. For the 3 tests in the current `ms-intrinsics-cpuid.c` test file, the emitted CIR looks like:

```
"cir.cpuid"(%{{.*}}, %{{.*}}, %{{.*}}) : (!cir.ptr<!s32i>, !s32i, !s32i) -> () loc(#loc{{.*}})
```

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


More information about the cfe-commits mailing list