/src/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 | 60.0k | Module() : header_({}), contains_debug_info_(false) {} |
57 | | |
58 | | // Sets the header to the given |header|. |
59 | 59.8k | void SetHeader(const ModuleHeader& header) { header_ = header; } |
60 | | |
61 | | // Sets the Id bound. The Id bound cannot be set to 0. |
62 | 18.9k | void SetIdBound(uint32_t bound) { |
63 | 18.9k | assert(bound != 0); |
64 | 18.9k | header_.bound = bound; |
65 | 18.9k | } |
66 | | |
67 | | // Returns the Id bound. |
68 | 35.2k | 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 | 1.40k | 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 | 8.10M | inline uint32_t id_bound() const { return header_.bound; } |
158 | | |
159 | 58.2k | 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 | 2.52M | iterator begin() { return iterator(&functions_, functions_.begin()); } |
262 | 2.62M | 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 | | // Invokes function |f| on all instructions in this module, and optionally on |
279 | | // the debug line instructions that precede them. Terminates early if |f| |
280 | | // returns false. Returns true if all invocations of |f| returned true; |
281 | | // otherwise returns false. |
282 | | bool WhileEachInst(const std::function<bool(Instruction*)>& f, |
283 | | bool run_on_debug_line_insts = false); |
284 | | bool WhileEachInst(const std::function<bool(const Instruction*)>& f, |
285 | | bool run_on_debug_line_insts = false) const; |
286 | | |
287 | | // Pushes the binary segments for this module into the back of *`binary`. |
288 | | // If `skip_nop` is true, OpNop instructions will not be added to binary. |
289 | | // If `filter_duplicate_decorations` is true, duplicate decorations will not |
290 | | // be added to the binary. |
291 | | void ToBinary(std::vector<uint32_t>* binary, bool skip_nop, |
292 | | bool filter_duplicate_decorations = true) const; |
293 | | |
294 | | // Returns 1 more than the maximum Id value mentioned in the module. |
295 | | uint32_t ComputeIdBound() const; |
296 | | |
297 | | // Returns true if module has capability |cap| |
298 | | bool HasExplicitCapability(uint32_t cap); |
299 | | |
300 | | // Returns id for OpExtInst instruction for extension |extstr|. |
301 | | // Returns 0 if not found. |
302 | | uint32_t GetExtInstImportId(const char* extstr); |
303 | | |
304 | | // Sets the associated context for this module |
305 | 60.0k | void SetContext(IRContext* c) { context_ = c; } |
306 | | |
307 | | // Gets the associated context for this module |
308 | 43.0M | IRContext* context() const { return context_; } |
309 | | |
310 | | // Sets the trailing debug line info to |dbg_line_info|. |
311 | 60.0k | void SetTrailingDbgLineInfo(std::vector<Instruction>&& dbg_line_info) { |
312 | 60.0k | trailing_dbg_line_info_ = std::move(dbg_line_info); |
313 | 60.0k | } |
314 | | |
315 | 0 | std::vector<Instruction>& trailing_dbg_line_info() { |
316 | 0 | return trailing_dbg_line_info_; |
317 | 0 | } |
318 | | |
319 | 0 | const std::vector<Instruction>& trailing_dbg_line_info() const { |
320 | 0 | return trailing_dbg_line_info_; |
321 | 0 | } |
322 | | |
323 | | private: |
324 | | // Helper template for WhileEachInst to share traversal logic between const |
325 | | // and non-const versions. |
326 | | template <typename ModuleT, typename InstT> |
327 | | static bool WhileEachInstImpl(ModuleT* module, |
328 | | const std::function<bool(InstT*)>& f, |
329 | | bool run_on_debug_line_insts); |
330 | | |
331 | | ModuleHeader header_; // Module header |
332 | | |
333 | | // The following fields respect the "Logical Layout of a Module" in |
334 | | // Section 2.4 of the SPIR-V specification. |
335 | | IRContext* context_; |
336 | | InstructionList capabilities_; |
337 | | InstructionList extensions_; |
338 | | InstructionList ext_inst_imports_; |
339 | | // A module only has one memory model instruction. |
340 | | std::unique_ptr<Instruction> memory_model_; |
341 | | // A module can only have one optional sampled image addressing mode |
342 | | std::unique_ptr<Instruction> sampled_image_address_mode_; |
343 | | InstructionList entry_points_; |
344 | | InstructionList graph_entry_points_; |
345 | | InstructionList execution_modes_; |
346 | | InstructionList debugs1_; |
347 | | InstructionList debugs2_; |
348 | | InstructionList debugs3_; |
349 | | InstructionList ext_inst_debuginfo_; |
350 | | InstructionList annotations_; |
351 | | // Type declarations, constants, and global variable declarations. |
352 | | InstructionList types_values_; |
353 | | std::vector<std::unique_ptr<Function>> functions_; |
354 | | std::vector<std::unique_ptr<Graph>> graphs_; |
355 | | |
356 | | // If the module ends with Op*Line instruction, they will not be attached to |
357 | | // any instruction. We record them here, so they will not be lost. |
358 | | std::vector<Instruction> trailing_dbg_line_info_; |
359 | | |
360 | | // This module contains DebugScope/DebugNoScope or OpLine/OpNoLine. |
361 | | bool contains_debug_info_; |
362 | | }; |
363 | | |
364 | | // Pretty-prints |module| to |str|. Returns |str|. |
365 | | std::ostream& operator<<(std::ostream& str, const Module& module); |
366 | | |
367 | 69.9k | inline void Module::AddCapability(std::unique_ptr<Instruction> c) { |
368 | 69.9k | capabilities_.push_back(std::move(c)); |
369 | 69.9k | } |
370 | | |
371 | 28.5k | inline void Module::AddExtension(std::unique_ptr<Instruction> e) { |
372 | 28.5k | extensions_.push_back(std::move(e)); |
373 | 28.5k | } |
374 | | |
375 | 25.2k | inline void Module::AddExtInstImport(std::unique_ptr<Instruction> e) { |
376 | 25.2k | ext_inst_imports_.push_back(std::move(e)); |
377 | 25.2k | } |
378 | | |
379 | 52.5k | inline void Module::SetMemoryModel(std::unique_ptr<Instruction> m) { |
380 | 52.5k | memory_model_ = std::move(m); |
381 | 52.5k | } |
382 | | |
383 | 128 | inline void Module::SetSampledImageAddressMode(std::unique_ptr<Instruction> m) { |
384 | 128 | sampled_image_address_mode_ = std::move(m); |
385 | 128 | } |
386 | | |
387 | 41.6k | inline void Module::AddEntryPoint(std::unique_ptr<Instruction> e) { |
388 | 41.6k | entry_points_.push_back(std::move(e)); |
389 | 41.6k | } |
390 | | |
391 | 62 | inline void Module::AddGraphEntryPoint(std::unique_ptr<Instruction> e) { |
392 | 62 | graph_entry_points_.push_back(std::move(e)); |
393 | 62 | } |
394 | | |
395 | 47.6k | inline void Module::AddExecutionMode(std::unique_ptr<Instruction> e) { |
396 | 47.6k | execution_modes_.push_back(std::move(e)); |
397 | 47.6k | } |
398 | | |
399 | 22.3k | inline void Module::AddDebug1Inst(std::unique_ptr<Instruction> d) { |
400 | 22.3k | debugs1_.push_back(std::move(d)); |
401 | 22.3k | } |
402 | | |
403 | 239k | inline void Module::AddDebug2Inst(std::unique_ptr<Instruction> d) { |
404 | 239k | debugs2_.push_back(std::move(d)); |
405 | 239k | } |
406 | | |
407 | 246 | inline void Module::AddDebug3Inst(std::unique_ptr<Instruction> d) { |
408 | 246 | debugs3_.push_back(std::move(d)); |
409 | 246 | } |
410 | | |
411 | 361 | inline void Module::AddExtInstDebugInfo(std::unique_ptr<Instruction> d) { |
412 | 361 | ext_inst_debuginfo_.push_back(std::move(d)); |
413 | 361 | } |
414 | | |
415 | 19.2M | inline void Module::AddAnnotationInst(std::unique_ptr<Instruction> a) { |
416 | 19.2M | annotations_.push_back(std::move(a)); |
417 | 19.2M | } |
418 | | |
419 | 559k | inline void Module::AddType(std::unique_ptr<Instruction> t) { |
420 | 559k | types_values_.push_back(std::move(t)); |
421 | 559k | } |
422 | | |
423 | 586k | inline void Module::AddGlobalValue(std::unique_ptr<Instruction> v) { |
424 | 586k | types_values_.push_back(std::move(v)); |
425 | 586k | } |
426 | | |
427 | 0 | inline void Module::AddFunctionDeclaration(std::unique_ptr<Function> f) { |
428 | 0 | // function declarations must come before function definitions. |
429 | 0 | functions_.emplace(functions_.begin(), std::move(f)); |
430 | 0 | } |
431 | | |
432 | 73.3k | inline void Module::AddFunction(std::unique_ptr<Function> f) { |
433 | 73.3k | functions_.emplace_back(std::move(f)); |
434 | 73.3k | } |
435 | | |
436 | 1 | inline void Module::AddGraph(std::unique_ptr<Graph> g) { |
437 | 1 | graphs_.emplace_back(std::move(g)); |
438 | 1 | } |
439 | | |
440 | 24.3k | inline void Module::SetContainsDebugInfo() { contains_debug_info_ = true; } |
441 | | |
442 | 0 | inline Module::inst_iterator Module::capability_begin() { |
443 | 0 | return capabilities_.begin(); |
444 | 0 | } |
445 | 0 | inline Module::inst_iterator Module::capability_end() { |
446 | 0 | return capabilities_.end(); |
447 | 0 | } |
448 | | |
449 | 745k | inline IteratorRange<Module::inst_iterator> Module::capabilities() { |
450 | 745k | return make_range(capabilities_.begin(), capabilities_.end()); |
451 | 745k | } |
452 | | |
453 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::capabilities() const { |
454 | 0 | return make_range(capabilities_.begin(), capabilities_.end()); |
455 | 0 | } |
456 | | |
457 | 0 | inline Module::inst_iterator Module::ext_inst_import_begin() { |
458 | 0 | return ext_inst_imports_.begin(); |
459 | 0 | } |
460 | 0 | inline Module::inst_iterator Module::ext_inst_import_end() { |
461 | 0 | return ext_inst_imports_.end(); |
462 | 0 | } |
463 | | |
464 | 983k | inline IteratorRange<Module::inst_iterator> Module::ext_inst_imports() { |
465 | 983k | return make_range(ext_inst_imports_.begin(), ext_inst_imports_.end()); |
466 | 983k | } |
467 | | |
468 | | inline IteratorRange<Module::const_inst_iterator> Module::ext_inst_imports() |
469 | 0 | const { |
470 | 0 | return make_range(ext_inst_imports_.begin(), ext_inst_imports_.end()); |
471 | 0 | } |
472 | | |
473 | 0 | inline Module::inst_iterator Module::debug1_begin() { return debugs1_.begin(); } |
474 | 0 | inline Module::inst_iterator Module::debug1_end() { return debugs1_.end(); } |
475 | | |
476 | 0 | inline IteratorRange<Module::inst_iterator> Module::debugs1() { |
477 | 0 | return make_range(debugs1_.begin(), debugs1_.end()); |
478 | 0 | } |
479 | | |
480 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs1() const { |
481 | 0 | return make_range(debugs1_.begin(), debugs1_.end()); |
482 | 0 | } |
483 | | |
484 | 76.2k | inline Module::inst_iterator Module::debug2_begin() { return debugs2_.begin(); } |
485 | 0 | inline Module::inst_iterator Module::debug2_end() { return debugs2_.end(); } |
486 | | |
487 | 83.4k | inline IteratorRange<Module::inst_iterator> Module::debugs2() { |
488 | 83.4k | return make_range(debugs2_.begin(), debugs2_.end()); |
489 | 83.4k | } |
490 | | |
491 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs2() const { |
492 | 0 | return make_range(debugs2_.begin(), debugs2_.end()); |
493 | 0 | } |
494 | | |
495 | 0 | inline Module::inst_iterator Module::debug3_begin() { return debugs3_.begin(); } |
496 | 0 | inline Module::inst_iterator Module::debug3_end() { return debugs3_.end(); } |
497 | | |
498 | 0 | inline IteratorRange<Module::inst_iterator> Module::debugs3() { |
499 | 0 | return make_range(debugs3_.begin(), debugs3_.end()); |
500 | 0 | } |
501 | | |
502 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::debugs3() const { |
503 | 0 | return make_range(debugs3_.begin(), debugs3_.end()); |
504 | 0 | } |
505 | | |
506 | 730k | inline Module::inst_iterator Module::ext_inst_debuginfo_begin() { |
507 | 730k | return ext_inst_debuginfo_.begin(); |
508 | 730k | } |
509 | 730k | inline Module::inst_iterator Module::ext_inst_debuginfo_end() { |
510 | 730k | return ext_inst_debuginfo_.end(); |
511 | 730k | } |
512 | | |
513 | 272k | inline IteratorRange<Module::inst_iterator> Module::ext_inst_debuginfo() { |
514 | 272k | return make_range(ext_inst_debuginfo_.begin(), ext_inst_debuginfo_.end()); |
515 | 272k | } |
516 | | |
517 | | inline IteratorRange<Module::const_inst_iterator> Module::ext_inst_debuginfo() |
518 | 0 | const { |
519 | 0 | return make_range(ext_inst_debuginfo_.begin(), ext_inst_debuginfo_.end()); |
520 | 0 | } |
521 | | |
522 | 508k | inline IteratorRange<Module::inst_iterator> Module::entry_points() { |
523 | 508k | return make_range(entry_points_.begin(), entry_points_.end()); |
524 | 508k | } |
525 | | |
526 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::entry_points() const { |
527 | 0 | return make_range(entry_points_.begin(), entry_points_.end()); |
528 | 0 | } |
529 | | |
530 | 0 | inline IteratorRange<Module::inst_iterator> Module::graph_entry_points() { |
531 | 0 | return make_range(graph_entry_points_.begin(), graph_entry_points_.end()); |
532 | 0 | } |
533 | | |
534 | | inline IteratorRange<Module::const_inst_iterator> Module::graph_entry_points() |
535 | 0 | const { |
536 | 0 | return make_range(graph_entry_points_.begin(), graph_entry_points_.end()); |
537 | 0 | } |
538 | | |
539 | 0 | inline Module::inst_iterator Module::execution_mode_begin() { |
540 | 0 | return execution_modes_.begin(); |
541 | 0 | } |
542 | 0 | inline Module::inst_iterator Module::execution_mode_end() { |
543 | 0 | return execution_modes_.end(); |
544 | 0 | } |
545 | | |
546 | 76.2k | inline IteratorRange<Module::inst_iterator> Module::execution_modes() { |
547 | 76.2k | return make_range(execution_modes_.begin(), execution_modes_.end()); |
548 | 76.2k | } |
549 | | |
550 | | inline IteratorRange<Module::const_inst_iterator> Module::execution_modes() |
551 | 0 | const { |
552 | 0 | return make_range(execution_modes_.begin(), execution_modes_.end()); |
553 | 0 | } |
554 | | |
555 | 0 | inline Module::inst_iterator Module::annotation_begin() { |
556 | 0 | return annotations_.begin(); |
557 | 0 | } |
558 | 212k | inline Module::inst_iterator Module::annotation_end() { |
559 | 212k | return annotations_.end(); |
560 | 212k | } |
561 | | |
562 | 994k | inline IteratorRange<Module::inst_iterator> Module::annotations() { |
563 | 994k | return make_range(annotations_.begin(), annotations_.end()); |
564 | 994k | } |
565 | | |
566 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::annotations() const { |
567 | 0 | return make_range(annotations_.begin(), annotations_.end()); |
568 | 0 | } |
569 | | |
570 | 0 | inline Module::inst_iterator Module::extension_begin() { |
571 | 0 | return extensions_.begin(); |
572 | 0 | } |
573 | 0 | inline Module::inst_iterator Module::extension_end() { |
574 | 0 | return extensions_.end(); |
575 | 0 | } |
576 | | |
577 | 897k | inline IteratorRange<Module::inst_iterator> Module::extensions() { |
578 | 897k | return make_range(extensions_.begin(), extensions_.end()); |
579 | 897k | } |
580 | | |
581 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::extensions() const { |
582 | 0 | return make_range(extensions_.begin(), extensions_.end()); |
583 | 0 | } |
584 | | |
585 | 91.3k | inline Module::inst_iterator Module::types_values_begin() { |
586 | 91.3k | return types_values_.begin(); |
587 | 91.3k | } |
588 | | |
589 | 1.49M | inline Module::inst_iterator Module::types_values_end() { |
590 | 1.49M | return types_values_.end(); |
591 | 1.49M | } |
592 | | |
593 | 160k | inline IteratorRange<Module::inst_iterator> Module::types_values() { |
594 | 160k | return make_range(types_values_.begin(), types_values_.end()); |
595 | 160k | } |
596 | | |
597 | 0 | inline IteratorRange<Module::const_inst_iterator> Module::types_values() const { |
598 | 0 | return make_range(types_values_.begin(), types_values_.end()); |
599 | 0 | } |
600 | | |
601 | 326 | inline const std::vector<std::unique_ptr<Graph>>& Module::graphs() const { |
602 | 326 | return graphs_; |
603 | 326 | } |
604 | | |
605 | 0 | inline Module::const_iterator Module::cbegin() const { |
606 | 0 | return const_iterator(&functions_, functions_.cbegin()); |
607 | 0 | } |
608 | | |
609 | 0 | inline Module::const_iterator Module::cend() const { |
610 | 0 | return const_iterator(&functions_, functions_.cend()); |
611 | 0 | } |
612 | | |
613 | | } // namespace opt |
614 | | } // namespace spvtools |
615 | | |
616 | | #endif // SOURCE_OPT_MODULE_H_ |