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/SPIRV/SPIRVOps.cpp | |
| 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/SPIRV/SPIRVOps.cpp')
| -rw-r--r-- | mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index b3a9f6f7443..3c1563ed515 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -658,7 +658,7 @@ void spirv::AddressOfOp::build(Builder *builder, OperationState &state, static ParseResult parseAddressOfOp(OpAsmParser &parser, OperationState &state) { - SymbolRefAttr varRefAttr; + FlatSymbolRefAttr varRefAttr; Type type; if (parser.parseAttribute(varRefAttr, Type(), kVariableAttrName, state.attributes) || @@ -1088,7 +1088,7 @@ static ParseResult parseEntryPointOp(OpAsmParser &parser, SmallVector<Type, 0> idTypes; SmallVector<Attribute, 4> interfaceVars; - SymbolRefAttr fn; + FlatSymbolRefAttr fn; if (parseEnumAttribute(execModel, parser, state) || parser.parseAttribute(fn, Type(), kFnNameAttrName, state.attributes)) { return failure(); @@ -1099,7 +1099,7 @@ static ParseResult parseEntryPointOp(OpAsmParser &parser, do { // The name of the interface variable attribute isnt important auto attrName = "var_symbol"; - SymbolRefAttr var; + FlatSymbolRefAttr var; SmallVector<NamedAttribute, 1> attrs; if (parser.parseAttribute(var, Type(), attrName, attrs)) { return failure(); @@ -1186,7 +1186,7 @@ static void print(spirv::ExecutionModeOp execModeOp, OpAsmPrinter &printer) { static ParseResult parseFunctionCallOp(OpAsmParser &parser, OperationState &state) { - SymbolRefAttr calleeAttr; + FlatSymbolRefAttr calleeAttr; FunctionType type; SmallVector<OpAsmParser::OperandType, 4> operands; auto loc = parser.getNameLoc(); @@ -1305,7 +1305,7 @@ static ParseResult parseGlobalVariableOp(OpAsmParser &parser, // Parse optional initializer if (succeeded(parser.parseOptionalKeyword(kInitializerAttrName))) { - SymbolRefAttr initSymbol; + FlatSymbolRefAttr initSymbol; if (parser.parseLParen() || parser.parseAttribute(initSymbol, Type(), kInitializerAttrName, state.attributes) || @@ -1361,7 +1361,8 @@ static LogicalResult verify(spirv::GlobalVariableOp varOp) { if (varOp.storageClass() == spirv::StorageClass::Generic) return varOp.emitOpError("storage class cannot be 'Generic'"); - if (auto init = varOp.getAttrOfType<SymbolRefAttr>(kInitializerAttrName)) { + if (auto init = + varOp.getAttrOfType<FlatSymbolRefAttr>(kInitializerAttrName)) { auto moduleOp = varOp.getParentOfType<spirv::ModuleOp>(); auto *initOp = moduleOp.lookupSymbol(init.getValue()); // TODO: Currently only variable initialization with specialization @@ -1713,7 +1714,7 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) { } if (auto interface = entryPointOp.interface()) { for (Attribute varRef : interface) { - auto varSymRef = varRef.dyn_cast<SymbolRefAttr>(); + auto varSymRef = varRef.dyn_cast<FlatSymbolRefAttr>(); if (!varSymRef) { return entryPointOp.emitError( "expected symbol reference for interface " @@ -1790,7 +1791,7 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) { static ParseResult parseReferenceOfOp(OpAsmParser &parser, OperationState &state) { - SymbolRefAttr constRefAttr; + FlatSymbolRefAttr constRefAttr; Type type; if (parser.parseAttribute(constRefAttr, Type(), kSpecConstAttrName, state.attributes) || |

