@@ -316,147 +316,6 @@ class AffineDmaWaitOp : public Op<AffineDmaWaitOp, OpTrait::VariadicOperands,
316
316
SmallVectorImpl<OpFoldResult> &results);
317
317
};
318
318
319
- // / The "affine.load" op reads an element from a memref, where the index
320
- // / for each memref dimension is an affine expression of loop induction
321
- // / variables and symbols. The output of 'affine.load' is a new value with the
322
- // / same type as the elements of the memref. An affine expression of loop IVs
323
- // / and symbols must be specified for each dimension of the memref. The keyword
324
- // / 'symbol' can be used to indicate SSA identifiers which are symbolic.
325
- //
326
- // Example 1:
327
- //
328
- // %1 = affine.load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>
329
- //
330
- // Example 2: Uses 'symbol' keyword for symbols '%n' and '%m'.
331
- //
332
- // %1 = affine.load %0[%i0 + symbol(%n), %i1 + symbol(%m)]
333
- // : memref<100x100xf32>
334
- //
335
- class AffineLoadOp : public Op <AffineLoadOp, OpTrait::OneResult,
336
- OpTrait::AtLeastNOperands<1 >::Impl> {
337
- public:
338
- using Op::Op;
339
-
340
- // / Builds an affine load op with the specified map and operands.
341
- static void build (OpBuilder &builder, OperationState &result, AffineMap map,
342
- ValueRange operands);
343
- // / Builds an affine load op with an identity map and operands.
344
- static void build (OpBuilder &builder, OperationState &result, Value memref,
345
- ValueRange indices = {});
346
- // / Builds an affine load op with the specified map and its operands.
347
- static void build (OpBuilder &builder, OperationState &result, Value memref,
348
- AffineMap map, ValueRange mapOperands);
349
-
350
- // / Returns the operand index of the memref.
351
- unsigned getMemRefOperandIndex () { return 0 ; }
352
-
353
- // / Get memref operand.
354
- Value getMemRef () { return getOperand (getMemRefOperandIndex ()); }
355
- void setMemRef (Value value) { setOperand (getMemRefOperandIndex (), value); }
356
- MemRefType getMemRefType () {
357
- return getMemRef ().getType ().cast <MemRefType>();
358
- }
359
-
360
- // / Get affine map operands.
361
- operand_range getMapOperands () { return llvm::drop_begin (getOperands (), 1 ); }
362
-
363
- // / Returns the affine map used to index the memref for this operation.
364
- AffineMap getAffineMap () { return getAffineMapAttr ().getValue (); }
365
- AffineMapAttr getAffineMapAttr () {
366
- return getAttr (getMapAttrName ()).cast <AffineMapAttr>();
367
- }
368
-
369
- // / Returns the AffineMapAttr associated with 'memref'.
370
- NamedAttribute getAffineMapAttrForMemRef (Value memref) {
371
- assert (memref == getMemRef ());
372
- return {Identifier::get (getMapAttrName (), getContext ()),
373
- getAffineMapAttr ()};
374
- }
375
-
376
- static StringRef getMapAttrName () { return " map" ; }
377
- static StringRef getOperationName () { return " affine.load" ; }
378
-
379
- // Hooks to customize behavior of this op.
380
- static ParseResult parse (OpAsmParser &parser, OperationState &result);
381
- void print (OpAsmPrinter &p);
382
- LogicalResult verify ();
383
- static void getCanonicalizationPatterns (OwningRewritePatternList &results,
384
- MLIRContext *context);
385
- OpFoldResult fold (ArrayRef<Attribute> operands);
386
- };
387
-
388
- // / The "affine.store" op writes an element to a memref, where the index
389
- // / for each memref dimension is an affine expression of loop induction
390
- // / variables and symbols. The 'affine.store' op stores a new value which is the
391
- // / same type as the elements of the memref. An affine expression of loop IVs
392
- // / and symbols must be specified for each dimension of the memref. The keyword
393
- // / 'symbol' can be used to indicate SSA identifiers which are symbolic.
394
- //
395
- // Example 1:
396
- //
397
- // affine.store %v0, %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>
398
- //
399
- // Example 2: Uses 'symbol' keyword for symbols '%n' and '%m'.
400
- //
401
- // affine.store %v0, %0[%i0 + symbol(%n), %i1 + symbol(%m)]
402
- // : memref<100x100xf32>
403
- //
404
- class AffineStoreOp : public Op <AffineStoreOp, OpTrait::ZeroResult,
405
- OpTrait::AtLeastNOperands<1 >::Impl> {
406
- public:
407
- using Op::Op;
408
-
409
- // / Builds an affine store operation with the provided indices (identity map).
410
- static void build (OpBuilder &builder, OperationState &result,
411
- Value valueToStore, Value memref, ValueRange indices);
412
- // / Builds an affine store operation with the specified map and its operands.
413
- static void build (OpBuilder &builder, OperationState &result,
414
- Value valueToStore, Value memref, AffineMap map,
415
- ValueRange mapOperands);
416
-
417
- // / Get value to be stored by store operation.
418
- Value getValueToStore () { return getOperand (0 ); }
419
-
420
- // / Returns the operand index of the memref.
421
- unsigned getMemRefOperandIndex () { return 1 ; }
422
-
423
- // / Get memref operand.
424
- Value getMemRef () { return getOperand (getMemRefOperandIndex ()); }
425
- void setMemRef (Value value) { setOperand (getMemRefOperandIndex (), value); }
426
-
427
- MemRefType getMemRefType () {
428
- return getMemRef ().getType ().cast <MemRefType>();
429
- }
430
-
431
- // / Get affine map operands.
432
- operand_range getMapOperands () { return llvm::drop_begin (getOperands (), 2 ); }
433
-
434
- // / Returns the affine map used to index the memref for this operation.
435
- AffineMap getAffineMap () { return getAffineMapAttr ().getValue (); }
436
- AffineMapAttr getAffineMapAttr () {
437
- return getAttr (getMapAttrName ()).cast <AffineMapAttr>();
438
- }
439
-
440
- // / Returns the AffineMapAttr associated with 'memref'.
441
- NamedAttribute getAffineMapAttrForMemRef (Value memref) {
442
- assert (memref == getMemRef ());
443
- return {Identifier::get (getMapAttrName (), getContext ()),
444
- getAffineMapAttr ()};
445
- }
446
-
447
- static StringRef getMapAttrName () { return " map" ; }
448
- static StringRef getOperationName () { return " affine.store" ; }
449
-
450
- // Hooks to customize behavior of this op.
451
- static ParseResult parse (OpAsmParser &parser, OperationState &result);
452
- void print (OpAsmPrinter &p);
453
- LogicalResult verify ();
454
- static void getCanonicalizationPatterns (OwningRewritePatternList &results,
455
- MLIRContext *context);
456
- LogicalResult fold (ArrayRef<Attribute> cstOperands,
457
- SmallVectorImpl<OpFoldResult> &results);
458
- };
459
-
460
319
// / Returns true if the given Value can be used as a dimension id.
461
320
bool isValidDim (Value value);
462
321
0 commit comments