Repository: llvm/llvm-project
File: clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h (C/C++)

Code before:
  }

  mlir::Value createAddrSpaceCast(mlir::Value src, mlir::Type newTy) {
    return createAddrSpaceCast(src.getLoc(), src, newTy);
  }

  //===--------------------------------------------------------------------===//
  // Other Instructions
  //===--------------------------------------------------------------------===//

  mlir::Value createExtractElement(mlir::Location loc, mlir::Value vec,
                                   uint64_t idx) {
    mlir::Value idxVal =
        getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
    return cir::VecExtractOp::create(*this, loc, vec, idxVal);
  }

  mlir::Value createInsertElement(mlir::Location loc, mlir::Value vec,
                                  mlir::Value newElt, uint64_t idx) {
    mlir::Value idxVal =
        getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
    return cir::VecInsertOp::create(*this, loc, vec, newElt, idxVal);
  }

  cir::SignBitOp createSignBit(mlir::Location loc, mlir::Value val) {
    mlir::Type resTy = cir::BoolType::get(getContext());
    return cir::SignBitOp::create(*this, loc, resTy, val);
  }

  //===--------------------------------------------------------------------===//
  // Binary Operators
  //===--------------------------------------------------------------------===//

  mlir::Value createBinop(mlir::Location loc, mlir::Value lhs,
                          cir::BinOpKind kind, mlir::Value rhs) {
    return cir::BinOp::create(*this, loc, lhs.getType(), kind, lhs, rhs);
  }

  mlir::Value createLowBitsSet(mlir::Location loc, unsigned size,
                               unsigned bits) {
    llvm::APInt val = llvm::APInt::getLowBitsSet(size, bits);
    auto type = cir::IntType::get(getContext(), size, /*isSigned=*/false);
    return getConstAPInt(loc, type, val);
  }

  mlir::Value createAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
    return createBinop(loc, lhs, cir::BinOpKind::And, rhs);
  }

  mlir::Value createOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
    return createBinop(loc, lhs, cir::BinOpKind::Or, rhs);

Review comment (suggestion):
```suggestion
    auto resTy = cir::BoolType::get(getContext());
```
It's OK to use auto here since the type is explicit in the code.

Code after:
  }

  mlir::Value createAddrSpaceCast(mlir::Value src, mlir::Type newTy) {
    return createAddrSpaceCast(src.getLoc(), src, newTy);
  }

  //===--------------------------------------------------------------------===//
  // Other Instructions
  //===--------------------------------------------------------------------===//

  mlir::Value createExtractElement(mlir::Location loc, mlir::Value vec,
                                   uint64_t idx) {
    mlir::Value idxVal =
        getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
    return cir::VecExtractOp::create(*this, loc, vec, idxVal);
  }

  mlir::Value createInsertElement(mlir::Location loc, mlir::Value vec,
                                  mlir::Value newElt, uint64_t idx) {
    mlir::Value idxVal =
        getConstAPInt(loc, getUIntNTy(64), llvm::APInt(64, idx));
    return cir::VecInsertOp::create(*this, loc, vec, newElt, idxVal);
  }

  cir::SignBitOp createSignBit(mlir::Location loc, mlir::Value val) {
    auto resTy = cir::BoolType::get(getContext());
    return cir::SignBitOp::create(*this, loc, resTy, val);
  }

  //===--------------------------------------------------------------------===//
  // Binary Operators
  //===--------------------------------------------------------------------===//

  mlir::Value createBinop(mlir::Location loc, mlir::Value lhs,
                          cir::BinOpKind kind, mlir::Value rhs) {
    return cir::BinOp::create(*this, loc, lhs.getType(), kind, lhs, rhs);
  }

  mlir::Value createLowBitsSet(mlir::Location loc, unsigned size,
                               unsigned bits) {
    llvm::APInt val = llvm::APInt::getLowBitsSet(size, bits);
    auto type = cir::IntType::get(getContext(), size, /*isSigned=*/false);
    return getConstAPInt(loc, type, val);
  }

  mlir::Value createAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
    return createBinop(loc, lhs, cir::BinOpKind::And, rhs);
  }

  mlir::Value createOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
    return createBinop(loc, lhs, cir::BinOpKind::Or, rhs);