Revise the AffineExpr printing logic to be more careful about paren emission.
This is still (intentionally) generating redundant parens for nested tightly
binding expressions, but I think that is reasonable for readability sake.
This also print x-y instead of x-(y*1)
PiperOrigin-RevId: 206847212
diff --git a/lib/IR/StandardOps.cpp b/lib/IR/StandardOps.cpp
index 66d3d05..3d74e58 100644
--- a/lib/IR/StandardOps.cpp
+++ b/lib/IR/StandardOps.cpp
@@ -96,11 +96,9 @@
auto *affineIntTy = builder.getAffineIntType();
AffineMapAttr *mapAttr;
- if (parser->parseAttribute(mapAttr))
- return {};
-
unsigned numDims;
- if (parseDimAndSymbolList(parser, opInfos, operands, numDims))
+ if (parser->parseAttribute(mapAttr) ||
+ parseDimAndSymbolList(parser, opInfos, operands, numDims))
return {};
auto *map = mapAttr->getValue();
@@ -158,13 +156,11 @@
SmallVector<SSAValue *, 4> operands;
SmallVector<OpAsmParser::OperandType, 4> operandsInfo;
- // Parse the dimension operands and optional symbol operands.
+ // Parse the dimension operands and optional symbol operands, followed by a
+ // memref type.
unsigned numDimOperands;
- if (parseDimAndSymbolList(parser, operandsInfo, operands, numDimOperands))
- return {};
-
- // Parse memref type.
- if (parser->parseColonType(type))
+ if (parseDimAndSymbolList(parser, operandsInfo, operands, numDimOperands) ||
+ parser->parseColonType(type))
return {};
// Check numDynamicDims against number of question marks in memref type.