brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.0 KiB · 93ce0be Raw
206 lines · plain
1R"(2//===----------------------------------------------------------------------===//3// __NAMESPACE_PATH__::__OP_CPP_NAME__ declarations4//===----------------------------------------------------------------------===//5 6__NAMESPACE_OPEN__7 8namespace detail {9 10class __OP_CPP_NAME__GenericAdaptorBase {11public:12  struct Properties {13  };14public:15  __OP_CPP_NAME__GenericAdaptorBase(::mlir::Operation *op)16    : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()),17               odsRegions(op->getRegions())18  {}19 20  /// Return the unstructured operand index of a structured operand along with21  // the amount of unstructured operands it contains.22  std::pair<unsigned, unsigned>23  getStructuredOperandIndexAndLength (unsigned index,24                                      unsigned odsOperandsSize) {25    return {index, 1};26  }27 28  const Properties &getProperties() {29    return properties;30  }31 32  ::mlir::DictionaryAttr getAttributes() {33    return odsAttrs;34  }35 36  __OP_REGION_ADAPTER_GETTER_DECLS__37 38  ::mlir::RegionRange getRegions() {39    return odsRegions;40  }41protected:42  ::mlir::DictionaryAttr odsAttrs;43  ::std::optional<::mlir::OperationName> odsOpName;44  Properties properties;45  ::mlir::RegionRange odsRegions;46};47 48} // namespace detail49 50template <typename RangeT>51class __OP_CPP_NAME__GenericAdaptor52  : public detail::__OP_CPP_NAME__GenericAdaptorBase {53  using ValueT = ::llvm::detail::ValueOfRange<RangeT>;54  using Base = detail::__OP_CPP_NAME__GenericAdaptorBase;55public:56  __OP_CPP_NAME__GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs,57                                ::mlir::OpaqueProperties properties,58                                ::mlir::RegionRange regions = {})59    : __OP_CPP_NAME__GenericAdaptor(values, attrs,60      (properties ? *properties.as<::mlir::EmptyProperties *>()61      : ::mlir::EmptyProperties{}), regions) {}62 63  __OP_CPP_NAME__GenericAdaptor(RangeT values,64                                const __OP_CPP_NAME__GenericAdaptorBase &base)65    : Base(base), odsOperands(values) {}66 67  // This template parameter allows using __OP_CPP_NAME__ which is declared68  // later.69  template <typename LateInst = __OP_CPP_NAME__,70            typename = std::enable_if_t<71                         std::is_same_v<LateInst, __OP_CPP_NAME__>>>72  __OP_CPP_NAME__GenericAdaptor(RangeT values, LateInst op)73    : Base(op), odsOperands(values) {}74 75  /// Return the unstructured operand index of a structured operand along with76  // the amount of unstructured operands it contains.77  std::pair<unsigned, unsigned>78  getStructuredOperandIndexAndLength(unsigned index) {79    return Base::getStructuredOperandIndexAndLength(index, odsOperands.size());80  }81 82  /// Get the n-th structured operand (single value, variadic or optional).83  RangeT getStructuredOperands(unsigned index) {84    auto valueRange = getStructuredOperandIndexAndLength(index);85    return {std::next(odsOperands.begin(), valueRange.first),86             std::next(odsOperands.begin(),87                       valueRange.first + valueRange.second)};88  }89 90  RangeT getOperands() {91    return odsOperands;92  }93 94  __OP_OPERAND_GETTER_DECLS__95 96private:97  RangeT odsOperands;98};99 100class __OP_CPP_NAME__Adaptor101  : public __OP_CPP_NAME__GenericAdaptor<::mlir::ValueRange> {102public:103  using __OP_CPP_NAME__GenericAdaptor::__OP_CPP_NAME__GenericAdaptor;104  __OP_CPP_NAME__Adaptor(__OP_CPP_NAME__ op);105 106  ::llvm::LogicalResult verify(::mlir::Location loc);107};108 109class __OP_CPP_NAME__ : public ::mlir::Op<__OP_TEMPLATE_ARGS__> {110public:111  using Op::Op;112  using Op::print;113  using Adaptor = __OP_CPP_NAME__Adaptor;114  template <typename RangeT>115  using GenericAdaptor = __OP_CPP_NAME__GenericAdaptor<RangeT>;116  using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;117  static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {118    return {};119  }120 121  ::llvm::LogicalResult verifyInvariantsImpl();122 123  static constexpr ::llvm::StringLiteral getOperationName() {124    return ::llvm::StringLiteral("__DIALECT_NAME__.__OP_NAME__");125  }126 127  static ::llvm::ArrayRef<::llvm::StringRef> getOperandNames() {128    static ::llvm::StringRef operandNames[] = __OP_OPERAND_INITIALIZER_LIST__;129    return operandNames;130  }131 132  static ::llvm::StringRef getOperandName(unsigned index) {133    assert(index < __OP_OPERAND_COUNT__ && "invalid attribute index");134    return getOperandNames()[index];135  }136 137  static ::llvm::ArrayRef<::llvm::StringRef> getResultNames() {138    static ::llvm::StringRef resultNames[] = __OP_RESULT_INITIALIZER_LIST__;139    return resultNames;140  }141 142  static ::llvm::StringRef getResultName(unsigned index) {143    assert(index < __OP_RESULT_COUNT__ && "invalid attribute index");144    return getResultNames()[index];145  }146 147  /// Return the unstructured operand index of a structured operand along with148  // the amount of unstructured operands it contains.149  std::pair<unsigned, unsigned>150  getStructuredOperandIndexAndLength(unsigned index) {151    return {index, 1};152  }153 154  /// Get the n-th structured operand (single value, variadic or optional).155  ::mlir::Operation::operand_range getStructuredOperands(unsigned index) {156    auto valueRange = getStructuredOperandIndexAndLength(index);157    return {std::next(getOperation()->operand_begin(), valueRange.first),158             std::next(getOperation()->operand_begin(),159                       valueRange.first + valueRange.second)};160  }161 162  /// Return the unstructured result index of a structured result along with163  // the amount of unstructured results it contains.164  std::pair<unsigned, unsigned>165  getStructuredResultIndexAndLength(unsigned index) {166    return {index, 1};167  }168 169  /// Get the n-th structured result (single value, variadic or optional).170  ::mlir::Operation::result_range getStructuredResults(unsigned index) {171    auto valueRange = getStructuredResultIndexAndLength(index);172    return {std::next(getOperation()->result_begin(), valueRange.first),173             std::next(getOperation()->result_begin(),174                       valueRange.first + valueRange.second)};175  }176 177  __OP_OPERAND_GETTER_DECLS__178  __OP_RESULT_GETTER_DECLS__179  __OP_REGION_GETTER_DECLS__180 181  __OP_BUILD_DECLS__182  static void build(::mlir::OpBuilder &odsBuilder,183                    ::mlir::OperationState &odsState,184                    ::mlir::TypeRange resultTypes,185                    ::mlir::ValueRange operands,186                    ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});187 188  static __OP_CPP_NAME__ create(::mlir::OpBuilder &odsBuilder,189                                ::mlir::Location location,190                                ::mlir::TypeRange resultTypes,191                                ::mlir::ValueRange operands,192                                ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});193 194  static __OP_CPP_NAME__ create(::mlir::ImplicitLocOpBuilder &odsBuilder,195                                ::mlir::TypeRange resultTypes,196                                ::mlir::ValueRange operands,197                                ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});198};199 200 201__NAMESPACE_CLOSE__202 203MLIR_DECLARE_EXPLICIT_TYPE_ID(__NAMESPACE_PATH__::__OP_CPP_NAME__)204 205)"206