@@ -32,6 +32,12 @@ namespace mlir {
32
32
class AffineMap ;
33
33
class Builder ;
34
34
35
+ namespace detail {
36
+ // / A custom binary operation printer that omits the "std." prefix from the
37
+ // / operation names.
38
+ void printStandardBinaryOp (const Instruction *op, OpAsmPrinter *p);
39
+ } // namespace detail
40
+
35
41
class StandardOpsDialect : public Dialect {
36
42
public:
37
43
StandardOpsDialect (MLIRContext *context);
@@ -67,7 +73,7 @@ class AllocOp
67
73
return getResult ()->getType ().cast <MemRefType>();
68
74
}
69
75
70
- static StringRef getOperationName () { return " alloc" ; }
76
+ static StringRef getOperationName () { return " std. alloc" ; }
71
77
72
78
// Hooks to customize behavior of this op.
73
79
static void build (Builder *builder, OperationState *result,
@@ -96,7 +102,7 @@ class AllocOp
96
102
class BranchOp : public Op <BranchOp, OpTrait::VariadicOperands,
97
103
OpTrait::ZeroResult, OpTrait::IsTerminator> {
98
104
public:
99
- static StringRef getOperationName () { return " br" ; }
105
+ static StringRef getOperationName () { return " std. br" ; }
100
106
101
107
static void build (Builder *builder, OperationState *result, Block *dest,
102
108
ArrayRef<Value *> operands = {});
@@ -129,7 +135,7 @@ class BranchOp : public Op<BranchOp, OpTrait::VariadicOperands,
129
135
class CallOp
130
136
: public Op<CallOp, OpTrait::VariadicOperands, OpTrait::VariadicResults> {
131
137
public:
132
- static StringRef getOperationName () { return " call" ; }
138
+ static StringRef getOperationName () { return " std. call" ; }
133
139
134
140
static void build (Builder *builder, OperationState *result, Function *callee,
135
141
ArrayRef<Value *> operands);
@@ -173,7 +179,7 @@ class CallOp
173
179
class CallIndirectOp : public Op <CallIndirectOp, OpTrait::VariadicOperands,
174
180
OpTrait::VariadicResults> {
175
181
public:
176
- static StringRef getOperationName () { return " call_indirect" ; }
182
+ static StringRef getOperationName () { return " std. call_indirect" ; }
177
183
178
184
static void build (Builder *builder, OperationState *result, Value *callee,
179
185
ArrayRef<Value *> operands);
@@ -245,7 +251,7 @@ enum class CmpIPredicate {
245
251
// /
246
252
// / %r1 = cmpi "eq" %0, %1 : i32
247
253
// / %r2 = cmpi "slt" %0, %1 : tensor<42x42xi64>
248
- // / %r3 = "cmpi"(%0, %1){predicate: 0} : (i8, i8) -> i1
254
+ // / %r3 = "std. cmpi"(%0, %1){predicate: 0} : (i8, i8) -> i1
249
255
class CmpIOp
250
256
: public Op<CmpIOp, OpTrait::OperandsAreIntegerLike,
251
257
OpTrait::SameTypeOperands, OpTrait::NOperands<2 >::Impl,
@@ -257,7 +263,7 @@ class CmpIOp
257
263
.getInt ();
258
264
}
259
265
260
- static StringRef getOperationName () { return " cmpi" ; }
266
+ static StringRef getOperationName () { return " std. cmpi" ; }
261
267
static StringRef getPredicateAttrName () { return " predicate" ; }
262
268
static CmpIPredicate getPredicateByName (StringRef name);
263
269
@@ -296,7 +302,7 @@ class CondBranchOp : public Op<CondBranchOp, OpTrait::AtLeastNOperands<1>::Impl,
296
302
// / follows:
297
303
// / { condition, [true_operands], [false_operands] }
298
304
public:
299
- static StringRef getOperationName () { return " cond_br" ; }
305
+ static StringRef getOperationName () { return " std. cond_br" ; }
300
306
301
307
static void build (Builder *builder, OperationState *result, Value *condition,
302
308
Block *trueDest, ArrayRef<Value *> trueOperands,
@@ -416,8 +422,8 @@ class CondBranchOp : public Op<CondBranchOp, OpTrait::AtLeastNOperands<1>::Impl,
416
422
// / The "constant" operation requires a single attribute named "value".
417
423
// / It returns its value as an SSA value. For example:
418
424
// /
419
- // / %1 = "constant"(){value: 42} : i32
420
- // / %2 = "constant"(){value: @foo} : (f32)->f32
425
+ // / %1 = "std. constant"(){value: 42} : i32
426
+ // / %2 = "std. constant"(){value: @foo} : (f32)->f32
421
427
// /
422
428
class ConstantOp : public Op <ConstantOp, OpTrait::ZeroOperands,
423
429
OpTrait::OneResult, OpTrait::HasNoSideEffect> {
@@ -432,7 +438,7 @@ class ConstantOp : public Op<ConstantOp, OpTrait::ZeroOperands,
432
438
433
439
Attribute getValue () const { return getAttr (" value" ); }
434
440
435
- static StringRef getOperationName () { return " constant" ; }
441
+ static StringRef getOperationName () { return " std. constant" ; }
436
442
437
443
// Hooks to customize behavior of this op.
438
444
static bool parse (OpAsmParser *parser, OperationState *result);
@@ -449,7 +455,7 @@ class ConstantOp : public Op<ConstantOp, OpTrait::ZeroOperands,
449
455
// / This is a refinement of the "constant" op for the case where it is
450
456
// / returning a float value of FloatType.
451
457
// /
452
- // / %1 = "constant"(){value: 42.0} : bf16
458
+ // / %1 = "std. constant"(){value: 42.0} : bf16
453
459
// /
454
460
class ConstantFloatOp : public ConstantOp {
455
461
public:
@@ -471,7 +477,7 @@ class ConstantFloatOp : public ConstantOp {
471
477
// / This is a refinement of the "constant" op for the case where it is
472
478
// / returning an integer value of IntegerType.
473
479
// /
474
- // / %1 = "constant"(){value: 42} : i32
480
+ // / %1 = "std. constant"(){value: 42} : i32
475
481
// /
476
482
class ConstantIntOp : public ConstantOp {
477
483
public:
@@ -498,7 +504,7 @@ class ConstantIntOp : public ConstantOp {
498
504
// / This is a refinement of the "constant" op for the case where it is
499
505
// / returning an integer value of Index type.
500
506
// /
501
- // / %1 = "constant"(){value: 99} : () -> index
507
+ // / %1 = "std. constant"(){value: 99} : () -> index
502
508
// /
503
509
class ConstantIndexOp : public ConstantOp {
504
510
public:
@@ -533,7 +539,7 @@ class DeallocOp
533
539
const Value *getMemRef () const { return getOperand (); }
534
540
void setMemRef (Value *value) { setOperand (value); }
535
541
536
- static StringRef getOperationName () { return " dealloc" ; }
542
+ static StringRef getOperationName () { return " std. dealloc" ; }
537
543
538
544
// Hooks to customize behavior of this op.
539
545
static void build (Builder *builder, OperationState *result, Value *memref);
@@ -568,7 +574,7 @@ class DimOp : public Op<DimOp, OpTrait::OneOperand, OpTrait::OneResult,
568
574
return getAttrOfType<IntegerAttr>(" index" ).getValue ().getZExtValue ();
569
575
}
570
576
571
- static StringRef getOperationName () { return " dim" ; }
577
+ static StringRef getOperationName () { return " std. dim" ; }
572
578
573
579
// Hooks to customize behavior of this op.
574
580
bool verify () const ;
@@ -706,7 +712,7 @@ class DmaStartOp
706
712
return isSrcMemorySpaceFaster () ? 0 : getSrcMemRefRank () + 1 ;
707
713
}
708
714
709
- static StringRef getOperationName () { return " dma_start" ; }
715
+ static StringRef getOperationName () { return " std. dma_start" ; }
710
716
static bool parse (OpAsmParser *parser, OperationState *result);
711
717
void print (OpAsmPrinter *p) const ;
712
718
bool verify () const ;
@@ -761,7 +767,7 @@ class DmaWaitOp
761
767
static void build (Builder *builder, OperationState *result, Value *tagMemRef,
762
768
ArrayRef<Value *> tagIndices, Value *numElements);
763
769
764
- static StringRef getOperationName () { return " dma_wait" ; }
770
+ static StringRef getOperationName () { return " std. dma_wait" ; }
765
771
766
772
// Returns the Tag MemRef associated with the DMA operation being waited on.
767
773
const Value *getTagMemRef () const { return getOperand (0 ); }
@@ -825,7 +831,7 @@ class ExtractElementOp
825
831
getInstruction ()->operand_end ()};
826
832
}
827
833
828
- static StringRef getOperationName () { return " extract_element" ; }
834
+ static StringRef getOperationName () { return " std. extract_element" ; }
829
835
830
836
// Hooks to customize behavior of this op.
831
837
bool verify () const ;
@@ -871,7 +877,7 @@ class LoadOp
871
877
getInstruction ()->operand_end ()};
872
878
}
873
879
874
- static StringRef getOperationName () { return " load" ; }
880
+ static StringRef getOperationName () { return " std. load" ; }
875
881
876
882
bool verify () const ;
877
883
static bool parse (OpAsmParser *parser, OperationState *result);
@@ -901,13 +907,15 @@ class LoadOp
901
907
// /
902
908
class MemRefCastOp : public CastOp <MemRefCastOp> {
903
909
public:
904
- static StringRef getOperationName () { return " memref_cast" ; }
910
+ static StringRef getOperationName () { return " std. memref_cast" ; }
905
911
906
912
// / The result of a memref_cast is always a memref.
907
913
MemRefType getType () const {
908
914
return getResult ()->getType ().cast <MemRefType>();
909
915
}
910
916
917
+ void print (OpAsmPrinter *p) const ;
918
+
911
919
bool verify () const ;
912
920
913
921
private:
@@ -920,14 +928,14 @@ class MemRefCastOp : public CastOp<MemRefCastOp> {
920
928
// / The operand number and types must match the signature of the function
921
929
// / that contains the operation. For example:
922
930
// /
923
- // / mlfunc @foo() : (i32, f8) {
931
+ // / func @foo() : (i32, f8) {
924
932
// / ...
925
933
// / return %0, %1 : i32, f8
926
934
// /
927
935
class ReturnOp : public Op <ReturnOp, OpTrait::VariadicOperands,
928
936
OpTrait::ZeroResult, OpTrait::IsTerminator> {
929
937
public:
930
- static StringRef getOperationName () { return " return" ; }
938
+ static StringRef getOperationName () { return " std. return" ; }
931
939
932
940
static void build (Builder *builder, OperationState *result,
933
941
ArrayRef<Value *> results = {});
@@ -956,7 +964,7 @@ class ReturnOp : public Op<ReturnOp, OpTrait::VariadicOperands,
956
964
class SelectOp : public Op <SelectOp, OpTrait::NOperands<3 >::Impl,
957
965
OpTrait::OneResult, OpTrait::HasNoSideEffect> {
958
966
public:
959
- static StringRef getOperationName () { return " select" ; }
967
+ static StringRef getOperationName () { return " std. select" ; }
960
968
static void build (Builder *builder, OperationState *result, Value *condition,
961
969
Value *trueValue, Value *falseValue);
962
970
static bool parse (OpAsmParser *parser, OperationState *result);
@@ -1015,7 +1023,7 @@ class StoreOp
1015
1023
getInstruction ()->operand_end ()};
1016
1024
}
1017
1025
1018
- static StringRef getOperationName () { return " store" ; }
1026
+ static StringRef getOperationName () { return " std. store" ; }
1019
1027
1020
1028
bool verify () const ;
1021
1029
static bool parse (OpAsmParser *parser, OperationState *result);
@@ -1041,13 +1049,15 @@ class StoreOp
1041
1049
// /
1042
1050
class TensorCastOp : public CastOp <TensorCastOp> {
1043
1051
public:
1044
- static StringRef getOperationName () { return " tensor_cast" ; }
1052
+ static StringRef getOperationName () { return " std. tensor_cast" ; }
1045
1053
1046
1054
// / The result of a tensor_cast is always a tensor.
1047
1055
TensorType getType () const {
1048
1056
return getResult ()->getType ().cast <TensorType>();
1049
1057
}
1050
1058
1059
+ void print (OpAsmPrinter *p) const ;
1060
+
1051
1061
bool verify () const ;
1052
1062
1053
1063
private:
0 commit comments