[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 11:11:21 PST 2026
================
@@ -4282,6 +4283,71 @@ mlir::LogicalResult CIRToLLVMAwaitOpLowering::matchAndRewrite(
return mlir::failure();
}
+mlir::LogicalResult CIRToLLVMCpuIdOpLowering::matchAndRewrite(
+ cir::CpuIdOp op, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type i32Ty = rewriter.getI32Type();
+ mlir::Type i64Ty = rewriter.getI64Type();
+ mlir::Type i32PtrTy = mlir::LLVM::LLVMPointerType::get(i32Ty.getContext(), 0);
+
+ mlir::Type cpuidRetTy = mlir::LLVM::LLVMStructType::getLiteral(
+ rewriter.getContext(), {i32Ty, i32Ty, i32Ty, i32Ty});
+
+ mlir::Value funcId = adaptor.getFunctionId();
+ mlir::Value subFuncId = adaptor.getSubFunctionId();
+ std::array<mlir::Value, 2> operands{funcId, subFuncId};
+
+ StringRef asmString, constraints;
+ mlir::ModuleOp module = op->getParentOfType<mlir::ModuleOp>();
----------------
rturrado wrote:
Good point!
https://github.com/llvm/llvm-project/pull/173197
More information about the cfe-commits
mailing list