/src/shaderc/third_party/spirv-tools/source/opt/module.h
Line | Count | Source |
1 | | // Copyright (c) 2016 Google Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef SOURCE_OPT_MODULE_H_ |
16 | | #define SOURCE_OPT_MODULE_H_ |
17 | | |
18 | | #include <functional> |
19 | | #include <memory> |
20 | | #include <string_view> |
21 | | #include <unordered_map> |
22 | | #include <utility> |
23 | | #include <vector> |
24 | | |
25 | | #include "source/opt/function.h" |
26 | | #include "source/opt/graph.h" |
27 | | #include "source/opt/instruction.h" |
28 | | #include "source/opt/iterator.h" |
29 | | |
30 | | namespace spvtools { |
31 | | namespace opt { |
32 | | |
33 | | class IRContext; |
34 | | |
35 | | // A struct for containing the module header information. |
36 | | struct ModuleHeader { |
37 | | uint32_t magic_number; |
38 | | uint32_t version; |
39 | | uint32_t generator; |
40 | | uint32_t bound; |
41 | | uint32_t schema; |
42 | | }; |
43 | | |
44 | | // A SPIR-V module. It contains all the information for a SPIR-V module and |
45 | | // serves as the backbone of optimization transformations. |
46 | | class Module { |
47 | | public: |
48 | | using iterator = UptrVectorIterator<Function>; |
49 | | using const_iterator = UptrVectorIterator<Function, true>; |
50 | | using inst_iterator = InstructionList::iterator; |
51 | | using const_inst_iterator = InstructionList::const_iterator; |
52 | | using graph_iterator = UptrVectorIterator<Graph>; |
53 | | using const_graph_iterator = UptrVectorIterator<Graph, true>; |
54 | | |
55 | | // Creates an empty module with zero'd header. |
56 | 128 | Module() : header_({}), contains_debug_info_(false) {} |
57 | | |
58 | | // Sets the header to the given |header|. |
59 | 128 | void SetHeader(const ModuleHeader& header) { header_ = header; } |
60 | | |
61 | | // Sets the Id bound. The Id bound cannot be set to 0. |
62 | 128 | void SetIdBound(uint32_t bound) { |
63 | 128 | assert(bound != 0); |
64 | 128 | header_.bound = bound; |
65 | 128 | } |
66 | | |
67 | | // Returns the Id bound. |
68 | 176 | uint32_t IdBound() const { return header_.bound; } |
69 | | |
70 | | // Returns the current Id bound and increases it to the next available value. |
71 | | // If the id bound has already reached its maximum value, then 0 is returned. |
72 | | // The maximum value for the id bound is obtained from the context. If there |
73 | | // is none, then the minimum that limit can be according to the spir-v |
74 | | // specification. |
75 | | // TODO(1841): Update the uses to check for a 0 return value. |
76 | | uint32_t TakeNextIdBound(); |
77 | | |
78 | | // Appends a capability instruction to this module. |
79 | | inline void AddCapability(std::unique_ptr<Instruction> c); |
80 | | |
81 | | // Appends an extension instruction to this module. |
82 | | inline void AddExtension(std::unique_ptr<Instruction> e); |
83 | | |
84 | | // Appends an extended instruction set instruction to this module. |
85 | | inline void AddExtInstImport(std::unique_ptr<Instruction> e); |
86 | | |
87 | | // Set the memory model for this module. |
88 | | inline void SetMemoryModel(std::unique_ptr<Instruction> m); |
89 | | |
90 | | // Set the sampled image addressing mode for this module. |
91 | | inline void SetSampledImageAddressMode(std::unique_ptr<Instruction> m); |
92 | | |
93 | | // Appends an entry point instruction to this module. |
94 | | inline void AddEntryPoint(std::unique_ptr<Instruction> e); |
95 | | |
96 | | // Appends a graph entry point instruction to this module. |
97 | | inline void AddGraphEntryPoint(std::unique_ptr<Instruction> e); |
98 | | |
99 | | // Appends an execution mode instruction to this module. |
100 | | inline void AddExecutionMode(std::unique_ptr<Instruction> e); |
101 | | |
102 | | // Appends a debug 1 instruction (excluding OpLine & OpNoLine) to this module. |
103 | | // "debug 1" instructions are the ones in layout section 7.a), see section |
104 | | // 2.4 Logical Layout of a Module from the SPIR-V specification. |
105 | | inline void AddDebug1Inst(std::unique_ptr<Instruction> d); |
106 | | |
107 | | // Appends a debug 2 instruction (excluding OpLine & OpNoLine) to this module. |
108 | | // "debug 2" instructions are the ones in layout section 7.b), see section |
109 | | // 2.4 Logical Layout of a Module from the SPIR-V specification. |
110 | | inline void AddDebug2Inst(std::unique_ptr<Instruction> d); |
111 | | |
112 | | // Appends a debug 3 instruction (OpModuleProcessed) to this module. |
113 | | // This is due to decision by the SPIR Working Group, pending publication. |
114 | | inline void AddDebug3Inst(std::unique_ptr<Instruction> d); |
115 | | |
116 | | // Appends a debug info extension (OpenCL.DebugInfo.100, |
117 | | // NonSemantic.Shader.DebugInfo, or DebugInfo) instruction to this module. |
118 | | inline void AddExtInstDebugInfo(std::unique_ptr<Instruction> d); |
119 | | |
120 | | // Appends an annotation instruction to this module. |
121 | | inline void AddAnnotationInst(std::unique_ptr<Instruction> a); |
122 | | |
123 | | // Appends a type-declaration instruction to this module. |
124 | | inline void AddType(std::unique_ptr<Instruction> t); |
125 | | |
126 | | // Appends a constant, global variable, or OpUndef instruction to this module. |
127 | | inline void AddGlobalValue(std::unique_ptr<Instruction> v); |
128 | | |
129 | | // Prepends a function declaration to this module. |
130 | | inline void AddFunctionDeclaration(std::unique_ptr<Function> f); |
131 | | |
132 | | // Appends a function to this module. |
133 | | inline void AddFunction(std::unique_ptr<Function> f); |
134 | | |
135 | | // Appends a graph to this module. |
136 | | inline void AddGraph(std::unique_ptr<Graph> g); |
137 | | |
138 | | // Sets |contains_debug_info_| as true. |
139 | | inline void SetContainsDebugInfo(); |
140 | 0 | inline bool ContainsDebugInfo() { return contains_debug_info_; } |
141 | | |
142 | | // Returns a vector of pointers to type-declaration instructions in this |
143 | | // module. |
144 | | std::vector<Instruction*> GetTypes(); |
145 | | std::vector<const Instruction*> GetTypes() const; |
146 | | // Returns a vector of pointers to constant-creation instructions in this |
147 | | // module. |
148 | | std::vector<Instruction*> GetConstants(); |
149 | | std::vector<const Instruction*> GetConstants() const; |
150 | | |
151 | | // Return result id of global value with |opcode|, 0 if not present. |
152 | | uint32_t GetGlobalValue(spv::Op opcode) const; |
153 | | |
154 | | // Add global value with |opcode|, |result_id| and |type_id| |
155 | | void AddGlobalValue(spv::Op opcode, uint32_t result_id, uint32_t type_id); |
156 | | |
157 | 12.3k | inline uint32_t id_bound() const { return header_.bound; } |
158 | | |
159 | 128 | inline uint32_t version() const { return header_.version; } |
160 | 0 | inline uint32_t generator() const { return header_.generator; } |
161 | 0 | inline uint32_t schema() const { return header_.schema; } |
162 | | |
163 | 0 | inline void set_version(uint32_t v) { header_.version = v; } |
164 | | |
165 | | // Iterators for capabilities instructions contained in this module. |
166 | | inline inst_iterator capability_begin(); |
167 | | inline inst_iterator capability_end(); |
168 | | inline IteratorRange<inst_iterator> capabilities(); |
169 | | inline IteratorRange<const_inst_iterator> capabilities() const; |
170 | | |
171 | | // Iterators for ext_inst_imports instructions contained in this module. |
172 | | inline inst_iterator ext_inst_import_begin(); |
173 | | inline inst_iterator ext_inst_import_end(); |
174 | | inline IteratorRange<inst_iterator> ext_inst_imports(); |
175 | | inline IteratorRange<const_inst_iterator> ext_inst_imports() const; |
176 | | |
177 | | // Return the memory model instruction contained in this module. |
178 | 0 | inline Instruction* GetMemoryModel() { return memory_model_.get(); } |
179 | 0 | inline const Instruction* GetMemoryModel() const { |
180 | 0 | return memory_model_.get(); |
181 | 0 | } |
182 | | |
183 | | // Return the sampled image address mode instruction contained in this module. |
184 | 0 | inline Instruction* GetSampledImageAddressMode() { |
185 | 0 | return sampled_image_address_mode_.get(); |
186 | 0 | } |
187 | 0 | inline const Instruction* GetSampledImageAddressMode() const { |
188 | 0 | return sampled_image_address_mode_.get(); |
189 | 0 | } |
190 | | |
191 | | // There are several kinds of debug instructions, according to where they can |
192 | | // appear in the logical layout of a module: |
193 | | // - Section 7a: OpString, OpSourceExtension, OpSource, OpSourceContinued |
194 | | // - Section 7b: OpName, OpMemberName |
195 | | // - Section 7c: OpModuleProcessed |
196 | | // - Mostly anywhere: OpLine and OpNoLine |
197 | | // |
198 | | |
199 | | // Iterators for debug 1 instructions (excluding OpLine & OpNoLine) contained |
200 | | // in this module. These are for layout section 7a. |
201 | | inline inst_iterator debug1_begin(); |
202 | | inline inst_iterator debug1_end(); |
203 | | inline IteratorRange<inst_iterator> debugs1(); |
204 | | inline IteratorRange<const_inst_iterator> debugs1() const; |
205 | | |
206 | | // Iterators for debug 2 instructions (excluding OpLine & OpNoLine) contained |
207 | | // in this module. These are for layout section 7b. |
208 | | inline inst_iterator debug2_begin(); |
209 | | inline inst_iterator debug2_end(); |
210 | | inline IteratorRange<inst_iterator> debugs2(); |
211 | | inline IteratorRange<const_inst_iterator> debugs2() const; |
212 | | |
213 | | // Iterators for debug 3 instructions (excluding OpLine & OpNoLine) contained |
214 | | // in this module. These are for layout section 7c. |
215 | | inline inst_iterator debug3_begin(); |
216 | | inline inst_iterator debug3_end(); |
217 | | inline IteratorRange<inst_iterator> debugs3(); |
218 | | inline IteratorRange<const_inst_iterator> debugs3() const; |
219 | | |
220 | | // Iterators for debug info instructions (excluding OpLine & OpNoLine) |
221 | | // contained in this module. These are OpExtInst for DebugInfo extension |
222 | | // placed between section 9 and 10. |
223 | | inline inst_iterator ext_inst_debuginfo_begin(); |
224 | | inline inst_iterator ext_inst_debuginfo_end(); |
225 | | inline IteratorRange<inst_iterator> ext_inst_debuginfo(); |
226 | | inline IteratorRange<const_inst_iterator> ext_inst_debuginfo() const; |
227 | | |
228 | | // Iterators for entry point instructions contained in this module |
229 | | inline IteratorRange<inst_iterator> entry_points(); |
230 | | inline IteratorRange<const_inst_iterator> entry_points() const; |
231 | | |
232 | | // Iterators for graph entry point instructions contained in this module |
233 | | inline IteratorRange<inst_iterator> graph_entry_points(); |
234 | | inline IteratorRange<const_inst_iterator> graph_entry_points() const; |
235 | | |
236 | | // Iterators for execution_modes instructions contained in this module. |
237 | | inline inst_iterator execution_mode_begin(); |
238 | | inline inst_iterator execution_mode_end(); |
239 | | inline IteratorRange<inst_iterator> execution_modes(); |
240 | | inline IteratorRange<const_inst_iterator> execution_modes() const; |
241 | | |
242 | | // Iterators for annotation instructions contained in this module. |
243 | | inline inst_iterator annotation_begin(); |
244 | | inline inst_iterator annotation_end(); |
245 | | IteratorRange<inst_iterator> annotations(); |
246 | | IteratorRange<const_inst_iterator> annotations() const; |
247 | | |
248 | | // Iterators for extension instructions contained in this module. |
249 | | inline inst_iterator extension_begin(); |
250 | | inline inst_iterator extension_end(); |
251 | | IteratorRange<inst_iterator> extensions(); |
252 | | IteratorRange<const_inst_iterator> extensions() const; |
253 | | |
254 | | // Iterators for types, constants and global variables instructions. |
255 | | inline inst_iterator types_values_begin(); |
256 | | inline inst_iterator types_values_end(); |
257 | | inline IteratorRange<inst_iterator> types_values(); |
258 | | inline IteratorRange<const_inst_iterator> types_values() const; |
259 | | |
260 | | // Iterators for functions contained in this module. |
261 | 7.82k | iterator begin() { return iterator(&functions_, functions_.begin()); } |
262 | 8.70k | iterator end() { return iterator(&functions_, functions_.end()); } |
263 | 0 | const_iterator begin() const { return cbegin(); } |
264 | 0 | const_iterator end() const { return cend(); } |
265 | | inline const_iterator cbegin() const; |
266 | | inline const_iterator cend() const; |
267 | | |
268 | | // Iterators for graphs contained in this module. |
269 | | inline const std::vector<std::unique_ptr<Graph>>& graphs() const; |
270 | | |
271 | | // Invokes function |f| on all instructions in this module, and optionally on |
272 | | // the debug line instructions that precede them. |
273 | | void ForEachInst(const std::function<void(Instruction*)>& f, |
274 | | bool run_on_debug_line_insts = false); |
275 | | void ForEachInst(const std::function<void(const Instruction*)>& f, |
276 | | bool run_on_debug_line_insts = false) const; |
277 | | |
278 | | // Pushes the binary segments for this instruction into the back of *|binary|. |
279 | | // If |skip_nop| is true and this is a OpNop, do nothing. |
280 | | void ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const; |
281 | | |
282 | | // Returns 1 more than the maximum Id value mentioned in the module. |
283 | | uint32_t ComputeIdBound() const; |
284 | | |
285 | | // Returns true if module has capability |cap| |
286 | | bool HasExplicitCapability(uint32_t cap); |
287 | | |
288 | | // Returns id for OpExtInst instruction for extension |extstr|. |
289 | | // Returns 0 if not found. |
290 | | uint32_t GetExtInstImportId(const char* extstr); |
291 | | |
292 | | // Sets the associated context for this module |
293 | 128 | void SetContext(IRContext* c) { context_ = c; } |
294 | | |
295 | | // Gets the associated context for this module |
296 | 65.8k | IRContext* context() const { return context_; } |
297 | | |
298 | | // Sets the trailing debug line info to |dbg_line_info|. |
299 | 128 | void SetTrailingDbgLineInfo(std::vector<Instruction>&& dbg_line_info) { |
300 | 128 | trailing_dbg_line_info_ = std::move(dbg_line_info); |
301 | 128 | } |
302 | | |
303 | 128 | std::vector<Instruction>& trailing_dbg_line_info() { |
304 | 128 | return trailing_dbg_line_info_; |
305 | 128 | } |
306 | | |
307 | 0 | const std::vector<Instruction>& trailing_dbg_line_info() const { |
308 | 0 | return trailing_dbg_line_info_; |
309 | 0 | } |
310 | | |
311 | | private: |
312 | | ModuleHeader header_; // Module header |
313 | | |
314 | | // The following fields respect the "Logical Layout of a Module" in |
315 | | // Section 2.4 of the SPIR-V specification. |
316 | | IRContext* context_; |
317 | | InstructionList capabilities_; |
318 | | InstructionList extensions_; |
319 | | InstructionList ext_inst_imports_; |
320 | | // A module only has one memory model instruction. |
321 | | std::unique_ptr<Instruction> memory_model_; |
322 | | // A module can only have one optional sampled image addressing mode |
323 | | std::unique_ptr<Instruction> sampled_image_address_mode_; |
324 | | InstructionList entry_points_; |
325 | | InstructionList graph_entry_points_; |
326 | | InstructionList execution_modes_; |
327 | | InstructionList debugs1_; |
328 | | InstructionList debugs2_; |
329 | | InstructionList debugs3_; |
330 | | InstructionList ext_inst_debuginfo_; |
331 | | InstructionList annotations_; |
332 | | // Type declarations, constants, and global variable declarations. |
333 | | InstructionList types_values_; |
334 | | std::vector<std::unique_ptr<Function>> functions_; |
335 | | std::vector<std::unique_ptr<Graph>> graphs_; |
336 | | |
337 | | // If the module ends with Op*Line instruction, they will not be attached to |
338 | | // any instruction. We record them here, so they will not be lost. |
339 | | std::vector<Instruction> trailing_dbg_line_info_; |
340 | | |
341 | | // This module contains DebugScope/DebugNoScope or OpLine/OpNoLine. |
342 | | bool contains_debug_info_; |
343 | | }; |
344 | | |
345 | | // Pretty-prints |module| to |str|. Returns |str|. |
346 | | std::ostream& operator<<(std::ostream& str, const Module& module); |
347 | | |
348 | 412 | inline void Module::AddCapability(std::unique_ptr<Instruction> c) { |
349 | 412 | capabilities_.push_back(std::move(c)); |
350 | 412 | } |
351 | | |
352 | 108 | inline void Module::AddExtension(std::unique_ptr<Instruction> e) { |
353 | 108 | extensions_.push_back(std::move(e)); |
354 | 108 | } |
355 | | |
356 | 132 | inline void Module::AddExtInstImport(std::unique_ptr<Instruction> e) { |
357 | 132 | ext_inst_imports_.push_back(std::move(e)); |
358 | 132 | } |
359 | | |
360 | 128 | inline void Module::SetMemoryModel(std::unique_ptr<Instruction> m) { |
361 | 128 | memory_model_ = std::move(m); |
362 | 128 | } |
363 | | |
364 | 0 | inline void Module::SetSampledImageAddressMode(std::unique_ptr<Instruction> m) { |
365 | 0 | sampled_image_address_mode_ = std::move(m); |
366 | 0 | } |
367 | | |
368 | 128 | inline void Module::AddEntryPoint(std::unique_ptr<Instruction> e) { |
369 | 128 | entry_points_.push_back(std::move(e)); |
370 | 128 | } |
371 | | |
372 | 0 | inline void Module::AddGraphEntryPoint(std::unique_ptr<Instruction> e) { |
373 | 0 | graph_entry_points_.push_back(std::move(e)); |
374 | 0 | } |
375 | | |
376 | 0 | inline void Module::AddExecutionMode(std::unique_ptr<Instruction> e) { |
377 | 0 | execution_modes_.push_back(std::move(e)); |
378 | 0 | } |
379 | | |
380 | 782 | inline void Module::AddDebug1Inst(std::unique_ptr<Instruction> d) { |
381 | 782 | debugs1_.push_back(std::move(d)); |
382 | 782 | } |
383 | | |
384 | 3.85k | inline void Module::AddDebug2Inst(std::unique_ptr<Instruction> d) { |
385 | 3.85k | debugs2_.push_back(std::move(d)); |
386 | 3.85k | } |
387 | | |
388 | 0 | inline void Module::AddDebug3Inst(std::unique_ptr<Instruction> d) { |
389 | 0 | debugs3_.push_back(std::move(d)); |
390 | 0 | } |
391 | | |
392 | 0 | inline void Module::AddExtInstDebugInfo(std::unique_ptr<Instruction> d) { |
393 | 0 | ext_inst_debuginfo_.push_back(std::move(d)); |
394 | 0 | } |
395 | | |
396 | 2.49k | inline void Module::AddAnnotationInst(std::unique_ptr<Instruction> a) { |
397 | 2.49k | annotations_.push_back(std::move(a)); |
398 | 2.49k | } |
399 | | |
400 | 3.82k | inline void Module::AddType(std::unique_ptr<Instruction> t) { |
401 | 3.82k | types_values_.push_back(std::move(t)); |
402 | 3.82k | } |
403 | | |
404 | 2.64k | inline void Module::AddGlobalValue(std::unique_ptr<Instruction> v) { |
405 | 2.64k | types_values_.push_back(std::move(v)); |
406 | 2.64k | } |
407 | | |
408 | 0 | inline void Module::AddFunctionDeclaration(std::unique_ptr<Function> f) { |
409 | 0 | // function declarations must come before function definitions. |
410 | 0 | functions_.emplace(functions_.begin(), std::move(f)); |
411 | 0 | } |
412 | | |
413 | 266 | inline void Module::AddFunction(std::unique_ptr<Function> f) { |
414 | 266 | functions_.emplace_back(std::move(f)); |
415 | 266 | } |
416 | | |
417 | 0 | inline void Module::AddGraph(std::unique_ptr<Graph> g) { |
418 | 0 | graphs_.emplace_back(std::move(g)); |
419 | 0 | } |
420 | | |
421 | 0 | inline void Module::SetContainsDebugInfo() { contains_debug_info_ = true; } |
422 | | |
423 | 0 | inline Module::inst_iterator Module::capability_begin() { |
424 | 0 | return capabilities_.begin(); |
425 | 0 | } |
426 | 0 | inline Module::inst_iterator Module::capability_end() { |
427 | 0 | return capabilities_.end(); |
428 | 0 | } |
429 | | |
430 | 472 | inline IteratorRange<Module::inst_iterator> Module::capabilities() { |
431 | 472 | return make_range(capabilities_.begin(), capabilities_.end()); |
432 | 472 | } |
433 | | |
434 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::capabilities() const { |
435 | 0 | return make_range(capabilities_.begin(), capabilities_.end()); |
436 | 0 | } |
437 | | |
438 | 0 | inline Module::inst_iterator Module::ext_inst_import_begin() { |
439 | 0 | return ext_inst_imports_.begin(); |
440 | 0 | } |
441 | 0 | inline Module::inst_iterator Module::ext_inst_import_end() { |
442 | 0 | return ext_inst_imports_.end(); |
443 | 0 | } |
444 | | |
445 | 2.61k | inline IteratorRange<Module::inst_iterator> Module::ext_inst_imports() { |
446 | 2.61k | return make_range(ext_inst_imports_.begin(), ext_inst_imports_.end()); |
447 | 2.61k | } |
448 | | |
449 | | inline IteratorRange<Module::const_inst_iterator> Module::ext_inst_imports() |
450 | 0 | const { |
451 | 0 | return make_range(ext_inst_imports_.begin(), ext_inst_imports_.end()); |
452 | 0 | } |
453 | | |
454 | 0 | inline Module::inst_iterator Module::debug1_begin() { return debugs1_.begin(); } |
455 | 0 | inline Module::inst_iterator Module::debug1_end() { return debugs1_.end(); } |
456 | | |
457 | 128 | inline IteratorRange<Module::inst_iterator> Module::debugs1() { |
458 | 128 | return make_range(debugs1_.begin(), debugs1_.end()); |
459 | 128 | } |
460 | | |
461 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs1() const { |
462 | 0 | return make_range(debugs1_.begin(), debugs1_.end()); |
463 | 0 | } |
464 | | |
465 | 748 | inline Module::inst_iterator Module::debug2_begin() { return debugs2_.begin(); } |
466 | 0 | inline Module::inst_iterator Module::debug2_end() { return debugs2_.end(); } |
467 | | |
468 | 844 | inline IteratorRange<Module::inst_iterator> Module::debugs2() { |
469 | 844 | return make_range(debugs2_.begin(), debugs2_.end()); |
470 | 844 | } |
471 | | |
472 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs2() const { |
473 | 0 | return make_range(debugs2_.begin(), debugs2_.end()); |
474 | 0 | } |
475 | | |
476 | 0 | inline Module::inst_iterator Module::debug3_begin() { return debugs3_.begin(); } |
477 | 0 | inline Module::inst_iterator Module::debug3_end() { return debugs3_.end(); } |
478 | | |
479 | 128 | inline IteratorRange<Module::inst_iterator> Module::debugs3() { |
480 | 128 | return make_range(debugs3_.begin(), debugs3_.end()); |
481 | 128 | } |
482 | | |
483 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs3() const { |
484 | 0 | return make_range(debugs3_.begin(), debugs3_.end()); |
485 | 0 | } |
486 | | |
487 | 3.65k | inline Module::inst_iterator Module::ext_inst_debuginfo_begin() { |
488 | 3.65k | return ext_inst_debuginfo_.begin(); |
489 | 3.65k | } |
490 | 3.65k | inline Module::inst_iterator Module::ext_inst_debuginfo_end() { |
491 | 3.65k | return ext_inst_debuginfo_.end(); |
492 | 3.65k | } |
493 | | |
494 | 2.71k | inline IteratorRange<Module::inst_iterator> Module::ext_inst_debuginfo() { |
495 | 2.71k | return make_range(ext_inst_debuginfo_.begin(), ext_inst_debuginfo_.end()); |
496 | 2.71k | } |
497 | | |
498 | | inline IteratorRange<Module::const_inst_iterator> Module::ext_inst_debuginfo() |
499 | 0 | const { |
500 | 0 | return make_range(ext_inst_debuginfo_.begin(), ext_inst_debuginfo_.end()); |
501 | 0 | } |
502 | | |
503 | 4.27k | inline IteratorRange<Module::inst_iterator> Module::entry_points() { |
504 | 4.27k | return make_range(entry_points_.begin(), entry_points_.end()); |
505 | 4.27k | } |
506 | | |
507 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::entry_points() const { |
508 | 0 | return make_range(entry_points_.begin(), entry_points_.end()); |
509 | 0 | } |
510 | | |
511 | 0 | inline IteratorRange<Module::inst_iterator> Module::graph_entry_points() { |
512 | 0 | return make_range(graph_entry_points_.begin(), graph_entry_points_.end()); |
513 | 0 | } |
514 | | |
515 | | inline IteratorRange<Module::const_inst_iterator> Module::graph_entry_points() |
516 | 0 | const { |
517 | 0 | return make_range(graph_entry_points_.begin(), graph_entry_points_.end()); |
518 | 0 | } |
519 | | |
520 | 0 | inline Module::inst_iterator Module::execution_mode_begin() { |
521 | 0 | return execution_modes_.begin(); |
522 | 0 | } |
523 | 0 | inline Module::inst_iterator Module::execution_mode_end() { |
524 | 0 | return execution_modes_.end(); |
525 | 0 | } |
526 | | |
527 | 748 | inline IteratorRange<Module::inst_iterator> Module::execution_modes() { |
528 | 748 | return make_range(execution_modes_.begin(), execution_modes_.end()); |
529 | 748 | } |
530 | | |
531 | | inline IteratorRange<Module::const_inst_iterator> Module::execution_modes() |
532 | 0 | const { |
533 | 0 | return make_range(execution_modes_.begin(), execution_modes_.end()); |
534 | 0 | } |
535 | | |
536 | 0 | inline Module::inst_iterator Module::annotation_begin() { |
537 | 0 | return annotations_.begin(); |
538 | 0 | } |
539 | 0 | inline Module::inst_iterator Module::annotation_end() { |
540 | 0 | return annotations_.end(); |
541 | 0 | } |
542 | | |
543 | 7.11k | inline IteratorRange<Module::inst_iterator> Module::annotations() { |
544 | 7.11k | return make_range(annotations_.begin(), annotations_.end()); |
545 | 7.11k | } |
546 | | |
547 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::annotations() const { |
548 | 0 | return make_range(annotations_.begin(), annotations_.end()); |
549 | 0 | } |
550 | | |
551 | 0 | inline Module::inst_iterator Module::extension_begin() { |
552 | 0 | return extensions_.begin(); |
553 | 0 | } |
554 | 0 | inline Module::inst_iterator Module::extension_end() { |
555 | 0 | return extensions_.end(); |
556 | 0 | } |
557 | | |
558 | 1.94k | inline IteratorRange<Module::inst_iterator> Module::extensions() { |
559 | 1.94k | return make_range(extensions_.begin(), extensions_.end()); |
560 | 1.94k | } |
561 | | |
562 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::extensions() const { |
563 | 0 | return make_range(extensions_.begin(), extensions_.end()); |
564 | 0 | } |
565 | | |
566 | 316 | inline Module::inst_iterator Module::types_values_begin() { |
567 | 316 | return types_values_.begin(); |
568 | 316 | } |
569 | | |
570 | 8.70k | inline Module::inst_iterator Module::types_values_end() { |
571 | 8.70k | return types_values_.end(); |
572 | 8.70k | } |
573 | | |
574 | 1.38k | inline IteratorRange<Module::inst_iterator> Module::types_values() { |
575 | 1.38k | return make_range(types_values_.begin(), types_values_.end()); |
576 | 1.38k | } |
577 | | |
578 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::types_values() const { |
579 | 0 | return make_range(types_values_.begin(), types_values_.end()); |
580 | 0 | } |
581 | | |
582 | 0 | inline const std::vector<std::unique_ptr<Graph>>& Module::graphs() const { |
583 | 0 | return graphs_; |
584 | 0 | } |
585 | | |
586 | 0 | inline Module::const_iterator Module::cbegin() const { |
587 | 0 | return const_iterator(&functions_, functions_.cbegin()); |
588 | 0 | } |
589 | | |
590 | 0 | inline Module::const_iterator Module::cend() const { |
591 | 0 | return const_iterator(&functions_, functions_.cend()); |
592 | 0 | } |
593 | | |
594 | | } // namespace opt |
595 | | } // namespace spvtools |
596 | | |
597 | | #endif // SOURCE_OPT_MODULE_H_ |