/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|*                                                                            *|
|* Op Definitions                                                             *|
|*                                                                            *|
|* Automatically generated file, do not edit!                                 *|
|*                                                                            *|
\*===----------------------------------------------------------------------===*/

#ifdef GET_OP_LIST
#undef GET_OP_LIST

::mlir::transform::EmptyTensorToAllocTensorOp,
::mlir::transform::OneShotBufferizeOp
#endif  // GET_OP_LIST

#ifdef GET_OP_CLASSES
#undef GET_OP_CLASSES


//===----------------------------------------------------------------------===//
// Local Utility Method Definitions
//===----------------------------------------------------------------------===//

namespace mlir {
namespace transform {

static ::mlir::LogicalResult __mlir_ods_local_type_constraint_BufferizationTransformOps0(
    ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
    unsigned valueIndex) {
  if (!(((type.isa<::mlir::transform::OperationType>())) && ((type.cast<::mlir::transform::OperationType>().getOperationName() == "tensor.empty")))) {
    return op->emitOpError(valueKind) << " #" << valueIndex
        << " must be Transform IR handle to tensor.empty operations, but got " << type;
  }
  return ::mlir::success();
}

static ::mlir::LogicalResult __mlir_ods_local_type_constraint_BufferizationTransformOps1(
    ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
    unsigned valueIndex) {
  if (!(((type.isa<::mlir::transform::OperationType>())) && ((type.cast<::mlir::transform::OperationType>().getOperationName() == "bufferization.alloc_tensor")))) {
    return op->emitOpError(valueKind) << " #" << valueIndex
        << " must be Transform IR handle to bufferization.alloc_tensor operations, but got " << type;
  }
  return ::mlir::success();
}

static ::mlir::LogicalResult __mlir_ods_local_type_constraint_BufferizationTransformOps2(
    ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
    unsigned valueIndex) {
  if (!((type.isa<::mlir::pdl::OperationType>()))) {
    return op->emitOpError(valueKind) << " #" << valueIndex
        << " must be PDL handle to an `mlir::Operation *`, but got " << type;
  }
  return ::mlir::success();
}

static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_BufferizationTransformOps0(
    ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
  if (attr && !((attr.isa<::mlir::bufferization::LayoutMapOptionAttr>()))) {
    return op->emitOpError("attribute '") << attrName
        << "' failed to satisfy constraint: option for map layout";
  }
  return ::mlir::success();
}

static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_BufferizationTransformOps1(
    ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
  if (attr && !((attr.isa<::mlir::BoolAttr>()))) {
    return op->emitOpError("attribute '") << attrName
        << "' failed to satisfy constraint: bool attribute";
  }
  return ::mlir::success();
}
} // namespace transform
} // namespace mlir
namespace mlir {
namespace transform {

//===----------------------------------------------------------------------===//
// ::mlir::transform::EmptyTensorToAllocTensorOp definitions
//===----------------------------------------------------------------------===//

namespace detail {
EmptyTensorToAllocTensorOpGenericAdaptorBase::EmptyTensorToAllocTensorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) {  if (odsAttrs)
    odsOpName.emplace("transform.bufferization.empty_tensor_to_alloc_tensor", odsAttrs.getContext());
}

std::pair<unsigned, unsigned> EmptyTensorToAllocTensorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
  return {index, 1};
}

::mlir::DictionaryAttr EmptyTensorToAllocTensorOpGenericAdaptorBase::getAttributes() {
  return odsAttrs;
}

} // namespace detail
EmptyTensorToAllocTensorOpAdaptor::EmptyTensorToAllocTensorOpAdaptor(EmptyTensorToAllocTensorOp op) : EmptyTensorToAllocTensorOpAdaptor(op->getOperands(), op->getAttrDictionary(), op->getRegions()) {}

::mlir::LogicalResult EmptyTensorToAllocTensorOpAdaptor::verify(::mlir::Location loc) {
  return ::mlir::success();
}

std::pair<unsigned, unsigned> EmptyTensorToAllocTensorOp::getODSOperandIndexAndLength(unsigned index) {
  return {index, 1};
}

::mlir::Operation::operand_range EmptyTensorToAllocTensorOp::getODSOperands(unsigned index) {
  auto valueRange = getODSOperandIndexAndLength(index);
  return {std::next(getOperation()->operand_begin(), valueRange.first),
           std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
}

::mlir::TypedValue<::mlir::transform::OperationType> EmptyTensorToAllocTensorOp::getTarget() {
  return *getODSOperands(0).begin();
}

::mlir::MutableOperandRange EmptyTensorToAllocTensorOp::getTargetMutable() {
  auto range = getODSOperandIndexAndLength(0);
  auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
  return mutableRange;
}

std::pair<unsigned, unsigned> EmptyTensorToAllocTensorOp::getODSResultIndexAndLength(unsigned index) {
  return {index, 1};
}

::mlir::Operation::result_range EmptyTensorToAllocTensorOp::getODSResults(unsigned index) {
  auto valueRange = getODSResultIndexAndLength(index);
  return {std::next(getOperation()->result_begin(), valueRange.first),
           std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
}

::mlir::TypedValue<::mlir::transform::OperationType> EmptyTensorToAllocTensorOp::getTransformed() {
  return *getODSResults(0).begin();
}

void EmptyTensorToAllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type transformed, ::mlir::Value target) {
  odsState.addOperands(target);
  odsState.addTypes(transformed);
}

void EmptyTensorToAllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) {
  odsState.addOperands(target);
  assert(resultTypes.size() == 1u && "mismatched number of results");
  odsState.addTypes(resultTypes);
}

void EmptyTensorToAllocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
  assert(operands.size() == 1u && "mismatched number of parameters");
  odsState.addOperands(operands);
  odsState.addAttributes(attributes);
  assert(resultTypes.size() == 1u && "mismatched number of return types");
  odsState.addTypes(resultTypes);
}

::mlir::LogicalResult EmptyTensorToAllocTensorOp::verifyInvariantsImpl() {
  {
    unsigned index = 0; (void)index;
    auto valueGroup0 = getODSOperands(0);

    for (auto v : valueGroup0) {
      if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationTransformOps0(*this, v.getType(), "operand", index++)))
        return ::mlir::failure();
    }
  }
  {
    unsigned index = 0; (void)index;
    auto valueGroup0 = getODSResults(0);

    for (auto v : valueGroup0) {
      if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationTransformOps1(*this, v.getType(), "result", index++)))
        return ::mlir::failure();
    }
  }
  return ::mlir::success();
}

::mlir::LogicalResult EmptyTensorToAllocTensorOp::verifyInvariants() {
  return verifyInvariantsImpl();
}

::mlir::ParseResult EmptyTensorToAllocTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
  ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1];
  ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands);  ::llvm::SMLoc targetOperandsLoc;
  (void)targetOperandsLoc;
  ::llvm::ArrayRef<::mlir::Type> allOperandTypes;
  ::llvm::ArrayRef<::mlir::Type> allResultTypes;

  targetOperandsLoc = parser.getCurrentLocation();
  if (parser.parseOperand(targetRawOperands[0]))
    return ::mlir::failure();
  if (parser.parseOptionalAttrDict(result.attributes))
    return ::mlir::failure();
  if (parser.parseColon())
    return ::mlir::failure();

  ::mlir::FunctionType allOperand__allResult_functionType;
  if (parser.parseType(allOperand__allResult_functionType))
    return ::mlir::failure();
  allOperandTypes = allOperand__allResult_functionType.getInputs();
  allResultTypes = allOperand__allResult_functionType.getResults();
  result.addTypes(allResultTypes);
  if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands))
    return ::mlir::failure();
  return ::mlir::success();
}

void EmptyTensorToAllocTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
  _odsPrinter << ' ';
  _odsPrinter << getTarget();
  ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
  _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
  _odsPrinter << ' ' << ":";
  _odsPrinter << ' ';
  _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
}

} // namespace transform
} // namespace mlir
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::EmptyTensorToAllocTensorOp)

namespace mlir {
namespace transform {

//===----------------------------------------------------------------------===//
// ::mlir::transform::OneShotBufferizeOp definitions
//===----------------------------------------------------------------------===//

namespace detail {
OneShotBufferizeOpGenericAdaptorBase::OneShotBufferizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) {  if (odsAttrs)
    odsOpName.emplace("transform.bufferization.one_shot_bufferize", odsAttrs.getContext());
}

std::pair<unsigned, unsigned> OneShotBufferizeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
  return {index, 1};
}

::mlir::DictionaryAttr OneShotBufferizeOpGenericAdaptorBase::getAttributes() {
  return odsAttrs;
}

::mlir::bufferization::LayoutMapOptionAttr OneShotBufferizeOpGenericAdaptorBase::getFunctionBoundaryTypeConversionAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getFunctionBoundaryTypeConversionAttrName(*odsOpName)).dyn_cast_or_null<::mlir::bufferization::LayoutMapOptionAttr>();
  return attr;
}

::std::optional<::mlir::bufferization::LayoutMapOption> OneShotBufferizeOpGenericAdaptorBase::getFunctionBoundaryTypeConversion() {
  auto attr = getFunctionBoundaryTypeConversionAttr();
  return attr ? ::std::optional<::mlir::bufferization::LayoutMapOption>(attr.getValue()) : (::std::nullopt);
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getAllowReturnAllocsAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getAllowReturnAllocsAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getAllowReturnAllocs() {
  auto attr = getAllowReturnAllocsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getAllowUnknownOpsAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getAllowUnknownOpsAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getAllowUnknownOps() {
  auto attr = getAllowUnknownOpsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getBufferizeFunctionBoundariesAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getBufferizeFunctionBoundariesAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getBufferizeFunctionBoundaries() {
  auto attr = getBufferizeFunctionBoundariesAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getCreateDeallocsAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getCreateDeallocsAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getCreateDeallocs() {
  auto attr = getCreateDeallocsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getTargetIsModuleAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getTargetIsModuleAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getTargetIsModule() {
  auto attr = getTargetIsModuleAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getTestAnalysisOnlyAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getTestAnalysisOnlyAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getTestAnalysisOnly() {
  auto attr = getTestAnalysisOnlyAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOpGenericAdaptorBase::getPrintConflictsAttr() {
  assert(odsAttrs && "no attributes when constructing adapter");
  auto attr = ::mlir::impl::getAttrFromSortedRange(odsAttrs.begin() + 0, odsAttrs.end() - 0, OneShotBufferizeOp::getPrintConflictsAttrName(*odsOpName)).dyn_cast_or_null<::mlir::BoolAttr>();
  return attr;
}

bool OneShotBufferizeOpGenericAdaptorBase::getPrintConflicts() {
  auto attr = getPrintConflictsAttr();
  return attr.getValue();
}

} // namespace detail
OneShotBufferizeOpAdaptor::OneShotBufferizeOpAdaptor(OneShotBufferizeOp op) : OneShotBufferizeOpAdaptor(op->getOperands(), op->getAttrDictionary(), op->getRegions()) {}

::mlir::LogicalResult OneShotBufferizeOpAdaptor::verify(::mlir::Location loc) {
  auto namedAttrRange = odsAttrs;
  auto namedAttrIt = namedAttrRange.begin();
  ::mlir::Attribute tblgen_allow_return_allocs;
  ::mlir::Attribute tblgen_allow_unknown_ops;
  ::mlir::Attribute tblgen_bufferize_function_boundaries;
  ::mlir::Attribute tblgen_create_deallocs;
  ::mlir::Attribute tblgen_function_boundary_type_conversion;
  ::mlir::Attribute tblgen_print_conflicts;
  ::mlir::Attribute tblgen_target_is_module;
  ::mlir::Attribute tblgen_test_analysis_only;
  while (true) {
    if (namedAttrIt == namedAttrRange.end()) {
      break;
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getAllowReturnAllocsAttrName(*odsOpName)) {
      tblgen_allow_return_allocs = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getAllowUnknownOpsAttrName(*odsOpName)) {
      tblgen_allow_unknown_ops = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getBufferizeFunctionBoundariesAttrName(*odsOpName)) {
      tblgen_bufferize_function_boundaries = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getCreateDeallocsAttrName(*odsOpName)) {
      tblgen_create_deallocs = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getFunctionBoundaryTypeConversionAttrName(*odsOpName)) {
      tblgen_function_boundary_type_conversion = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getPrintConflictsAttrName(*odsOpName)) {
      tblgen_print_conflicts = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getTargetIsModuleAttrName(*odsOpName)) {
      tblgen_target_is_module = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == OneShotBufferizeOp::getTestAnalysisOnlyAttrName(*odsOpName)) {
      tblgen_test_analysis_only = namedAttrIt->getValue();
    }
    ++namedAttrIt;
  }

  if (tblgen_function_boundary_type_conversion && !((tblgen_function_boundary_type_conversion.isa<::mlir::bufferization::LayoutMapOptionAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'function_boundary_type_conversion' failed to satisfy constraint: option for map layout");

  if (tblgen_allow_return_allocs && !((tblgen_allow_return_allocs.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'allow_return_allocs' failed to satisfy constraint: bool attribute");

  if (tblgen_allow_unknown_ops && !((tblgen_allow_unknown_ops.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'allow_unknown_ops' failed to satisfy constraint: bool attribute");

  if (tblgen_bufferize_function_boundaries && !((tblgen_bufferize_function_boundaries.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'bufferize_function_boundaries' failed to satisfy constraint: bool attribute");

  if (tblgen_create_deallocs && !((tblgen_create_deallocs.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'create_deallocs' failed to satisfy constraint: bool attribute");

  if (tblgen_target_is_module && !((tblgen_target_is_module.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'target_is_module' failed to satisfy constraint: bool attribute");

  if (tblgen_test_analysis_only && !((tblgen_test_analysis_only.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'test_analysis_only' failed to satisfy constraint: bool attribute");

  if (tblgen_print_conflicts && !((tblgen_print_conflicts.isa<::mlir::BoolAttr>())))
    return emitError(loc, "'transform.bufferization.one_shot_bufferize' op ""attribute 'print_conflicts' failed to satisfy constraint: bool attribute");
  return ::mlir::success();
}

std::pair<unsigned, unsigned> OneShotBufferizeOp::getODSOperandIndexAndLength(unsigned index) {
  return {index, 1};
}

::mlir::Operation::operand_range OneShotBufferizeOp::getODSOperands(unsigned index) {
  auto valueRange = getODSOperandIndexAndLength(index);
  return {std::next(getOperation()->operand_begin(), valueRange.first),
           std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
}

::mlir::TypedValue<::mlir::pdl::OperationType> OneShotBufferizeOp::getTarget() {
  return *getODSOperands(0).begin();
}

::mlir::MutableOperandRange OneShotBufferizeOp::getTargetMutable() {
  auto range = getODSOperandIndexAndLength(0);
  auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
  return mutableRange;
}

std::pair<unsigned, unsigned> OneShotBufferizeOp::getODSResultIndexAndLength(unsigned index) {
  return {index, 1};
}

::mlir::Operation::result_range OneShotBufferizeOp::getODSResults(unsigned index) {
  auto valueRange = getODSResultIndexAndLength(index);
  return {std::next(getOperation()->result_begin(), valueRange.first),
           std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
}

::mlir::bufferization::LayoutMapOptionAttr OneShotBufferizeOp::getFunctionBoundaryTypeConversionAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getFunctionBoundaryTypeConversionAttrName()).dyn_cast_or_null<::mlir::bufferization::LayoutMapOptionAttr>();
}

::std::optional<::mlir::bufferization::LayoutMapOption> OneShotBufferizeOp::getFunctionBoundaryTypeConversion() {
  auto attr = getFunctionBoundaryTypeConversionAttr();
  return attr ? ::std::optional<::mlir::bufferization::LayoutMapOption>(attr.getValue()) : (::std::nullopt);
}

::mlir::BoolAttr OneShotBufferizeOp::getAllowReturnAllocsAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getAllowReturnAllocsAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getAllowReturnAllocs() {
  auto attr = getAllowReturnAllocsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getAllowUnknownOpsAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getAllowUnknownOpsAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getAllowUnknownOps() {
  auto attr = getAllowUnknownOpsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getBufferizeFunctionBoundariesAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getBufferizeFunctionBoundariesAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getBufferizeFunctionBoundaries() {
  auto attr = getBufferizeFunctionBoundariesAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getCreateDeallocsAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getCreateDeallocsAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getCreateDeallocs() {
  auto attr = getCreateDeallocsAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getTargetIsModuleAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getTargetIsModuleAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getTargetIsModule() {
  auto attr = getTargetIsModuleAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getTestAnalysisOnlyAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getTestAnalysisOnlyAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getTestAnalysisOnly() {
  auto attr = getTestAnalysisOnlyAttr();
  return attr.getValue();
}

::mlir::BoolAttr OneShotBufferizeOp::getPrintConflictsAttr() {
  return ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 0, (*this)->getAttrs().end() - 0, getPrintConflictsAttrName()).dyn_cast_or_null<::mlir::BoolAttr>();
}

bool OneShotBufferizeOp::getPrintConflicts() {
  auto attr = getPrintConflictsAttr();
  return attr.getValue();
}

void OneShotBufferizeOp::setFunctionBoundaryTypeConversionAttr(::mlir::bufferization::LayoutMapOptionAttr attr) {
  (*this)->setAttr(getFunctionBoundaryTypeConversionAttrName(), attr);
}

void OneShotBufferizeOp::setFunctionBoundaryTypeConversion(::std::optional<::mlir::bufferization::LayoutMapOption> attrValue) {
    if (attrValue)
      return (*this)->setAttr(getFunctionBoundaryTypeConversionAttrName(), ::mlir::bufferization::LayoutMapOptionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue));
    (*this)->removeAttr(getFunctionBoundaryTypeConversionAttrName());
}

void OneShotBufferizeOp::setAllowReturnAllocsAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getAllowReturnAllocsAttrName(), attr);
}

void OneShotBufferizeOp::setAllowReturnAllocs(bool attrValue) {
  (*this)->setAttr(getAllowReturnAllocsAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setAllowUnknownOpsAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getAllowUnknownOpsAttrName(), attr);
}

void OneShotBufferizeOp::setAllowUnknownOps(bool attrValue) {
  (*this)->setAttr(getAllowUnknownOpsAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setBufferizeFunctionBoundariesAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getBufferizeFunctionBoundariesAttrName(), attr);
}

void OneShotBufferizeOp::setBufferizeFunctionBoundaries(bool attrValue) {
  (*this)->setAttr(getBufferizeFunctionBoundariesAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setCreateDeallocsAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getCreateDeallocsAttrName(), attr);
}

void OneShotBufferizeOp::setCreateDeallocs(bool attrValue) {
  (*this)->setAttr(getCreateDeallocsAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setTargetIsModuleAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getTargetIsModuleAttrName(), attr);
}

void OneShotBufferizeOp::setTargetIsModule(bool attrValue) {
  (*this)->setAttr(getTargetIsModuleAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setTestAnalysisOnlyAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getTestAnalysisOnlyAttrName(), attr);
}

void OneShotBufferizeOp::setTestAnalysisOnly(bool attrValue) {
  (*this)->setAttr(getTestAnalysisOnlyAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

void OneShotBufferizeOp::setPrintConflictsAttr(::mlir::BoolAttr attr) {
  (*this)->setAttr(getPrintConflictsAttrName(), attr);
}

void OneShotBufferizeOp::setPrintConflicts(bool attrValue) {
  (*this)->setAttr(getPrintConflictsAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue));
}

::mlir::Attribute OneShotBufferizeOp::removeFunctionBoundaryTypeConversionAttr() {
  return (*this)->removeAttr(getFunctionBoundaryTypeConversionAttrName());
}

void OneShotBufferizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, /*optional*/::mlir::bufferization::LayoutMapOptionAttr function_boundary_type_conversion, ::mlir::BoolAttr allow_return_allocs, ::mlir::BoolAttr allow_unknown_ops, ::mlir::BoolAttr bufferize_function_boundaries, ::mlir::BoolAttr create_deallocs, ::mlir::BoolAttr target_is_module, ::mlir::BoolAttr test_analysis_only, ::mlir::BoolAttr print_conflicts) {
  odsState.addOperands(target);
  if (function_boundary_type_conversion) {
    odsState.addAttribute(getFunctionBoundaryTypeConversionAttrName(odsState.name), function_boundary_type_conversion);
  }
  if (allow_return_allocs) {
    odsState.addAttribute(getAllowReturnAllocsAttrName(odsState.name), allow_return_allocs);
  }
  if (allow_unknown_ops) {
    odsState.addAttribute(getAllowUnknownOpsAttrName(odsState.name), allow_unknown_ops);
  }
  if (bufferize_function_boundaries) {
    odsState.addAttribute(getBufferizeFunctionBoundariesAttrName(odsState.name), bufferize_function_boundaries);
  }
  if (create_deallocs) {
    odsState.addAttribute(getCreateDeallocsAttrName(odsState.name), create_deallocs);
  }
  if (target_is_module) {
    odsState.addAttribute(getTargetIsModuleAttrName(odsState.name), target_is_module);
  }
  if (test_analysis_only) {
    odsState.addAttribute(getTestAnalysisOnlyAttrName(odsState.name), test_analysis_only);
  }
  if (print_conflicts) {
    odsState.addAttribute(getPrintConflictsAttrName(odsState.name), print_conflicts);
  }
}

void OneShotBufferizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/::mlir::bufferization::LayoutMapOptionAttr function_boundary_type_conversion, ::mlir::BoolAttr allow_return_allocs, ::mlir::BoolAttr allow_unknown_ops, ::mlir::BoolAttr bufferize_function_boundaries, ::mlir::BoolAttr create_deallocs, ::mlir::BoolAttr target_is_module, ::mlir::BoolAttr test_analysis_only, ::mlir::BoolAttr print_conflicts) {
  odsState.addOperands(target);
  if (function_boundary_type_conversion) {
    odsState.addAttribute(getFunctionBoundaryTypeConversionAttrName(odsState.name), function_boundary_type_conversion);
  }
  if (allow_return_allocs) {
    odsState.addAttribute(getAllowReturnAllocsAttrName(odsState.name), allow_return_allocs);
  }
  if (allow_unknown_ops) {
    odsState.addAttribute(getAllowUnknownOpsAttrName(odsState.name), allow_unknown_ops);
  }
  if (bufferize_function_boundaries) {
    odsState.addAttribute(getBufferizeFunctionBoundariesAttrName(odsState.name), bufferize_function_boundaries);
  }
  if (create_deallocs) {
    odsState.addAttribute(getCreateDeallocsAttrName(odsState.name), create_deallocs);
  }
  if (target_is_module) {
    odsState.addAttribute(getTargetIsModuleAttrName(odsState.name), target_is_module);
  }
  if (test_analysis_only) {
    odsState.addAttribute(getTestAnalysisOnlyAttrName(odsState.name), test_analysis_only);
  }
  if (print_conflicts) {
    odsState.addAttribute(getPrintConflictsAttrName(odsState.name), print_conflicts);
  }
  assert(resultTypes.size() == 0u && "mismatched number of results");
  odsState.addTypes(resultTypes);
}

void OneShotBufferizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, /*optional*/::mlir::bufferization::LayoutMapOptionAttr function_boundary_type_conversion, bool allow_return_allocs, bool allow_unknown_ops, bool bufferize_function_boundaries, bool create_deallocs, bool target_is_module, bool test_analysis_only, bool print_conflicts) {
  odsState.addOperands(target);
  if (function_boundary_type_conversion) {
    odsState.addAttribute(getFunctionBoundaryTypeConversionAttrName(odsState.name), function_boundary_type_conversion);
  }
  odsState.addAttribute(getAllowReturnAllocsAttrName(odsState.name), odsBuilder.getBoolAttr(allow_return_allocs));
  odsState.addAttribute(getAllowUnknownOpsAttrName(odsState.name), odsBuilder.getBoolAttr(allow_unknown_ops));
  odsState.addAttribute(getBufferizeFunctionBoundariesAttrName(odsState.name), odsBuilder.getBoolAttr(bufferize_function_boundaries));
  odsState.addAttribute(getCreateDeallocsAttrName(odsState.name), odsBuilder.getBoolAttr(create_deallocs));
  odsState.addAttribute(getTargetIsModuleAttrName(odsState.name), odsBuilder.getBoolAttr(target_is_module));
  odsState.addAttribute(getTestAnalysisOnlyAttrName(odsState.name), odsBuilder.getBoolAttr(test_analysis_only));
  odsState.addAttribute(getPrintConflictsAttrName(odsState.name), odsBuilder.getBoolAttr(print_conflicts));
}

void OneShotBufferizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/::mlir::bufferization::LayoutMapOptionAttr function_boundary_type_conversion, bool allow_return_allocs, bool allow_unknown_ops, bool bufferize_function_boundaries, bool create_deallocs, bool target_is_module, bool test_analysis_only, bool print_conflicts) {
  odsState.addOperands(target);
  if (function_boundary_type_conversion) {
    odsState.addAttribute(getFunctionBoundaryTypeConversionAttrName(odsState.name), function_boundary_type_conversion);
  }
  odsState.addAttribute(getAllowReturnAllocsAttrName(odsState.name), odsBuilder.getBoolAttr(allow_return_allocs));
  odsState.addAttribute(getAllowUnknownOpsAttrName(odsState.name), odsBuilder.getBoolAttr(allow_unknown_ops));
  odsState.addAttribute(getBufferizeFunctionBoundariesAttrName(odsState.name), odsBuilder.getBoolAttr(bufferize_function_boundaries));
  odsState.addAttribute(getCreateDeallocsAttrName(odsState.name), odsBuilder.getBoolAttr(create_deallocs));
  odsState.addAttribute(getTargetIsModuleAttrName(odsState.name), odsBuilder.getBoolAttr(target_is_module));
  odsState.addAttribute(getTestAnalysisOnlyAttrName(odsState.name), odsBuilder.getBoolAttr(test_analysis_only));
  odsState.addAttribute(getPrintConflictsAttrName(odsState.name), odsBuilder.getBoolAttr(print_conflicts));
  assert(resultTypes.size() == 0u && "mismatched number of results");
  odsState.addTypes(resultTypes);
}

void OneShotBufferizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
  assert(operands.size() == 1u && "mismatched number of parameters");
  odsState.addOperands(operands);
  odsState.addAttributes(attributes);
  assert(resultTypes.size() == 0u && "mismatched number of return types");
  odsState.addTypes(resultTypes);
}

void OneShotBufferizeOp::populateDefaultAttrs(const ::mlir::OperationName &opName, ::mlir::NamedAttrList &attributes) {
  auto attrNames = opName.getAttributeNames();
  ::mlir::Builder odsBuilder(attrNames.front().getContext());
  if (!attributes.get(attrNames[0])) {
    attributes.append(attrNames[0], odsBuilder.getBoolAttr(false));
  }
  if (!attributes.get(attrNames[1])) {
    attributes.append(attrNames[1], odsBuilder.getBoolAttr(false));
  }
  if (!attributes.get(attrNames[2])) {
    attributes.append(attrNames[2], odsBuilder.getBoolAttr(false));
  }
  if (!attributes.get(attrNames[3])) {
    attributes.append(attrNames[3], odsBuilder.getBoolAttr(true));
  }
  if (!attributes.get(attrNames[6])) {
    attributes.append(attrNames[6], odsBuilder.getBoolAttr(true));
  }
  if (!attributes.get(attrNames[7])) {
    attributes.append(attrNames[7], odsBuilder.getBoolAttr(false));
  }
  if (!attributes.get(attrNames[5])) {
    attributes.append(attrNames[5], odsBuilder.getBoolAttr(false));
  }
}

::mlir::LogicalResult OneShotBufferizeOp::verifyInvariantsImpl() {
  auto namedAttrRange = (*this)->getAttrs();
  auto namedAttrIt = namedAttrRange.begin();
  ::mlir::Attribute tblgen_allow_return_allocs;
  ::mlir::Attribute tblgen_allow_unknown_ops;
  ::mlir::Attribute tblgen_bufferize_function_boundaries;
  ::mlir::Attribute tblgen_create_deallocs;
  ::mlir::Attribute tblgen_function_boundary_type_conversion;
  ::mlir::Attribute tblgen_print_conflicts;
  ::mlir::Attribute tblgen_target_is_module;
  ::mlir::Attribute tblgen_test_analysis_only;
  while (true) {
    if (namedAttrIt == namedAttrRange.end()) {
      break;
    }
    else if (namedAttrIt->getName() == getAllowReturnAllocsAttrName()) {
      tblgen_allow_return_allocs = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getAllowUnknownOpsAttrName()) {
      tblgen_allow_unknown_ops = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getBufferizeFunctionBoundariesAttrName()) {
      tblgen_bufferize_function_boundaries = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getCreateDeallocsAttrName()) {
      tblgen_create_deallocs = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getFunctionBoundaryTypeConversionAttrName()) {
      tblgen_function_boundary_type_conversion = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getPrintConflictsAttrName()) {
      tblgen_print_conflicts = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getTargetIsModuleAttrName()) {
      tblgen_target_is_module = namedAttrIt->getValue();
    }
    else if (namedAttrIt->getName() == getTestAnalysisOnlyAttrName()) {
      tblgen_test_analysis_only = namedAttrIt->getValue();
    }
    ++namedAttrIt;
  }

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps0(*this, tblgen_function_boundary_type_conversion, "function_boundary_type_conversion")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_allow_return_allocs, "allow_return_allocs")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_allow_unknown_ops, "allow_unknown_ops")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_bufferize_function_boundaries, "bufferize_function_boundaries")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_create_deallocs, "create_deallocs")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_target_is_module, "target_is_module")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_test_analysis_only, "test_analysis_only")))
    return ::mlir::failure();

  if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationTransformOps1(*this, tblgen_print_conflicts, "print_conflicts")))
    return ::mlir::failure();
  {
    unsigned index = 0; (void)index;
    auto valueGroup0 = getODSOperands(0);

    for (auto v : valueGroup0) {
      if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationTransformOps2(*this, v.getType(), "operand", index++)))
        return ::mlir::failure();
    }
  }
  return ::mlir::success();
}

::mlir::LogicalResult OneShotBufferizeOp::verifyInvariants() {
  return verifyInvariantsImpl();
}

::mlir::ParseResult OneShotBufferizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
  ::mlir::bufferization::LayoutMapOptionAttr function_boundary_type_conversionAttr;
  ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1];
  ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands);  ::llvm::SMLoc targetOperandsLoc;
  (void)targetOperandsLoc;
  if (::mlir::succeeded(parser.parseOptionalKeyword("layout"))) {
  if (parser.parseLBrace())
    return ::mlir::failure();

  {
    ::llvm::StringRef attrStr;
    ::mlir::NamedAttrList attrStorage;
    auto loc = parser.getCurrentLocation();
    if (parser.parseOptionalKeyword(&attrStr, {"InferLayoutMap","IdentityLayoutMap","FullyDynamicLayoutMap"})) {
      ::mlir::StringAttr attrVal;
      ::mlir::OptionalParseResult parseResult =
        parser.parseOptionalAttribute(attrVal,
                                      parser.getBuilder().getNoneType(),
                                      "function_boundary_type_conversion", attrStorage);
      if (parseResult.has_value()) {
        if (failed(*parseResult))
          return ::mlir::failure();
        attrStr = attrVal.getValue();
      } else {
        return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'function_boundary_type_conversion' [InferLayoutMap, IdentityLayoutMap, FullyDynamicLayoutMap]");
      }
    }
    if (!attrStr.empty()) {
      auto attrOptional = ::mlir::bufferization::symbolizeLayoutMapOption(attrStr);
      if (!attrOptional)
        return parser.emitError(loc, "invalid ")
               << "function_boundary_type_conversion attribute specification: \"" << attrStr << '"';;

      function_boundary_type_conversionAttr = ::mlir::bufferization::LayoutMapOptionAttr::get(parser.getBuilder().getContext(), *attrOptional);
      result.addAttribute("function_boundary_type_conversion", function_boundary_type_conversionAttr);
    }
  }
  if (parser.parseRBrace())
    return ::mlir::failure();
  }

  targetOperandsLoc = parser.getCurrentLocation();
  if (parser.parseOperand(targetRawOperands[0]))
    return ::mlir::failure();
  if (parser.parseOptionalAttrDict(result.attributes))
    return ::mlir::failure();
  ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::pdl::OperationType>();
  if (parser.resolveOperands(targetOperands, odsBuildableType0, targetOperandsLoc, result.operands))
    return ::mlir::failure();
  return ::mlir::success();
}

void OneShotBufferizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
  if ((*this)->getAttr("function_boundary_type_conversion")) {
    _odsPrinter << ' ' << "layout";
    _odsPrinter << "{";

    {
      auto caseValue = *getFunctionBoundaryTypeConversion();
      auto caseValueStr = stringifyLayoutMapOption(caseValue);
      _odsPrinter << caseValueStr;
    }
    _odsPrinter << "}";
  }
  _odsPrinter << ' ';
  _odsPrinter << getTarget();
  ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
  elidedAttrs.push_back("function_boundary_type_conversion");
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getAllowReturnAllocsAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(false)))
       elidedAttrs.push_back("allow_return_allocs");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getAllowUnknownOpsAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(false)))
       elidedAttrs.push_back("allow_unknown_ops");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getBufferizeFunctionBoundariesAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(false)))
       elidedAttrs.push_back("bufferize_function_boundaries");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getCreateDeallocsAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(true)))
       elidedAttrs.push_back("create_deallocs");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getTargetIsModuleAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(true)))
       elidedAttrs.push_back("target_is_module");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getTestAnalysisOnlyAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(false)))
       elidedAttrs.push_back("test_analysis_only");
  }
  {
     ::mlir::Builder odsBuilder(getContext());
     ::mlir::Attribute attr = getPrintConflictsAttr();
     if(attr && (attr == odsBuilder.getBoolAttr(false)))
       elidedAttrs.push_back("print_conflicts");
  }
  _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
}

} // namespace transform
} // namespace mlir
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::OneShotBufferizeOp)


#endif  // GET_OP_CLASSES

