diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -35,31 +35,30 @@ using namespace mlir; // TODO: generate these strings using ODS. -static constexpr const char kMemoryAccessAttrName[] = "memory_access"; -static constexpr const char kSourceMemoryAccessAttrName[] = - "source_memory_access"; -static constexpr const char kAlignmentAttrName[] = "alignment"; -static constexpr const char kSourceAlignmentAttrName[] = "source_alignment"; -static constexpr const char kBranchWeightAttrName[] = "branch_weights"; -static constexpr const char kCallee[] = "callee"; -static constexpr const char kClusterSize[] = "cluster_size"; -static constexpr const char kControl[] = "control"; -static constexpr const char kDefaultValueAttrName[] = "default_value"; -static constexpr const char kExecutionScopeAttrName[] = "execution_scope"; -static constexpr const char kEqualSemanticsAttrName[] = "equal_semantics"; -static constexpr const char kFnNameAttrName[] = "fn"; -static constexpr const char kGroupOperationAttrName[] = "group_operation"; -static constexpr const char kIndicesAttrName[] = "indices"; -static constexpr const char kInitializerAttrName[] = "initializer"; -static constexpr const char kInterfaceAttrName[] = "interface"; -static constexpr const char kMemoryScopeAttrName[] = "memory_scope"; -static constexpr const char kSemanticsAttrName[] = "semantics"; -static constexpr const char kSpecIdAttrName[] = "spec_id"; -static constexpr const char kTypeAttrName[] = "type"; -static constexpr const char kUnequalSemanticsAttrName[] = "unequal_semantics"; -static constexpr const char kValueAttrName[] = "value"; -static constexpr const char kValuesAttrName[] = "values"; -static constexpr const char kCompositeSpecConstituentsName[] = "constituents"; +constexpr char kMemoryAccessAttrName[] = "memory_access"; +constexpr char kSourceMemoryAccessAttrName[] = "source_memory_access"; +constexpr char kAlignmentAttrName[] = "alignment"; +constexpr char kSourceAlignmentAttrName[] = "source_alignment"; +constexpr char kBranchWeightAttrName[] = "branch_weights"; +constexpr char kCallee[] = "callee"; +constexpr char kClusterSize[] = "cluster_size"; +constexpr char kControl[] = "control"; +constexpr char kDefaultValueAttrName[] = "default_value"; +constexpr char kExecutionScopeAttrName[] = "execution_scope"; +constexpr char kEqualSemanticsAttrName[] = "equal_semantics"; +constexpr char kFnNameAttrName[] = "fn"; +constexpr char kGroupOperationAttrName[] = "group_operation"; +constexpr char kIndicesAttrName[] = "indices"; +constexpr char kInitializerAttrName[] = "initializer"; +constexpr char kInterfaceAttrName[] = "interface"; +constexpr char kMemoryScopeAttrName[] = "memory_scope"; +constexpr char kSemanticsAttrName[] = "semantics"; +constexpr char kSpecIdAttrName[] = "spec_id"; +constexpr char kTypeAttrName[] = "type"; +constexpr char kUnequalSemanticsAttrName[] = "unequal_semantics"; +constexpr char kValueAttrName[] = "value"; +constexpr char kValuesAttrName[] = "values"; +constexpr char kCompositeSpecConstituentsName[] = "constituents"; //===----------------------------------------------------------------------===// // Common utility functions @@ -1029,7 +1028,7 @@ } ParseResult spirv::AccessChainOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { OpAsmParser::UnresolvedOperand ptrInfo; SmallVector indicesInfo; Type type; @@ -1039,15 +1038,15 @@ if (parser.parseOperand(ptrInfo) || parser.parseOperandList(indicesInfo, OpAsmParser::Delimiter::Square) || parser.parseColonType(type) || - parser.resolveOperand(ptrInfo, type, state.operands)) { + parser.resolveOperand(ptrInfo, type, result.operands)) { return failure(); } // Check that the provided indices list is not empty before parsing their // type list. if (indicesInfo.empty()) { - return mlir::emitError(state.location, "'spv.AccessChain' op expected at " - "least one index "); + return mlir::emitError(result.location, "'spv.AccessChain' op expected at " + "least one index "); } if (parser.parseComma() || parser.parseTypeList(indicesTypes)) @@ -1056,21 +1055,21 @@ // Check that the indices types list is not empty and that it has a one-to-one // mapping to the provided indices. if (indicesTypes.size() != indicesInfo.size()) { - return mlir::emitError(state.location, + return mlir::emitError(result.location, "'spv.AccessChain' op indices types' count must be " "equal to indices info count"); } - if (parser.resolveOperands(indicesInfo, indicesTypes, loc, state.operands)) + if (parser.resolveOperands(indicesInfo, indicesTypes, loc, result.operands)) return failure(); auto resultType = getElementPtrType( - type, llvm::makeArrayRef(state.operands).drop_front(), state.location); + type, llvm::makeArrayRef(result.operands).drop_front(), result.location); if (!resultType) { return failure(); } - state.addTypes(resultType); + result.addTypes(resultType); return success(); } @@ -1263,13 +1262,13 @@ } ParseResult spirv::AtomicExchangeOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { spirv::Scope memoryScope; spirv::MemorySemantics semantics; SmallVector operandInfo; Type type; - if (parseEnumStrAttr(memoryScope, parser, state, kMemoryScopeAttrName) || - parseEnumStrAttr(semantics, parser, state, kSemanticsAttrName) || + if (parseEnumStrAttr(memoryScope, parser, result, kMemoryScopeAttrName) || + parseEnumStrAttr(semantics, parser, result, kSemanticsAttrName) || parser.parseOperandList(operandInfo, 2)) return failure(); @@ -1282,10 +1281,10 @@ return parser.emitError(loc, "expected pointer type"); if (parser.resolveOperands(operandInfo, {ptrType, ptrType.getPointeeType()}, - parser.getNameLoc(), state.operands)) + parser.getNameLoc(), result.operands)) return failure(); - return parser.addTypeToList(ptrType.getPointeeType(), state.types); + return parser.addTypeToList(ptrType.getPointeeType(), result.types); } LogicalResult spirv::AtomicExchangeOp::verify() { @@ -1533,7 +1532,7 @@ } ParseResult spirv::BranchConditionalOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { auto &builder = parser.getBuilder(); OpAsmParser::UnresolvedOperand condInfo; Block *dest; @@ -1541,7 +1540,7 @@ // Parse the condition. Type boolTy = builder.getI1Type(); if (parser.parseOperand(condInfo) || - parser.resolveOperand(condInfo, boolTy, state.operands)) + parser.resolveOperand(condInfo, boolTy, result.operands)) return failure(); // Parse the optional branch weights. @@ -1556,8 +1555,8 @@ parser.parseRSquare()) return failure(); - state.addAttribute(kBranchWeightAttrName, - builder.getArrayAttr({trueWeight, falseWeight})); + result.addAttribute(kBranchWeightAttrName, + builder.getArrayAttr({trueWeight, falseWeight})); } // Parse the true branch. @@ -1565,17 +1564,17 @@ if (parser.parseComma() || parser.parseSuccessorAndUseList(dest, trueOperands)) return failure(); - state.addSuccessors(dest); - state.addOperands(trueOperands); + result.addSuccessors(dest); + result.addOperands(trueOperands); // Parse the false branch. SmallVector falseOperands; if (parser.parseComma() || parser.parseSuccessorAndUseList(dest, falseOperands)) return failure(); - state.addSuccessors(dest); - state.addOperands(falseOperands); - state.addAttribute( + result.addSuccessors(dest); + result.addOperands(falseOperands); + result.addAttribute( spirv::BranchConditionalOp::getOperandSegmentSizeAttr(), builder.getI32VectorAttr({1, static_cast(trueOperands.size()), static_cast(falseOperands.size())})); @@ -1696,7 +1695,7 @@ } ParseResult spirv::CompositeExtractOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { OpAsmParser::UnresolvedOperand compositeInfo; Attribute indicesAttr; Type compositeType; @@ -1704,9 +1703,9 @@ if (parser.parseOperand(compositeInfo) || parser.getCurrentLocation(&attrLocation) || - parser.parseAttribute(indicesAttr, kIndicesAttrName, state.attributes) || + parser.parseAttribute(indicesAttr, kIndicesAttrName, result.attributes) || parser.parseColonType(compositeType) || - parser.resolveOperand(compositeInfo, compositeType, state.operands)) { + parser.resolveOperand(compositeInfo, compositeType, result.operands)) { return failure(); } @@ -1715,7 +1714,7 @@ if (!resultType) { return failure(); } - state.addTypes(resultType); + result.addTypes(resultType); return success(); } @@ -1750,7 +1749,7 @@ } ParseResult spirv::CompositeInsertOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { SmallVector operands; Type objectType, compositeType; Attribute indicesAttr; @@ -1758,12 +1757,12 @@ return failure( parser.parseOperandList(operands, 2) || - parser.parseAttribute(indicesAttr, kIndicesAttrName, state.attributes) || + parser.parseAttribute(indicesAttr, kIndicesAttrName, result.attributes) || parser.parseColonType(objectType) || parser.parseKeywordType("into", compositeType) || parser.resolveOperands(operands, {objectType, compositeType}, loc, - state.operands) || - parser.addTypesToList(compositeType, state.types)); + result.operands) || + parser.addTypesToList(compositeType, result.types)); } LogicalResult spirv::CompositeInsertOp::verify() { @@ -1797,9 +1796,9 @@ //===----------------------------------------------------------------------===// ParseResult spirv::ConstantOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { Attribute value; - if (parser.parseAttribute(value, kValueAttrName, state.attributes)) + if (parser.parseAttribute(value, kValueAttrName, result.attributes)) return failure(); Type type = NoneType::get(parser.getContext()); @@ -1810,7 +1809,7 @@ return failure(); } - return parser.addTypeToList(type, state.types); + return parser.addTypeToList(type, result.types); } void spirv::ConstantOp::print(OpAsmPrinter &printer) { @@ -2069,15 +2068,15 @@ } ParseResult spirv::EntryPointOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { spirv::ExecutionModel execModel; SmallVector identifiers; SmallVector idTypes; SmallVector interfaceVars; FlatSymbolRefAttr fn; - if (parseEnumStrAttr(execModel, parser, state) || - parser.parseAttribute(fn, Type(), kFnNameAttrName, state.attributes)) { + if (parseEnumStrAttr(execModel, parser, result) || + parser.parseAttribute(fn, Type(), kFnNameAttrName, result.attributes)) { return failure(); } @@ -2094,8 +2093,8 @@ })) return failure(); } - state.addAttribute(kInterfaceAttrName, - parser.getBuilder().getArrayAttr(interfaceVars)); + result.addAttribute(kInterfaceAttrName, + parser.getBuilder().getArrayAttr(interfaceVars)); return success(); } @@ -2129,11 +2128,11 @@ } ParseResult spirv::ExecutionModeOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { spirv::ExecutionMode execMode; Attribute fn; - if (parser.parseAttribute(fn, kFnNameAttrName, state.attributes) || - parseEnumStrAttr(execMode, parser, state)) { + if (parser.parseAttribute(fn, kFnNameAttrName, result.attributes) || + parseEnumStrAttr(execMode, parser, result)) { return failure(); } @@ -2147,8 +2146,8 @@ } values.push_back(value.cast().getInt()); } - state.addAttribute(kValuesAttrName, - parser.getBuilder().getI32ArrayAttr(values)); + result.addAttribute(kValuesAttrName, + parser.getBuilder().getI32ArrayAttr(values)); return success(); } @@ -2193,7 +2192,7 @@ // spv.func //===----------------------------------------------------------------------===// -ParseResult spirv::FuncOp::parse(OpAsmParser &parser, OperationState &state) { +ParseResult spirv::FuncOp::parse(OpAsmParser &parser, OperationState &result) { SmallVector entryArgs; SmallVector resultAttrs; SmallVector resultTypes; @@ -2202,7 +2201,7 @@ // Parse the name as a symbol. StringAttr nameAttr; if (parser.parseSymbolName(nameAttr, SymbolTable::getSymbolAttrName(), - state.attributes)) + result.attributes)) return failure(); // Parse the function signature. @@ -2216,27 +2215,28 @@ for (auto &arg : entryArgs) argTypes.push_back(arg.type); auto fnType = builder.getFunctionType(argTypes, resultTypes); - state.addAttribute(FunctionOpInterface::getTypeAttrName(), - TypeAttr::get(fnType)); + result.addAttribute(FunctionOpInterface::getTypeAttrName(), + TypeAttr::get(fnType)); // Parse the optional function control keyword. spirv::FunctionControl fnControl; - if (parseEnumStrAttr(fnControl, parser, state)) + if (parseEnumStrAttr(fnControl, parser, result)) return failure(); // If additional attributes are present, parse them. - if (parser.parseOptionalAttrDictWithKeyword(state.attributes)) + if (parser.parseOptionalAttrDictWithKeyword(result.attributes)) return failure(); // Add the attributes to the function arguments. assert(resultAttrs.size() == resultTypes.size()); - function_interface_impl::addArgAndResultAttrs(builder, state, entryArgs, + function_interface_impl::addArgAndResultAttrs(builder, result, entryArgs, resultAttrs); // Parse the optional function body. - auto *body = state.addRegion(); - OptionalParseResult result = parser.parseOptionalRegion(*body, entryArgs); - return failure(result.has_value() && failed(*result)); + auto *body = result.addRegion(); + OptionalParseResult parseResult = + parser.parseOptionalRegion(*body, entryArgs); + return failure(parseResult.hasValue() && failed(*parseResult)); } void spirv::FuncOp::print(OpAsmPrinter &printer) { @@ -2449,11 +2449,11 @@ } ParseResult spirv::GlobalVariableOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { // Parse variable name. StringAttr nameAttr; if (parser.parseSymbolName(nameAttr, SymbolTable::getSymbolAttrName(), - state.attributes)) { + result.attributes)) { return failure(); } @@ -2462,12 +2462,12 @@ FlatSymbolRefAttr initSymbol; if (parser.parseLParen() || parser.parseAttribute(initSymbol, Type(), kInitializerAttrName, - state.attributes) || + result.attributes) || parser.parseRParen()) return failure(); } - if (parseVariableDecorations(parser, state)) { + if (parseVariableDecorations(parser, result)) { return failure(); } @@ -2479,7 +2479,7 @@ if (!type.isa()) { return parser.emitError(loc, "expected spv.ptr type"); } - state.addAttribute(kTypeAttrName, TypeAttr::get(type)); + result.addAttribute(kTypeAttrName, TypeAttr::get(type)); return success(); } @@ -2595,7 +2595,7 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SubgroupBlockReadINTELOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { // Parse the storage class specification spirv::StorageClass storageClass; OpAsmParser::UnresolvedOperand ptrInfo; @@ -2609,11 +2609,11 @@ if (auto valVecTy = elementType.dyn_cast()) ptrType = spirv::PointerType::get(valVecTy.getElementType(), storageClass); - if (parser.resolveOperand(ptrInfo, ptrType, state.operands)) { + if (parser.resolveOperand(ptrInfo, ptrType, result.operands)) { return failure(); } - state.addTypes(elementType); + result.addTypes(elementType); return success(); } @@ -2633,7 +2633,7 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SubgroupBlockWriteINTELOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { // Parse the storage class specification spirv::StorageClass storageClass; SmallVector operandInfo; @@ -2650,7 +2650,7 @@ ptrType = spirv::PointerType::get(valVecTy.getElementType(), storageClass); if (parser.resolveOperands(operandInfo, {ptrType, elementType}, loc, - state.operands)) { + result.operands)) { return failure(); } return success(); @@ -2848,9 +2848,9 @@ if (resultType.getNumElements() != 2) return emitOpError("expected result struct type containing two members"); - if (!llvm::is_splat(llvm::makeArrayRef( - {operand1().getType(), operand2().getType(), - resultType.getElementType(0), resultType.getElementType(1)}))) + if (!llvm::is_splat({operand1().getType(), operand2().getType(), + resultType.getElementType(0), + resultType.getElementType(1)})) return emitOpError( "expected all operand types and struct member types are the same"); @@ -2897,9 +2897,9 @@ if (resultType.getNumElements() != 2) return emitOpError("expected result struct type containing two members"); - if (!llvm::is_splat(llvm::makeArrayRef( - {operand1().getType(), operand2().getType(), - resultType.getElementType(0), resultType.getElementType(1)}))) + if (!llvm::is_splat({operand1().getType(), operand2().getType(), + resultType.getElementType(0), + resultType.getElementType(1)})) return emitOpError( "expected all operand types and struct member types are the same"); @@ -2949,24 +2949,24 @@ alignment); } -ParseResult spirv::LoadOp::parse(OpAsmParser &parser, OperationState &state) { +ParseResult spirv::LoadOp::parse(OpAsmParser &parser, OperationState &result) { // Parse the storage class specification spirv::StorageClass storageClass; OpAsmParser::UnresolvedOperand ptrInfo; Type elementType; if (parseEnumStrAttr(storageClass, parser) || parser.parseOperand(ptrInfo) || - parseMemoryAccessAttributes(parser, state) || - parser.parseOptionalAttrDict(state.attributes) || parser.parseColon() || + parseMemoryAccessAttributes(parser, result) || + parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() || parser.parseType(elementType)) { return failure(); } auto ptrType = spirv::PointerType::get(elementType, storageClass); - if (parser.resolveOperand(ptrInfo, ptrType, state.operands)) { + if (parser.resolveOperand(ptrInfo, ptrType, result.operands)) { return failure(); } - state.addTypes(elementType); + result.addTypes(elementType); return success(); } @@ -3003,11 +3003,10 @@ state.addRegion(); } -ParseResult spirv::LoopOp::parse(OpAsmParser &parser, OperationState &state) { - if (parseControlAttribute(parser, state)) +ParseResult spirv::LoopOp::parse(OpAsmParser &parser, OperationState &result) { + if (parseControlAttribute(parser, result)) return failure(); - return parser.parseRegion(*state.addRegion(), /*arguments=*/{}, - /*argTypes=*/{}); + return parser.parseRegion(*result.addRegion(), /*arguments=*/{}); } void spirv::LoopOp::print(OpAsmPrinter &printer) { @@ -3208,31 +3207,32 @@ builder.getStringAttr(*name)); } -ParseResult spirv::ModuleOp::parse(OpAsmParser &parser, OperationState &state) { - Region *body = state.addRegion(); +ParseResult spirv::ModuleOp::parse(OpAsmParser &parser, + OperationState &result) { + Region *body = result.addRegion(); // If the name is present, parse it. StringAttr nameAttr; (void)parser.parseOptionalSymbolName( - nameAttr, mlir::SymbolTable::getSymbolAttrName(), state.attributes); + nameAttr, mlir::SymbolTable::getSymbolAttrName(), result.attributes); // Parse attributes spirv::AddressingModel addrModel; spirv::MemoryModel memoryModel; - if (::parseEnumKeywordAttr(addrModel, parser, state) || - ::parseEnumKeywordAttr(memoryModel, parser, state)) + if (::parseEnumKeywordAttr(addrModel, parser, result) || + ::parseEnumKeywordAttr(memoryModel, parser, result)) return failure(); if (succeeded(parser.parseOptionalKeyword("requires"))) { spirv::VerCapExtAttr vceTriple; if (parser.parseAttribute(vceTriple, spirv::ModuleOp::getVCETripleAttrName(), - state.attributes)) + result.attributes)) return failure(); } - if (parser.parseOptionalAttrDictWithKeyword(state.attributes) || - parser.parseRegion(*body, /*arguments=*/{}, /*argTypes=*/{})) + if (parser.parseOptionalAttrDictWithKeyword(result.attributes) || + parser.parseRegion(*body, /*arguments=*/{})) return failure(); // Make sure we have at least one block. @@ -3400,11 +3400,10 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SelectionOp::parse(OpAsmParser &parser, - OperationState &state) { - if (parseControlAttribute(parser, state)) + OperationState &result) { + if (parseControlAttribute(parser, result)) return failure(); - return parser.parseRegion(*state.addRegion(), /*arguments=*/{}, - /*argTypes=*/{}); + return parser.parseRegion(*result.addRegion(), /*arguments=*/{}); } void spirv::SelectionOp::print(OpAsmPrinter &printer) { @@ -3515,25 +3514,26 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { StringAttr nameAttr; Attribute valueAttr; if (parser.parseSymbolName(nameAttr, SymbolTable::getSymbolAttrName(), - state.attributes)) + result.attributes)) return failure(); // Parse optional spec_id. if (succeeded(parser.parseOptionalKeyword(kSpecIdAttrName))) { IntegerAttr specIdAttr; if (parser.parseLParen() || - parser.parseAttribute(specIdAttr, kSpecIdAttrName, state.attributes) || + parser.parseAttribute(specIdAttr, kSpecIdAttrName, result.attributes) || parser.parseRParen()) return failure(); } if (parser.parseEqual() || - parser.parseAttribute(valueAttr, kDefaultValueAttrName, state.attributes)) + parser.parseAttribute(valueAttr, kDefaultValueAttrName, + result.attributes)) return failure(); return success(); @@ -3567,7 +3567,7 @@ // spv.StoreOp //===----------------------------------------------------------------------===// -ParseResult spirv::StoreOp::parse(OpAsmParser &parser, OperationState &state) { +ParseResult spirv::StoreOp::parse(OpAsmParser &parser, OperationState &result) { // Parse the storage class specification spirv::StorageClass storageClass; SmallVector operandInfo; @@ -3575,14 +3575,14 @@ Type elementType; if (parseEnumStrAttr(storageClass, parser) || parser.parseOperandList(operandInfo, 2) || - parseMemoryAccessAttributes(parser, state) || parser.parseColon() || + parseMemoryAccessAttributes(parser, result) || parser.parseColon() || parser.parseType(elementType)) { return failure(); } auto ptrType = spirv::PointerType::get(elementType, storageClass); if (parser.resolveOperands(operandInfo, {ptrType, elementType}, loc, - state.operands)) { + result.operands)) { return failure(); } return success(); @@ -3632,7 +3632,7 @@ //===----------------------------------------------------------------------===// ParseResult spirv::VariableOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { // Parse optional initializer Optional initInfo; if (succeeded(parser.parseOptionalKeyword("init"))) { @@ -3642,7 +3642,7 @@ return failure(); } - if (parseVariableDecorations(parser, state)) { + if (parseVariableDecorations(parser, result)) { return failure(); } @@ -3657,18 +3657,18 @@ auto ptrType = type.dyn_cast(); if (!ptrType) return parser.emitError(loc, "expected spv.ptr type"); - state.addTypes(ptrType); + result.addTypes(ptrType); // Resolve the initializer operand if (initInfo) { if (parser.resolveOperand(*initInfo, ptrType.getPointeeType(), - state.operands)) + result.operands)) return failure(); } auto attr = parser.getBuilder().getI32IntegerAttr( llvm::bit_cast(ptrType.getStorageClass())); - state.addAttribute(spirv::attributeName(), attr); + result.addAttribute(spirv::attributeName(), attr); return success(); } @@ -3762,24 +3762,24 @@ //===----------------------------------------------------------------------===// ParseResult spirv::CooperativeMatrixLoadNVOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { SmallVector operandInfo; Type strideType = parser.getBuilder().getIntegerType(32); Type columnMajorType = parser.getBuilder().getIntegerType(1); Type ptrType; Type elementType; if (parser.parseOperandList(operandInfo, 3) || - parseMemoryAccessAttributes(parser, state) || parser.parseColon() || + parseMemoryAccessAttributes(parser, result) || parser.parseColon() || parser.parseType(ptrType) || parser.parseKeywordType("as", elementType)) { return failure(); } if (parser.resolveOperands(operandInfo, {ptrType, strideType, columnMajorType}, - parser.getNameLoc(), state.operands)) { + parser.getNameLoc(), result.operands)) { return failure(); } - state.addTypes(elementType); + result.addTypes(elementType); return success(); } @@ -3820,21 +3820,21 @@ //===----------------------------------------------------------------------===// ParseResult spirv::CooperativeMatrixStoreNVOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { SmallVector operandInfo; Type strideType = parser.getBuilder().getIntegerType(32); Type columnMajorType = parser.getBuilder().getIntegerType(1); Type ptrType; Type elementType; if (parser.parseOperandList(operandInfo, 4) || - parseMemoryAccessAttributes(parser, state) || parser.parseColon() || + parseMemoryAccessAttributes(parser, result) || parser.parseColon() || parser.parseType(ptrType) || parser.parseComma() || parser.parseType(elementType)) { return failure(); } if (parser.resolveOperands( operandInfo, {ptrType, elementType, strideType, columnMajorType}, - parser.getNameLoc(), state.operands)) { + parser.getNameLoc(), result.operands)) { return failure(); } @@ -3950,7 +3950,7 @@ } ParseResult spirv::CopyMemoryOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { spirv::StorageClass targetStorageClass; OpAsmParser::UnresolvedOperand targetPtrInfo; @@ -3963,13 +3963,13 @@ parser.parseOperand(targetPtrInfo) || parser.parseComma() || parseEnumStrAttr(sourceStorageClass, parser) || parser.parseOperand(sourcePtrInfo) || - parseMemoryAccessAttributes(parser, state)) { + parseMemoryAccessAttributes(parser, result)) { return failure(); } if (!parser.parseOptionalComma()) { // Parse 2nd memory access attributes. - if (parseSourceMemoryAccessAttributes(parser, state)) { + if (parseSourceMemoryAccessAttributes(parser, result)) { return failure(); } } @@ -3977,14 +3977,14 @@ if (parser.parseColon() || parser.parseType(elementType)) return failure(); - if (parser.parseOptionalAttrDict(state.attributes)) + if (parser.parseOptionalAttrDict(result.attributes)) return failure(); auto targetPtrType = spirv::PointerType::get(elementType, targetStorageClass); auto sourcePtrType = spirv::PointerType::get(elementType, sourceStorageClass); - if (parser.resolveOperand(targetPtrInfo, targetPtrType, state.operands) || - parser.resolveOperand(sourcePtrInfo, sourcePtrType, state.operands)) { + if (parser.resolveOperand(targetPtrInfo, targetPtrType, result.operands) || + parser.resolveOperand(sourcePtrInfo, sourcePtrType, result.operands)) { return failure(); } @@ -4081,11 +4081,11 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantCompositeOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { StringAttr compositeName; if (parser.parseSymbolName(compositeName, SymbolTable::getSymbolAttrName(), - state.attributes)) + result.attributes)) return failure(); if (parser.parseLParen()) @@ -4108,14 +4108,14 @@ if (parser.parseRParen()) return failure(); - state.addAttribute(kCompositeSpecConstituentsName, - parser.getBuilder().getArrayAttr(constituents)); + result.addAttribute(kCompositeSpecConstituentsName, + parser.getBuilder().getArrayAttr(constituents)); Type type; if (parser.parseColonType(type)) return failure(); - state.addAttribute(kTypeAttrName, TypeAttr::get(type)); + result.addAttribute(kTypeAttrName, TypeAttr::get(type)); return success(); } @@ -4169,8 +4169,8 @@ //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantOperationOp::parse(OpAsmParser &parser, - OperationState &state) { - Region *body = state.addRegion(); + OperationState &result) { + Region *body = result.addRegion(); if (parser.parseKeyword("wraps")) return failure(); @@ -4185,11 +4185,11 @@ OpBuilder builder(parser.getContext()); builder.setInsertionPointToEnd(&block); builder.create(wrappedOp->getLoc(), wrappedOp->getResult(0)); - state.location = wrappedOp->getLoc(); + result.location = wrappedOp->getLoc(); - state.addTypes(wrappedOp->getResult(0).getType()); + result.addTypes(wrappedOp->getResult(0).getType()); - if (parser.parseOptionalAttrDict(state.attributes)) + if (parser.parseOptionalAttrDict(result.attributes)) return failure(); return success(); @@ -4479,9 +4479,9 @@ } ParseResult spirv::InBoundsPtrAccessChainOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { return parsePtrAccessChainOpImpl( - spirv::InBoundsPtrAccessChainOp::getOperationName(), parser, state); + spirv::InBoundsPtrAccessChainOp::getOperationName(), parser, result); } void spirv::InBoundsPtrAccessChainOp::print(OpAsmPrinter &printer) { @@ -4505,9 +4505,9 @@ } ParseResult spirv::PtrAccessChainOp::parse(OpAsmParser &parser, - OperationState &state) { + OperationState &result) { return parsePtrAccessChainOpImpl(spirv::PtrAccessChainOp::getOperationName(), - parser, state); + parser, result); } void spirv::PtrAccessChainOp::print(OpAsmPrinter &printer) {