@@ -103,15 +103,15 @@ class Deserializer {
103
103
LogicalResult deserialize ();
104
104
105
105
// / Collects the final SPIR-V ModuleOp.
106
- Optional< spirv::ModuleOp> collect ();
106
+ spirv::OwningSPIRVModuleRef collect ();
107
107
108
108
private:
109
109
// ===--------------------------------------------------------------------===//
110
110
// Module structure
111
111
// ===--------------------------------------------------------------------===//
112
112
113
113
// / Initializes the `module` ModuleOp in this deserializer instance.
114
- spirv::ModuleOp createModuleOp ();
114
+ spirv::OwningSPIRVModuleRef createModuleOp ();
115
115
116
116
// / Processes SPIR-V module header in `binary`.
117
117
LogicalResult processHeader ();
@@ -425,7 +425,7 @@ class Deserializer {
425
425
Location unknownLoc;
426
426
427
427
// / The SPIR-V ModuleOp.
428
- Optional< spirv::ModuleOp> module ;
428
+ spirv::OwningSPIRVModuleRef module ;
429
429
430
430
// / The current function under construction.
431
431
Optional<spirv::FuncOp> curFunction;
@@ -556,13 +556,15 @@ LogicalResult Deserializer::deserialize() {
556
556
return success ();
557
557
}
558
558
559
- Optional<spirv::ModuleOp> Deserializer::collect () { return module ; }
559
+ spirv::OwningSPIRVModuleRef Deserializer::collect () {
560
+ return std::move (module );
561
+ }
560
562
561
563
// ===----------------------------------------------------------------------===//
562
564
// Module structure
563
565
// ===----------------------------------------------------------------------===//
564
566
565
- spirv::ModuleOp Deserializer::createModuleOp () {
567
+ spirv::OwningSPIRVModuleRef Deserializer::createModuleOp () {
566
568
OpBuilder builder (context);
567
569
OperationState state (unknownLoc, spirv::ModuleOp::getOperationName ());
568
570
spirv::ModuleOp::build (builder, state);
@@ -1912,10 +1914,10 @@ LogicalResult ControlFlowStructurizer::structurizeImpl() {
1912
1914
// Go through all ops and remap the operands.
1913
1915
auto remapOperands = [&](Operation *op) {
1914
1916
for (auto &operand : op->getOpOperands ())
1915
- if (auto mappedOp = mapper.lookupOrNull (operand.get ()))
1917
+ if (Value mappedOp = mapper.lookupOrNull (operand.get ()))
1916
1918
operand.set (mappedOp);
1917
1919
for (auto &succOp : op->getBlockOperands ())
1918
- if (auto mappedOp = mapper.lookupOrNull (succOp.get ()))
1920
+ if (Block * mappedOp = mapper.lookupOrNull (succOp.get ()))
1919
1921
succOp.set (mappedOp);
1920
1922
};
1921
1923
for (auto &block : body) {
@@ -2354,7 +2356,7 @@ Deserializer::processOp<spirv::EntryPointOp>(ArrayRef<uint32_t> words) {
2354
2356
return emitError (unknownLoc,
2355
2357
" missing Execution Model specification in OpEntryPoint" );
2356
2358
}
2357
- auto exec_model = opBuilder.getI32IntegerAttr (words[wordIndex++]);
2359
+ auto execModel = opBuilder.getI32IntegerAttr (words[wordIndex++]);
2358
2360
if (wordIndex >= words.size ()) {
2359
2361
return emitError (unknownLoc, " missing <id> in OpEntryPoint" );
2360
2362
}
@@ -2382,7 +2384,7 @@ Deserializer::processOp<spirv::EntryPointOp>(ArrayRef<uint32_t> words) {
2382
2384
interface.push_back (opBuilder.getSymbolRefAttr (arg.getOperation ()));
2383
2385
wordIndex++;
2384
2386
}
2385
- opBuilder.create <spirv::EntryPointOp>(unknownLoc, exec_model ,
2387
+ opBuilder.create <spirv::EntryPointOp>(unknownLoc, execModel ,
2386
2388
opBuilder.getSymbolRefAttr (fnName),
2387
2389
opBuilder.getArrayAttr (interface));
2388
2390
return success ();
@@ -2594,5 +2596,5 @@ spirv::OwningSPIRVModuleRef spirv::deserialize(ArrayRef<uint32_t> binary,
2594
2596
if (failed (deserializer.deserialize ()))
2595
2597
return nullptr ;
2596
2598
2597
- return deserializer.collect (). getValueOr ( nullptr ) ;
2599
+ return deserializer.collect ();
2598
2600
}
0 commit comments