
# Autogenerated by mlir-tblgen; don't manually edit.

from ._ods_common import _cext as _ods_cext
from ._ods_common import (
    equally_sized_accessor as _ods_equally_sized_accessor,
    get_default_loc_context as _ods_get_default_loc_context,
    get_op_results_or_values as _get_op_results_or_values,
    segmented_accessor as _ods_segmented_accessor,
)
_ods_ir = _ods_cext.ir
_ods_cext.globals.register_traceback_file_exclusion(__file__)

import builtins
from typing import Any as _Any, Sequence as _Sequence, Union as _Union, Optional as _Optional
import sys as _sys
if _sys.version_info >= (3, 12):
  from collections.abc import Buffer as _Buffer  # pytype: disable=not-supported-yet
else:
  try:
    from typing_extensions import Buffer as _Buffer
  except ImportError:
    _Buffer = _Any


from ._transform_ops_gen import _Dialect

@_ods_cext.register_operation(_Dialect)
class ConvertLayoutOp(_ods_ir.OpView):
  r"""
  Adds an `xegpu.convert_layout` op to convert the `xegpu.layout` attribute
  of a value before its first use. The input and target layouts are defined
  by the `*sg_layout`, `*sg_data` and optional `*inst_data` and `*order`
  attributes. Returns a handle to the emitted `xegpu.convert_layout` op.
  """

  OPERATION_NAME = "transform.xegpu.convert_layout"

  _ODS_OPERAND_SEGMENTS = [1,-1,-1,-1,-1,-1,-1,]

  _ODS_REGIONS = (0, True)

  def __init__(self, newConvertOp: _ods_ir.Type, target: _ods_ir.Value, input_sg_layout: _Sequence[_ods_ir.Value], input_sg_data: _Sequence[_ods_ir.Value], input_inst_data: _Sequence[_ods_ir.Value], target_sg_layout: _Sequence[_ods_ir.Value], target_sg_data: _Sequence[_ods_ir.Value], target_inst_data: _Sequence[_ods_ir.Value], *, input_order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, static_input_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_input_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_input_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, target_order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None):
    operands = []
    attributes = {}
    regions = None
    operands.append(target)
    operands.append(_get_op_results_or_values(input_sg_layout))
    operands.append(_get_op_results_or_values(input_sg_data))
    operands.append(_get_op_results_or_values(input_inst_data))
    operands.append(_get_op_results_or_values(target_sg_layout))
    operands.append(_get_op_results_or_values(target_sg_data))
    operands.append(_get_op_results_or_values(target_inst_data))
    _ods_context = _ods_get_default_loc_context(loc)
    if input_order is not None: attributes["input_order"] = (input_order if (
        isinstance(input_order, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI32ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI32ArrayAttr')(input_order, context=_ods_context))
    if static_input_sg_layout is not None: attributes["static_input_sg_layout"] = (static_input_sg_layout if (
        isinstance(static_input_sg_layout, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_input_sg_layout, context=_ods_context))
    if static_input_sg_data is not None: attributes["static_input_sg_data"] = (static_input_sg_data if (
        isinstance(static_input_sg_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_input_sg_data, context=_ods_context))
    if static_input_inst_data is not None: attributes["static_input_inst_data"] = (static_input_inst_data if (
        isinstance(static_input_inst_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_input_inst_data, context=_ods_context))
    if static_target_sg_layout is not None: attributes["static_target_sg_layout"] = (static_target_sg_layout if (
        isinstance(static_target_sg_layout, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_target_sg_layout, context=_ods_context))
    if static_target_sg_data is not None: attributes["static_target_sg_data"] = (static_target_sg_data if (
        isinstance(static_target_sg_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_target_sg_data, context=_ods_context))
    if static_target_inst_data is not None: attributes["static_target_inst_data"] = (static_target_inst_data if (
        isinstance(static_target_inst_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_target_inst_data, context=_ods_context))
    if target_order is not None: attributes["target_order"] = (target_order if (
        isinstance(target_order, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI32ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI32ArrayAttr')(target_order, context=_ods_context))
    results = []
    results.append(newConvertOp)
    _ods_successors = None
    super().__init__(self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip)

  @builtins.property
  def target(self) -> _ods_ir.Value:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 0)
    return operand_range[0]

  @builtins.property
  def input_sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 1)
    return operand_range

  @builtins.property
  def input_sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 2)
    return operand_range

  @builtins.property
  def input_inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 3)
    return operand_range

  @builtins.property
  def target_sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 4)
    return operand_range

  @builtins.property
  def target_sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 5)
    return operand_range

  @builtins.property
  def target_inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 6)
    return operand_range

  @builtins.property
  def input_order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "input_order" not in self.operation.attributes:
      return None
    return self.operation.attributes["input_order"]

  @input_order.setter
  def input_order(self, value: _Optional[_ods_ir.DenseI32ArrayAttr]):
    if value is not None:
      self.operation.attributes["input_order"] = value
    elif "input_order" in self.operation.attributes:
      del self.operation.attributes["input_order"]

  @input_order.deleter
  def input_order(self):
    del self.operation.attributes["input_order"]

  @builtins.property
  def static_input_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_sg_layout" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_input_sg_layout"]

  @static_input_sg_layout.setter
  def static_input_sg_layout(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_input_sg_layout"] = value
    elif "static_input_sg_layout" in self.operation.attributes:
      del self.operation.attributes["static_input_sg_layout"]

  @static_input_sg_layout.deleter
  def static_input_sg_layout(self):
    del self.operation.attributes["static_input_sg_layout"]

  @builtins.property
  def static_input_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_sg_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_input_sg_data"]

  @static_input_sg_data.setter
  def static_input_sg_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_input_sg_data"] = value
    elif "static_input_sg_data" in self.operation.attributes:
      del self.operation.attributes["static_input_sg_data"]

  @static_input_sg_data.deleter
  def static_input_sg_data(self):
    del self.operation.attributes["static_input_sg_data"]

  @builtins.property
  def static_input_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_inst_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_input_inst_data"]

  @static_input_inst_data.setter
  def static_input_inst_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_input_inst_data"] = value
    elif "static_input_inst_data" in self.operation.attributes:
      del self.operation.attributes["static_input_inst_data"]

  @static_input_inst_data.deleter
  def static_input_inst_data(self):
    del self.operation.attributes["static_input_inst_data"]

  @builtins.property
  def static_target_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_sg_layout" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_target_sg_layout"]

  @static_target_sg_layout.setter
  def static_target_sg_layout(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_target_sg_layout"] = value
    elif "static_target_sg_layout" in self.operation.attributes:
      del self.operation.attributes["static_target_sg_layout"]

  @static_target_sg_layout.deleter
  def static_target_sg_layout(self):
    del self.operation.attributes["static_target_sg_layout"]

  @builtins.property
  def static_target_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_sg_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_target_sg_data"]

  @static_target_sg_data.setter
  def static_target_sg_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_target_sg_data"] = value
    elif "static_target_sg_data" in self.operation.attributes:
      del self.operation.attributes["static_target_sg_data"]

  @static_target_sg_data.deleter
  def static_target_sg_data(self):
    del self.operation.attributes["static_target_sg_data"]

  @builtins.property
  def static_target_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_inst_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_target_inst_data"]

  @static_target_inst_data.setter
  def static_target_inst_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_target_inst_data"] = value
    elif "static_target_inst_data" in self.operation.attributes:
      del self.operation.attributes["static_target_inst_data"]

  @static_target_inst_data.deleter
  def static_target_inst_data(self):
    del self.operation.attributes["static_target_inst_data"]

  @builtins.property
  def target_order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "target_order" not in self.operation.attributes:
      return None
    return self.operation.attributes["target_order"]

  @target_order.setter
  def target_order(self, value: _Optional[_ods_ir.DenseI32ArrayAttr]):
    if value is not None:
      self.operation.attributes["target_order"] = value
    elif "target_order" in self.operation.attributes:
      del self.operation.attributes["target_order"]

  @target_order.deleter
  def target_order(self):
    del self.operation.attributes["target_order"]

  @builtins.property
  def newConvertOp(self) -> _ods_ir.OpResult:
    return self.operation.results[0]

@_ods_cext.register_op_adaptor(ConvertLayoutOp)
class ConvertLayoutOpAdaptor(_ods_ir.OpAdaptor):
  OPERATION_NAME = "transform.xegpu.convert_layout"

  @builtins.property
  def target(self) -> _ods_ir.Value:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 0)
    return operand_range[0]

  @builtins.property
  def input_sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 1)
    return operand_range

  @builtins.property
  def input_sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 2)
    return operand_range

  @builtins.property
  def input_inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 3)
    return operand_range

  @builtins.property
  def target_sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 4)
    return operand_range

  @builtins.property
  def target_sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 5)
    return operand_range

  @builtins.property
  def target_inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 6)
    return operand_range

  @builtins.property
  def input_order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "input_order" not in self.attributes:
      return None
    return self.attributes["input_order"]

  @builtins.property
  def static_input_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_sg_layout" not in self.attributes:
      return None
    return self.attributes["static_input_sg_layout"]

  @builtins.property
  def static_input_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_sg_data" not in self.attributes:
      return None
    return self.attributes["static_input_sg_data"]

  @builtins.property
  def static_input_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_input_inst_data" not in self.attributes:
      return None
    return self.attributes["static_input_inst_data"]

  @builtins.property
  def static_target_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_sg_layout" not in self.attributes:
      return None
    return self.attributes["static_target_sg_layout"]

  @builtins.property
  def static_target_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_sg_data" not in self.attributes:
      return None
    return self.attributes["static_target_sg_data"]

  @builtins.property
  def static_target_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_target_inst_data" not in self.attributes:
      return None
    return self.attributes["static_target_inst_data"]

  @builtins.property
  def target_order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "target_order" not in self.attributes:
      return None
    return self.attributes["target_order"]

def xegpu_convert_layout(new_convert_op: _ods_ir.Type, target: _ods_ir.Value, input_sg_layout: _Sequence[_ods_ir.Value], input_sg_data: _Sequence[_ods_ir.Value], input_inst_data: _Sequence[_ods_ir.Value], target_sg_layout: _Sequence[_ods_ir.Value], target_sg_data: _Sequence[_ods_ir.Value], target_inst_data: _Sequence[_ods_ir.Value], *, input_order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, static_input_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_input_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_input_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_target_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, target_order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResult:
  return ConvertLayoutOp(newConvertOp=new_convert_op, target=target, input_sg_layout=input_sg_layout, input_sg_data=input_sg_data, input_inst_data=input_inst_data, target_sg_layout=target_sg_layout, target_sg_data=target_sg_data, target_inst_data=target_inst_data, input_order=input_order, static_input_sg_layout=static_input_sg_layout, static_input_sg_data=static_input_sg_data, static_input_inst_data=static_input_inst_data, static_target_sg_layout=static_target_sg_layout, static_target_sg_data=static_target_sg_data, static_target_inst_data=static_target_inst_data, target_order=target_order, loc=loc, ip=ip).result

@_ods_cext.register_operation(_Dialect)
class GetLoadOp(_ods_ir.OpView):
  r"""
  Traces the producers of the given value until an `xegpu.load_nd` or
  `xegpu.load` op is found. Returns a handle to it. Currently traces
  producers by following only the first operand of producer ops.
  """

  OPERATION_NAME = "transform.xegpu.get_load_op"

  _ODS_REGIONS = (0, True)

  def __init__(self, loadNdHandle: _ods_ir.Type, target: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None):
    operands = []
    attributes = {}
    regions = None
    operands.append(target)
    _ods_context = _ods_get_default_loc_context(loc)
    results = []
    results.append(loadNdHandle)
    _ods_successors = None
    super().__init__(self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip)

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operation.operands[0]

  @builtins.property
  def loadNdHandle(self) -> _ods_ir.OpResult:
    return self.operation.results[0]

@_ods_cext.register_op_adaptor(GetLoadOp)
class GetLoadOpAdaptor(_ods_ir.OpAdaptor):
  OPERATION_NAME = "transform.xegpu.get_load_op"

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operands[0]

def xegpu_get_load_op(load_nd_handle: _ods_ir.Type, target: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResult:
  return GetLoadOp(loadNdHandle=load_nd_handle, target=target, loc=loc, ip=ip).result

@_ods_cext.register_operation(_Dialect)
class InsertPrefetchOp(_ods_ir.OpView):
  r"""
  Inserts `xegpu.prefetch_nd` operations for the given `xegpu.load_nd` op.
  The load op must reside within the `scf.for` loop. Number of prefetch steps
  is set by the `nb_prefetch` argument (default value is 1). Returns a handle
  to the created `xegpu.create_nd_desc` op.
  """

  OPERATION_NAME = "transform.xegpu.insert_prefetch"

  _ODS_REGIONS = (0, True)

  def __init__(self, desc_op: _ods_ir.Type, target: _ods_ir.Value, *, dynamic_nb_prefetch: _Optional[_ods_ir.Value] = None, static_nb_prefetch: _Optional[_Union[int, _ods_ir.IntegerAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None):
    operands = []
    attributes = {}
    regions = None
    operands.append(target)
    if dynamic_nb_prefetch is not None: operands.append(dynamic_nb_prefetch)
    _ods_context = _ods_get_default_loc_context(loc)
    if static_nb_prefetch is not None: attributes["static_nb_prefetch"] = (static_nb_prefetch if (
        isinstance(static_nb_prefetch, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('I64Attr')) else
          _ods_ir.AttrBuilder.get('I64Attr')(static_nb_prefetch, context=_ods_context))
    results = []
    results.append(desc_op)
    _ods_successors = None
    super().__init__(self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip)

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operation.operands[0]

  @builtins.property
  def dynamic_nb_prefetch(self) -> _Optional[_ods_ir.Value]:
    return None if len(self.operation.operands) < 2 else self.operation.operands[1]

  @builtins.property
  def static_nb_prefetch(self) -> _Optional[_ods_ir.IntegerAttr]:
    if "static_nb_prefetch" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_nb_prefetch"]

  @static_nb_prefetch.setter
  def static_nb_prefetch(self, value: _Optional[_ods_ir.IntegerAttr]):
    if value is not None:
      self.operation.attributes["static_nb_prefetch"] = value
    elif "static_nb_prefetch" in self.operation.attributes:
      del self.operation.attributes["static_nb_prefetch"]

  @static_nb_prefetch.deleter
  def static_nb_prefetch(self):
    del self.operation.attributes["static_nb_prefetch"]

  @builtins.property
  def desc_op(self) -> _ods_ir.OpResult:
    return self.operation.results[0]

@_ods_cext.register_op_adaptor(InsertPrefetchOp)
class InsertPrefetchOpAdaptor(_ods_ir.OpAdaptor):
  OPERATION_NAME = "transform.xegpu.insert_prefetch"

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operands[0]

  @builtins.property
  def dynamic_nb_prefetch(self) -> _Optional[_ods_ir.Value]:
    return None if len(self.operands) < 2 else self.operands[1]

  @builtins.property
  def static_nb_prefetch(self) -> _Optional[_ods_ir.IntegerAttr]:
    if "static_nb_prefetch" not in self.attributes:
      return None
    return self.attributes["static_nb_prefetch"]

def xegpu_insert_prefetch(desc_op: _ods_ir.Type, target: _ods_ir.Value, *, dynamic_nb_prefetch: _Optional[_ods_ir.Value] = None, static_nb_prefetch: _Optional[_Union[int, _ods_ir.IntegerAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResult:
  return InsertPrefetchOp(desc_op=desc_op, target=target, dynamic_nb_prefetch=dynamic_nb_prefetch, static_nb_prefetch=static_nb_prefetch, loc=loc, ip=ip).result

@_ods_cext.register_operation(_Dialect)
class SetAnchorLayoutOp(_ods_ir.OpView):
  r"""
  Sets the `xegpu.layout` anchor layout for XeGPU ops that support it. The
  target operand value can be set by the `index` argument (currently only
  applicable to a DPAS op). The layout is defined by the `sg_layout`,
  `sg_data` and optional `inst_data` and `order` attributes. If `slice_dims`
  is provided, the `xegpu.layout` attribute is wrapped in an
  `xegpu.slice<..., dims=slice_dims>` attribute. Emits a silenceable failure
  if the target op does not support anchor layouts.
  """

  OPERATION_NAME = "transform.xegpu.set_anchor_layout"

  _ODS_OPERAND_SEGMENTS = [1,-1,-1,-1,]

  _ODS_REGIONS = (0, True)

  def __init__(self, target: _ods_ir.Value, sg_layout: _Sequence[_ods_ir.Value], sg_data: _Sequence[_ods_ir.Value], inst_data: _Sequence[_ods_ir.Value], *, index: _Optional[_Union[int, _ods_ir.IntegerAttr]] = None, static_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, slice_dims: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None):
    operands = []
    attributes = {}
    regions = None
    operands.append(target)
    operands.append(_get_op_results_or_values(sg_layout))
    operands.append(_get_op_results_or_values(sg_data))
    operands.append(_get_op_results_or_values(inst_data))
    _ods_context = _ods_get_default_loc_context(loc)
    if index is not None: attributes["index"] = (index if (
        isinstance(index, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('I64Attr')) else
          _ods_ir.AttrBuilder.get('I64Attr')(index, context=_ods_context))
    if static_sg_layout is not None: attributes["static_sg_layout"] = (static_sg_layout if (
        isinstance(static_sg_layout, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_sg_layout, context=_ods_context))
    if static_sg_data is not None: attributes["static_sg_data"] = (static_sg_data if (
        isinstance(static_sg_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_sg_data, context=_ods_context))
    if static_inst_data is not None: attributes["static_inst_data"] = (static_inst_data if (
        isinstance(static_inst_data, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_inst_data, context=_ods_context))
    if order is not None: attributes["order"] = (order if (
        isinstance(order, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI32ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI32ArrayAttr')(order, context=_ods_context))
    if slice_dims is not None: attributes["slice_dims"] = (slice_dims if (
        isinstance(slice_dims, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(slice_dims, context=_ods_context))
    results = []
    _ods_successors = None
    super().__init__(self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip)

  @builtins.property
  def target(self) -> _ods_ir.Value:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 0)
    return operand_range[0]

  @builtins.property
  def sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 1)
    return operand_range

  @builtins.property
  def sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 2)
    return operand_range

  @builtins.property
  def inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operation.operands,
         self.operation.attributes["operandSegmentSizes"], 3)
    return operand_range

  @builtins.property
  def index(self) -> _Optional[_ods_ir.IntegerAttr]:
    if "index" not in self.operation.attributes:
      return None
    return self.operation.attributes["index"]

  @index.setter
  def index(self, value: _Optional[_ods_ir.IntegerAttr]):
    if value is not None:
      self.operation.attributes["index"] = value
    elif "index" in self.operation.attributes:
      del self.operation.attributes["index"]

  @index.deleter
  def index(self):
    del self.operation.attributes["index"]

  @builtins.property
  def static_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_sg_layout" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_sg_layout"]

  @static_sg_layout.setter
  def static_sg_layout(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_sg_layout"] = value
    elif "static_sg_layout" in self.operation.attributes:
      del self.operation.attributes["static_sg_layout"]

  @static_sg_layout.deleter
  def static_sg_layout(self):
    del self.operation.attributes["static_sg_layout"]

  @builtins.property
  def static_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_sg_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_sg_data"]

  @static_sg_data.setter
  def static_sg_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_sg_data"] = value
    elif "static_sg_data" in self.operation.attributes:
      del self.operation.attributes["static_sg_data"]

  @static_sg_data.deleter
  def static_sg_data(self):
    del self.operation.attributes["static_sg_data"]

  @builtins.property
  def static_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_inst_data" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_inst_data"]

  @static_inst_data.setter
  def static_inst_data(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_inst_data"] = value
    elif "static_inst_data" in self.operation.attributes:
      del self.operation.attributes["static_inst_data"]

  @static_inst_data.deleter
  def static_inst_data(self):
    del self.operation.attributes["static_inst_data"]

  @builtins.property
  def order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "order" not in self.operation.attributes:
      return None
    return self.operation.attributes["order"]

  @order.setter
  def order(self, value: _Optional[_ods_ir.DenseI32ArrayAttr]):
    if value is not None:
      self.operation.attributes["order"] = value
    elif "order" in self.operation.attributes:
      del self.operation.attributes["order"]

  @order.deleter
  def order(self):
    del self.operation.attributes["order"]

  @builtins.property
  def slice_dims(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "slice_dims" not in self.operation.attributes:
      return None
    return self.operation.attributes["slice_dims"]

  @slice_dims.setter
  def slice_dims(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["slice_dims"] = value
    elif "slice_dims" in self.operation.attributes:
      del self.operation.attributes["slice_dims"]

  @slice_dims.deleter
  def slice_dims(self):
    del self.operation.attributes["slice_dims"]

@_ods_cext.register_op_adaptor(SetAnchorLayoutOp)
class SetAnchorLayoutOpAdaptor(_ods_ir.OpAdaptor):
  OPERATION_NAME = "transform.xegpu.set_anchor_layout"

  @builtins.property
  def target(self) -> _ods_ir.Value:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 0)
    return operand_range[0]

  @builtins.property
  def sg_layout(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 1)
    return operand_range

  @builtins.property
  def sg_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 2)
    return operand_range

  @builtins.property
  def inst_data(self) -> _ods_ir.OpOperandList:
    operand_range = _ods_segmented_accessor(
         self.operands,
         self.attributes["operandSegmentSizes"], 3)
    return operand_range

  @builtins.property
  def index(self) -> _Optional[_ods_ir.IntegerAttr]:
    if "index" not in self.attributes:
      return None
    return self.attributes["index"]

  @builtins.property
  def static_sg_layout(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_sg_layout" not in self.attributes:
      return None
    return self.attributes["static_sg_layout"]

  @builtins.property
  def static_sg_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_sg_data" not in self.attributes:
      return None
    return self.attributes["static_sg_data"]

  @builtins.property
  def static_inst_data(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_inst_data" not in self.attributes:
      return None
    return self.attributes["static_inst_data"]

  @builtins.property
  def order(self) -> _Optional[_ods_ir.DenseI32ArrayAttr]:
    if "order" not in self.attributes:
      return None
    return self.attributes["order"]

  @builtins.property
  def slice_dims(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "slice_dims" not in self.attributes:
      return None
    return self.attributes["slice_dims"]

def xegpu_set_anchor_layout(target: _ods_ir.Value, sg_layout: _Sequence[_ods_ir.Value], sg_data: _Sequence[_ods_ir.Value], inst_data: _Sequence[_ods_ir.Value], *, index: _Optional[_Union[int, _ods_ir.IntegerAttr]] = None, static_sg_layout: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_sg_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, static_inst_data: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, order: _Optional[_Union[_Sequence[int], _ods_ir.DenseI32ArrayAttr]] = None, slice_dims: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> SetAnchorLayoutOp:
  return SetAnchorLayoutOp(target=target, sg_layout=sg_layout, sg_data=sg_data, inst_data=inst_data, index=index, static_sg_layout=static_sg_layout, static_sg_data=static_sg_data, static_inst_data=static_inst_data, order=order, slice_dims=slice_dims, loc=loc, ip=ip)

@_ods_cext.register_operation(_Dialect)
class SetGPULaunchThreadsOp(_ods_ir.OpView):
  r"""
  Overrides the x,y,z threads operands of a given `gpu.launch` operation in-place.
  """

  OPERATION_NAME = "transform.xegpu.set_gpu_launch_threads"

  _ODS_REGIONS = (0, True)

  def __init__(self, target: _ods_ir.Value, threads: _Sequence[_ods_ir.Value], *, static_threads: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None):
    operands = []
    attributes = {}
    regions = None
    operands.append(target)
    operands.extend(_get_op_results_or_values(threads))
    _ods_context = _ods_get_default_loc_context(loc)
    if static_threads is not None: attributes["static_threads"] = (static_threads if (
        isinstance(static_threads, _ods_ir.Attribute) or
        not _ods_ir.AttrBuilder.contains('DenseI64ArrayAttr')) else
          _ods_ir.AttrBuilder.get('DenseI64ArrayAttr')(static_threads, context=_ods_context))
    results = []
    _ods_successors = None
    super().__init__(self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip)

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operation.operands[0]

  @builtins.property
  def threads(self) -> _ods_ir.OpOperandList:
    _ods_variadic_group_length = len(self.operation.operands) - 2 + 1
    return self.operation.operands[1:1 + _ods_variadic_group_length]

  @builtins.property
  def static_threads(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_threads" not in self.operation.attributes:
      return None
    return self.operation.attributes["static_threads"]

  @static_threads.setter
  def static_threads(self, value: _Optional[_ods_ir.DenseI64ArrayAttr]):
    if value is not None:
      self.operation.attributes["static_threads"] = value
    elif "static_threads" in self.operation.attributes:
      del self.operation.attributes["static_threads"]

  @static_threads.deleter
  def static_threads(self):
    del self.operation.attributes["static_threads"]

@_ods_cext.register_op_adaptor(SetGPULaunchThreadsOp)
class SetGPULaunchThreadsOpAdaptor(_ods_ir.OpAdaptor):
  OPERATION_NAME = "transform.xegpu.set_gpu_launch_threads"

  @builtins.property
  def target(self) -> _ods_ir.Value:
    return self.operands[0]

  @builtins.property
  def threads(self) -> _ods_ir.OpOperandList:
    _ods_variadic_group_length = len(self.operands) - 2 + 1
    return self.operands[1:1 + _ods_variadic_group_length]

  @builtins.property
  def static_threads(self) -> _Optional[_ods_ir.DenseI64ArrayAttr]:
    if "static_threads" not in self.attributes:
      return None
    return self.attributes["static_threads"]

def xegpu_set_gpu_launch_threads(target: _ods_ir.Value, threads: _Sequence[_ods_ir.Value], *, static_threads: _Optional[_Union[_Sequence[int], _ods_ir.DenseI64ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> SetGPULaunchThreadsOp:
  return SetGPULaunchThreadsOp(target=target, threads=threads, static_threads=static_threads, loc=loc, ip=ip)
