blob: 6523035e77fc0fec0c08aac54a1229397099172b [file] [log] [blame]
John Kessenich140f3df2015-06-26 16:58:36 -06001//
John Kessenich927608b2017-01-06 12:34:14 -07002// Copyright (C) 2014 LunarG, Inc.
John Kessenichb23d2322018-12-14 10:47:35 -07003// Copyright (C) 2015-2018 Google, Inc.
John Kessenich140f3df2015-06-26 16:58:36 -06004//
John Kessenich927608b2017-01-06 12:34:14 -07005// All rights reserved.
John Kessenich140f3df2015-06-26 16:58:36 -06006//
John Kessenich927608b2017-01-06 12:34:14 -07007// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
John Kessenich140f3df2015-06-26 16:58:36 -060010//
11// Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13//
14// Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following
16// disclaimer in the documentation and/or other materials provided
17// with the distribution.
18//
19// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
20// contributors may be used to endorse or promote products derived
21// from this software without specific prior written permission.
22//
John Kessenich927608b2017-01-06 12:34:14 -070023// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34// POSSIBILITY OF SUCH DAMAGE.
John Kessenich140f3df2015-06-26 16:58:36 -060035
John Kessenich140f3df2015-06-26 16:58:36 -060036// SPIRV-IR
37//
38// Simple in-memory representation (IR) of SPIRV. Just for holding
39// Each function's CFG of blocks. Has this hierarchy:
John Kessenichecba76f2017-01-06 00:34:48 -070040// - Module, which is a list of
41// - Function, which is a list of
42// - Block, which is a list of
John Kessenich140f3df2015-06-26 16:58:36 -060043// - Instruction
44//
45
46#pragma once
47#ifndef spvIR_H
48#define spvIR_H
49
John Kessenich5e4b1242015-08-06 22:53:06 -060050#include "spirv.hpp"
John Kessenich140f3df2015-06-26 16:58:36 -060051
Dejan Mircevskie537b8b2016-01-10 19:37:00 -050052#include <algorithm>
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -050053#include <cassert>
54#include <functional>
John Kessenich140f3df2015-06-26 16:58:36 -060055#include <iostream>
Andrew Woloszynb7946d12016-01-18 09:23:56 -050056#include <memory>
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -050057#include <vector>
John Kessenich140f3df2015-06-26 16:58:36 -060058
59namespace spv {
60
Dejan Mircevski38d039d2016-01-19 10:01:27 -050061class Block;
John Kessenich140f3df2015-06-26 16:58:36 -060062class Function;
63class Module;
64
65const Id NoResult = 0;
66const Id NoType = 0;
67
John Kessenich4016e382016-07-15 11:53:56 -060068const Decoration NoPrecision = DecorationMax;
LoopDawg2baa7742017-08-31 13:44:34 -060069
70#ifdef __GNUC__
71# define POTENTIALLY_UNUSED __attribute__((unused))
72#else
73# define POTENTIALLY_UNUSED
74#endif
75
76POTENTIALLY_UNUSED
John Kessenichecba76f2017-01-06 00:34:48 -070077const MemorySemanticsMask MemorySemanticsAllMemory =
John Kessenich82979362017-12-11 04:02:24 -070078 (MemorySemanticsMask)(MemorySemanticsUniformMemoryMask |
John Kessenich48891672016-01-22 10:15:03 -070079 MemorySemanticsWorkgroupMemoryMask |
John Kessenich48891672016-01-22 10:15:03 -070080 MemorySemanticsAtomicCounterMemoryMask |
81 MemorySemanticsImageMemoryMask);
John Kessenich140f3df2015-06-26 16:58:36 -060082
John Kessenich149afc32018-08-14 13:31:43 -060083struct IdImmediate {
84 bool isId; // true if word is an Id, false if word is an immediate
85 unsigned word;
Jeff Bolz4605e2e2019-02-19 13:10:32 -060086 IdImmediate(bool i, unsigned w) : isId(i), word(w) {}
John Kessenich149afc32018-08-14 13:31:43 -060087};
88
John Kessenich140f3df2015-06-26 16:58:36 -060089//
90// SPIR-V IR instruction.
91//
92
93class Instruction {
94public:
Dejan Mircevski34bc6c32016-01-19 14:08:32 -050095 Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode), block(nullptr) { }
96 explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), block(nullptr) { }
John Kessenich55e7d112015-11-15 21:33:39 -070097 virtual ~Instruction() {}
John Kessenich228e9642018-08-13 21:37:59 -060098 void addIdOperand(Id id) {
99 operands.push_back(id);
100 idOperand.push_back(true);
101 }
102 void addImmediateOperand(unsigned int immediate) {
103 operands.push_back(immediate);
104 idOperand.push_back(false);
105 }
Jeff Bolz9f2aec42019-01-06 17:58:04 -0600106 void setImmediateOperand(unsigned idx, unsigned int immediate) {
107 assert(!idOperand[idx]);
108 operands[idx] = immediate;
109 }
110
John Kessenich140f3df2015-06-26 16:58:36 -0600111 void addStringOperand(const char* str)
112 {
John Kessenich140f3df2015-06-26 16:58:36 -0600113 unsigned int word;
114 char* wordString = (char*)&word;
115 char* wordPtr = wordString;
116 int charCount = 0;
117 char c;
118 do {
119 c = *(str++);
120 *(wordPtr++) = c;
121 ++charCount;
122 if (charCount == 4) {
John Kessenich55e7d112015-11-15 21:33:39 -0700123 addImmediateOperand(word);
John Kessenich140f3df2015-06-26 16:58:36 -0600124 wordPtr = wordString;
125 charCount = 0;
126 }
127 } while (c != 0);
128
129 // deal with partial last word
130 if (charCount > 0) {
131 // pad with 0s
132 for (; charCount < 4; ++charCount)
133 *(wordPtr++) = 0;
John Kessenich55e7d112015-11-15 21:33:39 -0700134 addImmediateOperand(word);
John Kessenich140f3df2015-06-26 16:58:36 -0600135 }
136 }
John Kessenich31aa3d62018-08-15 13:54:09 -0600137 bool isIdOperand(int op) const { return idOperand[op]; }
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500138 void setBlock(Block* b) { block = b; }
Dejan Mircevskifa242902016-01-19 11:31:55 -0500139 Block* getBlock() const { return block; }
John Kessenich140f3df2015-06-26 16:58:36 -0600140 Op getOpCode() const { return opCode; }
John Kessenich228e9642018-08-13 21:37:59 -0600141 int getNumOperands() const
142 {
143 assert(operands.size() == idOperand.size());
144 return (int)operands.size();
145 }
John Kessenich140f3df2015-06-26 16:58:36 -0600146 Id getResultId() const { return resultId; }
147 Id getTypeId() const { return typeId; }
John Kessenich228e9642018-08-13 21:37:59 -0600148 Id getIdOperand(int op) const {
149 assert(idOperand[op]);
150 return operands[op];
151 }
152 unsigned int getImmediateOperand(int op) const {
153 assert(!idOperand[op]);
154 return operands[op];
155 }
John Kessenich140f3df2015-06-26 16:58:36 -0600156
157 // Write out the binary form.
158 void dump(std::vector<unsigned int>& out) const
159 {
160 // Compute the wordCount
161 unsigned int wordCount = 1;
162 if (typeId)
163 ++wordCount;
164 if (resultId)
165 ++wordCount;
166 wordCount += (unsigned int)operands.size();
John Kessenich140f3df2015-06-26 16:58:36 -0600167
168 // Write out the beginning of the instruction
169 out.push_back(((wordCount) << WordCountShift) | opCode);
170 if (typeId)
171 out.push_back(typeId);
172 if (resultId)
173 out.push_back(resultId);
174
175 // Write out the operands
176 for (int op = 0; op < (int)operands.size(); ++op)
177 out.push_back(operands[op]);
John Kessenich140f3df2015-06-26 16:58:36 -0600178 }
179
180protected:
181 Instruction(const Instruction&);
182 Id resultId;
183 Id typeId;
184 Op opCode;
John Kessenich228e9642018-08-13 21:37:59 -0600185 std::vector<Id> operands; // operands, both <id> and immediates (both are unsigned int)
186 std::vector<bool> idOperand; // true for operands that are <id>, false for immediates
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500187 Block* block;
John Kessenich140f3df2015-06-26 16:58:36 -0600188};
189
190//
191// SPIR-V IR block.
192//
193
194class Block {
195public:
196 Block(Id id, Function& parent);
197 virtual ~Block()
198 {
John Kessenich140f3df2015-06-26 16:58:36 -0600199 }
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -0500200
John Kessenich140f3df2015-06-26 16:58:36 -0600201 Id getId() { return instructions.front()->getResultId(); }
202
203 Function& getParent() const { return parent; }
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500204 void addInstruction(std::unique_ptr<Instruction> inst);
Dejan Mircevski5fe789b2016-01-17 23:27:45 -0500205 void addPredecessor(Block* pred) { predecessors.push_back(pred); pred->successors.push_back(this);}
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500206 void addLocalVariable(std::unique_ptr<Instruction> inst) { localVariables.push_back(std::move(inst)); }
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500207 const std::vector<Block*>& getPredecessors() const { return predecessors; }
208 const std::vector<Block*>& getSuccessors() const { return successors; }
qiningda397332016-03-09 19:54:03 -0500209 const std::vector<std::unique_ptr<Instruction> >& getInstructions() const {
210 return instructions;
211 }
Jeff Bolz9f2aec42019-01-06 17:58:04 -0600212 const std::vector<std::unique_ptr<Instruction> >& getLocalVariables() const { return localVariables; }
John Kessenich140f3df2015-06-26 16:58:36 -0600213 void setUnreachable() { unreachable = true; }
214 bool isUnreachable() const { return unreachable; }
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -0500215 // Returns the block's merge instruction, if one exists (otherwise null).
216 const Instruction* getMergeInstruction() const {
217 if (instructions.size() < 2) return nullptr;
Dejan Mircevski377f0ca2016-01-19 10:17:33 -0500218 const Instruction* nextToLast = (instructions.cend() - 2)->get();
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -0500219 switch (nextToLast->getOpCode()) {
220 case OpSelectionMerge:
221 case OpLoopMerge:
222 return nextToLast;
223 default:
224 return nullptr;
225 }
226 return nullptr;
227 }
John Kessenich140f3df2015-06-26 16:58:36 -0600228
David Neto8c3d5b42019-10-21 14:50:31 -0400229 // Change this block into a canonical dead merge block. Delete instructions
230 // as necessary. A canonical dead merge block has only an OpLabel and an
231 // OpUnreachable.
232 void rewriteAsCanonicalUnreachableMerge() {
233 assert(localVariables.empty());
234 // Delete all instructions except for the label.
235 assert(instructions.size() > 0);
236 instructions.resize(1);
237 successors.clear();
John Kessenich1fff3622020-04-01 00:46:57 -0600238 addInstruction(std::unique_ptr<Instruction>(new Instruction(OpUnreachable)));
David Neto8c3d5b42019-10-21 14:50:31 -0400239 }
240 // Change this block into a canonical dead continue target branching to the
241 // given header ID. Delete instructions as necessary. A canonical dead continue
242 // target has only an OpLabel and an unconditional branch back to the corresponding
243 // header.
244 void rewriteAsCanonicalUnreachableContinue(Block* header) {
245 assert(localVariables.empty());
246 // Delete all instructions except for the label.
247 assert(instructions.size() > 0);
248 instructions.resize(1);
249 successors.clear();
250 // Add OpBranch back to the header.
251 assert(header != nullptr);
252 Instruction* branch = new Instruction(OpBranch);
253 branch->addIdOperand(header->getId());
Ryan Harrison0552c0a2019-11-04 16:23:11 -0500254 addInstruction(std::unique_ptr<Instruction>(branch));
David Neto8c3d5b42019-10-21 14:50:31 -0400255 successors.push_back(header);
256 }
257
John Kessenich140f3df2015-06-26 16:58:36 -0600258 bool isTerminated() const
259 {
260 switch (instructions.back()->getOpCode()) {
261 case OpBranch:
262 case OpBranchConditional:
263 case OpSwitch:
264 case OpKill:
265 case OpReturn:
266 case OpReturnValue:
David Neto8c3d5b42019-10-21 14:50:31 -0400267 case OpUnreachable:
John Kessenich140f3df2015-06-26 16:58:36 -0600268 return true;
269 default:
270 return false;
271 }
272 }
273
274 void dump(std::vector<unsigned int>& out) const
275 {
John Kessenich140f3df2015-06-26 16:58:36 -0600276 instructions[0]->dump(out);
277 for (int i = 0; i < (int)localVariables.size(); ++i)
278 localVariables[i]->dump(out);
279 for (int i = 1; i < (int)instructions.size(); ++i)
280 instructions[i]->dump(out);
281 }
282
283protected:
284 Block(const Block&);
285 Block& operator=(Block&);
286
287 // To enforce keeping parent and ownership in sync:
288 friend Function;
289
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500290 std::vector<std::unique_ptr<Instruction> > instructions;
Dejan Mircevski5fe789b2016-01-17 23:27:45 -0500291 std::vector<Block*> predecessors, successors;
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500292 std::vector<std::unique_ptr<Instruction> > localVariables;
John Kessenich140f3df2015-06-26 16:58:36 -0600293 Function& parent;
294
John Kessenichecba76f2017-01-06 00:34:48 -0700295 // track whether this block is known to be uncreachable (not necessarily
John Kessenich140f3df2015-06-26 16:58:36 -0600296 // true for all unreachable blocks, but should be set at least
297 // for the extraneous ones introduced by the builder).
298 bool unreachable;
299};
300
David Neto8c3d5b42019-10-21 14:50:31 -0400301// The different reasons for reaching a block in the inReadableOrder traversal.
John Kessenich31c33702019-11-02 21:26:40 -0600302enum ReachReason {
David Neto8c3d5b42019-10-21 14:50:31 -0400303 // Reachable from the entry block via transfers of control, i.e. branches.
304 ReachViaControlFlow = 0,
305 // A continue target that is not reachable via control flow.
306 ReachDeadContinue,
307 // A merge block that is not reachable via control flow.
308 ReachDeadMerge
309};
310
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -0500311// Traverses the control-flow graph rooted at root in an order suited for
312// readable code generation. Invokes callback at every node in the traversal
David Neto8c3d5b42019-10-21 14:50:31 -0400313// order. The callback arguments are:
314// - the block,
315// - the reason we reached the block,
316// - if the reason was that block is an unreachable continue or unreachable merge block
317// then the last parameter is the corresponding header block.
318void inReadableOrder(Block* root, std::function<void(Block*, ReachReason, Block* header)> callback);
Dejan Mircevski44bfb0d2016-01-18 16:18:37 -0500319
John Kessenich140f3df2015-06-26 16:58:36 -0600320//
321// SPIR-V IR Function.
322//
323
324class Function {
325public:
326 Function(Id id, Id resultType, Id functionType, Id firstParam, Module& parent);
327 virtual ~Function()
328 {
329 for (int i = 0; i < (int)parameterInstructions.size(); ++i)
330 delete parameterInstructions[i];
331
332 for (int i = 0; i < (int)blocks.size(); ++i)
333 delete blocks[i];
334 }
335 Id getId() const { return functionInstruction.getResultId(); }
John Kessenichd3ed90b2018-05-04 11:43:03 -0600336 Id getParamId(int p) const { return parameterInstructions[p]->getResultId(); }
337 Id getParamType(int p) const { return parameterInstructions[p]->getTypeId(); }
John Kessenich140f3df2015-06-26 16:58:36 -0600338
339 void addBlock(Block* block) { blocks.push_back(block); }
Dejan Mircevskie537b8b2016-01-10 19:37:00 -0500340 void removeBlock(Block* block)
341 {
342 auto found = find(blocks.begin(), blocks.end(), block);
343 assert(found != blocks.end());
344 blocks.erase(found);
345 delete block;
346 }
John Kessenich140f3df2015-06-26 16:58:36 -0600347
348 Module& getParent() const { return parent; }
349 Block* getEntryBlock() const { return blocks.front(); }
350 Block* getLastBlock() const { return blocks.back(); }
qiningda397332016-03-09 19:54:03 -0500351 const std::vector<Block*>& getBlocks() const { return blocks; }
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500352 void addLocalVariable(std::unique_ptr<Instruction> inst);
John Kessenich140f3df2015-06-26 16:58:36 -0600353 Id getReturnType() const { return functionInstruction.getTypeId(); }
John Kessenich37789792017-03-21 23:56:40 -0600354
355 void setImplicitThis() { implicitThis = true; }
356 bool hasImplicitThis() const { return implicitThis; }
357
John Kessenich140f3df2015-06-26 16:58:36 -0600358 void dump(std::vector<unsigned int>& out) const
359 {
360 // OpFunction
361 functionInstruction.dump(out);
362
363 // OpFunctionParameter
364 for (int p = 0; p < (int)parameterInstructions.size(); ++p)
365 parameterInstructions[p]->dump(out);
366
367 // Blocks
David Neto8c3d5b42019-10-21 14:50:31 -0400368 inReadableOrder(blocks[0], [&out](const Block* b, ReachReason, Block*) { b->dump(out); });
John Kessenich140f3df2015-06-26 16:58:36 -0600369 Instruction end(0, 0, OpFunctionEnd);
370 end.dump(out);
371 }
372
373protected:
374 Function(const Function&);
375 Function& operator=(Function&);
376
377 Module& parent;
378 Instruction functionInstruction;
379 std::vector<Instruction*> parameterInstructions;
380 std::vector<Block*> blocks;
John Kessenich37789792017-03-21 23:56:40 -0600381 bool implicitThis; // true if this is a member function expecting to be passed a 'this' as the first argument
John Kessenich140f3df2015-06-26 16:58:36 -0600382};
383
384//
385// SPIR-V IR Module.
386//
387
388class Module {
389public:
390 Module() {}
391 virtual ~Module()
392 {
393 // TODO delete things
394 }
395
396 void addFunction(Function *fun) { functions.push_back(fun); }
397
398 void mapInstruction(Instruction *instruction)
399 {
400 spv::Id resultId = instruction->getResultId();
401 // map the instruction's result id
402 if (resultId >= idToInstruction.size())
403 idToInstruction.resize(resultId + 16);
404 idToInstruction[resultId] = instruction;
405 }
406
407 Instruction* getInstruction(Id id) const { return idToInstruction[id]; }
qiningda397332016-03-09 19:54:03 -0500408 const std::vector<Function*>& getFunctions() const { return functions; }
John Kessenich149afc32018-08-14 13:31:43 -0600409 spv::Id getTypeId(Id resultId) const {
410 return idToInstruction[resultId] == nullptr ? NoType : idToInstruction[resultId]->getTypeId();
411 }
John Kesseniche00e72d2015-12-08 20:48:49 -0700412 StorageClass getStorageClass(Id typeId) const
413 {
414 assert(idToInstruction[typeId]->getOpCode() == spv::OpTypePointer);
415 return (StorageClass)idToInstruction[typeId]->getImmediateOperand(0);
416 }
417
John Kessenich140f3df2015-06-26 16:58:36 -0600418 void dump(std::vector<unsigned int>& out) const
419 {
420 for (int f = 0; f < (int)functions.size(); ++f)
421 functions[f]->dump(out);
422 }
423
424protected:
425 Module(const Module&);
426 std::vector<Function*> functions;
427
428 // map from result id to instruction having that result id
429 std::vector<Instruction*> idToInstruction;
430
431 // map from a result id to its type id
432};
433
434//
435// Implementation (it's here due to circular type definitions).
436//
437
438// Add both
439// - the OpFunction instruction
440// - all the OpFunctionParameter instructions
441__inline Function::Function(Id id, Id resultType, Id functionType, Id firstParamId, Module& parent)
John Kessenich37789792017-03-21 23:56:40 -0600442 : parent(parent), functionInstruction(id, resultType, OpFunction), implicitThis(false)
John Kessenich140f3df2015-06-26 16:58:36 -0600443{
444 // OpFunction
445 functionInstruction.addImmediateOperand(FunctionControlMaskNone);
446 functionInstruction.addIdOperand(functionType);
447 parent.mapInstruction(&functionInstruction);
448 parent.addFunction(this);
449
450 // OpFunctionParameter
451 Instruction* typeInst = parent.getInstruction(functionType);
452 int numParams = typeInst->getNumOperands() - 1;
453 for (int p = 0; p < numParams; ++p) {
454 Instruction* param = new Instruction(firstParamId + p, typeInst->getIdOperand(p + 1), OpFunctionParameter);
455 parent.mapInstruction(param);
456 parameterInstructions.push_back(param);
457 }
458}
459
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500460__inline void Function::addLocalVariable(std::unique_ptr<Instruction> inst)
John Kessenich140f3df2015-06-26 16:58:36 -0600461{
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500462 Instruction* raw_instruction = inst.get();
463 blocks[0]->addLocalVariable(std::move(inst));
464 parent.mapInstruction(raw_instruction);
John Kessenich140f3df2015-06-26 16:58:36 -0600465}
466
467__inline Block::Block(Id id, Function& parent) : parent(parent), unreachable(false)
468{
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500469 instructions.push_back(std::unique_ptr<Instruction>(new Instruction(id, NoType, OpLabel)));
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500470 instructions.back()->setBlock(this);
Dejan Mircevski377f0ca2016-01-19 10:17:33 -0500471 parent.getParent().mapInstruction(instructions.back().get());
John Kessenich140f3df2015-06-26 16:58:36 -0600472}
473
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500474__inline void Block::addInstruction(std::unique_ptr<Instruction> inst)
John Kessenich140f3df2015-06-26 16:58:36 -0600475{
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500476 Instruction* raw_instruction = inst.get();
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500477 instructions.push_back(std::move(inst));
Dejan Mircevski38d039d2016-01-19 10:01:27 -0500478 raw_instruction->setBlock(this);
Andrew Woloszynb7946d12016-01-18 09:23:56 -0500479 if (raw_instruction->getResultId())
480 parent.getParent().mapInstruction(raw_instruction);
John Kessenich140f3df2015-06-26 16:58:36 -0600481}
482
Shahbaz Youssefi6cca0e92019-06-25 12:08:10 -0400483} // end spv namespace
John Kessenich140f3df2015-06-26 16:58:36 -0600484
485#endif // spvIR_H