| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Op Declarations *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* From: SCFOps.td *| |
| 7 | |* *| |
| 8 | \*===----------------------------------------------------------------------===*/ |
| 9 | |
| 10 | namespace mlir::scf { |
| 11 | |
| 12 | /// loop continuation condition |
| 13 | /// This operation accepts the continuation (i.e., inverse of exit) condition |
| 14 | /// of the `scf.while` construct. If its first argument is true, the "after" |
| 15 | /// region of `scf.while` is executed, with the remaining arguments forwarded |
| 16 | /// to the entry block of the region. Otherwise, the loop terminates. |
| 17 | class ConditionOp; |
| 18 | |
| 19 | } // namespace mlir::scf |
| 20 | namespace mlir::scf { |
| 21 | |
| 22 | /// operation that executes its region exactly once |
| 23 | /// The `scf.execute_region` operation is used to allow multiple blocks within SCF |
| 24 | /// and other operations which can hold only one block. The `scf.execute_region` |
| 25 | /// operation executes the region held exactly once and cannot have any operands. |
| 26 | /// As such, its region has no arguments. All SSA values that dominate the op can |
| 27 | /// be accessed inside the op. The op's region can have multiple blocks and the |
| 28 | /// blocks can have multiple distinct terminators. Values returned from this op's |
| 29 | /// region define the op's results. |
| 30 | /// The optional 'no_inline' flag can be set to request the ExecuteRegionOp to be |
| 31 | /// preserved as much as possible and not being inlined in the parent block until |
| 32 | /// an explicit lowering step. |
| 33 | /// |
| 34 | /// Example: |
| 35 | /// |
| 36 | /// ```mlir |
| 37 | /// scf.for %i = 0 to 128 step %c1 { |
| 38 | /// %y = scf.execute_region -> i32 { |
| 39 | /// %x = load %A[%i] : memref<128xi32> |
| 40 | /// scf.yield %x : i32 |
| 41 | /// } |
| 42 | /// } |
| 43 | /// |
| 44 | /// // the same as above but with no_inline attribute |
| 45 | /// scf.for %i = 0 to 128 step %c1 { |
| 46 | /// %y = scf.execute_region -> i32 no_inline { |
| 47 | /// %x = load %A[%i] : memref<128xi32> |
| 48 | /// scf.yield %x : i32 |
| 49 | /// } |
| 50 | /// } |
| 51 | /// |
| 52 | /// affine.for %i = 0 to 100 { |
| 53 | /// "foo"() : () -> () |
| 54 | /// %v = scf.execute_region -> i64 { |
| 55 | /// cf.cond_br %cond, ^bb1, ^bb2 |
| 56 | /// |
| 57 | /// ^bb1: |
| 58 | /// %c1 = arith.constant 1 : i64 |
| 59 | /// cf.br ^bb3(%c1 : i64) |
| 60 | /// |
| 61 | /// ^bb2: |
| 62 | /// %c2 = arith.constant 2 : i64 |
| 63 | /// cf.br ^bb3(%c2 : i64) |
| 64 | /// |
| 65 | /// ^bb3(%x : i64): |
| 66 | /// scf.yield %x : i64 |
| 67 | /// } |
| 68 | /// "bar"(%v) : (i64) -> () |
| 69 | /// } |
| 70 | /// ``` |
| 71 | class ExecuteRegionOp; |
| 72 | |
| 73 | } // namespace mlir::scf |
| 74 | namespace mlir::scf { |
| 75 | |
| 76 | /// for operation |
| 77 | /// The `scf.for` operation represents a loop whose first three operands are the |
| 78 | /// lower bound, upper bound and step respectively. The operation has one region |
| 79 | /// capturing the loop body. The induction variable is represented as an |
| 80 | /// argument of this region. |
| 81 | /// |
| 82 | /// Lower bound, upper bound, and step are interpreted as signed integers by |
| 83 | /// default, or as unsigned integers if the `unsignedCmp` unit attribute is |
| 84 | /// present. The step is required to be strictly positive. |
| 85 | /// |
| 86 | /// The lower and upper bounds specify a half-open range, including the lower |
| 87 | /// bound but excluding the upper bound. More precisely, the semantics is |
| 88 | /// governed by the following two rules, where arithmetic is performed with |
| 89 | /// arbitrary precision: |
| 90 | /// |
| 91 | /// 1. The trip count `n` is `max(0, ceil((UB - LB) / Step))` and the induction |
| 92 | /// variable takes the values `LB + j*Step` for `j = 0, ..., n - 1` in that |
| 93 | /// order. |
| 94 | /// 2. No-overflow condition: `LB + n*Step` must be representable in the type of |
| 95 | /// the induction variable. Otherwise the behavior is undefined. Leaving this |
| 96 | /// case undefined lets the loop be lowered to a plain increment-and-compare |
| 97 | /// on a single induction register without having to account for wraparound. |
| 98 | /// |
| 99 | /// The body region must contain exactly one block that terminates with |
| 100 | /// `scf.yield`. Calling ForOp::build will create such a region and insert |
| 101 | /// the terminator implicitly if none is defined, so will the parsing even in |
| 102 | /// cases when it is absent from the custom format. For example: |
| 103 | /// |
| 104 | /// ```mlir |
| 105 | /// // Index case. |
| 106 | /// scf.for %iv = %lb to %ub step %step { |
| 107 | /// ... // body |
| 108 | /// } |
| 109 | /// ... |
| 110 | /// // Unsigned integer case. |
| 111 | /// scf.for unsigned %iv_32 = %lb_32 to %ub_32 step %step_32 : i32 { |
| 112 | /// ... // body |
| 113 | /// } |
| 114 | /// ``` |
| 115 | /// |
| 116 | /// `scf.for` can also operate on loop-carried variables and returns the final |
| 117 | /// values after loop termination. The initial values of the variables are |
| 118 | /// passed as additional SSA operands to the `scf.for` following the 3 loop |
| 119 | /// control SSA values mentioned above (lower bound, upper bound and step). The |
| 120 | /// operation region has an argument for the induction variable, followed by |
| 121 | /// one argument for each loop-carried variable, representing the value of the |
| 122 | /// variable at the current iteration. |
| 123 | /// |
| 124 | /// The region must terminate with a `scf.yield` that passes the current |
| 125 | /// values of all loop-carried variables to the next iteration, or to the |
| 126 | /// `scf.for` result, if at the last iteration. The static type of a |
| 127 | /// loop-carried variable may not change with iterations; its runtime type is |
| 128 | /// allowed to change. Note, that when the loop-carried variables are present, |
| 129 | /// calling ForOp::build will not insert the terminator implicitly. The caller |
| 130 | /// must insert `scf.yield` in that case. |
| 131 | /// |
| 132 | /// `scf.for` results hold the final values after the last iteration. |
| 133 | /// For example, to sum-reduce a memref: |
| 134 | /// |
| 135 | /// ```mlir |
| 136 | /// func.func @reduce(%buffer: memref<1024xf32>, %lb: index, |
| 137 | /// %ub: index, %step: index) -> (f32) { |
| 138 | /// // Initial sum set to 0. |
| 139 | /// %sum_0 = arith.constant 0.0 : f32 |
| 140 | /// // iter_args binds initial values to the loop's region arguments. |
| 141 | /// %sum = scf.for %iv = %lb to %ub step %step |
| 142 | /// iter_args(%sum_iter = %sum_0) -> (f32) { |
| 143 | /// %t = load %buffer[%iv] : memref<1024xf32> |
| 144 | /// %sum_next = arith.addf %sum_iter, %t : f32 |
| 145 | /// // Yield current iteration sum to next iteration %sum_iter or to %sum |
| 146 | /// // if final iteration. |
| 147 | /// scf.yield %sum_next : f32 |
| 148 | /// } |
| 149 | /// return %sum : f32 |
| 150 | /// } |
| 151 | /// ``` |
| 152 | /// |
| 153 | /// If the `scf.for` defines any values, a yield must be explicitly present. |
| 154 | /// The number and types of the `scf.for` results must match the initial |
| 155 | /// values in the `iter_args` binding and the yield operands. |
| 156 | /// |
| 157 | /// Another example with a nested `scf.if` (see `scf.if` for details) to |
| 158 | /// perform conditional reduction: |
| 159 | /// |
| 160 | /// ```mlir |
| 161 | /// func.func @conditional_reduce(%buffer: memref<1024xf32>, %lb: index, |
| 162 | /// %ub: index, %step: index) -> (f32) { |
| 163 | /// %sum_0 = arith.constant 0.0 : f32 |
| 164 | /// %c0 = arith.constant 0.0 : f32 |
| 165 | /// %sum = scf.for %iv = %lb to %ub step %step |
| 166 | /// iter_args(%sum_iter = %sum_0) -> (f32) { |
| 167 | /// %t = load %buffer[%iv] : memref<1024xf32> |
| 168 | /// %cond = arith.cmpf "ugt", %t, %c0 : f32 |
| 169 | /// %sum_next = scf.if %cond -> (f32) { |
| 170 | /// %new_sum = arith.addf %sum_iter, %t : f32 |
| 171 | /// scf.yield %new_sum : f32 |
| 172 | /// } else { |
| 173 | /// scf.yield %sum_iter : f32 |
| 174 | /// } |
| 175 | /// scf.yield %sum_next : f32 |
| 176 | /// } |
| 177 | /// return %sum : f32 |
| 178 | /// } |
| 179 | /// ``` |
| 180 | class ForOp; |
| 181 | |
| 182 | } // namespace mlir::scf |
| 183 | namespace mlir::scf { |
| 184 | |
| 185 | /// evaluate a block multiple times in parallel |
| 186 | /// `scf.forall` is a target-independent multi-dimensional parallel |
| 187 | /// region application operation. It has exactly one block that represents the |
| 188 | /// parallel body and it takes index operands that specify lower bounds, upper |
| 189 | /// bounds and steps. |
| 190 | /// |
| 191 | /// The op also takes a variadic number of tensor operands (`shared_outs`). |
| 192 | /// The future buffers corresponding to these tensors are shared among all |
| 193 | /// threads. Shared tensors should be accessed via their corresponding block |
| 194 | /// arguments. If multiple threads write to a shared buffer in a racy |
| 195 | /// fashion, these writes will execute in some unspecified order. Tensors that |
| 196 | /// are not shared can be used inside the body (i.e., the op is not isolated |
| 197 | /// from above); however, if a use of such a tensor bufferizes to a memory |
| 198 | /// write, the tensor is privatized, i.e., a thread-local copy of the tensor is |
| 199 | /// used. This ensures that memory side effects of a thread are not visible to |
| 200 | /// other threads (or in the parent body), apart from explicitly shared tensors. |
| 201 | /// |
| 202 | /// The name "thread" conveys the fact that the parallel execution is mapped |
| 203 | /// (i.e. distributed) to a set of virtual threads of execution, one function |
| 204 | /// application per thread. Further lowerings are responsible for specifying |
| 205 | /// how this is materialized on concrete hardware resources. |
| 206 | /// |
| 207 | /// An optional `mapping` is an attribute array that specifies processing units |
| 208 | /// with their dimension, how it remaps 1-1 to a set of concrete processing |
| 209 | /// element resources (e.g. a CUDA grid dimension or a level of concrete nested |
| 210 | /// async parallelism). It is expressed via any attribute that implements the |
| 211 | /// device mapping interface. It is the reponsibility of the lowering mechanism |
| 212 | /// to interpret the `mapping` attributes in the context of the concrete target |
| 213 | /// the op is lowered to, or to ignore it when the specification is ill-formed |
| 214 | /// or unsupported for a particular target. |
| 215 | /// |
| 216 | /// The only allowed terminator is `scf.forall.in_parallel`. |
| 217 | /// `scf.forall` returns one value per `shared_out` operand. The |
| 218 | /// actions of the `scf.forall.in_parallel` terminators specify how to combine the |
| 219 | /// partial results of all parallel invocations into a full value, in some |
| 220 | /// unspecified order. The "destination" of each such op must be a `shared_out` |
| 221 | /// block argument of the `scf.forall` op. |
| 222 | /// |
| 223 | /// The actions involved in constructing the return values are further described |
| 224 | /// by `tensor.parallel_insert_slice`. |
| 225 | /// |
| 226 | /// `scf.forall` acts as an implicit synchronization point. |
| 227 | /// |
| 228 | /// When the parallel function body has side effects, their order is unspecified |
| 229 | /// across threads. |
| 230 | /// |
| 231 | /// `scf.forall` can be printed in two different ways depending on |
| 232 | /// whether the loop is normalized or not. The loop is 'normalized' when all |
| 233 | /// lower bounds are equal to zero and steps are equal to one. In that case, |
| 234 | /// `lowerBound` and `step` operands will be omitted during printing. |
| 235 | /// |
| 236 | /// Normalized loop example: |
| 237 | /// |
| 238 | /// ```mlir |
| 239 | /// // |
| 240 | /// // Sequential context. |
| 241 | /// // |
| 242 | /// %matmul_and_pointwise:2 = scf.forall (%thread_id_1, %thread_id_2) in |
| 243 | /// (%num_threads_1, %num_threads_2) shared_outs(%o1 = %C, %o2 = %pointwise) |
| 244 | /// -> (tensor<?x?xT>, tensor<?x?xT>) { |
| 245 | /// // |
| 246 | /// // Parallel context, each thread with id = (%thread_id_1, %thread_id_2) |
| 247 | /// // runs its version of the code. |
| 248 | /// // |
| 249 | /// %sA = tensor.extract_slice %A[f((%thread_id_1, %thread_id_2))]: |
| 250 | /// tensor<?x?xT> to tensor<?x?xT> |
| 251 | /// %sB = tensor.extract_slice %B[g((%thread_id_1, %thread_id_2))]: |
| 252 | /// tensor<?x?xT> to tensor<?x?xT> |
| 253 | /// %sC = tensor.extract_slice %o1[h((%thread_id_1, %thread_id_2))]: |
| 254 | /// tensor<?x?xT> to tensor<?x?xT> |
| 255 | /// %sD = linalg.matmul |
| 256 | /// ins(%sA, %sB : tensor<?x?xT>, tensor<?x?xT>) |
| 257 | /// outs(%sC : tensor<?x?xT>) -> tensor<?x?xT> |
| 258 | /// |
| 259 | /// %spointwise = tensor.extract_slice %o2[i((%thread_id_1, %thread_id_2))]: |
| 260 | /// tensor<?x?xT> to tensor<?x?xT> |
| 261 | /// %sE = linalg.add |
| 262 | /// ins(%sD, %spointwise : tensor<?x?xT>, tensor<?x?xT>) |
| 263 | /// outs(%spointwise : tensor<?x?xT>) -> tensor<?x?xT> |
| 264 | /// |
| 265 | /// scf.forall.in_parallel { |
| 266 | /// tensor.parallel_insert_slice %sD into %o1[h((%thread_id_1, %thread_id_2))]: |
| 267 | /// tensor<?x?xT> into tensor<?x?xT> |
| 268 | /// |
| 269 | /// tensor.parallel_insert_slice %sE into %o2[i((%thread_id_1, %thread_id_2))]: |
| 270 | /// tensor<?x?xT> into tensor<?x?xT> |
| 271 | /// } |
| 272 | /// } |
| 273 | /// // Implicit synchronization point. |
| 274 | /// // Sequential context. |
| 275 | /// // |
| 276 | /// ``` |
| 277 | /// |
| 278 | /// Loop with loop bounds example: |
| 279 | /// |
| 280 | /// ```mlir |
| 281 | /// // |
| 282 | /// // Sequential context. |
| 283 | /// // |
| 284 | /// %pointwise = scf.forall (%i, %j) = (0, 0) to (%dim1, %dim2) |
| 285 | /// step (%tileSize1, %tileSize2) shared_outs(%o = %out) |
| 286 | /// -> (tensor<?x?xT>) { |
| 287 | /// // |
| 288 | /// // Parallel context. |
| 289 | /// // |
| 290 | /// %sA = tensor.extract_slice %A[%i, %j][%tileSize1, %tileSize2][1, 1] |
| 291 | /// : tensor<?x?xT> to tensor<?x?xT> |
| 292 | /// %sB = tensor.extract_slice %B[%i, %j][%tileSize1, %tileSize2][1, 1] |
| 293 | /// : tensor<?x?xT> to tensor<?x?xT> |
| 294 | /// %sC = tensor.extract_slice %o[%i, %j][%tileSize1, %tileSize2][1, 1] |
| 295 | /// : tensor<?x?xT> to tensor<?x?xT> |
| 296 | /// |
| 297 | /// %add = linalg.map { arith.addf } |
| 298 | /// ins(%sA, %sB : tensor<?x?xT>, tensor<?x?xT>) |
| 299 | /// outs(%sC : tensor<?x?xT>) |
| 300 | /// |
| 301 | /// scf.forall.in_parallel { |
| 302 | /// tensor.parallel_insert_slice %add into |
| 303 | /// %o[%i, %j][%tileSize1, %tileSize2][1, 1] |
| 304 | /// : tensor<?x?xT> into tensor<?x?xT> |
| 305 | /// } |
| 306 | /// } |
| 307 | /// // Implicit synchronization point. |
| 308 | /// // Sequential context. |
| 309 | /// // |
| 310 | /// ``` |
| 311 | /// |
| 312 | /// Example with mapping attribute: |
| 313 | /// |
| 314 | /// ```mlir |
| 315 | /// // |
| 316 | /// // Sequential context. Here `mapping` is expressed as GPU thread mapping |
| 317 | /// // attributes |
| 318 | /// // |
| 319 | /// %matmul_and_pointwise:2 = scf.forall (%thread_id_1, %thread_id_2) in |
| 320 | /// (%num_threads_1, %numthread_id_2) shared_outs(...) |
| 321 | /// -> (tensor<?x?xT>, tensor<?xT>) { |
| 322 | /// // |
| 323 | /// // Parallel context, each thread with id = **(%thread_id_2, %thread_id_1)** |
| 324 | /// // runs its version of the code. |
| 325 | /// // |
| 326 | /// scf.forall.in_parallel { |
| 327 | /// ... |
| 328 | /// } |
| 329 | /// } { mapping = [#gpu.thread<y>, #gpu.thread<x>] } |
| 330 | /// // Implicit synchronization point. |
| 331 | /// // Sequential context. |
| 332 | /// // |
| 333 | /// ``` |
| 334 | /// |
| 335 | /// Example with privatized tensors: |
| 336 | /// |
| 337 | /// ```mlir |
| 338 | /// %t0 = ... |
| 339 | /// %t1 = ... |
| 340 | /// %r = scf.forall ... shared_outs(%o = t0) -> tensor<?xf32> { |
| 341 | /// // %t0 and %t1 are privatized. %t0 is definitely copied for each thread |
| 342 | /// // because the scf.forall op's %t0 use bufferizes to a memory |
| 343 | /// // write. In the absence of other conflicts, %t1 is copied only if there |
| 344 | /// // are uses of %t1 in the body that bufferize to a memory read and to a |
| 345 | /// // memory write. |
| 346 | /// "some_use"(%t0) |
| 347 | /// "some_use"(%t1) |
| 348 | /// } |
| 349 | /// ``` |
| 350 | class ForallOp; |
| 351 | |
| 352 | } // namespace mlir::scf |
| 353 | namespace mlir::scf { |
| 354 | |
| 355 | /// if-then-else operation |
| 356 | /// The `scf.if` operation represents an if-then-else construct for |
| 357 | /// conditionally executing two regions of code. The operand to an if operation |
| 358 | /// is a boolean value. For example: |
| 359 | /// |
| 360 | /// ```mlir |
| 361 | /// scf.if %b { |
| 362 | /// ... |
| 363 | /// } else { |
| 364 | /// ... |
| 365 | /// } |
| 366 | /// ``` |
| 367 | /// |
| 368 | /// `scf.if` may also produce results. Which values are returned depends on |
| 369 | /// which execution path is taken. |
| 370 | /// |
| 371 | /// Example: |
| 372 | /// |
| 373 | /// ```mlir |
| 374 | /// %x, %y = scf.if %b -> (f32, f32) { |
| 375 | /// %x_true = ... |
| 376 | /// %y_true = ... |
| 377 | /// scf.yield %x_true, %y_true : f32, f32 |
| 378 | /// } else { |
| 379 | /// %x_false = ... |
| 380 | /// %y_false = ... |
| 381 | /// scf.yield %x_false, %y_false : f32, f32 |
| 382 | /// } |
| 383 | /// ``` |
| 384 | /// |
| 385 | /// The "then" region has exactly 1 block. The "else" region may have 0 or 1 |
| 386 | /// block. In case the `scf.if` produces results, the "else" region must also |
| 387 | /// have exactly 1 block. |
| 388 | /// |
| 389 | /// The blocks are always terminated with `scf.yield`. If `scf.if` defines no |
| 390 | /// values, the `scf.yield` can be left out, and will be inserted implicitly. |
| 391 | /// Otherwise, it must be explicit. |
| 392 | /// |
| 393 | /// Example: |
| 394 | /// |
| 395 | /// ```mlir |
| 396 | /// scf.if %b { |
| 397 | /// ... |
| 398 | /// } |
| 399 | /// ``` |
| 400 | /// |
| 401 | /// The types of the yielded values must match the result types of the |
| 402 | /// `scf.if`. |
| 403 | class IfOp; |
| 404 | |
| 405 | } // namespace mlir::scf |
| 406 | namespace mlir::scf { |
| 407 | |
| 408 | /// terminates a `forall` block |
| 409 | /// The `scf.forall.in_parallel` is a designated terminator for |
| 410 | /// the `scf.forall` operation. |
| 411 | /// |
| 412 | /// It has a single region with a single block that contains a flat list of ops. |
| 413 | /// Each such op participates in the aggregate formation of a single result of |
| 414 | /// the enclosing `scf.forall`. |
| 415 | /// The result number corresponds to the position of the op in the terminator. |
| 416 | class InParallelOp; |
| 417 | |
| 418 | } // namespace mlir::scf |
| 419 | namespace mlir::scf { |
| 420 | |
| 421 | /// switch-case operation on an index argument |
| 422 | /// The `scf.index_switch` is a control-flow operation that branches to one of |
| 423 | /// the given regions based on the values of the argument and the cases. The |
| 424 | /// argument is always of type `index`. |
| 425 | /// |
| 426 | /// The operation always has a "default" region and any number of case regions |
| 427 | /// denoted by integer constants. Control-flow transfers to the case region |
| 428 | /// whose constant value equals the value of the argument. If the argument does |
| 429 | /// not equal any of the case values, control-flow transfer to the "default" |
| 430 | /// region. |
| 431 | /// |
| 432 | /// Example: |
| 433 | /// |
| 434 | /// ```mlir |
| 435 | /// %0 = scf.index_switch %arg0 : index -> i32 |
| 436 | /// case 2 { |
| 437 | /// %1 = arith.constant 10 : i32 |
| 438 | /// scf.yield %1 : i32 |
| 439 | /// } |
| 440 | /// case 5 { |
| 441 | /// %2 = arith.constant 20 : i32 |
| 442 | /// scf.yield %2 : i32 |
| 443 | /// } |
| 444 | /// default { |
| 445 | /// %3 = arith.constant 30 : i32 |
| 446 | /// scf.yield %3 : i32 |
| 447 | /// } |
| 448 | /// ``` |
| 449 | class IndexSwitchOp; |
| 450 | |
| 451 | } // namespace mlir::scf |
| 452 | namespace mlir::scf { |
| 453 | |
| 454 | /// parallel for operation |
| 455 | /// The `scf.parallel` operation represents a loop nest taking 4 groups of SSA |
| 456 | /// values as operands that represent the lower bounds, upper bounds, steps and |
| 457 | /// initial values, respectively. The operation defines a variadic number of |
| 458 | /// SSA values for its induction variables. It has one region capturing the |
| 459 | /// loop body. The induction variables are represented as an argument of this |
| 460 | /// region. These SSA values always have type index, which is the size of the |
| 461 | /// machine word. The steps are values of type index, required to be positive. |
| 462 | /// The lower and upper bounds specify a half-open range: the range includes |
| 463 | /// the lower bound but does not include the upper bound. Lower bounds, upper |
| 464 | /// bounds and steps are interpreted as signed integers by default, or as |
| 465 | /// unsigned integers if the `unsignedCmp` unit attribute is present. The |
| 466 | /// initial values have the same types as results of `scf.parallel`. If there |
| 467 | /// are no results, the keyword `init` can be omitted. |
| 468 | /// |
| 469 | /// More precisely, the iteration space of each dimension is governed by the |
| 470 | /// following two rules, where arithmetic is performed with arbitrary |
| 471 | /// precision: |
| 472 | /// |
| 473 | /// 1. The trip count `n` is `max(0, ceil((UB - LB) / Step))` and the induction |
| 474 | /// variable takes the values `LB + j*Step` for `j = 0, ..., n - 1`. |
| 475 | /// 2. No-overflow condition: `LB + n*Step` must be representable in the type of |
| 476 | /// the induction variable. Otherwise the behavior is undefined. Leaving this |
| 477 | /// case undefined lets the loop be lowered to a plain increment-and-compare |
| 478 | /// on a single induction register without having to account for wraparound. |
| 479 | /// |
| 480 | /// Semantically we require that the iteration space can be iterated in any |
| 481 | /// order, and the loop body can be executed in parallel. If there are data |
| 482 | /// races, the behavior is undefined. |
| 483 | /// |
| 484 | /// The parallel loop operation supports reduction of values produced by |
| 485 | /// individual iterations into a single result. This is modeled using the |
| 486 | /// `scf.reduce` terminator operation (see `scf.reduce` for details). The i-th |
| 487 | /// result of an `scf.parallel` operation is associated with the i-th initial |
| 488 | /// value operand, the i-th operand of the `scf.reduce` operation (the value to |
| 489 | /// be reduced) and the i-th region of the `scf.reduce` operation (the reduction |
| 490 | /// function). Consequently, we require that the number of results of an |
| 491 | /// `scf.parallel` op matches the number of initial values and the the number of |
| 492 | /// reductions in the `scf.reduce` terminator. |
| 493 | /// |
| 494 | /// The body region must contain exactly one block that terminates with a |
| 495 | /// `scf.reduce` operation. If an `scf.parallel` op has no reductions, the |
| 496 | /// terminator has no operands and no regions. The `scf.parallel` parser will |
| 497 | /// automatically insert the terminator for ops that have no reductions if it is |
| 498 | /// absent. |
| 499 | /// |
| 500 | /// Example: |
| 501 | /// |
| 502 | /// ```mlir |
| 503 | /// %init = arith.constant 0.0 : f32 |
| 504 | /// %r:2 = scf.parallel (%iv) = (%lb) to (%ub) step (%step) init (%init, %init) |
| 505 | /// -> f32, f32 { |
| 506 | /// %elem_to_reduce1 = load %buffer1[%iv] : memref<100xf32> |
| 507 | /// %elem_to_reduce2 = load %buffer2[%iv] : memref<100xf32> |
| 508 | /// scf.reduce(%elem_to_reduce1, %elem_to_reduce2 : f32, f32) { |
| 509 | /// ^bb0(%lhs : f32, %rhs: f32): |
| 510 | /// %res = arith.addf %lhs, %rhs : f32 |
| 511 | /// scf.reduce.return %res : f32 |
| 512 | /// }, { |
| 513 | /// ^bb0(%lhs : f32, %rhs: f32): |
| 514 | /// %res = arith.mulf %lhs, %rhs : f32 |
| 515 | /// scf.reduce.return %res : f32 |
| 516 | /// } |
| 517 | /// } |
| 518 | /// ``` |
| 519 | class ParallelOp; |
| 520 | |
| 521 | } // namespace mlir::scf |
| 522 | namespace mlir::scf { |
| 523 | |
| 524 | /// reduce operation for scf.parallel |
| 525 | /// The `scf.reduce` operation is the terminator for `scf.parallel` operations. It can model |
| 526 | /// an arbitrary number of reductions. It has one region per reduction. Each |
| 527 | /// region has one block with two arguments which have the same type as the |
| 528 | /// corresponding operand of `scf.reduce`. The operands of the op are the values |
| 529 | /// that should be reduce; one value per reduction. |
| 530 | /// |
| 531 | /// The i-th reduction (i.e., the i-th region and the i-th operand) corresponds |
| 532 | /// the i-th initial value and the i-th result of the enclosing `scf.parallel` |
| 533 | /// op. |
| 534 | /// |
| 535 | /// The `scf.reduce` operation contains regions whose entry blocks expect two |
| 536 | /// arguments of the same type as the corresponding operand. As the iteration |
| 537 | /// order of the enclosing parallel loop and hence reduction order is |
| 538 | /// unspecified, the results of the reductions may be non-deterministic unless |
| 539 | /// the reductions are associative and commutative. |
| 540 | /// |
| 541 | /// The result of a reduction region (`scf.reduce.return` operand) must have the |
| 542 | /// same type as the corresponding `scf.reduce` operand and the corresponding |
| 543 | /// `scf.parallel` initial value. |
| 544 | /// |
| 545 | /// Example: |
| 546 | /// |
| 547 | /// ```mlir |
| 548 | /// %operand = arith.constant 1.0 : f32 |
| 549 | /// scf.reduce(%operand : f32) { |
| 550 | /// ^bb0(%lhs : f32, %rhs: f32): |
| 551 | /// %res = arith.addf %lhs, %rhs : f32 |
| 552 | /// scf.reduce.return %res : f32 |
| 553 | /// } |
| 554 | /// ``` |
| 555 | class ReduceOp; |
| 556 | |
| 557 | } // namespace mlir::scf |
| 558 | namespace mlir::scf { |
| 559 | |
| 560 | /// terminator for reduce operation |
| 561 | /// The `scf.reduce.return` operation is a special terminator operation for the block inside |
| 562 | /// `scf.reduce` regions. It terminates the region. It should have the same |
| 563 | /// operand type as the corresponding operand of the enclosing `scf.reduce` op. |
| 564 | /// |
| 565 | /// Example: |
| 566 | /// |
| 567 | /// ```mlir |
| 568 | /// scf.reduce.return %res : f32 |
| 569 | /// ``` |
| 570 | class ReduceReturnOp; |
| 571 | |
| 572 | } // namespace mlir::scf |
| 573 | namespace mlir::scf { |
| 574 | |
| 575 | /// a generic 'while' loop |
| 576 | /// This operation represents a generic "while"/"do-while" loop that keeps |
| 577 | /// iterating as long as a condition is satisfied. There is no restriction on |
| 578 | /// the complexity of the condition. It consists of two regions (with single |
| 579 | /// block each): "before" region and "after" region. The names of regions |
| 580 | /// indicates whether they execute before or after the condition check. |
| 581 | /// Therefore, if the main loop payload is located in the "before" region, the |
| 582 | /// operation is a "do-while" loop. Otherwise, it is a "while" loop. |
| 583 | /// |
| 584 | /// The "before" region terminates with a special operation, `scf.condition`, |
| 585 | /// that accepts as its first operand an `i1` value indicating whether to |
| 586 | /// proceed to the "after" region (value is `true`) or not. The two regions |
| 587 | /// communicate by means of region arguments. Initially, the "before" region |
| 588 | /// accepts as arguments the operands of the `scf.while` operation and uses them |
| 589 | /// to evaluate the condition. It forwards the trailing, non-condition operands |
| 590 | /// of the `scf.condition` terminator either to the "after" region if the |
| 591 | /// control flow is transferred there or to results of the `scf.while` operation |
| 592 | /// otherwise. The "after" region takes as arguments the values produced by the |
| 593 | /// "before" region and uses `scf.yield` to supply new arguments for the |
| 594 | /// "before" region, into which it transfers the control flow unconditionally. |
| 595 | /// |
| 596 | /// A simple "while" loop can be represented as follows. |
| 597 | /// |
| 598 | /// ```mlir |
| 599 | /// %res = scf.while (%arg1 = %init1) : (f32) -> f32 { |
| 600 | /// // "Before" region. |
| 601 | /// // In a "while" loop, this region computes the condition. |
| 602 | /// %condition = call @evaluate_condition(%arg1) : (f32) -> i1 |
| 603 | /// |
| 604 | /// // Forward the argument (as result or "after" region argument). |
| 605 | /// scf.condition(%condition) %arg1 : f32 |
| 606 | /// |
| 607 | /// } do { |
| 608 | /// ^bb0(%arg2: f32): |
| 609 | /// // "After" region. |
| 610 | /// // In a "while" loop, this region is the loop body. |
| 611 | /// %next = call @payload(%arg2) : (f32) -> f32 |
| 612 | /// |
| 613 | /// // Forward the new value to the "before" region. |
| 614 | /// // The operand types must match the types of the `scf.while` operands. |
| 615 | /// scf.yield %next : f32 |
| 616 | /// } |
| 617 | /// ``` |
| 618 | /// |
| 619 | /// A simple "do-while" loop can be represented by reducing the "after" block |
| 620 | /// to a simple forwarder. |
| 621 | /// |
| 622 | /// ```mlir |
| 623 | /// %res = scf.while (%arg1 = %init1) : (f32) -> f32 { |
| 624 | /// // "Before" region. |
| 625 | /// // In a "do-while" loop, this region contains the loop body. |
| 626 | /// %next = call @payload(%arg1) : (f32) -> f32 |
| 627 | /// |
| 628 | /// // And also evaluates the condition. |
| 629 | /// %condition = call @evaluate_condition(%arg1) : (f32) -> i1 |
| 630 | /// |
| 631 | /// // Loop through the "after" region. |
| 632 | /// scf.condition(%condition) %next : f32 |
| 633 | /// |
| 634 | /// } do { |
| 635 | /// ^bb0(%arg2: f32): |
| 636 | /// // "After" region. |
| 637 | /// // Forwards the values back to "before" region unmodified. |
| 638 | /// scf.yield %arg2 : f32 |
| 639 | /// } |
| 640 | /// ``` |
| 641 | /// |
| 642 | /// Note that the types of region arguments need not to match with each other. |
| 643 | /// The op expects the operand types to match with argument types of the |
| 644 | /// "before" region; the result types to match with the trailing operand types |
| 645 | /// of the terminator of the "before" region, and with the argument types of the |
| 646 | /// "after" region. The following scheme can be used to share the results of |
| 647 | /// some operations executed in the "before" region with the "after" region, |
| 648 | /// avoiding the need to recompute them. |
| 649 | /// |
| 650 | /// ```mlir |
| 651 | /// %res = scf.while (%arg1 = %init1) : (f32) -> i64 { |
| 652 | /// // One can perform some computations, e.g., necessary to evaluate the |
| 653 | /// // condition, in the "before" region and forward their results to the |
| 654 | /// // "after" region. |
| 655 | /// %shared = call @shared_compute(%arg1) : (f32) -> i64 |
| 656 | /// |
| 657 | /// // Evaluate the condition. |
| 658 | /// %condition = call @evaluate_condition(%arg1, %shared) : (f32, i64) -> i1 |
| 659 | /// |
| 660 | /// // Forward the result of the shared computation to the "after" region. |
| 661 | /// // The types must match the arguments of the "after" region as well as |
| 662 | /// // those of the `scf.while` results. |
| 663 | /// scf.condition(%condition) %shared : i64 |
| 664 | /// |
| 665 | /// } do { |
| 666 | /// ^bb0(%arg2: i64) { |
| 667 | /// // Use the partial result to compute the rest of the payload in the |
| 668 | /// // "after" region. |
| 669 | /// %res = call @payload(%arg2) : (i64) -> f32 |
| 670 | /// |
| 671 | /// // Forward the new value to the "before" region. |
| 672 | /// // The operand types must match the types of the `scf.while` operands. |
| 673 | /// scf.yield %res : f32 |
| 674 | /// } |
| 675 | /// ``` |
| 676 | /// |
| 677 | /// The custom syntax for this operation is as follows. |
| 678 | /// |
| 679 | /// ``` |
| 680 | /// op ::= `scf.while` assignments `:` function-type region `do` region |
| 681 | /// `attributes` attribute-dict |
| 682 | /// initializer ::= /* empty */ | `(` assignment-list `)` |
| 683 | /// assignment-list ::= assignment | assignment `,` assignment-list |
| 684 | /// assignment ::= ssa-value `=` ssa-value |
| 685 | /// ``` |
| 686 | class WhileOp; |
| 687 | |
| 688 | } // namespace mlir::scf |
| 689 | namespace mlir::scf { |
| 690 | |
| 691 | /// loop yield and termination operation |
| 692 | /// The `scf.yield` operation yields an SSA value from the SCF dialect op region and |
| 693 | /// terminates the regions. The semantics of how the values are yielded is |
| 694 | /// defined by the parent operation. |
| 695 | /// If `scf.yield` has any operands, the operands must match the parent |
| 696 | /// operation's results. |
| 697 | /// If the parent operation defines no values, then the `scf.yield` may be |
| 698 | /// left out in the custom syntax and the builders will insert one implicitly. |
| 699 | /// Otherwise, it has to be present in the syntax to indicate which values are |
| 700 | /// yielded. |
| 701 | class YieldOp; |
| 702 | |
| 703 | } // namespace mlir::scf |
| 704 | #ifdef GET_OP_CLASSES |
| 705 | #undef GET_OP_CLASSES |
| 706 | |
| 707 | #include "mlir/Bytecode/BytecodeOpInterface.h" |
| 708 | #include "mlir/IR/BuiltinAttributes.h" |
| 709 | #include "mlir/IR/BuiltinTypes.h" |
| 710 | #include "mlir/IR/OpDefinition.h" |
| 711 | #include "mlir/IR/RegionKindInterface.h" |
| 712 | #include "mlir/IR/Types.h" |
| 713 | #include "mlir/Interfaces/ControlFlowInterfaces.h" |
| 714 | #include "mlir/Interfaces/DestinationStyleOpInterface.h" |
| 715 | #include "mlir/Interfaces/InferTypeOpInterface.h" |
| 716 | #include "mlir/Interfaces/LoopLikeInterface.h" |
| 717 | #include "mlir/Interfaces/MemorySlotInterfaces.h" |
| 718 | #include "mlir/Interfaces/ParallelCombiningOpInterface.h" |
| 719 | #include "mlir/Interfaces/SideEffectInterfaces.h" |
| 720 | |
| 721 | namespace mlir::scf { |
| 722 | |
| 723 | |
| 724 | //===----------------------------------------------------------------------===// |
| 725 | // ::mlir::scf::ConditionOp declarations |
| 726 | //===----------------------------------------------------------------------===// |
| 727 | |
| 728 | namespace detail { |
| 729 | |
| 730 | class ConditionOpGenericAdaptorBase { |
| 731 | public: |
| 732 | using Properties = ::mlir::EmptyProperties; |
| 733 | protected: |
| 734 | ::mlir::DictionaryAttr odsAttrs; |
| 735 | ::std::optional<::mlir::OperationName> odsOpName; |
| 736 | Properties properties; |
| 737 | ::mlir::RegionRange odsRegions; |
| 738 | public: |
| 739 | ConditionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 740 | odsOpName.emplace(args: "scf.condition" , args: odsAttrs.getContext()); |
| 741 | } |
| 742 | |
| 743 | ConditionOpGenericAdaptorBase(ConditionOp op); |
| 744 | |
| 745 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 746 | const Properties &getProperties() { |
| 747 | return properties; |
| 748 | } |
| 749 | |
| 750 | ::mlir::DictionaryAttr getAttributes() { |
| 751 | return odsAttrs; |
| 752 | } |
| 753 | |
| 754 | }; |
| 755 | |
| 756 | } // namespace detail |
| 757 | template <typename RangeT> |
| 758 | class ConditionOpGenericAdaptor : public detail::ConditionOpGenericAdaptorBase { |
| 759 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 760 | using Base = detail::ConditionOpGenericAdaptorBase; |
| 761 | static constexpr int odsIndex_condition = 0; |
| 762 | static constexpr int odsIndex_args = 1; |
| 763 | public: |
| 764 | ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 765 | |
| 766 | ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ConditionOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 767 | |
| 768 | ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConditionOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 769 | |
| 770 | ConditionOpGenericAdaptor(RangeT values, const ConditionOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 771 | |
| 772 | template <typename LateInst = ConditionOp, typename = std::enable_if_t<std::is_same_v<LateInst, ConditionOp>>> |
| 773 | ConditionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 774 | |
| 775 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 776 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 777 | } |
| 778 | |
| 779 | RangeT getODSOperands(unsigned index) { |
| 780 | auto valueRange = getODSOperandIndexAndLength(index); |
| 781 | return {std::next(odsOperands.begin(), valueRange.first), |
| 782 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 783 | } |
| 784 | |
| 785 | ValueT getCondition() { |
| 786 | return (*getODSOperands(index: 0).begin()); |
| 787 | } |
| 788 | |
| 789 | RangeT getArgs() { |
| 790 | return getODSOperands(index: 1); |
| 791 | } |
| 792 | |
| 793 | RangeT getOperands() { |
| 794 | return odsOperands; |
| 795 | } |
| 796 | |
| 797 | private: |
| 798 | RangeT odsOperands; |
| 799 | }; |
| 800 | class ConditionOpAdaptor : public ConditionOpGenericAdaptor<::mlir::ValueRange> { |
| 801 | public: |
| 802 | using ConditionOpGenericAdaptor::ConditionOpGenericAdaptor; |
| 803 | ConditionOpAdaptor(ConditionOp op); |
| 804 | |
| 805 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 806 | }; |
| 807 | class ConditionOp : public ::mlir::Op<ConditionOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::HasParent<WhileOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> { |
| 808 | public: |
| 809 | using Op::Op; |
| 810 | using Op::print; |
| 811 | using Adaptor = ConditionOpAdaptor; |
| 812 | template <typename RangeT> |
| 813 | using GenericAdaptor = ConditionOpGenericAdaptor<RangeT>; |
| 814 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 815 | static constexpr int odsIndex_condition = 0; |
| 816 | static constexpr int odsIndex_args = 1; |
| 817 | using Properties = FoldAdaptor::Properties; |
| 818 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 819 | return {}; |
| 820 | } |
| 821 | |
| 822 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 823 | return ::llvm::StringLiteral("scf.condition" ); |
| 824 | } |
| 825 | |
| 826 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 827 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 828 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 829 | return getOperation()->getOperands().slice(n: start, m: length); |
| 830 | } |
| 831 | |
| 832 | ::mlir::TypedValue<::mlir::IntegerType> getCondition() { |
| 833 | return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(Val: *getODSOperands(index: 0).begin()); |
| 834 | } |
| 835 | |
| 836 | ::mlir::Operation::operand_range getArgs() { |
| 837 | return getODSOperands(index: 1); |
| 838 | } |
| 839 | |
| 840 | ::mlir::OpOperand &getConditionMutable() { |
| 841 | auto range = getODSOperandIndexAndLength(index: 0); |
| 842 | return getOperation()->getOpOperand(idx: range.first); |
| 843 | } |
| 844 | |
| 845 | ::mlir::MutableOperandRange getArgsMutable(); |
| 846 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index) { |
| 847 | return {index, 1}; |
| 848 | } |
| 849 | |
| 850 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 851 | auto valueRange = getODSResultIndexAndLength(index); |
| 852 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 853 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 854 | } |
| 855 | |
| 856 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 857 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 858 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 859 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 860 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 861 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 862 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 863 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value condition, ::mlir::ValueRange args); |
| 864 | static ConditionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value condition, ::mlir::ValueRange args); |
| 865 | static ConditionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value condition, ::mlir::ValueRange args); |
| 866 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args); |
| 867 | static ConditionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args); |
| 868 | static ConditionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args); |
| 869 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 870 | static ConditionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 871 | static ConditionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 872 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 873 | static ConditionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 874 | static ConditionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 875 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 876 | ::llvm::LogicalResult verifyInvariants(); |
| 877 | ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionSuccessor point); |
| 878 | void getSuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 879 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 880 | LLVM_ATTRIBUTE_MINSIZE void print(::mlir::OpAsmPrinter &_odsPrinter); |
| 881 | void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); |
| 882 | public: |
| 883 | }; |
| 884 | |
| 885 | } // namespace mlir::scf |
| 886 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ConditionOp) |
| 887 | |
| 888 | namespace mlir::scf { |
| 889 | |
| 890 | |
| 891 | //===----------------------------------------------------------------------===// |
| 892 | // ::mlir::scf::ExecuteRegionOp declarations |
| 893 | //===----------------------------------------------------------------------===// |
| 894 | |
| 895 | namespace detail { |
| 896 | |
| 897 | class ExecuteRegionOpGenericAdaptorBase { |
| 898 | public: |
| 899 | struct Properties { |
| 900 | using no_inlineTy = ::mlir::UnitAttr; |
| 901 | no_inlineTy no_inline; |
| 902 | |
| 903 | auto getNoInline() const { |
| 904 | auto &propStorage = this->no_inline; |
| 905 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val: propStorage); |
| 906 | } |
| 907 | void setNoInline(const ::mlir::UnitAttr &propValue) { |
| 908 | this->no_inline = propValue; |
| 909 | } |
| 910 | bool operator==(const Properties &rhs) const { |
| 911 | return |
| 912 | rhs.no_inline == this->no_inline && |
| 913 | true; |
| 914 | } |
| 915 | bool operator!=(const Properties &rhs) const { |
| 916 | return !(*this == rhs); |
| 917 | } |
| 918 | }; |
| 919 | protected: |
| 920 | ::mlir::DictionaryAttr odsAttrs; |
| 921 | ::std::optional<::mlir::OperationName> odsOpName; |
| 922 | Properties properties; |
| 923 | ::mlir::RegionRange odsRegions; |
| 924 | public: |
| 925 | ExecuteRegionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 926 | odsOpName.emplace(args: "scf.execute_region" , args: odsAttrs.getContext()); |
| 927 | } |
| 928 | |
| 929 | ExecuteRegionOpGenericAdaptorBase(ExecuteRegionOp op); |
| 930 | |
| 931 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 932 | return {index, 1}; |
| 933 | } |
| 934 | |
| 935 | const Properties &getProperties() { |
| 936 | return properties; |
| 937 | } |
| 938 | |
| 939 | ::mlir::DictionaryAttr getAttributes() { |
| 940 | return odsAttrs; |
| 941 | } |
| 942 | |
| 943 | ::mlir::UnitAttr getNoInlineAttr(); |
| 944 | bool getNoInline(); |
| 945 | ::mlir::Region &getRegion() { |
| 946 | return *odsRegions[0]; |
| 947 | } |
| 948 | |
| 949 | ::mlir::RegionRange getRegions() { |
| 950 | return odsRegions; |
| 951 | } |
| 952 | |
| 953 | }; |
| 954 | |
| 955 | } // namespace detail |
| 956 | template <typename RangeT> |
| 957 | class ExecuteRegionOpGenericAdaptor : public detail::ExecuteRegionOpGenericAdaptorBase { |
| 958 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 959 | using Base = detail::ExecuteRegionOpGenericAdaptorBase; |
| 960 | public: |
| 961 | ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 962 | |
| 963 | ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ExecuteRegionOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 964 | |
| 965 | ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ExecuteRegionOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 966 | |
| 967 | ExecuteRegionOpGenericAdaptor(RangeT values, const ExecuteRegionOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 968 | |
| 969 | template <typename LateInst = ExecuteRegionOp, typename = std::enable_if_t<std::is_same_v<LateInst, ExecuteRegionOp>>> |
| 970 | ExecuteRegionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 971 | |
| 972 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 973 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 974 | } |
| 975 | |
| 976 | RangeT getODSOperands(unsigned index) { |
| 977 | auto valueRange = getODSOperandIndexAndLength(index); |
| 978 | return {std::next(odsOperands.begin(), valueRange.first), |
| 979 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 980 | } |
| 981 | |
| 982 | RangeT getOperands() { |
| 983 | return odsOperands; |
| 984 | } |
| 985 | |
| 986 | private: |
| 987 | RangeT odsOperands; |
| 988 | }; |
| 989 | class ExecuteRegionOpAdaptor : public ExecuteRegionOpGenericAdaptor<::mlir::ValueRange> { |
| 990 | public: |
| 991 | using ExecuteRegionOpGenericAdaptor::ExecuteRegionOpGenericAdaptor; |
| 992 | ExecuteRegionOpAdaptor(ExecuteRegionOp op); |
| 993 | |
| 994 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 995 | }; |
| 996 | class ExecuteRegionOp : public ::mlir::Op<ExecuteRegionOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { |
| 997 | public: |
| 998 | using Op::Op; |
| 999 | using Op::print; |
| 1000 | using Adaptor = ExecuteRegionOpAdaptor; |
| 1001 | template <typename RangeT> |
| 1002 | using GenericAdaptor = ExecuteRegionOpGenericAdaptor<RangeT>; |
| 1003 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 1004 | using Properties = FoldAdaptor::Properties; |
| 1005 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::getEntrySuccessorOperands; |
| 1006 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::getEntrySuccessorRegions; |
| 1007 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::getSuccessorRegions; |
| 1008 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::getPredecessors; |
| 1009 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::getPredecessorValues; |
| 1010 | using ::mlir::RegionBranchOpInterface::Trait<ExecuteRegionOp>::areTypesCompatible; |
| 1011 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 1012 | static ::llvm::StringRef attrNames[] = {::llvm::StringRef("no_inline" )}; |
| 1013 | return ::llvm::ArrayRef(attrNames); |
| 1014 | } |
| 1015 | |
| 1016 | ::mlir::StringAttr getNoInlineAttrName() { |
| 1017 | return getAttributeNameForIndex(index: 0); |
| 1018 | } |
| 1019 | |
| 1020 | static ::mlir::StringAttr getNoInlineAttrName(::mlir::OperationName name) { |
| 1021 | return getAttributeNameForIndex(name, index: 0); |
| 1022 | } |
| 1023 | |
| 1024 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 1025 | return ::llvm::StringLiteral("scf.execute_region" ); |
| 1026 | } |
| 1027 | |
| 1028 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 1029 | return {index, 1}; |
| 1030 | } |
| 1031 | |
| 1032 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 1033 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 1034 | return getOperation()->getOperands().slice(n: start, m: length); |
| 1035 | } |
| 1036 | |
| 1037 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 1038 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 1039 | auto valueRange = getODSResultIndexAndLength(index); |
| 1040 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 1041 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 1042 | } |
| 1043 | |
| 1044 | ::mlir::Region &getRegion() { |
| 1045 | return (*this)->getRegion(index: 0); |
| 1046 | } |
| 1047 | |
| 1048 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1049 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 1050 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 1051 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 1052 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 1053 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 1054 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1055 | static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); |
| 1056 | void writeProperties(::mlir::DialectBytecodeWriter &writer); |
| 1057 | ::mlir::UnitAttr getNoInlineAttr() { |
| 1058 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val&: getProperties().no_inline); |
| 1059 | } |
| 1060 | |
| 1061 | bool getNoInline(); |
| 1062 | void setNoInlineAttr(::mlir::UnitAttr attr) { |
| 1063 | getProperties().no_inline = attr; |
| 1064 | } |
| 1065 | |
| 1066 | void setNoInline(bool attrValue); |
| 1067 | ::mlir::Attribute removeNoInlineAttr() { |
| 1068 | auto attr = getProperties().no_inline; |
| 1069 | getProperties().no_inline = {}; |
| 1070 | return attr; |
| 1071 | } |
| 1072 | |
| 1073 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, /*optional*/::mlir::UnitAttr no_inline); |
| 1074 | static ExecuteRegionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultType0, /*optional*/::mlir::UnitAttr no_inline); |
| 1075 | static ExecuteRegionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultType0, /*optional*/::mlir::UnitAttr no_inline); |
| 1076 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, /*optional*/bool no_inline = false); |
| 1077 | static ExecuteRegionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultType0, /*optional*/bool no_inline = false); |
| 1078 | static ExecuteRegionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultType0, /*optional*/bool no_inline = false); |
| 1079 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 1080 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 1081 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 1082 | static ExecuteRegionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 1083 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 1084 | static ExecuteRegionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 1085 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 1086 | static ExecuteRegionOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 1087 | static ExecuteRegionOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 1088 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 1089 | void print(::mlir::OpAsmPrinter &p); |
| 1090 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 1091 | ::llvm::LogicalResult verifyInvariants(); |
| 1092 | ::llvm::LogicalResult verify(); |
| 1093 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 1094 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 1095 | ::mlir::ValueRange getSuccessorInputs(::mlir::RegionSuccessor successor); |
| 1096 | void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); |
| 1097 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 1098 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 1099 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 1100 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1101 | private: |
| 1102 | ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { |
| 1103 | return getAttributeNameForIndex(name: (*this)->getName(), index); |
| 1104 | } |
| 1105 | |
| 1106 | static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { |
| 1107 | assert(index < 1 && "invalid attribute index" ); |
| 1108 | assert(name.getStringRef() == getOperationName() && "invalid operation name" ); |
| 1109 | assert(name.isRegistered() && "Operation isn't registered, missing a " |
| 1110 | "dependent dialect loading?" ); |
| 1111 | return name.getAttributeNames()[index]; |
| 1112 | } |
| 1113 | |
| 1114 | static void buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes); |
| 1115 | public: |
| 1116 | }; |
| 1117 | |
| 1118 | } // namespace mlir::scf |
| 1119 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ExecuteRegionOp) |
| 1120 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::detail::ExecuteRegionOpGenericAdaptorBase::Properties) |
| 1121 | |
| 1122 | namespace mlir::scf { |
| 1123 | |
| 1124 | |
| 1125 | //===----------------------------------------------------------------------===// |
| 1126 | // ::mlir::scf::ForOp declarations |
| 1127 | //===----------------------------------------------------------------------===// |
| 1128 | |
| 1129 | namespace detail { |
| 1130 | |
| 1131 | class ForOpGenericAdaptorBase { |
| 1132 | public: |
| 1133 | struct Properties { |
| 1134 | using unsignedCmpTy = ::mlir::UnitAttr; |
| 1135 | unsignedCmpTy unsignedCmp; |
| 1136 | |
| 1137 | auto getUnsignedCmp() const { |
| 1138 | auto &propStorage = this->unsignedCmp; |
| 1139 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val: propStorage); |
| 1140 | } |
| 1141 | void setUnsignedCmp(const ::mlir::UnitAttr &propValue) { |
| 1142 | this->unsignedCmp = propValue; |
| 1143 | } |
| 1144 | bool operator==(const Properties &rhs) const { |
| 1145 | return |
| 1146 | rhs.unsignedCmp == this->unsignedCmp && |
| 1147 | true; |
| 1148 | } |
| 1149 | bool operator!=(const Properties &rhs) const { |
| 1150 | return !(*this == rhs); |
| 1151 | } |
| 1152 | }; |
| 1153 | protected: |
| 1154 | ::mlir::DictionaryAttr odsAttrs; |
| 1155 | ::std::optional<::mlir::OperationName> odsOpName; |
| 1156 | Properties properties; |
| 1157 | ::mlir::RegionRange odsRegions; |
| 1158 | public: |
| 1159 | ForOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 1160 | odsOpName.emplace(args: "scf.for" , args: odsAttrs.getContext()); |
| 1161 | } |
| 1162 | |
| 1163 | ForOpGenericAdaptorBase(ForOp op); |
| 1164 | |
| 1165 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 1166 | const Properties &getProperties() { |
| 1167 | return properties; |
| 1168 | } |
| 1169 | |
| 1170 | ::mlir::DictionaryAttr getAttributes() { |
| 1171 | return odsAttrs; |
| 1172 | } |
| 1173 | |
| 1174 | ::mlir::UnitAttr getUnsignedCmpAttr(); |
| 1175 | bool getUnsignedCmp(); |
| 1176 | ::mlir::Region &getRegion() { |
| 1177 | return *odsRegions[0]; |
| 1178 | } |
| 1179 | |
| 1180 | ::mlir::RegionRange getRegions() { |
| 1181 | return odsRegions; |
| 1182 | } |
| 1183 | |
| 1184 | }; |
| 1185 | |
| 1186 | } // namespace detail |
| 1187 | template <typename RangeT> |
| 1188 | class ForOpGenericAdaptor : public detail::ForOpGenericAdaptorBase { |
| 1189 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 1190 | using Base = detail::ForOpGenericAdaptorBase; |
| 1191 | static constexpr int odsIndex_lowerBound = 0; |
| 1192 | static constexpr int odsIndex_upperBound = 1; |
| 1193 | static constexpr int odsIndex_step = 2; |
| 1194 | static constexpr int odsIndex_initArgs = 3; |
| 1195 | public: |
| 1196 | ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 1197 | |
| 1198 | ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ForOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 1199 | |
| 1200 | ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ForOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 1201 | |
| 1202 | ForOpGenericAdaptor(RangeT values, const ForOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 1203 | |
| 1204 | template <typename LateInst = ForOp, typename = std::enable_if_t<std::is_same_v<LateInst, ForOp>>> |
| 1205 | ForOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 1206 | |
| 1207 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 1208 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 1209 | } |
| 1210 | |
| 1211 | RangeT getODSOperands(unsigned index) { |
| 1212 | auto valueRange = getODSOperandIndexAndLength(index); |
| 1213 | return {std::next(odsOperands.begin(), valueRange.first), |
| 1214 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 1215 | } |
| 1216 | |
| 1217 | ValueT getLowerBound() { |
| 1218 | return (*getODSOperands(index: 0).begin()); |
| 1219 | } |
| 1220 | |
| 1221 | ValueT getUpperBound() { |
| 1222 | return (*getODSOperands(index: 1).begin()); |
| 1223 | } |
| 1224 | |
| 1225 | ValueT getStep() { |
| 1226 | return (*getODSOperands(index: 2).begin()); |
| 1227 | } |
| 1228 | |
| 1229 | RangeT getInitArgs() { |
| 1230 | return getODSOperands(index: 3); |
| 1231 | } |
| 1232 | |
| 1233 | RangeT getOperands() { |
| 1234 | return odsOperands; |
| 1235 | } |
| 1236 | |
| 1237 | private: |
| 1238 | RangeT odsOperands; |
| 1239 | }; |
| 1240 | class ForOpAdaptor : public ForOpGenericAdaptor<::mlir::ValueRange> { |
| 1241 | public: |
| 1242 | using ForOpGenericAdaptor::ForOpGenericAdaptor; |
| 1243 | ForOpAdaptor(ForOp op); |
| 1244 | |
| 1245 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 1246 | }; |
| 1247 | class ForOp : public ::mlir::Op<ForOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<3>::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { |
| 1248 | public: |
| 1249 | using Op::Op; |
| 1250 | using Op::print; |
| 1251 | using Adaptor = ForOpAdaptor; |
| 1252 | template <typename RangeT> |
| 1253 | using GenericAdaptor = ForOpGenericAdaptor<RangeT>; |
| 1254 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 1255 | static constexpr int odsIndex_lowerBound = 0; |
| 1256 | static constexpr int odsIndex_upperBound = 1; |
| 1257 | static constexpr int odsIndex_step = 2; |
| 1258 | static constexpr int odsIndex_initArgs = 3; |
| 1259 | static constexpr int odsIndex_results = 0; |
| 1260 | using Properties = FoldAdaptor::Properties; |
| 1261 | using ::mlir::LoopLikeOpInterface::Trait<ForOp>::isDefinedOutsideOfLoop; |
| 1262 | using ::mlir::LoopLikeOpInterface::Trait<ForOp>::moveOutOfLoop; |
| 1263 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::getEntrySuccessorRegions; |
| 1264 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::getSuccessorRegions; |
| 1265 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::getPredecessors; |
| 1266 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::getPredecessorValues; |
| 1267 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::getRegionInvocationBounds; |
| 1268 | using ::mlir::RegionBranchOpInterface::Trait<ForOp>::areTypesCompatible; |
| 1269 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 1270 | static ::llvm::StringRef attrNames[] = {::llvm::StringRef("unsignedCmp" )}; |
| 1271 | return ::llvm::ArrayRef(attrNames); |
| 1272 | } |
| 1273 | |
| 1274 | ::mlir::StringAttr getUnsignedCmpAttrName() { |
| 1275 | return getAttributeNameForIndex(index: 0); |
| 1276 | } |
| 1277 | |
| 1278 | static ::mlir::StringAttr getUnsignedCmpAttrName(::mlir::OperationName name) { |
| 1279 | return getAttributeNameForIndex(name, index: 0); |
| 1280 | } |
| 1281 | |
| 1282 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 1283 | return ::llvm::StringLiteral("scf.for" ); |
| 1284 | } |
| 1285 | |
| 1286 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 1287 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 1288 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 1289 | return getOperation()->getOperands().slice(n: start, m: length); |
| 1290 | } |
| 1291 | |
| 1292 | ::mlir::TypedValue<::mlir::Type> getLowerBound() { |
| 1293 | return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(Val: *getODSOperands(index: 0).begin()); |
| 1294 | } |
| 1295 | |
| 1296 | ::mlir::TypedValue<::mlir::Type> getUpperBound() { |
| 1297 | return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(Val: *getODSOperands(index: 1).begin()); |
| 1298 | } |
| 1299 | |
| 1300 | ::mlir::TypedValue<::mlir::Type> getStep() { |
| 1301 | return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(Val: *getODSOperands(index: 2).begin()); |
| 1302 | } |
| 1303 | |
| 1304 | ::mlir::Operation::operand_range getInitArgs() { |
| 1305 | return getODSOperands(index: 3); |
| 1306 | } |
| 1307 | |
| 1308 | ::mlir::OpOperand &getLowerBoundMutable() { |
| 1309 | auto range = getODSOperandIndexAndLength(index: 0); |
| 1310 | return getOperation()->getOpOperand(idx: range.first); |
| 1311 | } |
| 1312 | |
| 1313 | ::mlir::OpOperand &getUpperBoundMutable() { |
| 1314 | auto range = getODSOperandIndexAndLength(index: 1); |
| 1315 | return getOperation()->getOpOperand(idx: range.first); |
| 1316 | } |
| 1317 | |
| 1318 | ::mlir::OpOperand &getStepMutable() { |
| 1319 | auto range = getODSOperandIndexAndLength(index: 2); |
| 1320 | return getOperation()->getOpOperand(idx: range.first); |
| 1321 | } |
| 1322 | |
| 1323 | ::mlir::MutableOperandRange getInitArgsMutable(); |
| 1324 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 1325 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 1326 | auto valueRange = getODSResultIndexAndLength(index); |
| 1327 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 1328 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 1329 | } |
| 1330 | |
| 1331 | ::mlir::Operation::result_range getResults() { |
| 1332 | return getODSResults(index: 0); |
| 1333 | } |
| 1334 | |
| 1335 | ::mlir::Region &getRegion() { |
| 1336 | return (*this)->getRegion(index: 0); |
| 1337 | } |
| 1338 | |
| 1339 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1340 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 1341 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 1342 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 1343 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 1344 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 1345 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1346 | static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); |
| 1347 | void writeProperties(::mlir::DialectBytecodeWriter &writer); |
| 1348 | ::mlir::UnitAttr getUnsignedCmpAttr() { |
| 1349 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val&: getProperties().unsignedCmp); |
| 1350 | } |
| 1351 | |
| 1352 | bool getUnsignedCmp(); |
| 1353 | void setUnsignedCmpAttr(::mlir::UnitAttr attr) { |
| 1354 | getProperties().unsignedCmp = attr; |
| 1355 | } |
| 1356 | |
| 1357 | void setUnsignedCmp(bool attrValue); |
| 1358 | ::mlir::Attribute removeUnsignedCmpAttr() { |
| 1359 | auto attr = getProperties().unsignedCmp; |
| 1360 | getProperties().unsignedCmp = {}; |
| 1361 | return attr; |
| 1362 | } |
| 1363 | |
| 1364 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lowerBound, Value upperBound, Value step, ValueRange initArgs = {}, function_ref<void(OpBuilder &, Location, Value, ValueRange)> odsArg4 = nullptr, bool unsignedCmp = false); |
| 1365 | static ForOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lowerBound, Value upperBound, Value step, ValueRange initArgs = {}, function_ref<void(OpBuilder &, Location, Value, ValueRange)> odsArg4 = nullptr, bool unsignedCmp = false); |
| 1366 | static ForOp create(::mlir::ImplicitLocOpBuilder &builder, Value lowerBound, Value upperBound, Value step, ValueRange initArgs = {}, function_ref<void(OpBuilder &, Location, Value, ValueRange)> odsArg4 = nullptr, bool unsignedCmp = false); |
| 1367 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 1368 | void print(::mlir::OpAsmPrinter &p); |
| 1369 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 1370 | ::llvm::LogicalResult verifyInvariants(); |
| 1371 | ::llvm::LogicalResult verify(); |
| 1372 | ::llvm::LogicalResult verifyRegions(); |
| 1373 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 1374 | ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); |
| 1375 | ::llvm::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter); |
| 1376 | ::std::optional<::llvm::SmallVector<::mlir::Value>> getLoopInductionVars(); |
| 1377 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopLowerBounds(); |
| 1378 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopSteps(); |
| 1379 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopUpperBounds(); |
| 1380 | ::llvm::MutableArrayRef<::mlir::OpOperand> getInitsMutable(); |
| 1381 | ::mlir::Block::BlockArgListType getRegionIterArgs(); |
| 1382 | ::std::optional<::llvm::MutableArrayRef<::mlir::OpOperand>> getYieldedValuesMutable(); |
| 1383 | ::std::optional<::mlir::ResultRange> getLoopResults(); |
| 1384 | ::mlir::FailureOr<::mlir::LoopLikeOpInterface> replaceWithAdditionalYields(::mlir::RewriterBase &rewriter, ::mlir::ValueRange newInitOperands, bool replaceInitOperandUsesInLoop, const ::mlir::NewYieldValuesFn &newYieldValuesFn); |
| 1385 | ::std::optional<::llvm::APInt> getStaticTripCount(); |
| 1386 | bool isValidInductionVarType(::mlir::Type type); |
| 1387 | ::mlir::LogicalResult setLoopLowerBounds(::llvm::ArrayRef<::mlir::OpFoldResult> bounds); |
| 1388 | ::mlir::LogicalResult setLoopUpperBounds(::llvm::ArrayRef<::mlir::OpFoldResult> bounds); |
| 1389 | ::mlir::LogicalResult setLoopSteps(::llvm::ArrayRef<::mlir::OpFoldResult> steps); |
| 1390 | ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionSuccessor successor); |
| 1391 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 1392 | ::mlir::ValueRange getSuccessorInputs(::mlir::RegionSuccessor successor); |
| 1393 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 1394 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 1395 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 1396 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1397 | private: |
| 1398 | ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { |
| 1399 | return getAttributeNameForIndex(name: (*this)->getName(), index); |
| 1400 | } |
| 1401 | |
| 1402 | static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { |
| 1403 | assert(index < 1 && "invalid attribute index" ); |
| 1404 | assert(name.getStringRef() == getOperationName() && "invalid operation name" ); |
| 1405 | assert(name.isRegistered() && "Operation isn't registered, missing a " |
| 1406 | "dependent dialect loading?" ); |
| 1407 | return name.getAttributeNames()[index]; |
| 1408 | } |
| 1409 | |
| 1410 | public: |
| 1411 | using BodyBuilderFn = |
| 1412 | function_ref<void(OpBuilder &, Location, Value, ValueRange)>; |
| 1413 | |
| 1414 | Value getInductionVar() { return getBody()->getArgument(i: 0); } |
| 1415 | |
| 1416 | /// Return the `index`-th region iteration argument. |
| 1417 | BlockArgument getRegionIterArg(unsigned index) { |
| 1418 | assert(index < getNumRegionIterArgs() && |
| 1419 | "expected an index less than the number of region iter args" ); |
| 1420 | return getBody()->getArguments().drop_front(N: getNumInductionVars())[index]; |
| 1421 | } |
| 1422 | |
| 1423 | void setLowerBound(Value bound) { getOperation()->setOperand(idx: 0, value: bound); } |
| 1424 | void setUpperBound(Value bound) { getOperation()->setOperand(idx: 1, value: bound); } |
| 1425 | void setStep(Value step) { getOperation()->setOperand(idx: 2, value: step); } |
| 1426 | |
| 1427 | /// Number of induction variables, always 1 for scf::ForOp. |
| 1428 | unsigned getNumInductionVars() { return 1; } |
| 1429 | /// Number of region arguments for loop-carried values |
| 1430 | unsigned getNumRegionIterArgs() { |
| 1431 | return getBody()->getNumArguments() - getNumInductionVars(); |
| 1432 | } |
| 1433 | /// Number of operands controlling the loop: lb, ub, step |
| 1434 | unsigned getNumControlOperands() { return 3; } |
| 1435 | |
| 1436 | /// Returns the step as an `APInt` if it is constant. |
| 1437 | std::optional<APInt> getConstantStep(); |
| 1438 | |
| 1439 | /// Interface method for ConditionallySpeculatable. |
| 1440 | Speculation::Speculatability getSpeculatability(); |
| 1441 | }; |
| 1442 | |
| 1443 | } // namespace mlir::scf |
| 1444 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForOp) |
| 1445 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::detail::ForOpGenericAdaptorBase::Properties) |
| 1446 | |
| 1447 | namespace mlir::scf { |
| 1448 | |
| 1449 | |
| 1450 | //===----------------------------------------------------------------------===// |
| 1451 | // ::mlir::scf::ForallOp declarations |
| 1452 | //===----------------------------------------------------------------------===// |
| 1453 | |
| 1454 | namespace detail { |
| 1455 | |
| 1456 | class ForallOpGenericAdaptorBase { |
| 1457 | public: |
| 1458 | struct Properties { |
| 1459 | using mappingTy = ::mlir::ArrayAttr; |
| 1460 | mappingTy mapping; |
| 1461 | |
| 1462 | auto getMapping() const { |
| 1463 | auto &propStorage = this->mapping; |
| 1464 | return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(Val: propStorage); |
| 1465 | } |
| 1466 | void setMapping(const ::mlir::ArrayAttr &propValue) { |
| 1467 | this->mapping = propValue; |
| 1468 | } |
| 1469 | using staticLowerBoundTy = ::mlir::DenseI64ArrayAttr; |
| 1470 | staticLowerBoundTy staticLowerBound; |
| 1471 | |
| 1472 | auto getStaticLowerBound() const { |
| 1473 | auto &propStorage = this->staticLowerBound; |
| 1474 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: propStorage); |
| 1475 | } |
| 1476 | void setStaticLowerBound(const ::mlir::DenseI64ArrayAttr &propValue) { |
| 1477 | this->staticLowerBound = propValue; |
| 1478 | } |
| 1479 | using staticStepTy = ::mlir::DenseI64ArrayAttr; |
| 1480 | staticStepTy staticStep; |
| 1481 | |
| 1482 | auto getStaticStep() const { |
| 1483 | auto &propStorage = this->staticStep; |
| 1484 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: propStorage); |
| 1485 | } |
| 1486 | void setStaticStep(const ::mlir::DenseI64ArrayAttr &propValue) { |
| 1487 | this->staticStep = propValue; |
| 1488 | } |
| 1489 | using staticUpperBoundTy = ::mlir::DenseI64ArrayAttr; |
| 1490 | staticUpperBoundTy staticUpperBound; |
| 1491 | |
| 1492 | auto getStaticUpperBound() const { |
| 1493 | auto &propStorage = this->staticUpperBound; |
| 1494 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: propStorage); |
| 1495 | } |
| 1496 | void setStaticUpperBound(const ::mlir::DenseI64ArrayAttr &propValue) { |
| 1497 | this->staticUpperBound = propValue; |
| 1498 | } |
| 1499 | using operandSegmentSizesTy = std::array<int32_t, 4>; |
| 1500 | operandSegmentSizesTy operandSegmentSizes; |
| 1501 | ::llvm::ArrayRef<int32_t> getOperandSegmentSizes() const { |
| 1502 | auto &propStorage = this->operandSegmentSizes; |
| 1503 | return propStorage; |
| 1504 | } |
| 1505 | void setOperandSegmentSizes(::llvm::ArrayRef<int32_t> propValue) { |
| 1506 | auto &propStorage = this->operandSegmentSizes; |
| 1507 | ::llvm::copy(Range&: propValue, Out: propStorage.begin()); |
| 1508 | } |
| 1509 | bool operator==(const Properties &rhs) const { |
| 1510 | return |
| 1511 | rhs.mapping == this->mapping && |
| 1512 | rhs.staticLowerBound == this->staticLowerBound && |
| 1513 | rhs.staticStep == this->staticStep && |
| 1514 | rhs.staticUpperBound == this->staticUpperBound && |
| 1515 | rhs.operandSegmentSizes == this->operandSegmentSizes && |
| 1516 | true; |
| 1517 | } |
| 1518 | bool operator!=(const Properties &rhs) const { |
| 1519 | return !(*this == rhs); |
| 1520 | } |
| 1521 | }; |
| 1522 | protected: |
| 1523 | ::mlir::DictionaryAttr odsAttrs; |
| 1524 | ::std::optional<::mlir::OperationName> odsOpName; |
| 1525 | Properties properties; |
| 1526 | ::mlir::RegionRange odsRegions; |
| 1527 | public: |
| 1528 | ForallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 1529 | odsOpName.emplace(args: "scf.forall" , args: odsAttrs.getContext()); |
| 1530 | } |
| 1531 | |
| 1532 | ForallOpGenericAdaptorBase(ForallOp op); |
| 1533 | |
| 1534 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 1535 | const Properties &getProperties() { |
| 1536 | return properties; |
| 1537 | } |
| 1538 | |
| 1539 | ::mlir::DictionaryAttr getAttributes() { |
| 1540 | return odsAttrs; |
| 1541 | } |
| 1542 | |
| 1543 | ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr() { |
| 1544 | auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: getProperties().staticLowerBound); |
| 1545 | return attr; |
| 1546 | } |
| 1547 | |
| 1548 | ::llvm::ArrayRef<int64_t> getStaticLowerBound(); |
| 1549 | ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr() { |
| 1550 | auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: getProperties().staticUpperBound); |
| 1551 | return attr; |
| 1552 | } |
| 1553 | |
| 1554 | ::llvm::ArrayRef<int64_t> getStaticUpperBound(); |
| 1555 | ::mlir::DenseI64ArrayAttr getStaticStepAttr() { |
| 1556 | auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: getProperties().staticStep); |
| 1557 | return attr; |
| 1558 | } |
| 1559 | |
| 1560 | ::llvm::ArrayRef<int64_t> getStaticStep(); |
| 1561 | ::mlir::ArrayAttr getMappingAttr() { |
| 1562 | auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(Val: getProperties().mapping); |
| 1563 | return attr; |
| 1564 | } |
| 1565 | |
| 1566 | ::std::optional< ::mlir::ArrayAttr > getMapping(); |
| 1567 | ::mlir::Region &getRegion() { |
| 1568 | return *odsRegions[0]; |
| 1569 | } |
| 1570 | |
| 1571 | ::mlir::RegionRange getRegions() { |
| 1572 | return odsRegions; |
| 1573 | } |
| 1574 | |
| 1575 | }; |
| 1576 | |
| 1577 | } // namespace detail |
| 1578 | template <typename RangeT> |
| 1579 | class ForallOpGenericAdaptor : public detail::ForallOpGenericAdaptorBase { |
| 1580 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 1581 | using Base = detail::ForallOpGenericAdaptorBase; |
| 1582 | static constexpr int odsIndex_dynamicLowerBound = 0; |
| 1583 | static constexpr int odsIndex_dynamicUpperBound = 1; |
| 1584 | static constexpr int odsIndex_dynamicStep = 2; |
| 1585 | static constexpr int odsIndex_outputs = 3; |
| 1586 | public: |
| 1587 | ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 1588 | |
| 1589 | ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ForallOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 1590 | |
| 1591 | ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs) : ForallOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 1592 | |
| 1593 | ForallOpGenericAdaptor(RangeT values, const ForallOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 1594 | |
| 1595 | template <typename LateInst = ForallOp, typename = std::enable_if_t<std::is_same_v<LateInst, ForallOp>>> |
| 1596 | ForallOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 1597 | |
| 1598 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 1599 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 1600 | } |
| 1601 | |
| 1602 | RangeT getODSOperands(unsigned index) { |
| 1603 | auto valueRange = getODSOperandIndexAndLength(index); |
| 1604 | return {std::next(odsOperands.begin(), valueRange.first), |
| 1605 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 1606 | } |
| 1607 | |
| 1608 | RangeT getDynamicLowerBound() { |
| 1609 | return getODSOperands(index: 0); |
| 1610 | } |
| 1611 | |
| 1612 | RangeT getDynamicUpperBound() { |
| 1613 | return getODSOperands(index: 1); |
| 1614 | } |
| 1615 | |
| 1616 | RangeT getDynamicStep() { |
| 1617 | return getODSOperands(index: 2); |
| 1618 | } |
| 1619 | |
| 1620 | RangeT getOutputs() { |
| 1621 | return getODSOperands(index: 3); |
| 1622 | } |
| 1623 | |
| 1624 | RangeT getOperands() { |
| 1625 | return odsOperands; |
| 1626 | } |
| 1627 | |
| 1628 | private: |
| 1629 | RangeT odsOperands; |
| 1630 | }; |
| 1631 | class ForallOpAdaptor : public ForallOpGenericAdaptor<::mlir::ValueRange> { |
| 1632 | public: |
| 1633 | using ForallOpGenericAdaptor::ForallOpGenericAdaptor; |
| 1634 | ForallOpAdaptor(ForallOp op); |
| 1635 | |
| 1636 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 1637 | }; |
| 1638 | class ForallOp : public ::mlir::Op<ForallOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::InParallelOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait, ::mlir::OpTrait::HasParallelRegion> { |
| 1639 | public: |
| 1640 | using Op::Op; |
| 1641 | using Op::print; |
| 1642 | using Adaptor = ForallOpAdaptor; |
| 1643 | template <typename RangeT> |
| 1644 | using GenericAdaptor = ForallOpGenericAdaptor<RangeT>; |
| 1645 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 1646 | static constexpr int odsIndex_dynamicLowerBound = 0; |
| 1647 | static constexpr int odsIndex_dynamicUpperBound = 1; |
| 1648 | static constexpr int odsIndex_dynamicStep = 2; |
| 1649 | static constexpr int odsIndex_outputs = 3; |
| 1650 | static constexpr int odsIndex_results = 0; |
| 1651 | using Properties = FoldAdaptor::Properties; |
| 1652 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::isDefinedOutsideOfLoop; |
| 1653 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::moveOutOfLoop; |
| 1654 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::getYieldedValuesMutable; |
| 1655 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::getLoopResults; |
| 1656 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::replaceWithAdditionalYields; |
| 1657 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::getStaticTripCount; |
| 1658 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::isValidInductionVarType; |
| 1659 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::setLoopLowerBounds; |
| 1660 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::setLoopUpperBounds; |
| 1661 | using ::mlir::LoopLikeOpInterface::Trait<ForallOp>::setLoopSteps; |
| 1662 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getEntrySuccessorOperands; |
| 1663 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getEntrySuccessorRegions; |
| 1664 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getSuccessorRegions; |
| 1665 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getSuccessorInputs; |
| 1666 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getPredecessors; |
| 1667 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getPredecessorValues; |
| 1668 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::getRegionInvocationBounds; |
| 1669 | using ::mlir::RegionBranchOpInterface::Trait<ForallOp>::areTypesCompatible; |
| 1670 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 1671 | static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mapping" ), ::llvm::StringRef("staticLowerBound" ), ::llvm::StringRef("staticStep" ), ::llvm::StringRef("staticUpperBound" ), ::llvm::StringRef("operandSegmentSizes" )}; |
| 1672 | return ::llvm::ArrayRef(attrNames); |
| 1673 | } |
| 1674 | |
| 1675 | ::mlir::StringAttr getMappingAttrName() { |
| 1676 | return getAttributeNameForIndex(index: 0); |
| 1677 | } |
| 1678 | |
| 1679 | static ::mlir::StringAttr getMappingAttrName(::mlir::OperationName name) { |
| 1680 | return getAttributeNameForIndex(name, index: 0); |
| 1681 | } |
| 1682 | |
| 1683 | ::mlir::StringAttr getStaticLowerBoundAttrName() { |
| 1684 | return getAttributeNameForIndex(index: 1); |
| 1685 | } |
| 1686 | |
| 1687 | static ::mlir::StringAttr getStaticLowerBoundAttrName(::mlir::OperationName name) { |
| 1688 | return getAttributeNameForIndex(name, index: 1); |
| 1689 | } |
| 1690 | |
| 1691 | ::mlir::StringAttr getStaticStepAttrName() { |
| 1692 | return getAttributeNameForIndex(index: 2); |
| 1693 | } |
| 1694 | |
| 1695 | static ::mlir::StringAttr getStaticStepAttrName(::mlir::OperationName name) { |
| 1696 | return getAttributeNameForIndex(name, index: 2); |
| 1697 | } |
| 1698 | |
| 1699 | ::mlir::StringAttr getStaticUpperBoundAttrName() { |
| 1700 | return getAttributeNameForIndex(index: 3); |
| 1701 | } |
| 1702 | |
| 1703 | static ::mlir::StringAttr getStaticUpperBoundAttrName(::mlir::OperationName name) { |
| 1704 | return getAttributeNameForIndex(name, index: 3); |
| 1705 | } |
| 1706 | |
| 1707 | ::mlir::StringAttr getOperandSegmentSizesAttrName() { |
| 1708 | return (*this)->getName().getAttributeNames().back(); |
| 1709 | } |
| 1710 | |
| 1711 | static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { |
| 1712 | return name.getAttributeNames().back(); |
| 1713 | } |
| 1714 | |
| 1715 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 1716 | return ::llvm::StringLiteral("scf.forall" ); |
| 1717 | } |
| 1718 | |
| 1719 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 1720 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 1721 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 1722 | return getOperation()->getOperands().slice(n: start, m: length); |
| 1723 | } |
| 1724 | |
| 1725 | ::mlir::Operation::operand_range getDynamicLowerBound() { |
| 1726 | return getODSOperands(index: 0); |
| 1727 | } |
| 1728 | |
| 1729 | ::mlir::Operation::operand_range getDynamicUpperBound() { |
| 1730 | return getODSOperands(index: 1); |
| 1731 | } |
| 1732 | |
| 1733 | ::mlir::Operation::operand_range getDynamicStep() { |
| 1734 | return getODSOperands(index: 2); |
| 1735 | } |
| 1736 | |
| 1737 | ::mlir::Operation::operand_range getOutputs() { |
| 1738 | return getODSOperands(index: 3); |
| 1739 | } |
| 1740 | |
| 1741 | ::mlir::MutableOperandRange getDynamicLowerBoundMutable(); |
| 1742 | ::mlir::MutableOperandRange getDynamicUpperBoundMutable(); |
| 1743 | ::mlir::MutableOperandRange getDynamicStepMutable(); |
| 1744 | ::mlir::MutableOperandRange getOutputsMutable(); |
| 1745 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 1746 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 1747 | auto valueRange = getODSResultIndexAndLength(index); |
| 1748 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 1749 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 1750 | } |
| 1751 | |
| 1752 | ::mlir::Operation::result_range getResults() { |
| 1753 | return getODSResults(index: 0); |
| 1754 | } |
| 1755 | |
| 1756 | ::mlir::Region &getRegion() { |
| 1757 | return (*this)->getRegion(index: 0); |
| 1758 | } |
| 1759 | |
| 1760 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1761 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 1762 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 1763 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 1764 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 1765 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 1766 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1767 | static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); |
| 1768 | void writeProperties(::mlir::DialectBytecodeWriter &writer); |
| 1769 | ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr() { |
| 1770 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val&: getProperties().staticLowerBound); |
| 1771 | } |
| 1772 | |
| 1773 | ::llvm::ArrayRef<int64_t> getStaticLowerBound(); |
| 1774 | ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr() { |
| 1775 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val&: getProperties().staticUpperBound); |
| 1776 | } |
| 1777 | |
| 1778 | ::llvm::ArrayRef<int64_t> getStaticUpperBound(); |
| 1779 | ::mlir::DenseI64ArrayAttr getStaticStepAttr() { |
| 1780 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val&: getProperties().staticStep); |
| 1781 | } |
| 1782 | |
| 1783 | ::llvm::ArrayRef<int64_t> getStaticStep(); |
| 1784 | ::mlir::ArrayAttr getMappingAttr() { |
| 1785 | return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(Val&: getProperties().mapping); |
| 1786 | } |
| 1787 | |
| 1788 | ::std::optional< ::mlir::ArrayAttr > getMapping(); |
| 1789 | void setStaticLowerBoundAttr(::mlir::DenseI64ArrayAttr attr) { |
| 1790 | getProperties().staticLowerBound = attr; |
| 1791 | } |
| 1792 | |
| 1793 | void setStaticLowerBound(::llvm::ArrayRef<int64_t> attrValue); |
| 1794 | void setStaticUpperBoundAttr(::mlir::DenseI64ArrayAttr attr) { |
| 1795 | getProperties().staticUpperBound = attr; |
| 1796 | } |
| 1797 | |
| 1798 | void setStaticUpperBound(::llvm::ArrayRef<int64_t> attrValue); |
| 1799 | void setStaticStepAttr(::mlir::DenseI64ArrayAttr attr) { |
| 1800 | getProperties().staticStep = attr; |
| 1801 | } |
| 1802 | |
| 1803 | void setStaticStep(::llvm::ArrayRef<int64_t> attrValue); |
| 1804 | void setMappingAttr(::mlir::ArrayAttr attr) { |
| 1805 | getProperties().mapping = attr; |
| 1806 | } |
| 1807 | |
| 1808 | ::mlir::Attribute removeMappingAttr() { |
| 1809 | auto attr = getProperties().mapping; |
| 1810 | getProperties().mapping = {}; |
| 1811 | return attr; |
| 1812 | } |
| 1813 | |
| 1814 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef<OpFoldResult> lbs, ArrayRef<OpFoldResult> ubs, ArrayRef<OpFoldResult> steps, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1815 | static ForallOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef<OpFoldResult> lbs, ArrayRef<OpFoldResult> ubs, ArrayRef<OpFoldResult> steps, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1816 | static ForallOp create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef<OpFoldResult> lbs, ArrayRef<OpFoldResult> ubs, ArrayRef<OpFoldResult> steps, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1817 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef<OpFoldResult> ubs, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1818 | static ForallOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef<OpFoldResult> ubs, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1819 | static ForallOp create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef<OpFoldResult> ubs, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr); |
| 1820 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 1821 | void print(::mlir::OpAsmPrinter &p); |
| 1822 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 1823 | ::llvm::LogicalResult verifyInvariants(); |
| 1824 | ::llvm::LogicalResult verify(); |
| 1825 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 1826 | ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); |
| 1827 | ::llvm::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter); |
| 1828 | ::std::optional<::llvm::SmallVector<::mlir::Value>> getLoopInductionVars(); |
| 1829 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopLowerBounds(); |
| 1830 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopSteps(); |
| 1831 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopUpperBounds(); |
| 1832 | ::llvm::MutableArrayRef<::mlir::OpOperand> getInitsMutable(); |
| 1833 | ::mlir::Block::BlockArgListType getRegionIterArgs(); |
| 1834 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 1835 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 1836 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 1837 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 1838 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 1839 | private: |
| 1840 | ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { |
| 1841 | return getAttributeNameForIndex(name: (*this)->getName(), index); |
| 1842 | } |
| 1843 | |
| 1844 | static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { |
| 1845 | assert(index < 4 && "invalid attribute index" ); |
| 1846 | assert(name.getStringRef() == getOperationName() && "invalid operation name" ); |
| 1847 | assert(name.isRegistered() && "Operation isn't registered, missing a " |
| 1848 | "dependent dialect loading?" ); |
| 1849 | return name.getAttributeNames()[index]; |
| 1850 | } |
| 1851 | |
| 1852 | public: |
| 1853 | /// Get induction variables. |
| 1854 | SmallVector<Value> getInductionVars() { |
| 1855 | std::optional<SmallVector<Value>> maybeInductionVars = getLoopInductionVars(); |
| 1856 | assert(maybeInductionVars.has_value() && "expected values" ); |
| 1857 | return *maybeInductionVars; |
| 1858 | } |
| 1859 | /// Get lower bounds as OpFoldResult. |
| 1860 | SmallVector<OpFoldResult> getMixedLowerBound() { |
| 1861 | std::optional<SmallVector<OpFoldResult>> maybeLowerBounds = getLoopLowerBounds(); |
| 1862 | assert(maybeLowerBounds.has_value() && "expected values" ); |
| 1863 | return *maybeLowerBounds; |
| 1864 | } |
| 1865 | |
| 1866 | /// Get upper bounds as OpFoldResult. |
| 1867 | SmallVector<OpFoldResult> getMixedUpperBound() { |
| 1868 | std::optional<SmallVector<OpFoldResult>> maybeUpperBounds = getLoopUpperBounds(); |
| 1869 | assert(maybeUpperBounds.has_value() && "expected values" ); |
| 1870 | return *maybeUpperBounds; |
| 1871 | } |
| 1872 | |
| 1873 | /// Get steps as OpFoldResult. |
| 1874 | SmallVector<OpFoldResult> getMixedStep() { |
| 1875 | std::optional<SmallVector<OpFoldResult>> maybeSteps = getLoopSteps(); |
| 1876 | assert(maybeSteps.has_value() && "expected values" ); |
| 1877 | return *maybeSteps; |
| 1878 | } |
| 1879 | |
| 1880 | /// Get lower bounds as values. |
| 1881 | SmallVector<Value> getLowerBound(OpBuilder &b) { |
| 1882 | return getValueOrCreateConstantIndexOp(b, loc: getLoc(), valueOrAttrVec: getMixedLowerBound()); |
| 1883 | } |
| 1884 | |
| 1885 | /// Get upper bounds as values. |
| 1886 | SmallVector<Value> getUpperBound(OpBuilder &b) { |
| 1887 | return getValueOrCreateConstantIndexOp(b, loc: getLoc(), valueOrAttrVec: getMixedUpperBound()); |
| 1888 | } |
| 1889 | |
| 1890 | /// Get steps as values. |
| 1891 | SmallVector<Value> getStep(OpBuilder &b) { |
| 1892 | return getValueOrCreateConstantIndexOp(b, loc: getLoc(), valueOrAttrVec: getMixedStep()); |
| 1893 | } |
| 1894 | |
| 1895 | int64_t getRank() { return getStaticLowerBound().size(); } |
| 1896 | |
| 1897 | /// Number of operands controlling the loop: lbs, ubs, steps |
| 1898 | unsigned getNumControlOperands() { return 3 * getRank(); } |
| 1899 | |
| 1900 | /// Number of dynamic operands controlling the loop: lbs, ubs, steps |
| 1901 | unsigned getNumDynamicControlOperands() { |
| 1902 | return getODSOperandIndexAndLength(index: 3).first; |
| 1903 | } |
| 1904 | |
| 1905 | OpResult getTiedOpResult(OpOperand *opOperand) { |
| 1906 | assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() && |
| 1907 | "invalid operand" ); |
| 1908 | return getOperation()->getOpResult( |
| 1909 | idx: opOperand->getOperandNumber() - getNumDynamicControlOperands()); |
| 1910 | } |
| 1911 | |
| 1912 | /// Return the num_threads operand that is tied to the given thread id |
| 1913 | /// block argument. |
| 1914 | OpOperand *getTiedOpOperand(BlockArgument bbArg) { |
| 1915 | assert(bbArg.getArgNumber() >= getRank() && "invalid bbArg" ); |
| 1916 | |
| 1917 | return &getOperation()->getOpOperand(idx: getNumDynamicControlOperands() + |
| 1918 | bbArg.getArgNumber() - getRank()); |
| 1919 | } |
| 1920 | |
| 1921 | /// Return the shared_outs operand that is tied to the given OpResult. |
| 1922 | OpOperand *getTiedOpOperand(OpResult opResult) { |
| 1923 | assert(opResult.getDefiningOp() == getOperation() && "invalid OpResult" ); |
| 1924 | return &getOperation()->getOpOperand(idx: getNumDynamicControlOperands() + |
| 1925 | opResult.getResultNumber()); |
| 1926 | } |
| 1927 | |
| 1928 | BlockArgument getTiedBlockArgument(OpOperand *opOperand) { |
| 1929 | assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() && |
| 1930 | "invalid operand" ); |
| 1931 | |
| 1932 | return getBody()->getArgument(i: opOperand->getOperandNumber() - |
| 1933 | getNumDynamicControlOperands() + getRank()); |
| 1934 | } |
| 1935 | |
| 1936 | BlockArgument getTiedBlockArgument(OpResult opResult) { |
| 1937 | assert(opResult.getDefiningOp() == getOperation() && "invalid OpResult" ); |
| 1938 | return getBody()->getArgument(i: getRank() + opResult.getResultNumber()); |
| 1939 | } |
| 1940 | |
| 1941 | ::mlir::Value getInductionVar(int64_t idx) { |
| 1942 | return getInductionVars()[idx]; |
| 1943 | } |
| 1944 | |
| 1945 | ::mlir::Block::BlockArgListType getRegionOutArgs() { |
| 1946 | return getBody()->getArguments().drop_front(N: getRank()); |
| 1947 | } |
| 1948 | |
| 1949 | /// Checks if the lbs are zeros and steps are ones. |
| 1950 | bool isNormalized(); |
| 1951 | |
| 1952 | InParallelOp getTerminator(); |
| 1953 | |
| 1954 | // Declare the shared_outs as inits/outs to DestinationStyleOpInterface. |
| 1955 | MutableOperandRange getDpsInitsMutable() { return getOutputsMutable(); } |
| 1956 | |
| 1957 | /// Returns operations within scf.forall.in_parallel whose destination |
| 1958 | /// operand is the block argument `bbArg`. |
| 1959 | SmallVector<Operation*> getCombiningOps(BlockArgument bbArg); |
| 1960 | |
| 1961 | /// Returns the subset of DeviceMappingArrayAttrs of type |
| 1962 | /// DeviceMappingAttrInterface. |
| 1963 | SmallVector<DeviceMappingAttrInterface> getDeviceMappingAttrs(); |
| 1964 | |
| 1965 | /// Returns the at most one DeviceMaskingAttrInterface in the mapping. |
| 1966 | /// If more than one DeviceMaskingAttrInterface is specified, returns |
| 1967 | /// failure. If no mapping is present, returns nullptr. |
| 1968 | FailureOr<DeviceMaskingAttrInterface> getDeviceMaskingAttr(); |
| 1969 | |
| 1970 | /// Returns true if the mapping specified for this forall op is linear. |
| 1971 | bool usesLinearMapping(); |
| 1972 | }; |
| 1973 | |
| 1974 | } // namespace mlir::scf |
| 1975 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForallOp) |
| 1976 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::detail::ForallOpGenericAdaptorBase::Properties) |
| 1977 | |
| 1978 | namespace mlir::scf { |
| 1979 | |
| 1980 | |
| 1981 | //===----------------------------------------------------------------------===// |
| 1982 | // ::mlir::scf::IfOp declarations |
| 1983 | //===----------------------------------------------------------------------===// |
| 1984 | |
| 1985 | namespace detail { |
| 1986 | |
| 1987 | class IfOpGenericAdaptorBase { |
| 1988 | public: |
| 1989 | using Properties = ::mlir::EmptyProperties; |
| 1990 | protected: |
| 1991 | ::mlir::DictionaryAttr odsAttrs; |
| 1992 | ::std::optional<::mlir::OperationName> odsOpName; |
| 1993 | Properties properties; |
| 1994 | ::mlir::RegionRange odsRegions; |
| 1995 | public: |
| 1996 | IfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 1997 | odsOpName.emplace(args: "scf.if" , args: odsAttrs.getContext()); |
| 1998 | } |
| 1999 | |
| 2000 | IfOpGenericAdaptorBase(IfOp op); |
| 2001 | |
| 2002 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 2003 | return {index, 1}; |
| 2004 | } |
| 2005 | |
| 2006 | const Properties &getProperties() { |
| 2007 | return properties; |
| 2008 | } |
| 2009 | |
| 2010 | ::mlir::DictionaryAttr getAttributes() { |
| 2011 | return odsAttrs; |
| 2012 | } |
| 2013 | |
| 2014 | ::mlir::Region &getThenRegion() { |
| 2015 | return *odsRegions[0]; |
| 2016 | } |
| 2017 | |
| 2018 | ::mlir::Region &getElseRegion() { |
| 2019 | return *odsRegions[1]; |
| 2020 | } |
| 2021 | |
| 2022 | ::mlir::RegionRange getRegions() { |
| 2023 | return odsRegions; |
| 2024 | } |
| 2025 | |
| 2026 | }; |
| 2027 | |
| 2028 | } // namespace detail |
| 2029 | template <typename RangeT> |
| 2030 | class IfOpGenericAdaptor : public detail::IfOpGenericAdaptorBase { |
| 2031 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 2032 | using Base = detail::IfOpGenericAdaptorBase; |
| 2033 | static constexpr int odsIndex_condition = 0; |
| 2034 | public: |
| 2035 | IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 2036 | |
| 2037 | IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : IfOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 2038 | |
| 2039 | IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IfOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 2040 | |
| 2041 | IfOpGenericAdaptor(RangeT values, const IfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 2042 | |
| 2043 | template <typename LateInst = IfOp, typename = std::enable_if_t<std::is_same_v<LateInst, IfOp>>> |
| 2044 | IfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 2045 | |
| 2046 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2047 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 2048 | } |
| 2049 | |
| 2050 | RangeT getODSOperands(unsigned index) { |
| 2051 | auto valueRange = getODSOperandIndexAndLength(index); |
| 2052 | return {std::next(odsOperands.begin(), valueRange.first), |
| 2053 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 2054 | } |
| 2055 | |
| 2056 | ValueT getCondition() { |
| 2057 | return (*getODSOperands(index: 0).begin()); |
| 2058 | } |
| 2059 | |
| 2060 | RangeT getOperands() { |
| 2061 | return odsOperands; |
| 2062 | } |
| 2063 | |
| 2064 | private: |
| 2065 | RangeT odsOperands; |
| 2066 | }; |
| 2067 | class IfOpAdaptor : public IfOpGenericAdaptor<::mlir::ValueRange> { |
| 2068 | public: |
| 2069 | using IfOpGenericAdaptor::IfOpGenericAdaptor; |
| 2070 | IfOpAdaptor(IfOp op); |
| 2071 | |
| 2072 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 2073 | }; |
| 2074 | class IfOp : public ::mlir::Op<IfOp, ::mlir::OpTrait::NRegions<2>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::NoRegionArguments, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::RecursivelySpeculatableImplTrait> { |
| 2075 | public: |
| 2076 | using Op::Op; |
| 2077 | using Op::print; |
| 2078 | using Adaptor = IfOpAdaptor; |
| 2079 | template <typename RangeT> |
| 2080 | using GenericAdaptor = IfOpGenericAdaptor<RangeT>; |
| 2081 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 2082 | static constexpr int odsIndex_condition = 0; |
| 2083 | static constexpr int odsIndex_results = 0; |
| 2084 | using Properties = FoldAdaptor::Properties; |
| 2085 | using ::mlir::RegionBranchOpInterface::Trait<IfOp>::getEntrySuccessorOperands; |
| 2086 | using ::mlir::RegionBranchOpInterface::Trait<IfOp>::getSuccessorRegions; |
| 2087 | using ::mlir::RegionBranchOpInterface::Trait<IfOp>::getPredecessors; |
| 2088 | using ::mlir::RegionBranchOpInterface::Trait<IfOp>::getPredecessorValues; |
| 2089 | using ::mlir::RegionBranchOpInterface::Trait<IfOp>::areTypesCompatible; |
| 2090 | using ::mlir::InferTypeOpInterface::Trait<IfOp>::refineReturnTypes; |
| 2091 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 2092 | return {}; |
| 2093 | } |
| 2094 | |
| 2095 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 2096 | return ::llvm::StringLiteral("scf.if" ); |
| 2097 | } |
| 2098 | |
| 2099 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2100 | return {index, 1}; |
| 2101 | } |
| 2102 | |
| 2103 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 2104 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 2105 | return getOperation()->getOperands().slice(n: start, m: length); |
| 2106 | } |
| 2107 | |
| 2108 | ::mlir::TypedValue<::mlir::IntegerType> getCondition() { |
| 2109 | return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(Val: *getODSOperands(index: 0).begin()); |
| 2110 | } |
| 2111 | |
| 2112 | ::mlir::OpOperand &getConditionMutable() { |
| 2113 | auto range = getODSOperandIndexAndLength(index: 0); |
| 2114 | return getOperation()->getOpOperand(idx: range.first); |
| 2115 | } |
| 2116 | |
| 2117 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 2118 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 2119 | auto valueRange = getODSResultIndexAndLength(index); |
| 2120 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 2121 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 2122 | } |
| 2123 | |
| 2124 | ::mlir::Operation::result_range getResults() { |
| 2125 | return getODSResults(index: 0); |
| 2126 | } |
| 2127 | |
| 2128 | ::mlir::Region &getThenRegion() { |
| 2129 | return (*this)->getRegion(index: 0); |
| 2130 | } |
| 2131 | |
| 2132 | ::mlir::Region &getElseRegion() { |
| 2133 | return (*this)->getRegion(index: 1); |
| 2134 | } |
| 2135 | |
| 2136 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2137 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 2138 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 2139 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 2140 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 2141 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 2142 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2143 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond); |
| 2144 | static IfOp create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange resultTypes, Value cond); |
| 2145 | static IfOp create(::mlir::ImplicitLocOpBuilder &builder, TypeRange resultTypes, Value cond); |
| 2146 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool addThenBlock, bool addElseBlock); |
| 2147 | static IfOp create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange resultTypes, Value cond, bool addThenBlock, bool addElseBlock); |
| 2148 | static IfOp create(::mlir::ImplicitLocOpBuilder &builder, TypeRange resultTypes, Value cond, bool addThenBlock, bool addElseBlock); |
| 2149 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, bool withElseRegion); |
| 2150 | static IfOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Value cond, bool withElseRegion); |
| 2151 | static IfOp create(::mlir::ImplicitLocOpBuilder &builder, Value cond, bool withElseRegion); |
| 2152 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool withElseRegion); |
| 2153 | static IfOp create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange resultTypes, Value cond, bool withElseRegion); |
| 2154 | static IfOp create(::mlir::ImplicitLocOpBuilder &builder, TypeRange resultTypes, Value cond, bool withElseRegion); |
| 2155 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, function_ref<void(OpBuilder &, Location)> thenBuilder = buildTerminatedBody, function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr); |
| 2156 | static IfOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Value cond, function_ref<void(OpBuilder &, Location)> thenBuilder = buildTerminatedBody, function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr); |
| 2157 | static IfOp create(::mlir::ImplicitLocOpBuilder &builder, Value cond, function_ref<void(OpBuilder &, Location)> thenBuilder = buildTerminatedBody, function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr); |
| 2158 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 2159 | void print(::mlir::OpAsmPrinter &p); |
| 2160 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 2161 | ::llvm::LogicalResult verifyInvariants(); |
| 2162 | ::llvm::LogicalResult verify(); |
| 2163 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 2164 | ::llvm::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); |
| 2165 | void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 2166 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 2167 | ::mlir::ValueRange getSuccessorInputs(::mlir::RegionSuccessor successor); |
| 2168 | void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); |
| 2169 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 2170 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 2171 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 2172 | static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); |
| 2173 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2174 | public: |
| 2175 | static ::llvm::LogicalResult |
| 2176 | inferReturnTypes(::mlir::MLIRContext *context, |
| 2177 | std::optional<::mlir::Location> location, |
| 2178 | Adaptor adaptor, |
| 2179 | ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); |
| 2180 | |
| 2181 | |
| 2182 | OpBuilder getThenBodyBuilder(OpBuilder::Listener *listener = nullptr) { |
| 2183 | Block* body = getBody(idx: 0); |
| 2184 | return getResults().empty() ? OpBuilder::atBlockTerminator(block: body, listener) |
| 2185 | : OpBuilder::atBlockEnd(block: body, listener); |
| 2186 | } |
| 2187 | OpBuilder getElseBodyBuilder(OpBuilder::Listener *listener = nullptr) { |
| 2188 | Block* body = getBody(idx: 1); |
| 2189 | return getResults().empty() ? OpBuilder::atBlockTerminator(block: body, listener) |
| 2190 | : OpBuilder::atBlockEnd(block: body, listener); |
| 2191 | } |
| 2192 | Block* thenBlock(); |
| 2193 | YieldOp thenYield(); |
| 2194 | Block* elseBlock(); |
| 2195 | YieldOp elseYield(); |
| 2196 | }; |
| 2197 | |
| 2198 | } // namespace mlir::scf |
| 2199 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IfOp) |
| 2200 | |
| 2201 | namespace mlir::scf { |
| 2202 | |
| 2203 | |
| 2204 | //===----------------------------------------------------------------------===// |
| 2205 | // ::mlir::scf::InParallelOp declarations |
| 2206 | //===----------------------------------------------------------------------===// |
| 2207 | |
| 2208 | namespace detail { |
| 2209 | |
| 2210 | class InParallelOpGenericAdaptorBase { |
| 2211 | public: |
| 2212 | using Properties = ::mlir::EmptyProperties; |
| 2213 | protected: |
| 2214 | ::mlir::DictionaryAttr odsAttrs; |
| 2215 | ::std::optional<::mlir::OperationName> odsOpName; |
| 2216 | Properties properties; |
| 2217 | ::mlir::RegionRange odsRegions; |
| 2218 | public: |
| 2219 | InParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 2220 | odsOpName.emplace(args: "scf.forall.in_parallel" , args: odsAttrs.getContext()); |
| 2221 | } |
| 2222 | |
| 2223 | InParallelOpGenericAdaptorBase(InParallelOp op); |
| 2224 | |
| 2225 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 2226 | return {index, 1}; |
| 2227 | } |
| 2228 | |
| 2229 | const Properties &getProperties() { |
| 2230 | return properties; |
| 2231 | } |
| 2232 | |
| 2233 | ::mlir::DictionaryAttr getAttributes() { |
| 2234 | return odsAttrs; |
| 2235 | } |
| 2236 | |
| 2237 | ::mlir::Region &getRegion() { |
| 2238 | return *odsRegions[0]; |
| 2239 | } |
| 2240 | |
| 2241 | ::mlir::RegionRange getRegions() { |
| 2242 | return odsRegions; |
| 2243 | } |
| 2244 | |
| 2245 | }; |
| 2246 | |
| 2247 | } // namespace detail |
| 2248 | template <typename RangeT> |
| 2249 | class InParallelOpGenericAdaptor : public detail::InParallelOpGenericAdaptorBase { |
| 2250 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 2251 | using Base = detail::InParallelOpGenericAdaptorBase; |
| 2252 | public: |
| 2253 | InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 2254 | |
| 2255 | InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : InParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 2256 | |
| 2257 | InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : InParallelOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 2258 | |
| 2259 | InParallelOpGenericAdaptor(RangeT values, const InParallelOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 2260 | |
| 2261 | template <typename LateInst = InParallelOp, typename = std::enable_if_t<std::is_same_v<LateInst, InParallelOp>>> |
| 2262 | InParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 2263 | |
| 2264 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2265 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 2266 | } |
| 2267 | |
| 2268 | RangeT getODSOperands(unsigned index) { |
| 2269 | auto valueRange = getODSOperandIndexAndLength(index); |
| 2270 | return {std::next(odsOperands.begin(), valueRange.first), |
| 2271 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 2272 | } |
| 2273 | |
| 2274 | RangeT getOperands() { |
| 2275 | return odsOperands; |
| 2276 | } |
| 2277 | |
| 2278 | private: |
| 2279 | RangeT odsOperands; |
| 2280 | }; |
| 2281 | class InParallelOpAdaptor : public InParallelOpGenericAdaptor<::mlir::ValueRange> { |
| 2282 | public: |
| 2283 | using InParallelOpGenericAdaptor::InParallelOpGenericAdaptor; |
| 2284 | InParallelOpAdaptor(InParallelOp op); |
| 2285 | |
| 2286 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 2287 | }; |
| 2288 | class InParallelOp : public ::mlir::Op<InParallelOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::HasParent<ForallOp>::Impl, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator, ::mlir::InParallelOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::RegionKindInterface::Trait, ::mlir::OpTrait::HasOnlyGraphRegion> { |
| 2289 | public: |
| 2290 | using Op::Op; |
| 2291 | using Op::print; |
| 2292 | using Adaptor = InParallelOpAdaptor; |
| 2293 | template <typename RangeT> |
| 2294 | using GenericAdaptor = InParallelOpGenericAdaptor<RangeT>; |
| 2295 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 2296 | using Properties = FoldAdaptor::Properties; |
| 2297 | using ::mlir::RegionBranchTerminatorOpInterface::Trait<InParallelOp>::getMutableSuccessorOperands; |
| 2298 | using ::mlir::RegionBranchTerminatorOpInterface::Trait<InParallelOp>::getSuccessorRegions; |
| 2299 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 2300 | return {}; |
| 2301 | } |
| 2302 | |
| 2303 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 2304 | return ::llvm::StringLiteral("scf.forall.in_parallel" ); |
| 2305 | } |
| 2306 | |
| 2307 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2308 | return {index, 1}; |
| 2309 | } |
| 2310 | |
| 2311 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 2312 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 2313 | return getOperation()->getOperands().slice(n: start, m: length); |
| 2314 | } |
| 2315 | |
| 2316 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index) { |
| 2317 | return {index, 1}; |
| 2318 | } |
| 2319 | |
| 2320 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 2321 | auto valueRange = getODSResultIndexAndLength(index); |
| 2322 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 2323 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 2324 | } |
| 2325 | |
| 2326 | ::mlir::Region &getRegion() { |
| 2327 | return (*this)->getRegion(index: 0); |
| 2328 | } |
| 2329 | |
| 2330 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2331 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 2332 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 2333 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 2334 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 2335 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 2336 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2337 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); |
| 2338 | static InParallelOp create(::mlir::OpBuilder &builder, ::mlir::Location location); |
| 2339 | static InParallelOp create(::mlir::ImplicitLocOpBuilder &builder); |
| 2340 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 2341 | void print(::mlir::OpAsmPrinter &p); |
| 2342 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 2343 | ::llvm::LogicalResult verifyInvariants(); |
| 2344 | ::llvm::LogicalResult verify(); |
| 2345 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2346 | void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); |
| 2347 | public: |
| 2348 | ::llvm::SmallVector<::mlir::BlockArgument> getDests(); |
| 2349 | ::llvm::iterator_range<::mlir::Block::iterator> getYieldingOps(); |
| 2350 | ::mlir::OpResult getParentResult(int64_t idx); |
| 2351 | }; |
| 2352 | |
| 2353 | } // namespace mlir::scf |
| 2354 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::InParallelOp) |
| 2355 | |
| 2356 | namespace mlir::scf { |
| 2357 | |
| 2358 | |
| 2359 | //===----------------------------------------------------------------------===// |
| 2360 | // ::mlir::scf::IndexSwitchOp declarations |
| 2361 | //===----------------------------------------------------------------------===// |
| 2362 | |
| 2363 | namespace detail { |
| 2364 | |
| 2365 | class IndexSwitchOpGenericAdaptorBase { |
| 2366 | public: |
| 2367 | struct Properties { |
| 2368 | using casesTy = ::mlir::DenseI64ArrayAttr; |
| 2369 | casesTy cases; |
| 2370 | |
| 2371 | auto getCases() const { |
| 2372 | auto &propStorage = this->cases; |
| 2373 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: propStorage); |
| 2374 | } |
| 2375 | void setCases(const ::mlir::DenseI64ArrayAttr &propValue) { |
| 2376 | this->cases = propValue; |
| 2377 | } |
| 2378 | bool operator==(const Properties &rhs) const { |
| 2379 | return |
| 2380 | rhs.cases == this->cases && |
| 2381 | true; |
| 2382 | } |
| 2383 | bool operator!=(const Properties &rhs) const { |
| 2384 | return !(*this == rhs); |
| 2385 | } |
| 2386 | }; |
| 2387 | protected: |
| 2388 | ::mlir::DictionaryAttr odsAttrs; |
| 2389 | ::std::optional<::mlir::OperationName> odsOpName; |
| 2390 | Properties properties; |
| 2391 | ::mlir::RegionRange odsRegions; |
| 2392 | public: |
| 2393 | IndexSwitchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 2394 | odsOpName.emplace(args: "scf.index_switch" , args: odsAttrs.getContext()); |
| 2395 | } |
| 2396 | |
| 2397 | IndexSwitchOpGenericAdaptorBase(IndexSwitchOp op); |
| 2398 | |
| 2399 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 2400 | return {index, 1}; |
| 2401 | } |
| 2402 | |
| 2403 | const Properties &getProperties() { |
| 2404 | return properties; |
| 2405 | } |
| 2406 | |
| 2407 | ::mlir::DictionaryAttr getAttributes() { |
| 2408 | return odsAttrs; |
| 2409 | } |
| 2410 | |
| 2411 | ::mlir::DenseI64ArrayAttr getCasesAttr() { |
| 2412 | auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val: getProperties().cases); |
| 2413 | return attr; |
| 2414 | } |
| 2415 | |
| 2416 | ::llvm::ArrayRef<int64_t> getCases(); |
| 2417 | ::mlir::Region &getDefaultRegion() { |
| 2418 | return *odsRegions[0]; |
| 2419 | } |
| 2420 | |
| 2421 | ::mlir::RegionRange getCaseRegions() { |
| 2422 | return odsRegions.drop_front(n: 1); |
| 2423 | } |
| 2424 | |
| 2425 | ::mlir::RegionRange getRegions() { |
| 2426 | return odsRegions; |
| 2427 | } |
| 2428 | |
| 2429 | }; |
| 2430 | |
| 2431 | } // namespace detail |
| 2432 | template <typename RangeT> |
| 2433 | class IndexSwitchOpGenericAdaptor : public detail::IndexSwitchOpGenericAdaptorBase { |
| 2434 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 2435 | using Base = detail::IndexSwitchOpGenericAdaptorBase; |
| 2436 | static constexpr int odsIndex_arg = 0; |
| 2437 | public: |
| 2438 | IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 2439 | |
| 2440 | IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : IndexSwitchOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 2441 | |
| 2442 | IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IndexSwitchOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 2443 | |
| 2444 | IndexSwitchOpGenericAdaptor(RangeT values, const IndexSwitchOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 2445 | |
| 2446 | template <typename LateInst = IndexSwitchOp, typename = std::enable_if_t<std::is_same_v<LateInst, IndexSwitchOp>>> |
| 2447 | IndexSwitchOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 2448 | |
| 2449 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2450 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 2451 | } |
| 2452 | |
| 2453 | RangeT getODSOperands(unsigned index) { |
| 2454 | auto valueRange = getODSOperandIndexAndLength(index); |
| 2455 | return {std::next(odsOperands.begin(), valueRange.first), |
| 2456 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 2457 | } |
| 2458 | |
| 2459 | ValueT getArg() { |
| 2460 | return (*getODSOperands(index: 0).begin()); |
| 2461 | } |
| 2462 | |
| 2463 | RangeT getOperands() { |
| 2464 | return odsOperands; |
| 2465 | } |
| 2466 | |
| 2467 | private: |
| 2468 | RangeT odsOperands; |
| 2469 | }; |
| 2470 | class IndexSwitchOpAdaptor : public IndexSwitchOpGenericAdaptor<::mlir::ValueRange> { |
| 2471 | public: |
| 2472 | using IndexSwitchOpGenericAdaptor::IndexSwitchOpGenericAdaptor; |
| 2473 | IndexSwitchOpAdaptor(IndexSwitchOp op); |
| 2474 | |
| 2475 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 2476 | }; |
| 2477 | class IndexSwitchOp : public ::mlir::Op<IndexSwitchOp, ::mlir::OpTrait::AtLeastNRegions<1>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::RegionBranchOpInterface::Trait> { |
| 2478 | public: |
| 2479 | using Op::Op; |
| 2480 | using Op::print; |
| 2481 | using Adaptor = IndexSwitchOpAdaptor; |
| 2482 | template <typename RangeT> |
| 2483 | using GenericAdaptor = IndexSwitchOpGenericAdaptor<RangeT>; |
| 2484 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 2485 | static constexpr int odsIndex_arg = 0; |
| 2486 | static constexpr int odsIndex_results = 0; |
| 2487 | using Properties = FoldAdaptor::Properties; |
| 2488 | using ::mlir::RegionBranchOpInterface::Trait<IndexSwitchOp>::getEntrySuccessorOperands; |
| 2489 | using ::mlir::RegionBranchOpInterface::Trait<IndexSwitchOp>::getSuccessorRegions; |
| 2490 | using ::mlir::RegionBranchOpInterface::Trait<IndexSwitchOp>::getPredecessors; |
| 2491 | using ::mlir::RegionBranchOpInterface::Trait<IndexSwitchOp>::getPredecessorValues; |
| 2492 | using ::mlir::RegionBranchOpInterface::Trait<IndexSwitchOp>::areTypesCompatible; |
| 2493 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 2494 | static ::llvm::StringRef attrNames[] = {::llvm::StringRef("cases" )}; |
| 2495 | return ::llvm::ArrayRef(attrNames); |
| 2496 | } |
| 2497 | |
| 2498 | ::mlir::StringAttr getCasesAttrName() { |
| 2499 | return getAttributeNameForIndex(index: 0); |
| 2500 | } |
| 2501 | |
| 2502 | static ::mlir::StringAttr getCasesAttrName(::mlir::OperationName name) { |
| 2503 | return getAttributeNameForIndex(name, index: 0); |
| 2504 | } |
| 2505 | |
| 2506 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 2507 | return ::llvm::StringLiteral("scf.index_switch" ); |
| 2508 | } |
| 2509 | |
| 2510 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2511 | return {index, 1}; |
| 2512 | } |
| 2513 | |
| 2514 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 2515 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 2516 | return getOperation()->getOperands().slice(n: start, m: length); |
| 2517 | } |
| 2518 | |
| 2519 | ::mlir::TypedValue<::mlir::IndexType> getArg() { |
| 2520 | return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(Val: *getODSOperands(index: 0).begin()); |
| 2521 | } |
| 2522 | |
| 2523 | ::mlir::OpOperand &getArgMutable() { |
| 2524 | auto range = getODSOperandIndexAndLength(index: 0); |
| 2525 | return getOperation()->getOpOperand(idx: range.first); |
| 2526 | } |
| 2527 | |
| 2528 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 2529 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 2530 | auto valueRange = getODSResultIndexAndLength(index); |
| 2531 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 2532 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 2533 | } |
| 2534 | |
| 2535 | ::mlir::Operation::result_range getResults() { |
| 2536 | return getODSResults(index: 0); |
| 2537 | } |
| 2538 | |
| 2539 | ::mlir::Region &getDefaultRegion() { |
| 2540 | return (*this)->getRegion(index: 0); |
| 2541 | } |
| 2542 | |
| 2543 | ::mlir::MutableArrayRef<::mlir::Region> getCaseRegions() { |
| 2544 | return (*this)->getRegions().drop_front(N: 1); |
| 2545 | } |
| 2546 | |
| 2547 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2548 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 2549 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 2550 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 2551 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 2552 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 2553 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2554 | static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); |
| 2555 | void writeProperties(::mlir::DialectBytecodeWriter &writer); |
| 2556 | ::mlir::DenseI64ArrayAttr getCasesAttr() { |
| 2557 | return ::llvm::cast<::mlir::DenseI64ArrayAttr>(Val&: getProperties().cases); |
| 2558 | } |
| 2559 | |
| 2560 | ::llvm::ArrayRef<int64_t> getCases(); |
| 2561 | void setCasesAttr(::mlir::DenseI64ArrayAttr attr) { |
| 2562 | getProperties().cases = attr; |
| 2563 | } |
| 2564 | |
| 2565 | void setCases(::llvm::ArrayRef<int64_t> attrValue); |
| 2566 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount); |
| 2567 | static IndexSwitchOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount); |
| 2568 | static IndexSwitchOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount); |
| 2569 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef<int64_t> cases, unsigned caseRegionsCount); |
| 2570 | static IndexSwitchOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef<int64_t> cases, unsigned caseRegionsCount); |
| 2571 | static IndexSwitchOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef<int64_t> cases, unsigned caseRegionsCount); |
| 2572 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 2573 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); |
| 2574 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 2575 | static IndexSwitchOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); |
| 2576 | [[deprecated("use the overload taking Properties and discardableAttributes instead" )]] |
| 2577 | static IndexSwitchOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); |
| 2578 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); |
| 2579 | static IndexSwitchOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); |
| 2580 | static IndexSwitchOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); |
| 2581 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 2582 | ::llvm::LogicalResult verifyInvariants(); |
| 2583 | ::llvm::LogicalResult verify(); |
| 2584 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 2585 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 2586 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 2587 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 2588 | void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 2589 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 2590 | ::mlir::ValueRange getSuccessorInputs(::mlir::RegionSuccessor successor); |
| 2591 | void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); |
| 2592 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 2593 | LLVM_ATTRIBUTE_MINSIZE void print(::mlir::OpAsmPrinter &_odsPrinter); |
| 2594 | private: |
| 2595 | ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { |
| 2596 | return getAttributeNameForIndex(name: (*this)->getName(), index); |
| 2597 | } |
| 2598 | |
| 2599 | static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { |
| 2600 | assert(index < 1 && "invalid attribute index" ); |
| 2601 | assert(name.getStringRef() == getOperationName() && "invalid operation name" ); |
| 2602 | assert(name.isRegistered() && "Operation isn't registered, missing a " |
| 2603 | "dependent dialect loading?" ); |
| 2604 | return name.getAttributeNames()[index]; |
| 2605 | } |
| 2606 | |
| 2607 | static void buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes); |
| 2608 | public: |
| 2609 | /// Get the number of cases. |
| 2610 | unsigned getNumCases(); |
| 2611 | |
| 2612 | /// Get the default region body. |
| 2613 | Block &getDefaultBlock(); |
| 2614 | |
| 2615 | /// Get the body of a case region. |
| 2616 | Block &getCaseBlock(unsigned idx); |
| 2617 | }; |
| 2618 | |
| 2619 | } // namespace mlir::scf |
| 2620 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IndexSwitchOp) |
| 2621 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::detail::IndexSwitchOpGenericAdaptorBase::Properties) |
| 2622 | |
| 2623 | namespace mlir::scf { |
| 2624 | |
| 2625 | |
| 2626 | //===----------------------------------------------------------------------===// |
| 2627 | // ::mlir::scf::ParallelOp declarations |
| 2628 | //===----------------------------------------------------------------------===// |
| 2629 | |
| 2630 | namespace detail { |
| 2631 | |
| 2632 | class ParallelOpGenericAdaptorBase { |
| 2633 | public: |
| 2634 | struct Properties { |
| 2635 | using unsignedCmpTy = ::mlir::UnitAttr; |
| 2636 | unsignedCmpTy unsignedCmp; |
| 2637 | |
| 2638 | auto getUnsignedCmp() const { |
| 2639 | auto &propStorage = this->unsignedCmp; |
| 2640 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val: propStorage); |
| 2641 | } |
| 2642 | void setUnsignedCmp(const ::mlir::UnitAttr &propValue) { |
| 2643 | this->unsignedCmp = propValue; |
| 2644 | } |
| 2645 | using operandSegmentSizesTy = std::array<int32_t, 4>; |
| 2646 | operandSegmentSizesTy operandSegmentSizes; |
| 2647 | ::llvm::ArrayRef<int32_t> getOperandSegmentSizes() const { |
| 2648 | auto &propStorage = this->operandSegmentSizes; |
| 2649 | return propStorage; |
| 2650 | } |
| 2651 | void setOperandSegmentSizes(::llvm::ArrayRef<int32_t> propValue) { |
| 2652 | auto &propStorage = this->operandSegmentSizes; |
| 2653 | ::llvm::copy(Range&: propValue, Out: propStorage.begin()); |
| 2654 | } |
| 2655 | bool operator==(const Properties &rhs) const { |
| 2656 | return |
| 2657 | rhs.unsignedCmp == this->unsignedCmp && |
| 2658 | rhs.operandSegmentSizes == this->operandSegmentSizes && |
| 2659 | true; |
| 2660 | } |
| 2661 | bool operator!=(const Properties &rhs) const { |
| 2662 | return !(*this == rhs); |
| 2663 | } |
| 2664 | }; |
| 2665 | protected: |
| 2666 | ::mlir::DictionaryAttr odsAttrs; |
| 2667 | ::std::optional<::mlir::OperationName> odsOpName; |
| 2668 | Properties properties; |
| 2669 | ::mlir::RegionRange odsRegions; |
| 2670 | public: |
| 2671 | ParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 2672 | odsOpName.emplace(args: "scf.parallel" , args: odsAttrs.getContext()); |
| 2673 | } |
| 2674 | |
| 2675 | ParallelOpGenericAdaptorBase(ParallelOp op); |
| 2676 | |
| 2677 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 2678 | const Properties &getProperties() { |
| 2679 | return properties; |
| 2680 | } |
| 2681 | |
| 2682 | ::mlir::DictionaryAttr getAttributes() { |
| 2683 | return odsAttrs; |
| 2684 | } |
| 2685 | |
| 2686 | ::mlir::UnitAttr getUnsignedCmpAttr(); |
| 2687 | bool getUnsignedCmp(); |
| 2688 | ::mlir::Region &getRegion() { |
| 2689 | return *odsRegions[0]; |
| 2690 | } |
| 2691 | |
| 2692 | ::mlir::RegionRange getRegions() { |
| 2693 | return odsRegions; |
| 2694 | } |
| 2695 | |
| 2696 | }; |
| 2697 | |
| 2698 | } // namespace detail |
| 2699 | template <typename RangeT> |
| 2700 | class ParallelOpGenericAdaptor : public detail::ParallelOpGenericAdaptorBase { |
| 2701 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 2702 | using Base = detail::ParallelOpGenericAdaptorBase; |
| 2703 | static constexpr int odsIndex_lowerBound = 0; |
| 2704 | static constexpr int odsIndex_upperBound = 1; |
| 2705 | static constexpr int odsIndex_step = 2; |
| 2706 | static constexpr int odsIndex_initVals = 3; |
| 2707 | public: |
| 2708 | ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 2709 | |
| 2710 | ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 2711 | |
| 2712 | ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs) : ParallelOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 2713 | |
| 2714 | ParallelOpGenericAdaptor(RangeT values, const ParallelOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 2715 | |
| 2716 | template <typename LateInst = ParallelOp, typename = std::enable_if_t<std::is_same_v<LateInst, ParallelOp>>> |
| 2717 | ParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 2718 | |
| 2719 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2720 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 2721 | } |
| 2722 | |
| 2723 | RangeT getODSOperands(unsigned index) { |
| 2724 | auto valueRange = getODSOperandIndexAndLength(index); |
| 2725 | return {std::next(odsOperands.begin(), valueRange.first), |
| 2726 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 2727 | } |
| 2728 | |
| 2729 | RangeT getLowerBound() { |
| 2730 | return getODSOperands(index: 0); |
| 2731 | } |
| 2732 | |
| 2733 | RangeT getUpperBound() { |
| 2734 | return getODSOperands(index: 1); |
| 2735 | } |
| 2736 | |
| 2737 | RangeT getStep() { |
| 2738 | return getODSOperands(index: 2); |
| 2739 | } |
| 2740 | |
| 2741 | RangeT getInitVals() { |
| 2742 | return getODSOperands(index: 3); |
| 2743 | } |
| 2744 | |
| 2745 | RangeT getOperands() { |
| 2746 | return odsOperands; |
| 2747 | } |
| 2748 | |
| 2749 | private: |
| 2750 | RangeT odsOperands; |
| 2751 | }; |
| 2752 | class ParallelOpAdaptor : public ParallelOpGenericAdaptor<::mlir::ValueRange> { |
| 2753 | public: |
| 2754 | using ParallelOpGenericAdaptor::ParallelOpGenericAdaptor; |
| 2755 | ParallelOpAdaptor(ParallelOp op); |
| 2756 | |
| 2757 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 2758 | }; |
| 2759 | class ParallelOp : public ::mlir::Op<ParallelOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::ReduceOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::OpTrait::HasParallelRegion> { |
| 2760 | public: |
| 2761 | using Op::Op; |
| 2762 | using Op::print; |
| 2763 | using Adaptor = ParallelOpAdaptor; |
| 2764 | template <typename RangeT> |
| 2765 | using GenericAdaptor = ParallelOpGenericAdaptor<RangeT>; |
| 2766 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 2767 | static constexpr int odsIndex_lowerBound = 0; |
| 2768 | static constexpr int odsIndex_upperBound = 1; |
| 2769 | static constexpr int odsIndex_step = 2; |
| 2770 | static constexpr int odsIndex_initVals = 3; |
| 2771 | static constexpr int odsIndex_results = 0; |
| 2772 | using Properties = FoldAdaptor::Properties; |
| 2773 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::isDefinedOutsideOfLoop; |
| 2774 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::moveOutOfLoop; |
| 2775 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::promoteIfSingleIteration; |
| 2776 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::getInitsMutable; |
| 2777 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::getRegionIterArgs; |
| 2778 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::getYieldedValuesMutable; |
| 2779 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::getLoopResults; |
| 2780 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::replaceWithAdditionalYields; |
| 2781 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::getStaticTripCount; |
| 2782 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::isValidInductionVarType; |
| 2783 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::setLoopLowerBounds; |
| 2784 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::setLoopUpperBounds; |
| 2785 | using ::mlir::LoopLikeOpInterface::Trait<ParallelOp>::setLoopSteps; |
| 2786 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getEntrySuccessorOperands; |
| 2787 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getEntrySuccessorRegions; |
| 2788 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getSuccessorRegions; |
| 2789 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getSuccessorInputs; |
| 2790 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getPredecessors; |
| 2791 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getPredecessorValues; |
| 2792 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::getRegionInvocationBounds; |
| 2793 | using ::mlir::RegionBranchOpInterface::Trait<ParallelOp>::areTypesCompatible; |
| 2794 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 2795 | static ::llvm::StringRef attrNames[] = {::llvm::StringRef("unsignedCmp" ), ::llvm::StringRef("operandSegmentSizes" )}; |
| 2796 | return ::llvm::ArrayRef(attrNames); |
| 2797 | } |
| 2798 | |
| 2799 | ::mlir::StringAttr getUnsignedCmpAttrName() { |
| 2800 | return getAttributeNameForIndex(index: 0); |
| 2801 | } |
| 2802 | |
| 2803 | static ::mlir::StringAttr getUnsignedCmpAttrName(::mlir::OperationName name) { |
| 2804 | return getAttributeNameForIndex(name, index: 0); |
| 2805 | } |
| 2806 | |
| 2807 | ::mlir::StringAttr getOperandSegmentSizesAttrName() { |
| 2808 | return (*this)->getName().getAttributeNames().back(); |
| 2809 | } |
| 2810 | |
| 2811 | static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { |
| 2812 | return name.getAttributeNames().back(); |
| 2813 | } |
| 2814 | |
| 2815 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 2816 | return ::llvm::StringLiteral("scf.parallel" ); |
| 2817 | } |
| 2818 | |
| 2819 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 2820 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 2821 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 2822 | return getOperation()->getOperands().slice(n: start, m: length); |
| 2823 | } |
| 2824 | |
| 2825 | ::mlir::Operation::operand_range getLowerBound() { |
| 2826 | return getODSOperands(index: 0); |
| 2827 | } |
| 2828 | |
| 2829 | ::mlir::Operation::operand_range getUpperBound() { |
| 2830 | return getODSOperands(index: 1); |
| 2831 | } |
| 2832 | |
| 2833 | ::mlir::Operation::operand_range getStep() { |
| 2834 | return getODSOperands(index: 2); |
| 2835 | } |
| 2836 | |
| 2837 | ::mlir::Operation::operand_range getInitVals() { |
| 2838 | return getODSOperands(index: 3); |
| 2839 | } |
| 2840 | |
| 2841 | ::mlir::MutableOperandRange getLowerBoundMutable(); |
| 2842 | ::mlir::MutableOperandRange getUpperBoundMutable(); |
| 2843 | ::mlir::MutableOperandRange getStepMutable(); |
| 2844 | ::mlir::MutableOperandRange getInitValsMutable(); |
| 2845 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 2846 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 2847 | auto valueRange = getODSResultIndexAndLength(index); |
| 2848 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 2849 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 2850 | } |
| 2851 | |
| 2852 | ::mlir::Operation::result_range getResults() { |
| 2853 | return getODSResults(index: 0); |
| 2854 | } |
| 2855 | |
| 2856 | ::mlir::Region &getRegion() { |
| 2857 | return (*this)->getRegion(index: 0); |
| 2858 | } |
| 2859 | |
| 2860 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2861 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 2862 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 2863 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 2864 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 2865 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 2866 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2867 | static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); |
| 2868 | void writeProperties(::mlir::DialectBytecodeWriter &writer); |
| 2869 | ::mlir::UnitAttr getUnsignedCmpAttr() { |
| 2870 | return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(Val&: getProperties().unsignedCmp); |
| 2871 | } |
| 2872 | |
| 2873 | bool getUnsignedCmp(); |
| 2874 | void setUnsignedCmpAttr(::mlir::UnitAttr attr) { |
| 2875 | getProperties().unsignedCmp = attr; |
| 2876 | } |
| 2877 | |
| 2878 | void setUnsignedCmp(bool attrValue); |
| 2879 | ::mlir::Attribute removeUnsignedCmpAttr() { |
| 2880 | auto attr = getProperties().unsignedCmp; |
| 2881 | getProperties().unsignedCmp = {}; |
| 2882 | return attr; |
| 2883 | } |
| 2884 | |
| 2885 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, ValueRange initVals, function_ref<void (OpBuilder &, Location, ValueRange, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2886 | static ParallelOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, ValueRange initVals, function_ref<void (OpBuilder &, Location, ValueRange, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2887 | static ParallelOp create(::mlir::ImplicitLocOpBuilder &builder, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, ValueRange initVals, function_ref<void (OpBuilder &, Location, ValueRange, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2888 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, function_ref<void (OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2889 | static ParallelOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, function_ref<void (OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2890 | static ParallelOp create(::mlir::ImplicitLocOpBuilder &builder, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, function_ref<void (OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr, bool unsignedCmp = false); |
| 2891 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 2892 | void print(::mlir::OpAsmPrinter &p); |
| 2893 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 2894 | ::llvm::LogicalResult verifyInvariants(); |
| 2895 | ::llvm::LogicalResult verify(); |
| 2896 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 2897 | ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); |
| 2898 | ::std::optional<::llvm::SmallVector<::mlir::Value>> getLoopInductionVars(); |
| 2899 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopLowerBounds(); |
| 2900 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopSteps(); |
| 2901 | ::std::optional<::llvm::SmallVector<::mlir::OpFoldResult>> getLoopUpperBounds(); |
| 2902 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 2903 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 2904 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 2905 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 2906 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 2907 | private: |
| 2908 | ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { |
| 2909 | return getAttributeNameForIndex(name: (*this)->getName(), index); |
| 2910 | } |
| 2911 | |
| 2912 | static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { |
| 2913 | assert(index < 1 && "invalid attribute index" ); |
| 2914 | assert(name.getStringRef() == getOperationName() && "invalid operation name" ); |
| 2915 | assert(name.isRegistered() && "Operation isn't registered, missing a " |
| 2916 | "dependent dialect loading?" ); |
| 2917 | return name.getAttributeNames()[index]; |
| 2918 | } |
| 2919 | |
| 2920 | public: |
| 2921 | /// Get induction variables. |
| 2922 | SmallVector<Value> getInductionVars() { |
| 2923 | std::optional<SmallVector<Value>> maybeInductionVars = getLoopInductionVars();; |
| 2924 | assert(maybeInductionVars.has_value() && "expected values" ); |
| 2925 | return *maybeInductionVars; |
| 2926 | } |
| 2927 | unsigned getNumLoops() { return getStep().size(); } |
| 2928 | unsigned getNumReductions() { return getInitVals().size(); } |
| 2929 | }; |
| 2930 | |
| 2931 | } // namespace mlir::scf |
| 2932 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ParallelOp) |
| 2933 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::detail::ParallelOpGenericAdaptorBase::Properties) |
| 2934 | |
| 2935 | namespace mlir::scf { |
| 2936 | |
| 2937 | |
| 2938 | //===----------------------------------------------------------------------===// |
| 2939 | // ::mlir::scf::ReduceOp declarations |
| 2940 | //===----------------------------------------------------------------------===// |
| 2941 | |
| 2942 | namespace detail { |
| 2943 | |
| 2944 | class ReduceOpGenericAdaptorBase { |
| 2945 | public: |
| 2946 | using Properties = ::mlir::EmptyProperties; |
| 2947 | protected: |
| 2948 | ::mlir::DictionaryAttr odsAttrs; |
| 2949 | ::std::optional<::mlir::OperationName> odsOpName; |
| 2950 | Properties properties; |
| 2951 | ::mlir::RegionRange odsRegions; |
| 2952 | public: |
| 2953 | ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 2954 | odsOpName.emplace(args: "scf.reduce" , args: odsAttrs.getContext()); |
| 2955 | } |
| 2956 | |
| 2957 | ReduceOpGenericAdaptorBase(ReduceOp op); |
| 2958 | |
| 2959 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 2960 | const Properties &getProperties() { |
| 2961 | return properties; |
| 2962 | } |
| 2963 | |
| 2964 | ::mlir::DictionaryAttr getAttributes() { |
| 2965 | return odsAttrs; |
| 2966 | } |
| 2967 | |
| 2968 | ::mlir::RegionRange getReductions() { |
| 2969 | return odsRegions.drop_front(n: 0); |
| 2970 | } |
| 2971 | |
| 2972 | ::mlir::RegionRange getRegions() { |
| 2973 | return odsRegions; |
| 2974 | } |
| 2975 | |
| 2976 | }; |
| 2977 | |
| 2978 | } // namespace detail |
| 2979 | template <typename RangeT> |
| 2980 | class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase { |
| 2981 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 2982 | using Base = detail::ReduceOpGenericAdaptorBase; |
| 2983 | static constexpr int odsIndex_operands = 0; |
| 2984 | public: |
| 2985 | ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 2986 | |
| 2987 | ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 2988 | |
| 2989 | ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 2990 | |
| 2991 | ReduceOpGenericAdaptor(RangeT values, const ReduceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 2992 | |
| 2993 | template <typename LateInst = ReduceOp, typename = std::enable_if_t<std::is_same_v<LateInst, ReduceOp>>> |
| 2994 | ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 2995 | |
| 2996 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 2997 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 2998 | } |
| 2999 | |
| 3000 | RangeT getODSOperands(unsigned index) { |
| 3001 | auto valueRange = getODSOperandIndexAndLength(index); |
| 3002 | return {std::next(odsOperands.begin(), valueRange.first), |
| 3003 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 3004 | } |
| 3005 | |
| 3006 | RangeT getOperands() { |
| 3007 | return getODSOperands(index: 0); |
| 3008 | } |
| 3009 | |
| 3010 | private: |
| 3011 | RangeT odsOperands; |
| 3012 | }; |
| 3013 | class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> { |
| 3014 | public: |
| 3015 | using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor; |
| 3016 | ReduceOpAdaptor(ReduceOp op); |
| 3017 | |
| 3018 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 3019 | }; |
| 3020 | class ReduceOp : public ::mlir::Op<ReduceOp, ::mlir::OpTrait::VariadicRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::HasParent<ParallelOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsTerminator, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait> { |
| 3021 | public: |
| 3022 | using Op::Op; |
| 3023 | using Op::print; |
| 3024 | using Adaptor = ReduceOpAdaptor; |
| 3025 | template <typename RangeT> |
| 3026 | using GenericAdaptor = ReduceOpGenericAdaptor<RangeT>; |
| 3027 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 3028 | static constexpr int odsIndex_operands = 0; |
| 3029 | using Properties = FoldAdaptor::Properties; |
| 3030 | using ::mlir::RegionBranchTerminatorOpInterface::Trait<ReduceOp>::getSuccessorRegions; |
| 3031 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 3032 | return {}; |
| 3033 | } |
| 3034 | |
| 3035 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 3036 | return ::llvm::StringLiteral("scf.reduce" ); |
| 3037 | } |
| 3038 | |
| 3039 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 3040 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 3041 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 3042 | return getOperation()->getOperands().slice(n: start, m: length); |
| 3043 | } |
| 3044 | |
| 3045 | ::mlir::Operation::operand_range getOperands() { |
| 3046 | return getODSOperands(index: 0); |
| 3047 | } |
| 3048 | |
| 3049 | ::mlir::MutableOperandRange getOperandsMutable(); |
| 3050 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index) { |
| 3051 | return {index, 1}; |
| 3052 | } |
| 3053 | |
| 3054 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 3055 | auto valueRange = getODSResultIndexAndLength(index); |
| 3056 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 3057 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 3058 | } |
| 3059 | |
| 3060 | ::mlir::MutableArrayRef<::mlir::Region> getReductions() { |
| 3061 | return (*this)->getRegions().drop_front(N: 0); |
| 3062 | } |
| 3063 | |
| 3064 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3065 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 3066 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 3067 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 3068 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 3069 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 3070 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3071 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange operands); |
| 3072 | static ReduceOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ValueRange operands); |
| 3073 | static ReduceOp create(::mlir::ImplicitLocOpBuilder &builder, ValueRange operands); |
| 3074 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); |
| 3075 | static ReduceOp create(::mlir::OpBuilder &builder, ::mlir::Location location); |
| 3076 | static ReduceOp create(::mlir::ImplicitLocOpBuilder &builder); |
| 3077 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 3078 | ::llvm::LogicalResult verifyInvariants(); |
| 3079 | ::llvm::LogicalResult verifyRegions(); |
| 3080 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 3081 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 3082 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 3083 | ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionSuccessor point); |
| 3084 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 3085 | LLVM_ATTRIBUTE_MINSIZE void print(::mlir::OpAsmPrinter &_odsPrinter); |
| 3086 | public: |
| 3087 | }; |
| 3088 | |
| 3089 | } // namespace mlir::scf |
| 3090 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceOp) |
| 3091 | |
| 3092 | namespace mlir::scf { |
| 3093 | |
| 3094 | |
| 3095 | //===----------------------------------------------------------------------===// |
| 3096 | // ::mlir::scf::ReduceReturnOp declarations |
| 3097 | //===----------------------------------------------------------------------===// |
| 3098 | |
| 3099 | namespace detail { |
| 3100 | |
| 3101 | class ReduceReturnOpGenericAdaptorBase { |
| 3102 | public: |
| 3103 | using Properties = ::mlir::EmptyProperties; |
| 3104 | protected: |
| 3105 | ::mlir::DictionaryAttr odsAttrs; |
| 3106 | ::std::optional<::mlir::OperationName> odsOpName; |
| 3107 | Properties properties; |
| 3108 | ::mlir::RegionRange odsRegions; |
| 3109 | public: |
| 3110 | ReduceReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 3111 | odsOpName.emplace(args: "scf.reduce.return" , args: odsAttrs.getContext()); |
| 3112 | } |
| 3113 | |
| 3114 | ReduceReturnOpGenericAdaptorBase(ReduceReturnOp op); |
| 3115 | |
| 3116 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 3117 | return {index, 1}; |
| 3118 | } |
| 3119 | |
| 3120 | const Properties &getProperties() { |
| 3121 | return properties; |
| 3122 | } |
| 3123 | |
| 3124 | ::mlir::DictionaryAttr getAttributes() { |
| 3125 | return odsAttrs; |
| 3126 | } |
| 3127 | |
| 3128 | }; |
| 3129 | |
| 3130 | } // namespace detail |
| 3131 | template <typename RangeT> |
| 3132 | class ReduceReturnOpGenericAdaptor : public detail::ReduceReturnOpGenericAdaptorBase { |
| 3133 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 3134 | using Base = detail::ReduceReturnOpGenericAdaptorBase; |
| 3135 | static constexpr int odsIndex_result = 0; |
| 3136 | public: |
| 3137 | ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 3138 | |
| 3139 | ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : ReduceReturnOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 3140 | |
| 3141 | ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceReturnOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 3142 | |
| 3143 | ReduceReturnOpGenericAdaptor(RangeT values, const ReduceReturnOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 3144 | |
| 3145 | template <typename LateInst = ReduceReturnOp, typename = std::enable_if_t<std::is_same_v<LateInst, ReduceReturnOp>>> |
| 3146 | ReduceReturnOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 3147 | |
| 3148 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 3149 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 3150 | } |
| 3151 | |
| 3152 | RangeT getODSOperands(unsigned index) { |
| 3153 | auto valueRange = getODSOperandIndexAndLength(index); |
| 3154 | return {std::next(odsOperands.begin(), valueRange.first), |
| 3155 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 3156 | } |
| 3157 | |
| 3158 | ValueT getResult() { |
| 3159 | return (*getODSOperands(index: 0).begin()); |
| 3160 | } |
| 3161 | |
| 3162 | RangeT getOperands() { |
| 3163 | return odsOperands; |
| 3164 | } |
| 3165 | |
| 3166 | private: |
| 3167 | RangeT odsOperands; |
| 3168 | }; |
| 3169 | class ReduceReturnOpAdaptor : public ReduceReturnOpGenericAdaptor<::mlir::ValueRange> { |
| 3170 | public: |
| 3171 | using ReduceReturnOpGenericAdaptor::ReduceReturnOpGenericAdaptor; |
| 3172 | ReduceReturnOpAdaptor(ReduceReturnOp op); |
| 3173 | |
| 3174 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 3175 | }; |
| 3176 | class ReduceReturnOp : public ::mlir::Op<ReduceReturnOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::HasParent<ReduceOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> { |
| 3177 | public: |
| 3178 | using Op::Op; |
| 3179 | using Op::print; |
| 3180 | using Adaptor = ReduceReturnOpAdaptor; |
| 3181 | template <typename RangeT> |
| 3182 | using GenericAdaptor = ReduceReturnOpGenericAdaptor<RangeT>; |
| 3183 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 3184 | static constexpr int odsIndex_result = 0; |
| 3185 | using Properties = FoldAdaptor::Properties; |
| 3186 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 3187 | return {}; |
| 3188 | } |
| 3189 | |
| 3190 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 3191 | return ::llvm::StringLiteral("scf.reduce.return" ); |
| 3192 | } |
| 3193 | |
| 3194 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 3195 | return {index, 1}; |
| 3196 | } |
| 3197 | |
| 3198 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 3199 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 3200 | return getOperation()->getOperands().slice(n: start, m: length); |
| 3201 | } |
| 3202 | |
| 3203 | ::mlir::TypedValue<::mlir::Type> getResult() { |
| 3204 | return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(Val: *getODSOperands(index: 0).begin()); |
| 3205 | } |
| 3206 | |
| 3207 | ::mlir::OpOperand &getResultMutable() { |
| 3208 | auto range = getODSOperandIndexAndLength(index: 0); |
| 3209 | return getOperation()->getOpOperand(idx: range.first); |
| 3210 | } |
| 3211 | |
| 3212 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index) { |
| 3213 | return {index, 1}; |
| 3214 | } |
| 3215 | |
| 3216 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 3217 | auto valueRange = getODSResultIndexAndLength(index); |
| 3218 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 3219 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 3220 | } |
| 3221 | |
| 3222 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3223 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 3224 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 3225 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 3226 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 3227 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 3228 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3229 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value result); |
| 3230 | static ReduceReturnOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value result); |
| 3231 | static ReduceReturnOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value result); |
| 3232 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value result); |
| 3233 | static ReduceReturnOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value result); |
| 3234 | static ReduceReturnOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value result); |
| 3235 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3236 | static ReduceReturnOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3237 | static ReduceReturnOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3238 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3239 | static ReduceReturnOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3240 | static ReduceReturnOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3241 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 3242 | ::llvm::LogicalResult verifyInvariants(); |
| 3243 | ::llvm::LogicalResult verify(); |
| 3244 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 3245 | LLVM_ATTRIBUTE_MINSIZE void print(::mlir::OpAsmPrinter &_odsPrinter); |
| 3246 | void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); |
| 3247 | public: |
| 3248 | }; |
| 3249 | |
| 3250 | } // namespace mlir::scf |
| 3251 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceReturnOp) |
| 3252 | |
| 3253 | namespace mlir::scf { |
| 3254 | |
| 3255 | |
| 3256 | //===----------------------------------------------------------------------===// |
| 3257 | // ::mlir::scf::WhileOp declarations |
| 3258 | //===----------------------------------------------------------------------===// |
| 3259 | |
| 3260 | namespace detail { |
| 3261 | |
| 3262 | class WhileOpGenericAdaptorBase { |
| 3263 | public: |
| 3264 | using Properties = ::mlir::EmptyProperties; |
| 3265 | protected: |
| 3266 | ::mlir::DictionaryAttr odsAttrs; |
| 3267 | ::std::optional<::mlir::OperationName> odsOpName; |
| 3268 | Properties properties; |
| 3269 | ::mlir::RegionRange odsRegions; |
| 3270 | public: |
| 3271 | WhileOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 3272 | odsOpName.emplace(args: "scf.while" , args: odsAttrs.getContext()); |
| 3273 | } |
| 3274 | |
| 3275 | WhileOpGenericAdaptorBase(WhileOp op); |
| 3276 | |
| 3277 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 3278 | const Properties &getProperties() { |
| 3279 | return properties; |
| 3280 | } |
| 3281 | |
| 3282 | ::mlir::DictionaryAttr getAttributes() { |
| 3283 | return odsAttrs; |
| 3284 | } |
| 3285 | |
| 3286 | ::mlir::Region &getBefore() { |
| 3287 | return *odsRegions[0]; |
| 3288 | } |
| 3289 | |
| 3290 | ::mlir::Region &getAfter() { |
| 3291 | return *odsRegions[1]; |
| 3292 | } |
| 3293 | |
| 3294 | ::mlir::RegionRange getRegions() { |
| 3295 | return odsRegions; |
| 3296 | } |
| 3297 | |
| 3298 | }; |
| 3299 | |
| 3300 | } // namespace detail |
| 3301 | template <typename RangeT> |
| 3302 | class WhileOpGenericAdaptor : public detail::WhileOpGenericAdaptorBase { |
| 3303 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 3304 | using Base = detail::WhileOpGenericAdaptorBase; |
| 3305 | static constexpr int odsIndex_inits = 0; |
| 3306 | public: |
| 3307 | WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 3308 | |
| 3309 | WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : WhileOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 3310 | |
| 3311 | WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : WhileOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 3312 | |
| 3313 | WhileOpGenericAdaptor(RangeT values, const WhileOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 3314 | |
| 3315 | template <typename LateInst = WhileOp, typename = std::enable_if_t<std::is_same_v<LateInst, WhileOp>>> |
| 3316 | WhileOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 3317 | |
| 3318 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 3319 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 3320 | } |
| 3321 | |
| 3322 | RangeT getODSOperands(unsigned index) { |
| 3323 | auto valueRange = getODSOperandIndexAndLength(index); |
| 3324 | return {std::next(odsOperands.begin(), valueRange.first), |
| 3325 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 3326 | } |
| 3327 | |
| 3328 | RangeT getInits() { |
| 3329 | return getODSOperands(index: 0); |
| 3330 | } |
| 3331 | |
| 3332 | RangeT getOperands() { |
| 3333 | return odsOperands; |
| 3334 | } |
| 3335 | |
| 3336 | private: |
| 3337 | RangeT odsOperands; |
| 3338 | }; |
| 3339 | class WhileOpAdaptor : public WhileOpGenericAdaptor<::mlir::ValueRange> { |
| 3340 | public: |
| 3341 | using WhileOpGenericAdaptor::WhileOpGenericAdaptor; |
| 3342 | WhileOpAdaptor(WhileOp op); |
| 3343 | |
| 3344 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 3345 | }; |
| 3346 | class WhileOp : public ::mlir::Op<WhileOp, ::mlir::OpTrait::NRegions<2>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::LoopLikeOpInterface::Trait, ::mlir::PromotableRegionOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { |
| 3347 | public: |
| 3348 | using Op::Op; |
| 3349 | using Op::print; |
| 3350 | using Adaptor = WhileOpAdaptor; |
| 3351 | template <typename RangeT> |
| 3352 | using GenericAdaptor = WhileOpGenericAdaptor<RangeT>; |
| 3353 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 3354 | static constexpr int odsIndex_inits = 0; |
| 3355 | static constexpr int odsIndex_results = 0; |
| 3356 | using Properties = FoldAdaptor::Properties; |
| 3357 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::getEntrySuccessorRegions; |
| 3358 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::getSuccessorRegions; |
| 3359 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::getPredecessors; |
| 3360 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::getPredecessorValues; |
| 3361 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::getRegionInvocationBounds; |
| 3362 | using ::mlir::RegionBranchOpInterface::Trait<WhileOp>::areTypesCompatible; |
| 3363 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::isDefinedOutsideOfLoop; |
| 3364 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::moveOutOfLoop; |
| 3365 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::promoteIfSingleIteration; |
| 3366 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getLoopInductionVars; |
| 3367 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getLoopLowerBounds; |
| 3368 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getLoopSteps; |
| 3369 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getLoopUpperBounds; |
| 3370 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getInitsMutable; |
| 3371 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getLoopResults; |
| 3372 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::replaceWithAdditionalYields; |
| 3373 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::getStaticTripCount; |
| 3374 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::isValidInductionVarType; |
| 3375 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::setLoopLowerBounds; |
| 3376 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::setLoopUpperBounds; |
| 3377 | using ::mlir::LoopLikeOpInterface::Trait<WhileOp>::setLoopSteps; |
| 3378 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 3379 | return {}; |
| 3380 | } |
| 3381 | |
| 3382 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 3383 | return ::llvm::StringLiteral("scf.while" ); |
| 3384 | } |
| 3385 | |
| 3386 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 3387 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 3388 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 3389 | return getOperation()->getOperands().slice(n: start, m: length); |
| 3390 | } |
| 3391 | |
| 3392 | ::mlir::Operation::operand_range getInits() { |
| 3393 | return getODSOperands(index: 0); |
| 3394 | } |
| 3395 | |
| 3396 | ::mlir::MutableOperandRange getInitsMutable(); |
| 3397 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index); |
| 3398 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 3399 | auto valueRange = getODSResultIndexAndLength(index); |
| 3400 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 3401 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 3402 | } |
| 3403 | |
| 3404 | ::mlir::Operation::result_range getResults() { |
| 3405 | return getODSResults(index: 0); |
| 3406 | } |
| 3407 | |
| 3408 | ::mlir::Region &getBefore() { |
| 3409 | return (*this)->getRegion(index: 0); |
| 3410 | } |
| 3411 | |
| 3412 | ::mlir::Region &getAfter() { |
| 3413 | return (*this)->getRegion(index: 1); |
| 3414 | } |
| 3415 | |
| 3416 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3417 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 3418 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 3419 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 3420 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 3421 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 3422 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3423 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, ValueRange inits, function_ref<void(OpBuilder &, Location, ValueRange)> beforeBuilder, function_ref<void(OpBuilder &, Location, ValueRange)> afterBuilder); |
| 3424 | static WhileOp create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange resultTypes, ValueRange inits, function_ref<void(OpBuilder &, Location, ValueRange)> beforeBuilder, function_ref<void(OpBuilder &, Location, ValueRange)> afterBuilder); |
| 3425 | static WhileOp create(::mlir::ImplicitLocOpBuilder &builder, TypeRange resultTypes, ValueRange inits, function_ref<void(OpBuilder &, Location, ValueRange)> beforeBuilder, function_ref<void(OpBuilder &, Location, ValueRange)> afterBuilder); |
| 3426 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3427 | static WhileOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3428 | static WhileOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3429 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3430 | static WhileOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3431 | static WhileOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3432 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 3433 | void print(::mlir::OpAsmPrinter &p); |
| 3434 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 3435 | ::llvm::LogicalResult verifyInvariants(); |
| 3436 | ::llvm::LogicalResult verify(); |
| 3437 | static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); |
| 3438 | ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionSuccessor successor); |
| 3439 | void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); |
| 3440 | ::mlir::ValueRange getSuccessorInputs(::mlir::RegionSuccessor successor); |
| 3441 | ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); |
| 3442 | ::mlir::Block::BlockArgListType getRegionIterArgs(); |
| 3443 | ::std::optional<::llvm::MutableArrayRef<::mlir::OpOperand>> getYieldedValuesMutable(); |
| 3444 | bool isRegionPromotable(const ::mlir::MemorySlot &slot, ::mlir::Region *region, bool hasValueStores); |
| 3445 | void setupPromotion(const ::mlir::MemorySlot &slot, ::mlir::Value reachingDef, bool hasValueStores, ::llvm::SmallMapVector<::mlir::Region *, ::mlir::Value, 2> ®ionsToProcess); |
| 3446 | ::mlir::Value finalizePromotion(const ::mlir::MemorySlot &slot, ::mlir::Value entryReachingDef, bool hasValueStores, const ::llvm::DenseMap<::mlir::Block *, ::mlir::Value> &reachingAtBlockEnd, ::mlir::OpBuilder &builder); |
| 3447 | static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3448 | public: |
| 3449 | using BodyBuilderFn = |
| 3450 | function_ref<void(OpBuilder &, Location, ValueRange)>; |
| 3451 | |
| 3452 | ConditionOp getConditionOp(); |
| 3453 | YieldOp getYieldOp(); |
| 3454 | |
| 3455 | Block::BlockArgListType getBeforeArguments(); |
| 3456 | Block::BlockArgListType getAfterArguments(); |
| 3457 | Block *getBeforeBody() { return &getBefore().front(); } |
| 3458 | Block *getAfterBody() { return &getAfter().front(); } |
| 3459 | }; |
| 3460 | |
| 3461 | } // namespace mlir::scf |
| 3462 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::WhileOp) |
| 3463 | |
| 3464 | namespace mlir::scf { |
| 3465 | |
| 3466 | |
| 3467 | //===----------------------------------------------------------------------===// |
| 3468 | // ::mlir::scf::YieldOp declarations |
| 3469 | //===----------------------------------------------------------------------===// |
| 3470 | |
| 3471 | namespace detail { |
| 3472 | |
| 3473 | class YieldOpGenericAdaptorBase { |
| 3474 | public: |
| 3475 | using Properties = ::mlir::EmptyProperties; |
| 3476 | protected: |
| 3477 | ::mlir::DictionaryAttr odsAttrs; |
| 3478 | ::std::optional<::mlir::OperationName> odsOpName; |
| 3479 | Properties properties; |
| 3480 | ::mlir::RegionRange odsRegions; |
| 3481 | public: |
| 3482 | YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) |
| 3483 | odsOpName.emplace(args: "scf.yield" , args: odsAttrs.getContext()); |
| 3484 | } |
| 3485 | |
| 3486 | YieldOpGenericAdaptorBase(YieldOp op); |
| 3487 | |
| 3488 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); |
| 3489 | const Properties &getProperties() { |
| 3490 | return properties; |
| 3491 | } |
| 3492 | |
| 3493 | ::mlir::DictionaryAttr getAttributes() { |
| 3494 | return odsAttrs; |
| 3495 | } |
| 3496 | |
| 3497 | }; |
| 3498 | |
| 3499 | } // namespace detail |
| 3500 | template <typename RangeT> |
| 3501 | class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { |
| 3502 | using ValueT = ::llvm::detail::ValueOfRange<RangeT>; |
| 3503 | using Base = detail::YieldOpGenericAdaptorBase; |
| 3504 | static constexpr int odsIndex_results = 0; |
| 3505 | public: |
| 3506 | YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} |
| 3507 | |
| 3508 | YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::PropertyRef properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {} |
| 3509 | |
| 3510 | YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : YieldOpGenericAdaptor(values, attrs, Properties{}, {}) {} |
| 3511 | |
| 3512 | YieldOpGenericAdaptor(RangeT values, const YieldOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} |
| 3513 | |
| 3514 | template <typename LateInst = YieldOp, typename = std::enable_if_t<std::is_same_v<LateInst, YieldOp>>> |
| 3515 | YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} |
| 3516 | |
| 3517 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) { |
| 3518 | return Base::getODSOperandIndexAndLength(index, odsOperandsSize: odsOperands.size()); |
| 3519 | } |
| 3520 | |
| 3521 | RangeT getODSOperands(unsigned index) { |
| 3522 | auto valueRange = getODSOperandIndexAndLength(index); |
| 3523 | return {std::next(odsOperands.begin(), valueRange.first), |
| 3524 | std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; |
| 3525 | } |
| 3526 | |
| 3527 | RangeT getResults() { |
| 3528 | return getODSOperands(index: 0); |
| 3529 | } |
| 3530 | |
| 3531 | RangeT getOperands() { |
| 3532 | return odsOperands; |
| 3533 | } |
| 3534 | |
| 3535 | private: |
| 3536 | RangeT odsOperands; |
| 3537 | }; |
| 3538 | class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { |
| 3539 | public: |
| 3540 | using YieldOpGenericAdaptor::YieldOpGenericAdaptor; |
| 3541 | YieldOpAdaptor(YieldOp op); |
| 3542 | |
| 3543 | ::llvm::LogicalResult verify(::mlir::Location loc); |
| 3544 | }; |
| 3545 | class YieldOp : public ::mlir::Op<YieldOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::HasParent<ExecuteRegionOp, ForOp, IfOp, IndexSwitchOp, WhileOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { |
| 3546 | public: |
| 3547 | using Op::Op; |
| 3548 | using Op::print; |
| 3549 | using Adaptor = YieldOpAdaptor; |
| 3550 | template <typename RangeT> |
| 3551 | using GenericAdaptor = YieldOpGenericAdaptor<RangeT>; |
| 3552 | using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; |
| 3553 | static constexpr int odsIndex_results = 0; |
| 3554 | using Properties = FoldAdaptor::Properties; |
| 3555 | using ::mlir::RegionBranchTerminatorOpInterface::Trait<YieldOp>::getMutableSuccessorOperands; |
| 3556 | using ::mlir::RegionBranchTerminatorOpInterface::Trait<YieldOp>::getSuccessorRegions; |
| 3557 | static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { |
| 3558 | return {}; |
| 3559 | } |
| 3560 | |
| 3561 | static constexpr ::llvm::StringLiteral getOperationName() { |
| 3562 | return ::llvm::StringLiteral("scf.yield" ); |
| 3563 | } |
| 3564 | |
| 3565 | std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index); |
| 3566 | ::mlir::Operation::operand_range getODSOperands(unsigned index) { |
| 3567 | auto [start, length] = getODSOperandIndexAndLength(index); |
| 3568 | return getOperation()->getOperands().slice(n: start, m: length); |
| 3569 | } |
| 3570 | |
| 3571 | ::mlir::Operation::operand_range getResults() { |
| 3572 | return getODSOperands(index: 0); |
| 3573 | } |
| 3574 | |
| 3575 | ::mlir::MutableOperandRange getResultsMutable(); |
| 3576 | std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index) { |
| 3577 | return {index, 1}; |
| 3578 | } |
| 3579 | |
| 3580 | ::mlir::Operation::result_range getODSResults(unsigned index) { |
| 3581 | auto valueRange = getODSResultIndexAndLength(index); |
| 3582 | return {std::next(x: getOperation()->result_begin(), n: valueRange.first), |
| 3583 | std::next(x: getOperation()->result_begin(), n: valueRange.first + valueRange.second)}; |
| 3584 | } |
| 3585 | |
| 3586 | static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3587 | static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); |
| 3588 | static llvm::hash_code computePropertiesHash(const Properties &prop); |
| 3589 | static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); |
| 3590 | static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); |
| 3591 | static void walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor); |
| 3592 | static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); |
| 3593 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); |
| 3594 | static YieldOp create(::mlir::OpBuilder &builder, ::mlir::Location location); |
| 3595 | static YieldOp create(::mlir::ImplicitLocOpBuilder &builder); |
| 3596 | static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results); |
| 3597 | static YieldOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange results); |
| 3598 | static YieldOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange results); |
| 3599 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3600 | static YieldOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3601 | static YieldOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); |
| 3602 | static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3603 | static YieldOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3604 | static YieldOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); |
| 3605 | ::llvm::LogicalResult verifyInvariantsImpl(); |
| 3606 | ::llvm::LogicalResult verifyInvariants(); |
| 3607 | static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); |
| 3608 | LLVM_ATTRIBUTE_MINSIZE void print(::mlir::OpAsmPrinter &_odsPrinter); |
| 3609 | void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); |
| 3610 | public: |
| 3611 | }; |
| 3612 | |
| 3613 | } // namespace mlir::scf |
| 3614 | MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::YieldOp) |
| 3615 | |
| 3616 | |
| 3617 | #endif // GET_OP_CLASSES |
| 3618 | |
| 3619 | |