diff options
| author | River Riddle <riverriddle@google.com> | 2019-11-11 18:18:02 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-11-11 18:18:31 -0800 |
| commit | 9b9c647cefea0a81fdf7d2bf6586a13f99d9a2cf (patch) | |
| tree | 2fd6e7aeaa1e41a5e5a6355f860f35bc63ca8d99 /mlir/lib/Dialect/StandardOps | |
| parent | 5cf6e0ce7f03f9841675b1a9d44232540f3df5cc (diff) | |
| download | bcm5719-llvm-9b9c647cefea0a81fdf7d2bf6586a13f99d9a2cf.tar.gz bcm5719-llvm-9b9c647cefea0a81fdf7d2bf6586a13f99d9a2cf.zip | |
Add support for nested symbol references.
This change allows for adding additional nested references to a SymbolRefAttr to allow for further resolving a symbol if that symbol also defines a SymbolTable. If a referenced symbol also defines a symbol table, a nested reference can be used to refer to a symbol within that table. Nested references are printed after the main reference in the following form:
symbol-ref-attribute ::= symbol-ref-id (`::` symbol-ref-id)*
Example:
module @reference {
func @nested_reference()
}
my_reference_op @reference::@nested_reference
Given that SymbolRefAttr is now more general, the existing functionality centered around a single reference is moved to a derived class FlatSymbolRefAttr. Followup commits will add support to lookups, rauw, etc. for scoped references.
PiperOrigin-RevId: 279860501
Diffstat (limited to 'mlir/lib/Dialect/StandardOps')
| -rw-r--r-- | mlir/lib/Dialect/StandardOps/Ops.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 12029248168..8c08868bc7a 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -528,7 +528,7 @@ void BranchOp::getCanonicalizationPatterns(OwningRewritePatternList &results, //===----------------------------------------------------------------------===// static ParseResult parseCallOp(OpAsmParser &parser, OperationState &result) { - SymbolRefAttr calleeAttr; + FlatSymbolRefAttr calleeAttr; FunctionType calleeType; SmallVector<OpAsmParser::OperandType, 4> operands; auto calleeLoc = parser.getNameLoc(); @@ -555,7 +555,7 @@ static void print(OpAsmPrinter &p, CallOp op) { static LogicalResult verify(CallOp op) { // Check that the callee attribute was specified. - auto fnAttr = op.getAttrOfType<SymbolRefAttr>("callee"); + auto fnAttr = op.getAttrOfType<FlatSymbolRefAttr>("callee"); if (!fnAttr) return op.emitOpError("requires a 'callee' symbol reference attribute"); auto fn = @@ -608,8 +608,8 @@ struct SimplifyIndirectCallWithKnownCallee // Replace with a direct call. SmallVector<Type, 8> callResults(indirectCall.getResultTypes()); SmallVector<Value *, 8> callOperands(indirectCall.getArgOperands()); - rewriter.replaceOpWithNewOp<CallOp>(indirectCall, calledFn.getValue(), - callResults, callOperands); + rewriter.replaceOpWithNewOp<CallOp>(indirectCall, calledFn, callResults, + callOperands); return matchSuccess(); } }; @@ -1206,7 +1206,7 @@ static LogicalResult verify(ConstantOp &op) { } if (type.isa<FunctionType>()) { - auto fnAttr = value.dyn_cast<SymbolRefAttr>(); + auto fnAttr = value.dyn_cast<FlatSymbolRefAttr>(); if (!fnAttr) return op.emitOpError("requires 'value' to be a function reference"); |

