[clang] [CIR][X86]Implement handling for Select/Selectsh builtins in CIR (PR #174003)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 5 10:24:48 PST 2026
================
@@ -487,6 +487,37 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createAddrSpaceCast(src.getLoc(), src, newTy);
}
+ //===--------------------------------------------------------------------===//
+ // Other Instructions
+ //===--------------------------------------------------------------------===//
+
+ mlir::Value createExtractElement(mlir::Location loc, mlir::Value vec,
+ mlir::Value idx) {
+ auto vecTy = mlir::cast<cir::VectorType>(vec.getType());
+ mlir::Type eltTy = vecTy.getElementType();
+ auto op = cir::VecExtractOp::create(*this, loc, eltTy, vec, idx);
+ return op.getResult();
+ }
+
+ mlir::Value createExtractElement(mlir::Location loc, mlir::Value vec,
+ uint64_t idx) {
+ auto idxVal = getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
+ return createExtractElement(loc, vec, idxVal);
+ }
+
+ mlir::Value createInsertElement(mlir::Location loc, mlir::Value vec,
+ mlir::Value newElt, mlir::Value idx) {
+ auto op =
+ cir::VecInsertOp::create(*this, loc, vec.getType(), vec, newElt, idx);
+ return op.getResult();
+ }
+
+ mlir::Value createInsertElement(mlir::Location loc, mlir::Value vec,
+ mlir::Value newElt, uint64_t idx) {
+ auto idxVal = getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
----------------
andykaylor wrote:
```suggestion
mlir::Value idxVal = getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
```
https://github.com/llvm/llvm-project/pull/174003
More information about the cfe-commits
mailing list