fix duplicate decorations
[kazan.git] / src / spirv_to_llvm / core_instructions.cpp
1 /*
2 * Copyright 2017 Jacob Lifshay
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 *
22 */
23 #include "spirv_to_llvm_implementation.h"
24
25 namespace kazan
26 {
27 namespace spirv_to_llvm
28 {
29 using namespace spirv;
30
31 void Spirv_to_llvm::handle_instruction_op_nop([[gnu::unused]] Op_nop instruction,
32 [[gnu::unused]] std::size_t instruction_start_index)
33 {
34 }
35
36 void Spirv_to_llvm::handle_instruction_op_undef(Op_undef instruction,
37 std::size_t instruction_start_index)
38 {
39 #warning finish
40 throw Parser_error(instruction_start_index,
41 instruction_start_index,
42 "instruction not implemented: "
43 + std::string(get_enumerant_name(instruction.get_operation())));
44 }
45
46 void Spirv_to_llvm::handle_instruction_op_source_continued(
47 [[gnu::unused]] Op_source_continued instruction,
48 [[gnu::unused]] std::size_t instruction_start_index)
49 {
50 }
51
52 void Spirv_to_llvm::handle_instruction_op_source(
53 Op_source instruction, [[gnu::unused]] std::size_t instruction_start_index)
54 {
55 if(stage == util::Enum_traits<Stage>::values[0] && instruction.file)
56 {
57 std::string filename(
58 get_id_state(*instruction.file).op_string.value_or(Op_string_state()).value);
59 ::LLVMSetModuleIdentifier(module.get(), filename.data(), filename.size());
60 }
61 }
62
63 void Spirv_to_llvm::handle_instruction_op_source_extension(
64 [[gnu::unused]] Op_source_extension instruction,
65 [[gnu::unused]] std::size_t instruction_start_index)
66 {
67 }
68
69 void Spirv_to_llvm::handle_instruction_op_name(Op_name instruction,
70 [[gnu::unused]] std::size_t instruction_start_index)
71 {
72 if(stage == util::Enum_traits<Stage>::values[0])
73 get_id_state(instruction.target).name = Name{std::string(instruction.name)};
74 }
75
76 void Spirv_to_llvm::handle_instruction_op_member_name(
77 Op_member_name instruction, [[gnu::unused]] std::size_t instruction_start_index)
78 {
79 if(stage == util::Enum_traits<Stage>::values[0])
80 {
81 auto &state = get_id_state(instruction.type);
82 state.member_names.push_back(std::move(instruction));
83 }
84 }
85
86 void Spirv_to_llvm::handle_instruction_op_string(
87 Op_string instruction, [[gnu::unused]] std::size_t instruction_start_index)
88 {
89 if(stage == util::Enum_traits<Stage>::values[0])
90 get_id_state(instruction.result).op_string = Op_string_state{instruction.string};
91 }
92
93 void Spirv_to_llvm::handle_instruction_op_line(Op_line instruction,
94 std::size_t instruction_start_index)
95 {
96 #warning finish
97 throw Parser_error(instruction_start_index,
98 instruction_start_index,
99 "instruction not implemented: "
100 + std::string(get_enumerant_name(instruction.get_operation())));
101 }
102
103 void Spirv_to_llvm::handle_instruction_op_extension(Op_extension instruction,
104 std::size_t instruction_start_index)
105 {
106 #warning finish
107 throw Parser_error(instruction_start_index,
108 instruction_start_index,
109 "instruction not implemented: "
110 + std::string(get_enumerant_name(instruction.get_operation())));
111 }
112
113 void Spirv_to_llvm::handle_instruction_op_ext_inst_import(Op_ext_inst_import instruction,
114 std::size_t instruction_start_index)
115 {
116 if(stage == util::Enum_traits<Stage>::values[0])
117 {
118 get_id_state(instruction.result).op_ext_inst_import = Op_ext_inst_import_state{};
119 for(auto instruction_set : util::Enum_traits<Extension_instruction_set>::values)
120 {
121 if(instruction_set == Extension_instruction_set::unknown)
122 continue;
123 if(instruction.name == get_enumerant_name(instruction_set))
124 return;
125 }
126 throw Parser_error(instruction_start_index,
127 instruction_start_index,
128 "unknown instruction set: \"" + std::string(instruction.name) + "\"");
129 }
130 }
131
132 void Spirv_to_llvm::handle_instruction_op_ext_inst(Op_ext_inst instruction,
133 std::size_t instruction_start_index)
134 {
135 #warning finish
136 throw Parser_error(instruction_start_index,
137 instruction_start_index,
138 "instruction not implemented: "
139 + std::string(get_enumerant_name(instruction.get_operation())));
140 }
141
142 void Spirv_to_llvm::handle_instruction_op_memory_model(Op_memory_model instruction,
143 std::size_t instruction_start_index)
144 {
145 if(instruction.addressing_model != Addressing_model::logical)
146 throw Parser_error(instruction_start_index,
147 instruction_start_index,
148 "unsupported addressing model: "
149 + std::string(get_enumerant_name(instruction.addressing_model)));
150 switch(instruction.memory_model)
151 {
152 case Memory_model::simple:
153 case Memory_model::glsl450:
154 break;
155 default:
156 throw Parser_error(instruction_start_index,
157 instruction_start_index,
158 "unsupported memory model: "
159 + std::string(get_enumerant_name(instruction.memory_model)));
160 }
161 }
162
163 void Spirv_to_llvm::handle_instruction_op_entry_point(Op_entry_point instruction,
164 std::size_t instruction_start_index)
165 {
166 if(stage == util::Enum_traits<Stage>::values[0])
167 {
168 if(entry_point_state_pointer)
169 throw Parser_error(instruction_start_index,
170 instruction_start_index,
171 "invalid location for OpEntryPoint");
172 auto &state = get_id_state(instruction.entry_point);
173 state.op_entry_points.push_back(
174 Op_entry_point_state{std::move(instruction), instruction_start_index});
175 }
176 }
177
178 void Spirv_to_llvm::handle_instruction_op_execution_mode(Op_execution_mode instruction,
179 std::size_t instruction_start_index)
180 {
181 if(stage == util::Enum_traits<Stage>::values[0])
182 {
183 auto &state = get_id_state(instruction.entry_point);
184 if(state.op_entry_points.empty())
185 throw Parser_error(instruction_start_index,
186 instruction_start_index,
187 "entry point not defined in OpExecutionMode");
188 state.op_entry_points.back().execution_modes.push_back(std::move(instruction.mode));
189 }
190 }
191
192 void Spirv_to_llvm::handle_instruction_op_capability(Op_capability instruction,
193 std::size_t instruction_start_index)
194 {
195 if(stage == util::Enum_traits<Stage>::values[0])
196 {
197 util::Enum_set<Capability> work_list{instruction.capability};
198 while(!work_list.empty())
199 {
200 auto capability = *work_list.begin();
201 work_list.erase(capability);
202 if(std::get<1>(enabled_capabilities.insert(capability)))
203 {
204 auto additional_capabilities = get_directly_required_capabilities(capability);
205 work_list.insert(additional_capabilities.begin(), additional_capabilities.end());
206 }
207 }
208 constexpr util::Enum_set<Capability> implemented_capabilities{
209 Capability::matrix,
210 Capability::shader,
211 Capability::input_attachment,
212 Capability::sampled1d,
213 Capability::image1d,
214 Capability::sampled_buffer,
215 Capability::image_buffer,
216 Capability::image_query,
217 Capability::derivative_control,
218 Capability::int64,
219 };
220 for(auto capability : enabled_capabilities)
221 {
222 if(implemented_capabilities.count(capability) == 0)
223 throw Parser_error(
224 instruction_start_index,
225 instruction_start_index,
226 "capability not implemented: " + std::string(get_enumerant_name(capability)));
227 }
228 }
229 }
230
231 void Spirv_to_llvm::handle_instruction_op_type_void(
232 Op_type_void instruction, [[gnu::unused]] std::size_t instruction_start_index)
233 {
234 switch(stage)
235 {
236 case Stage::calculate_types:
237 {
238 auto &state = get_id_state(instruction.result);
239 if(!state.decorations.empty())
240 throw Parser_error(instruction_start_index,
241 instruction_start_index,
242 "decorations on instruction not implemented: "
243 + std::string(get_enumerant_name(instruction.get_operation())));
244 state.type = std::make_shared<Simple_type_descriptor>(
245 state.decorations, LLVM_type_and_alignment(::LLVMVoidTypeInContext(context), 1));
246 break;
247 }
248 case Stage::generate_code:
249 break;
250 }
251 }
252
253 void Spirv_to_llvm::handle_instruction_op_type_bool(Op_type_bool instruction,
254 std::size_t instruction_start_index)
255 {
256 #warning finish
257 throw Parser_error(instruction_start_index,
258 instruction_start_index,
259 "instruction not implemented: "
260 + std::string(get_enumerant_name(instruction.get_operation())));
261 }
262
263 void Spirv_to_llvm::handle_instruction_op_type_int(Op_type_int instruction,
264 std::size_t instruction_start_index)
265 {
266 switch(stage)
267 {
268 case Stage::calculate_types:
269 {
270 auto &state = get_id_state(instruction.result);
271 if(!state.decorations.empty())
272 throw Parser_error(instruction_start_index,
273 instruction_start_index,
274 "decorations on instruction not implemented: "
275 + std::string(get_enumerant_name(instruction.get_operation())));
276 switch(instruction.width)
277 {
278 case 8:
279 case 16:
280 case 32:
281 case 64:
282 {
283 auto type = ::LLVMIntTypeInContext(context, instruction.width);
284 state.type = std::make_shared<Simple_type_descriptor>(
285 state.decorations,
286 LLVM_type_and_alignment(type, ::LLVMPreferredAlignmentOfType(target_data, type)));
287 break;
288 }
289 default:
290 throw Parser_error(
291 instruction_start_index, instruction_start_index, "invalid int width");
292 }
293 break;
294 }
295 case Stage::generate_code:
296 break;
297 }
298 }
299
300 void Spirv_to_llvm::handle_instruction_op_type_float(Op_type_float instruction,
301 std::size_t instruction_start_index)
302 {
303 switch(stage)
304 {
305 case Stage::calculate_types:
306 {
307 auto &state = get_id_state(instruction.result);
308 if(!state.decorations.empty())
309 throw Parser_error(instruction_start_index,
310 instruction_start_index,
311 "decorations on instruction not implemented: "
312 + std::string(get_enumerant_name(instruction.get_operation())));
313 ::LLVMTypeRef type = nullptr;
314 switch(instruction.width)
315 {
316 case 16:
317 type = ::LLVMHalfTypeInContext(context);
318 break;
319 case 32:
320 type = ::LLVMFloatTypeInContext(context);
321 break;
322 case 64:
323 type = ::LLVMDoubleTypeInContext(context);
324 break;
325 default:
326 throw Parser_error(
327 instruction_start_index, instruction_start_index, "invalid float width");
328 }
329 state.type = std::make_shared<Simple_type_descriptor>(
330 state.decorations,
331 LLVM_type_and_alignment(type, ::LLVMPreferredAlignmentOfType(target_data, type)));
332 break;
333 }
334 case Stage::generate_code:
335 break;
336 }
337 }
338
339 void Spirv_to_llvm::handle_instruction_op_type_vector(Op_type_vector instruction,
340 std::size_t instruction_start_index)
341 {
342 switch(stage)
343 {
344 case Stage::calculate_types:
345 {
346 auto &state = get_id_state(instruction.result);
347 if(!state.decorations.empty())
348 throw Parser_error(instruction_start_index,
349 instruction_start_index,
350 "decorations on instruction not implemented: "
351 + std::string(get_enumerant_name(instruction.get_operation())));
352 state.type = std::make_shared<Vector_type_descriptor>(
353 state.decorations,
354 get_type<Simple_type_descriptor>(instruction.component_type, instruction_start_index),
355 instruction.component_count,
356 target_data);
357 break;
358 }
359 case Stage::generate_code:
360 break;
361 }
362 }
363
364 void Spirv_to_llvm::handle_instruction_op_type_matrix(Op_type_matrix instruction,
365 std::size_t instruction_start_index)
366 {
367 switch(stage)
368 {
369 case Stage::calculate_types:
370 {
371 auto &state = get_id_state(instruction.result);
372 if(!state.decorations.empty())
373 throw Parser_error(instruction_start_index,
374 instruction_start_index,
375 "decorations on instruction not implemented: "
376 + std::string(get_enumerant_name(instruction.get_operation())));
377 state.type = std::make_shared<Matrix_type_descriptor>(
378 state.decorations,
379 get_type<Vector_type_descriptor>(instruction.column_type, instruction_start_index),
380 instruction.column_count);
381 break;
382 }
383 case Stage::generate_code:
384 break;
385 }
386 }
387
388 void Spirv_to_llvm::handle_instruction_op_type_image(Op_type_image instruction,
389 std::size_t instruction_start_index)
390 {
391 #warning finish
392 throw Parser_error(instruction_start_index,
393 instruction_start_index,
394 "instruction not implemented: "
395 + std::string(get_enumerant_name(instruction.get_operation())));
396 }
397
398 void Spirv_to_llvm::handle_instruction_op_type_sampler(Op_type_sampler instruction,
399 std::size_t instruction_start_index)
400 {
401 #warning finish
402 throw Parser_error(instruction_start_index,
403 instruction_start_index,
404 "instruction not implemented: "
405 + std::string(get_enumerant_name(instruction.get_operation())));
406 }
407
408 void Spirv_to_llvm::handle_instruction_op_type_sampled_image(Op_type_sampled_image instruction,
409 std::size_t instruction_start_index)
410 {
411 #warning finish
412 throw Parser_error(instruction_start_index,
413 instruction_start_index,
414 "instruction not implemented: "
415 + std::string(get_enumerant_name(instruction.get_operation())));
416 }
417
418 void Spirv_to_llvm::handle_instruction_op_type_array(Op_type_array instruction,
419 std::size_t instruction_start_index)
420 {
421 switch(stage)
422 {
423 case Stage::calculate_types:
424 {
425 auto &state = get_id_state(instruction.result);
426 if(!state.decorations.empty())
427 throw Parser_error(instruction_start_index,
428 instruction_start_index,
429 "decorations on instruction not implemented: "
430 + std::string(get_enumerant_name(instruction.get_operation())));
431 auto length = get_unsigned_integer_constant(instruction.length, instruction_start_index);
432 if(length <= 0)
433 throw Parser_error(instruction_start_index,
434 instruction_start_index,
435 "OpTypeArray length must be a positive constant integer");
436 state.type = std::make_shared<Array_type_descriptor>(
437 state.decorations,
438 get_type(instruction.element_type, instruction_start_index),
439 length,
440 instruction_start_index);
441 break;
442 }
443 case Stage::generate_code:
444 break;
445 }
446 }
447
448 void Spirv_to_llvm::handle_instruction_op_type_runtime_array(Op_type_runtime_array instruction,
449 std::size_t instruction_start_index)
450 {
451 #warning finish
452 throw Parser_error(instruction_start_index,
453 instruction_start_index,
454 "instruction not implemented: "
455 + std::string(get_enumerant_name(instruction.get_operation())));
456 }
457
458 void Spirv_to_llvm::handle_instruction_op_type_struct(Op_type_struct instruction,
459 std::size_t instruction_start_index)
460 {
461 switch(stage)
462 {
463 case Stage::calculate_types:
464 {
465 auto &state = get_id_state(instruction.result);
466 std::vector<Struct_type_descriptor::Member> members;
467 members.reserve(instruction.member_0_type_member_1_type.size());
468 for(auto &member_id : instruction.member_0_type_member_1_type)
469 members.push_back(
470 Struct_type_descriptor::Member({}, get_type(member_id, instruction_start_index)));
471 for(auto &decoration : state.member_decorations)
472 {
473 if(decoration.member >= members.size())
474 throw Parser_error(instruction_start_index,
475 instruction_start_index,
476 "member decoration's member index is out of range");
477 auto &member = members[decoration.member];
478 member.decorations.push_back(decoration.decoration);
479 }
480 state.type = std::make_shared<Struct_type_descriptor>(
481 state.decorations,
482 context,
483 ::LLVMGetModuleDataLayout(module.get()),
484 get_prefixed_name(get_name(instruction.result), false).c_str(),
485 instruction_start_index,
486 std::move(members));
487 break;
488 }
489 case Stage::generate_code:
490 break;
491 }
492 }
493
494 void Spirv_to_llvm::handle_instruction_op_type_opaque(Op_type_opaque instruction,
495 std::size_t instruction_start_index)
496 {
497 #warning finish
498 throw Parser_error(instruction_start_index,
499 instruction_start_index,
500 "instruction not implemented: "
501 + std::string(get_enumerant_name(instruction.get_operation())));
502 }
503
504 void Spirv_to_llvm::handle_instruction_op_type_pointer(Op_type_pointer instruction,
505 std::size_t instruction_start_index)
506 {
507 switch(stage)
508 {
509 case Stage::calculate_types:
510 {
511 auto &state = get_id_state(instruction.result);
512 if(!state.decorations.empty())
513 throw Parser_error(instruction_start_index,
514 instruction_start_index,
515 "decorations on instruction not implemented: "
516 + std::string(get_enumerant_name(instruction.get_operation())));
517 if(!state.type)
518 {
519 state.type = std::make_shared<Pointer_type_descriptor>(
520 state.decorations,
521 get_type(instruction.type, instruction_start_index),
522 instruction_start_index,
523 target_data);
524 }
525 else if(auto *pointer_type = dynamic_cast<Pointer_type_descriptor *>(state.type.get()))
526 {
527 if(pointer_type->get_base_type())
528 throw Parser_error(instruction_start_index,
529 instruction_start_index,
530 "result type is not a pointer forward declaration");
531 pointer_type->set_base_type(get_type(instruction.type, instruction_start_index));
532 }
533 else
534 {
535 throw Parser_error(instruction_start_index,
536 instruction_start_index,
537 "result type is not a pointer forward declaration");
538 }
539 break;
540 }
541 case Stage::generate_code:
542 break;
543 }
544 }
545
546 void Spirv_to_llvm::handle_instruction_op_type_function(Op_type_function instruction,
547 std::size_t instruction_start_index)
548 {
549 switch(stage)
550 {
551 case Stage::calculate_types:
552 {
553 std::vector<std::shared_ptr<Type_descriptor>> args;
554 args.reserve(implicit_function_arguments.size()
555 + instruction.parameter_0_type_parameter_1_type.size());
556 for(auto &arg : implicit_function_arguments)
557 args.push_back(arg);
558 bool return_type_is_void = false;
559 auto return_type = get_type(instruction.return_type, instruction_start_index);
560 if(auto *simple_return_type = dynamic_cast<Simple_type_descriptor *>(return_type.get()))
561 if(simple_return_type->get_or_make_type().type == ::LLVMVoidTypeInContext(context))
562 return_type_is_void = true;
563 bool valid_for_entry_point =
564 instruction.parameter_0_type_parameter_1_type.empty() && return_type_is_void;
565 for(Id_ref type : instruction.parameter_0_type_parameter_1_type)
566 {
567 args.push_back(get_type(type, instruction_start_index));
568 }
569 auto &state = get_id_state(instruction.result);
570 if(!state.decorations.empty())
571 throw Parser_error(instruction_start_index,
572 instruction_start_index,
573 "decorations on instruction not implemented: "
574 + std::string(get_enumerant_name(instruction.get_operation())));
575 constexpr bool is_var_arg = false;
576 state.type = std::make_shared<Function_type_descriptor>(
577 state.decorations,
578 get_type(instruction.return_type, instruction_start_index),
579 std::move(args),
580 instruction_start_index,
581 target_data,
582 valid_for_entry_point,
583 is_var_arg);
584 break;
585 }
586 case Stage::generate_code:
587 break;
588 }
589 }
590
591 void Spirv_to_llvm::handle_instruction_op_type_event(Op_type_event instruction,
592 std::size_t instruction_start_index)
593 {
594 #warning finish
595 throw Parser_error(instruction_start_index,
596 instruction_start_index,
597 "instruction not implemented: "
598 + std::string(get_enumerant_name(instruction.get_operation())));
599 }
600
601 void Spirv_to_llvm::handle_instruction_op_type_device_event(Op_type_device_event instruction,
602 std::size_t instruction_start_index)
603 {
604 #warning finish
605 throw Parser_error(instruction_start_index,
606 instruction_start_index,
607 "instruction not implemented: "
608 + std::string(get_enumerant_name(instruction.get_operation())));
609 }
610
611 void Spirv_to_llvm::handle_instruction_op_type_reserve_id(Op_type_reserve_id instruction,
612 std::size_t instruction_start_index)
613 {
614 #warning finish
615 throw Parser_error(instruction_start_index,
616 instruction_start_index,
617 "instruction not implemented: "
618 + std::string(get_enumerant_name(instruction.get_operation())));
619 }
620
621 void Spirv_to_llvm::handle_instruction_op_type_queue(Op_type_queue instruction,
622 std::size_t instruction_start_index)
623 {
624 #warning finish
625 throw Parser_error(instruction_start_index,
626 instruction_start_index,
627 "instruction not implemented: "
628 + std::string(get_enumerant_name(instruction.get_operation())));
629 }
630
631 void Spirv_to_llvm::handle_instruction_op_type_pipe(Op_type_pipe instruction,
632 std::size_t instruction_start_index)
633 {
634 #warning finish
635 throw Parser_error(instruction_start_index,
636 instruction_start_index,
637 "instruction not implemented: "
638 + std::string(get_enumerant_name(instruction.get_operation())));
639 }
640
641 void Spirv_to_llvm::handle_instruction_op_type_forward_pointer(Op_type_forward_pointer instruction,
642 std::size_t instruction_start_index)
643 {
644 #warning finish
645 throw Parser_error(instruction_start_index,
646 instruction_start_index,
647 "instruction not implemented: "
648 + std::string(get_enumerant_name(instruction.get_operation())));
649 }
650
651 void Spirv_to_llvm::handle_instruction_op_constant_true(Op_constant_true instruction,
652 std::size_t instruction_start_index)
653 {
654 #warning finish
655 throw Parser_error(instruction_start_index,
656 instruction_start_index,
657 "instruction not implemented: "
658 + std::string(get_enumerant_name(instruction.get_operation())));
659 }
660
661 void Spirv_to_llvm::handle_instruction_op_constant_false(Op_constant_false instruction,
662 std::size_t instruction_start_index)
663 {
664 #warning finish
665 throw Parser_error(instruction_start_index,
666 instruction_start_index,
667 "instruction not implemented: "
668 + std::string(get_enumerant_name(instruction.get_operation())));
669 }
670
671 void Spirv_to_llvm::handle_instruction_op_constant(Op_constant instruction,
672 std::size_t instruction_start_index)
673 {
674 switch(stage)
675 {
676 case Stage::calculate_types:
677 {
678 auto &state = get_id_state(instruction.result);
679 if(!state.decorations.empty())
680 throw Parser_error(instruction_start_index,
681 instruction_start_index,
682 "decorations on instruction not implemented: "
683 + std::string(get_enumerant_name(instruction.get_operation())));
684 auto type = get_type(instruction.result_type, instruction_start_index);
685 if(auto *simple_type = dynamic_cast<Simple_type_descriptor *>(type.get()))
686 {
687 auto llvm_type = simple_type->get_or_make_type();
688 switch(::LLVMGetTypeKind(llvm_type.type))
689 {
690 case LLVMFloatTypeKind:
691 {
692 if(instruction.value.size() != 1)
693 throw Parser_error(instruction_start_index,
694 instruction_start_index,
695 "OpConstant immediate value is wrong size for type float32");
696 state.constant = std::make_shared<Simple_constant_descriptor>(
697 type,
698 ::LLVMConstBitCast(
699 ::LLVMConstInt(
700 ::LLVMInt32TypeInContext(context), instruction.value[0], false),
701 llvm_type.type));
702 break;
703 }
704 case LLVMIntegerTypeKind:
705 {
706 switch(::LLVMGetIntTypeWidth(llvm_type.type))
707 {
708 case 16:
709 {
710 if(instruction.value.size() != 1)
711 throw Parser_error(
712 instruction_start_index,
713 instruction_start_index,
714 "OpConstant immediate value is wrong size for type int16");
715 state.constant = std::make_shared<Simple_constant_descriptor>(
716 type, ::LLVMConstInt(llvm_type.type, instruction.value[0], false));
717 break;
718 }
719 case 32:
720 {
721 if(instruction.value.size() != 1)
722 throw Parser_error(
723 instruction_start_index,
724 instruction_start_index,
725 "OpConstant immediate value is wrong size for type int32");
726 state.constant = std::make_shared<Simple_constant_descriptor>(
727 type, ::LLVMConstInt(llvm_type.type, instruction.value[0], false));
728 break;
729 }
730 case 64:
731 {
732 if(instruction.value.size() != 2)
733 throw Parser_error(
734 instruction_start_index,
735 instruction_start_index,
736 "OpConstant immediate value is wrong size for type int64");
737 state.constant = std::make_shared<Simple_constant_descriptor>(
738 type,
739 ::LLVMConstInt(llvm_type.type,
740 (static_cast<std::uint64_t>(instruction.value[1]) << 32)
741 | instruction.value[0],
742 false));
743 break;
744 }
745 case 1: // bool
746 default:
747 throw Parser_error(
748 instruction_start_index,
749 instruction_start_index,
750 "unimplemented simple type for OpConstant: "
751 + std::string(llvm_wrapper::print_type_to_string(llvm_type.type)));
752 }
753 break;
754 }
755 case LLVMDoubleTypeKind:
756 {
757 if(instruction.value.size() != 2)
758 throw Parser_error(instruction_start_index,
759 instruction_start_index,
760 "OpConstant immediate value is wrong size for type float64");
761 state.constant = std::make_shared<Simple_constant_descriptor>(
762 type,
763 ::LLVMConstBitCast(
764 ::LLVMConstInt(::LLVMInt64TypeInContext(context),
765 (static_cast<std::uint64_t>(instruction.value[1]) << 32)
766 | instruction.value[0],
767 false),
768 llvm_type.type));
769 break;
770 }
771 case LLVMHalfTypeKind:
772 {
773 if(instruction.value.size() != 1)
774 throw Parser_error(instruction_start_index,
775 instruction_start_index,
776 "OpConstant immediate value is wrong size for type float16");
777 state.constant = std::make_shared<Simple_constant_descriptor>(
778 type,
779 ::LLVMConstBitCast(
780 ::LLVMConstInt(
781 ::LLVMInt16TypeInContext(context), instruction.value[0], false),
782 llvm_type.type));
783 break;
784 }
785 default:
786 {
787 throw Parser_error(
788 instruction_start_index,
789 instruction_start_index,
790 "unimplemented simple type for OpConstant: "
791 + std::string(llvm_wrapper::print_type_to_string(llvm_type.type)));
792 }
793 }
794 }
795 else
796 {
797 throw Parser_error(instruction_start_index,
798 instruction_start_index,
799 "unimplemented type for OpConstant");
800 }
801 break;
802 }
803 case Stage::generate_code:
804 {
805 auto &state = get_id_state(instruction.result);
806 state.value = Value(state.constant->get_or_make_value(),
807 get_type(instruction.result_type, instruction_start_index));
808 break;
809 }
810 }
811 }
812
813 void Spirv_to_llvm::handle_instruction_op_constant_composite(Op_constant_composite instruction,
814 std::size_t instruction_start_index)
815 {
816 switch(stage)
817 {
818 case Stage::calculate_types:
819 {
820 auto &state = get_id_state(instruction.result);
821 if(!state.decorations.empty())
822 throw Parser_error(instruction_start_index,
823 instruction_start_index,
824 "decorations on instruction not implemented: "
825 + std::string(get_enumerant_name(instruction.get_operation())));
826 auto type = get_type(instruction.result_type, instruction_start_index);
827 if(auto *vector_type = dynamic_cast<Vector_type_descriptor *>(type.get()))
828 {
829 if(instruction.constituents.size() != vector_type->get_element_count())
830 throw Parser_error(instruction_start_index,
831 instruction_start_index,
832 "wrong number of constituents for type");
833 std::vector<::LLVMValueRef> constituents;
834 constituents.reserve(instruction.constituents.size());
835 for(Id_ref constituent : instruction.constituents)
836 {
837 auto &constituent_state = get_id_state(constituent);
838 if(!constituent_state.constant)
839 throw Parser_error(instruction_start_index,
840 instruction_start_index,
841 "constituent must be a constant or OpUndef");
842 constituents.push_back(constituent_state.constant->get_or_make_value());
843 }
844 state.constant = std::make_shared<Simple_constant_descriptor>(
845 type, ::LLVMConstVector(constituents.data(), constituents.size()));
846 break;
847 }
848 else if(auto *array_type = dynamic_cast<Array_type_descriptor *>(type.get()))
849 {
850 if(instruction.constituents.size() != array_type->get_element_count())
851 throw Parser_error(instruction_start_index,
852 instruction_start_index,
853 "wrong number of constituents for type");
854 std::vector<::LLVMValueRef> constituents;
855 constituents.reserve(instruction.constituents.size());
856 for(Id_ref constituent : instruction.constituents)
857 {
858 auto &constituent_state = get_id_state(constituent);
859 if(!constituent_state.constant)
860 throw Parser_error(instruction_start_index,
861 instruction_start_index,
862 "constituent must be a constant or OpUndef");
863 constituents.push_back(constituent_state.constant->get_or_make_value());
864 }
865 state.constant = std::make_shared<Simple_constant_descriptor>(
866 type,
867 ::LLVMConstArray(array_type->get_element_type()->get_or_make_type().type,
868 constituents.data(),
869 constituents.size()));
870 break;
871 }
872 else
873 {
874 throw Parser_error(instruction_start_index,
875 instruction_start_index,
876 "unimplemented type for OpConstantComposite");
877 }
878 break;
879 }
880 case Stage::generate_code:
881 {
882 auto type = get_type(instruction.result_type, instruction_start_index);
883 auto llvm_type = type->get_or_make_type();
884 auto &state = get_id_state(instruction.result);
885 auto global = ::LLVMAddGlobal(module.get(), llvm_type.type, "");
886 ::LLVMSetAlignment(global, llvm_type.alignment);
887 ::LLVMSetGlobalConstant(global, true);
888 ::LLVMSetInitializer(global, state.constant->get_or_make_value());
889 ::LLVMSetLinkage(global, ::LLVMInternalLinkage);
890 ::LLVMSetUnnamedAddr(global, true);
891 assert(!current_function_id);
892 auto set_value_fn = [this, &state, global, type, llvm_type]()
893 {
894 auto load = ::LLVMBuildLoad(builder.get(), global, "");
895 ::LLVMSetAlignment(load, llvm_type.alignment);
896 state.value = Value(load, type);
897 };
898 function_entry_block_handlers.push_back(set_value_fn);
899 break;
900 }
901 }
902 }
903
904 void Spirv_to_llvm::handle_instruction_op_constant_sampler(Op_constant_sampler instruction,
905 std::size_t instruction_start_index)
906 {
907 #warning finish
908 throw Parser_error(instruction_start_index,
909 instruction_start_index,
910 "instruction not implemented: "
911 + std::string(get_enumerant_name(instruction.get_operation())));
912 }
913
914 void Spirv_to_llvm::handle_instruction_op_constant_null(Op_constant_null instruction,
915 std::size_t instruction_start_index)
916 {
917 #warning finish
918 throw Parser_error(instruction_start_index,
919 instruction_start_index,
920 "instruction not implemented: "
921 + std::string(get_enumerant_name(instruction.get_operation())));
922 }
923
924 void Spirv_to_llvm::handle_instruction_op_spec_constant_true(Op_spec_constant_true instruction,
925 std::size_t instruction_start_index)
926 {
927 #warning finish
928 throw Parser_error(instruction_start_index,
929 instruction_start_index,
930 "instruction not implemented: "
931 + std::string(get_enumerant_name(instruction.get_operation())));
932 }
933
934 void Spirv_to_llvm::handle_instruction_op_spec_constant_false(Op_spec_constant_false instruction,
935 std::size_t instruction_start_index)
936 {
937 #warning finish
938 throw Parser_error(instruction_start_index,
939 instruction_start_index,
940 "instruction not implemented: "
941 + std::string(get_enumerant_name(instruction.get_operation())));
942 }
943
944 void Spirv_to_llvm::handle_instruction_op_spec_constant(Op_spec_constant instruction,
945 std::size_t instruction_start_index)
946 {
947 #warning finish
948 throw Parser_error(instruction_start_index,
949 instruction_start_index,
950 "instruction not implemented: "
951 + std::string(get_enumerant_name(instruction.get_operation())));
952 }
953
954 void Spirv_to_llvm::handle_instruction_op_spec_constant_composite(
955 Op_spec_constant_composite instruction, std::size_t instruction_start_index)
956 {
957 #warning finish
958 throw Parser_error(instruction_start_index,
959 instruction_start_index,
960 "instruction not implemented: "
961 + std::string(get_enumerant_name(instruction.get_operation())));
962 }
963
964 void Spirv_to_llvm::handle_instruction_op_spec_constant_op(Op_spec_constant_op instruction,
965 std::size_t instruction_start_index)
966 {
967 #warning finish
968 throw Parser_error(instruction_start_index,
969 instruction_start_index,
970 "instruction not implemented: "
971 + std::string(get_enumerant_name(instruction.get_operation())));
972 }
973
974 void Spirv_to_llvm::handle_instruction_op_function(Op_function instruction,
975 std::size_t instruction_start_index)
976 {
977 if(current_function_id)
978 throw Parser_error(instruction_start_index,
979 instruction_start_index,
980 "missing OpFunctionEnd before starting a new function");
981 current_function_id = instruction.result;
982 switch(stage)
983 {
984 case Stage::calculate_types:
985 break;
986 case Stage::generate_code:
987 {
988 auto &state = get_id_state(current_function_id);
989 if(!state.decorations.empty())
990 throw Parser_error(instruction_start_index,
991 instruction_start_index,
992 "decorations on instruction not implemented: "
993 + std::string(get_enumerant_name(instruction.get_operation())));
994 auto function_type =
995 get_type<Function_type_descriptor>(instruction.function_type, instruction_start_index);
996 auto function_name = get_name(current_function_id);
997 if(function_name.empty() && state.op_entry_points.size() == 1)
998 function_name = std::string(state.op_entry_points[0].entry_point.name);
999 if(!state.op_entry_points.empty() && !function_type->is_valid_for_entry_point())
1000 throw Parser_error(instruction_start_index,
1001 instruction_start_index,
1002 "invalid function type for entry point");
1003 function_name = get_or_make_prefixed_name(std::move(function_name), false);
1004 auto function = ::LLVMAddFunction(
1005 module.get(), function_name.c_str(), function_type->get_or_make_type().type);
1006 llvm_wrapper::Module::set_function_target_machine(function, target_machine);
1007 ::LLVMSetLinkage(function, ::LLVMInternalLinkage);
1008 state.function = Function_state(function_type, function, std::move(function_name));
1009 break;
1010 }
1011 }
1012 }
1013
1014 void Spirv_to_llvm::handle_instruction_op_function_parameter(Op_function_parameter instruction,
1015 std::size_t instruction_start_index)
1016 {
1017 #warning finish
1018 throw Parser_error(instruction_start_index,
1019 instruction_start_index,
1020 "instruction not implemented: "
1021 + std::string(get_enumerant_name(instruction.get_operation())));
1022 }
1023
1024 void Spirv_to_llvm::handle_instruction_op_function_end([[gnu::unused]] Op_function_end instruction,
1025 std::size_t instruction_start_index)
1026 {
1027 if(!current_function_id)
1028 throw Parser_error(instruction_start_index,
1029 instruction_start_index,
1030 "OpFunctionEnd without matching OpFunction");
1031 current_function_id = 0;
1032 switch(stage)
1033 {
1034 case Stage::calculate_types:
1035 break;
1036 case Stage::generate_code:
1037 break;
1038 }
1039 }
1040
1041 void Spirv_to_llvm::handle_instruction_op_function_call(Op_function_call instruction,
1042 std::size_t instruction_start_index)
1043 {
1044 #warning finish
1045 throw Parser_error(instruction_start_index,
1046 instruction_start_index,
1047 "instruction not implemented: "
1048 + std::string(get_enumerant_name(instruction.get_operation())));
1049 }
1050
1051 void Spirv_to_llvm::handle_instruction_op_variable(Op_variable instruction,
1052 std::size_t instruction_start_index)
1053 {
1054 switch(stage)
1055 {
1056 case Stage::calculate_types:
1057 {
1058 auto &state = get_id_state(instruction.result);
1059 bool check_decorations = true;
1060 [&]()
1061 {
1062 switch(instruction.storage_class)
1063 {
1064 case Storage_class::uniform_constant:
1065 #warning finish implementing Storage_class::uniform_constant
1066 break;
1067 case Storage_class::input:
1068 {
1069 if(instruction.initializer)
1070 throw Parser_error(instruction_start_index,
1071 instruction_start_index,
1072 "shader input variable initializers are not implemented");
1073 auto type = get_type<Pointer_type_descriptor>(instruction.result_type,
1074 instruction_start_index)
1075 ->get_base_type();
1076 state.variable =
1077 Input_variable_state{type,
1078 inputs_struct->add_member(Struct_type_descriptor::Member(
1079 state.decorations, type))};
1080 check_decorations = false;
1081 return;
1082 }
1083 case Storage_class::uniform:
1084 {
1085 if(instruction.initializer)
1086 throw Parser_error(instruction_start_index,
1087 instruction_start_index,
1088 "shader uniform variable initializers are not implemented");
1089 state.variable = Uniform_variable_state{};
1090 return;
1091 }
1092 case Storage_class::output:
1093 {
1094 if(instruction.initializer)
1095 throw Parser_error(instruction_start_index,
1096 instruction_start_index,
1097 "shader output variable initializers are not implemented");
1098 auto type = get_type<Pointer_type_descriptor>(instruction.result_type,
1099 instruction_start_index)
1100 ->get_base_type();
1101 state.variable =
1102 Output_variable_state{type,
1103 outputs_struct->add_member(Struct_type_descriptor::Member(
1104 state.decorations, type))};
1105 check_decorations = false;
1106 return;
1107 }
1108 case Storage_class::workgroup:
1109 #warning finish implementing Storage_class::workgroup
1110 break;
1111 case Storage_class::cross_workgroup:
1112 #warning finish implementing Storage_class::cross_workgroup
1113 break;
1114 case Storage_class::private_:
1115 #warning finish implementing Storage_class::private_
1116 break;
1117 case Storage_class::function:
1118 {
1119 if(!current_function_id)
1120 throw Parser_error(instruction_start_index,
1121 instruction_start_index,
1122 "function-local variable must be inside function");
1123 return;
1124 }
1125 case Storage_class::generic:
1126 #warning finish implementing Storage_class::generic
1127 break;
1128 case Storage_class::push_constant:
1129 #warning finish implementing Storage_class::push_constant
1130 break;
1131 case Storage_class::atomic_counter:
1132 #warning finish implementing Storage_class::atomic_counter
1133 break;
1134 case Storage_class::image:
1135 #warning finish implementing Storage_class::image
1136 break;
1137 case Storage_class::storage_buffer:
1138 #warning finish implementing Storage_class::storage_buffer
1139 break;
1140 }
1141 throw Parser_error(instruction_start_index,
1142 instruction_start_index,
1143 "unimplemented OpVariable storage class: "
1144 + std::string(get_enumerant_name(instruction.storage_class)));
1145 }();
1146 if(check_decorations)
1147 {
1148 for(auto &decoration : state.decorations)
1149 {
1150 switch(decoration.value)
1151 {
1152 case Decoration::relaxed_precision:
1153 #warning finish implementing Decoration::relaxed_precision
1154 break;
1155 case Decoration::spec_id:
1156 #warning finish implementing Decoration::spec_id
1157 break;
1158 case Decoration::block:
1159 #warning finish implementing Decoration::block
1160 break;
1161 case Decoration::buffer_block:
1162 #warning finish implementing Decoration::buffer_block
1163 break;
1164 case Decoration::row_major:
1165 #warning finish implementing Decoration::row_major
1166 break;
1167 case Decoration::col_major:
1168 #warning finish implementing Decoration::col_major
1169 break;
1170 case Decoration::array_stride:
1171 #warning finish implementing Decoration::array_stride
1172 break;
1173 case Decoration::matrix_stride:
1174 #warning finish implementing Decoration::matrix_stride
1175 break;
1176 case Decoration::glsl_shared:
1177 #warning finish implementing Decoration::glsl_shared
1178 break;
1179 case Decoration::glsl_packed:
1180 #warning finish implementing Decoration::glsl_packed
1181 break;
1182 case Decoration::c_packed:
1183 #warning finish implementing Decoration::c_packed
1184 break;
1185 case Decoration::built_in:
1186 #warning finish implementing Decoration::built_in
1187 break;
1188 case Decoration::no_perspective:
1189 #warning finish implementing Decoration::no_perspective
1190 break;
1191 case Decoration::flat:
1192 #warning finish implementing Decoration::flat
1193 break;
1194 case Decoration::patch:
1195 #warning finish implementing Decoration::patch
1196 break;
1197 case Decoration::centroid:
1198 #warning finish implementing Decoration::centroid
1199 break;
1200 case Decoration::sample:
1201 #warning finish implementing Decoration::sample
1202 break;
1203 case Decoration::invariant:
1204 #warning finish implementing Decoration::invariant
1205 break;
1206 case Decoration::restrict:
1207 #warning finish implementing Decoration::restrict
1208 break;
1209 case Decoration::aliased:
1210 #warning finish implementing Decoration::aliased
1211 break;
1212 case Decoration::volatile_:
1213 #warning finish implementing Decoration::volatile_
1214 break;
1215 case Decoration::constant:
1216 #warning finish implementing Decoration::constant
1217 break;
1218 case Decoration::coherent:
1219 #warning finish implementing Decoration::coherent
1220 break;
1221 case Decoration::non_writable:
1222 #warning finish implementing Decoration::non_writable
1223 break;
1224 case Decoration::non_readable:
1225 #warning finish implementing Decoration::non_readable
1226 break;
1227 case Decoration::uniform:
1228 #warning finish implementing Decoration::uniform
1229 break;
1230 case Decoration::saturated_conversion:
1231 #warning finish implementing Decoration::saturated_conversion
1232 break;
1233 case Decoration::stream:
1234 #warning finish implementing Decoration::stream
1235 break;
1236 case Decoration::location:
1237 #warning finish implementing Decoration::location
1238 break;
1239 case Decoration::component:
1240 #warning finish implementing Decoration::component
1241 break;
1242 case Decoration::index:
1243 #warning finish implementing Decoration::index
1244 break;
1245 case Decoration::binding:
1246 {
1247 switch(instruction.storage_class)
1248 {
1249 case spirv::Storage_class::uniform:
1250 continue;
1251 #warning finish implementing Decoration::binding
1252 default:
1253 throw Parser_error(
1254 instruction_start_index,
1255 instruction_start_index,
1256 "OpVariable Binding decoration not implemented for storage "
1257 "class: "
1258 + std::string(get_enumerant_name(instruction.storage_class)));
1259 }
1260 }
1261 case Decoration::descriptor_set:
1262 {
1263 switch(instruction.storage_class)
1264 {
1265 case spirv::Storage_class::uniform:
1266 continue;
1267 #warning finish implementing Decoration::descriptor_set
1268 default:
1269 throw Parser_error(
1270 instruction_start_index,
1271 instruction_start_index,
1272 "OpVariable DescriptorSet decoration not implemented for storage "
1273 "class: "
1274 + std::string(get_enumerant_name(instruction.storage_class)));
1275 }
1276 }
1277 case Decoration::offset:
1278 #warning finish implementing Decoration::offset
1279 break;
1280 case Decoration::xfb_buffer:
1281 #warning finish implementing Decoration::xfb_buffer
1282 break;
1283 case Decoration::xfb_stride:
1284 #warning finish implementing Decoration::xfb_stride
1285 break;
1286 case Decoration::func_param_attr:
1287 #warning finish implementing Decoration::func_param_attr
1288 break;
1289 case Decoration::fp_rounding_mode:
1290 #warning finish implementing Decoration::fp_rounding_mode
1291 break;
1292 case Decoration::fp_fast_math_mode:
1293 #warning finish implementing Decoration::fp_fast_math_mode
1294 break;
1295 case Decoration::linkage_attributes:
1296 #warning finish implementing Decoration::linkage_attributes
1297 break;
1298 case Decoration::no_contraction:
1299 #warning finish implementing Decoration::no_contraction
1300 break;
1301 case Decoration::input_attachment_index:
1302 #warning finish implementing Decoration::input_attachment_index
1303 break;
1304 case Decoration::alignment:
1305 #warning finish implementing Decoration::alignment
1306 break;
1307 case Decoration::max_byte_offset:
1308 #warning finish implementing Decoration::max_byte_offset
1309 break;
1310 case Decoration::alignment_id:
1311 #warning finish implementing Decoration::alignment_id
1312 break;
1313 case Decoration::max_byte_offset_id:
1314 #warning finish implementing Decoration::max_byte_offset_id
1315 break;
1316 case Decoration::override_coverage_nv:
1317 #warning finish implementing Decoration::override_coverage_nv
1318 break;
1319 case Decoration::passthrough_nv:
1320 #warning finish implementing Decoration::passthrough_nv
1321 break;
1322 case Decoration::viewport_relative_nv:
1323 #warning finish implementing Decoration::viewport_relative_nv
1324 break;
1325 case Decoration::secondary_viewport_relative_nv:
1326 #warning finish implementing Decoration::secondary_viewport_relative_nv
1327 break;
1328 }
1329 throw Parser_error(instruction_start_index,
1330 instruction_start_index,
1331 "unimplemented decoration on OpVariable: "
1332 + std::string(get_enumerant_name(decoration.value)));
1333 }
1334 }
1335 break;
1336 }
1337 case Stage::generate_code:
1338 {
1339 auto &state = get_id_state(instruction.result);
1340 auto &entry_point_state = get_entry_point_state();
1341 bool is_part_of_entry_point_interface = false;
1342 for(Id_ref id : entry_point_state.entry_point.interface)
1343 {
1344 if(instruction.result == id)
1345 {
1346 is_part_of_entry_point_interface = true;
1347 break;
1348 }
1349 }
1350 switch(instruction.storage_class)
1351 {
1352 case Storage_class::uniform_constant:
1353 #warning finish implementing Storage_class::uniform_constant
1354 break;
1355 case Storage_class::input:
1356 {
1357 if(instruction.initializer)
1358 throw Parser_error(instruction_start_index,
1359 instruction_start_index,
1360 "shader input variable initializers are not implemented");
1361 if(!is_part_of_entry_point_interface)
1362 {
1363 auto type = get_type(instruction.result_type, instruction_start_index);
1364 state.value = Value(::LLVMGetUndef(type->get_or_make_type().type), type);
1365 return;
1366 }
1367 auto set_value_fn = [this, instruction, &state, instruction_start_index]()
1368 {
1369 auto &variable = util::get<Input_variable_state>(state.variable);
1370 state.value = Value(
1371 ::LLVMBuildStructGEP(
1372 builder.get(),
1373 get_id_state(current_function_id).function->entry_block->inputs_struct,
1374 inputs_struct->get_members(true)[variable.member_index].llvm_member_index,
1375 get_name(instruction.result).c_str()),
1376 get_type(instruction.result_type, instruction_start_index));
1377 };
1378 if(current_function_id)
1379 set_value_fn();
1380 else
1381 function_entry_block_handlers.push_back(set_value_fn);
1382 return;
1383 }
1384 case Storage_class::uniform:
1385 #warning finish implementing Storage_class::uniform
1386 break;
1387 case Storage_class::output:
1388 {
1389 if(instruction.initializer)
1390 throw Parser_error(instruction_start_index,
1391 instruction_start_index,
1392 "shader output variable initializers are not implemented");
1393 if(!is_part_of_entry_point_interface)
1394 {
1395 auto type = get_type(instruction.result_type, instruction_start_index);
1396 state.value = Value(::LLVMGetUndef(type->get_or_make_type().type), type);
1397 return;
1398 }
1399 auto set_value_fn = [this, instruction, &state, instruction_start_index]()
1400 {
1401 auto &variable = util::get<Output_variable_state>(state.variable);
1402 state.value = Value(
1403 ::LLVMBuildStructGEP(
1404 builder.get(),
1405 get_id_state(current_function_id).function->entry_block->outputs_struct,
1406 outputs_struct->get_members(true)[variable.member_index].llvm_member_index,
1407 get_name(instruction.result).c_str()),
1408 get_type(instruction.result_type, instruction_start_index));
1409 };
1410 if(current_function_id)
1411 set_value_fn();
1412 else
1413 function_entry_block_handlers.push_back(set_value_fn);
1414 return;
1415 }
1416 case Storage_class::workgroup:
1417 #warning finish implementing Storage_class::workgroup
1418 break;
1419 case Storage_class::cross_workgroup:
1420 #warning finish implementing Storage_class::cross_workgroup
1421 break;
1422 case Storage_class::private_:
1423 #warning finish implementing Storage_class::private_
1424 break;
1425 case Storage_class::function:
1426 {
1427 if(!current_function_id)
1428 throw Parser_error(instruction_start_index,
1429 instruction_start_index,
1430 "function-local variable must be inside function");
1431 auto &function = get_id_state(current_function_id).function.value();
1432 if(!function.entry_block
1433 || function.entry_block->entry_block != get_or_make_label(current_basic_block_id))
1434 throw Parser_error(instruction_start_index,
1435 instruction_start_index,
1436 "function-local variable must be inside initial basic block");
1437 auto type =
1438 get_type<Pointer_type_descriptor>(instruction.result_type, instruction_start_index);
1439 state.value = Value(::LLVMBuildAlloca(builder.get(),
1440 type->get_base_type()->get_or_make_type().type,
1441 get_name(instruction.result).c_str()),
1442 type);
1443 ::LLVMSetAlignment(state.value->value,
1444 type->get_base_type()->get_or_make_type().alignment);
1445 return;
1446 }
1447 case Storage_class::generic:
1448 #warning finish implementing Storage_class::generic
1449 break;
1450 case Storage_class::push_constant:
1451 #warning finish implementing Storage_class::push_constant
1452 break;
1453 case Storage_class::atomic_counter:
1454 #warning finish implementing Storage_class::atomic_counter
1455 break;
1456 case Storage_class::image:
1457 #warning finish implementing Storage_class::image
1458 break;
1459 case Storage_class::storage_buffer:
1460 #warning finish implementing Storage_class::storage_buffer
1461 break;
1462 }
1463 break;
1464 }
1465 }
1466 }
1467
1468 void Spirv_to_llvm::handle_instruction_op_image_texel_pointer(Op_image_texel_pointer instruction,
1469 std::size_t instruction_start_index)
1470 {
1471 #warning finish
1472 throw Parser_error(instruction_start_index,
1473 instruction_start_index,
1474 "instruction not implemented: "
1475 + std::string(get_enumerant_name(instruction.get_operation())));
1476 }
1477
1478 void Spirv_to_llvm::handle_instruction_op_load(Op_load instruction,
1479 std::size_t instruction_start_index)
1480 {
1481 switch(stage)
1482 {
1483 case Stage::calculate_types:
1484 break;
1485 case Stage::generate_code:
1486 {
1487 auto &state = get_id_state(instruction.result);
1488 if(!state.decorations.empty())
1489 throw Parser_error(instruction_start_index,
1490 instruction_start_index,
1491 "decorations on instruction not implemented: "
1492 + std::string(get_enumerant_name(instruction.get_operation())));
1493 auto memory_access = instruction.memory_access.value_or(
1494 Memory_access_with_parameters(Memory_access::none, {}));
1495 if((memory_access.value & Memory_access::volatile_) == Memory_access::volatile_)
1496 throw Parser_error(instruction_start_index,
1497 instruction_start_index,
1498 "OpLoad volatile not implemented");
1499 if((memory_access.value & Memory_access::aligned) == Memory_access::aligned)
1500 throw Parser_error(instruction_start_index,
1501 instruction_start_index,
1502 "OpLoad alignment not implemented");
1503 if((memory_access.value & Memory_access::nontemporal) == Memory_access::nontemporal)
1504 throw Parser_error(instruction_start_index,
1505 instruction_start_index,
1506 "OpLoad nontemporal not implemented");
1507 auto result_type = get_type(instruction.result_type, instruction_start_index);
1508 auto &pointer_value = get_id_state(instruction.pointer).value.value();
1509 assert(dynamic_cast<Pointer_type_descriptor *>(pointer_value.type.get()));
1510 auto pointer_type = std::static_pointer_cast<Pointer_type_descriptor>(pointer_value.type);
1511 auto memory_type = pointer_type->get_base_type();
1512 switch(memory_type->get_load_store_implementation_kind())
1513 {
1514 case Type_descriptor::Load_store_implementation_kind::Simple:
1515 state.value =
1516 Value(::LLVMBuildLoad(builder.get(),
1517 get_id_state(instruction.pointer).value.value().value,
1518 get_name(instruction.result).c_str()),
1519 result_type);
1520 ::LLVMSetAlignment(state.value->value, memory_type->get_or_make_type().alignment);
1521 break;
1522 case Type_descriptor::Load_store_implementation_kind::Transpose_matrix:
1523 {
1524 auto untransposed_value = ::LLVMBuildLoad(
1525 builder.get(), get_id_state(instruction.pointer).value.value().value, "");
1526 ::LLVMSetAlignment(untransposed_value, memory_type->get_or_make_type().alignment);
1527 state.value = Value(matrix_operations::transpose(context,
1528 builder.get(),
1529 untransposed_value,
1530 get_name(instruction.result).c_str()),
1531 result_type);
1532 break;
1533 }
1534 }
1535 break;
1536 }
1537 }
1538 }
1539
1540 void Spirv_to_llvm::handle_instruction_op_store(Op_store instruction,
1541 std::size_t instruction_start_index)
1542 {
1543 switch(stage)
1544 {
1545 case Stage::calculate_types:
1546 break;
1547 case Stage::generate_code:
1548 {
1549 auto memory_access = instruction.memory_access.value_or(
1550 Memory_access_with_parameters(Memory_access::none, {}));
1551 if((memory_access.value & Memory_access::volatile_) == Memory_access::volatile_)
1552 throw Parser_error(instruction_start_index,
1553 instruction_start_index,
1554 "OpStore volatile not implemented");
1555 if((memory_access.value & Memory_access::aligned) == Memory_access::aligned)
1556 throw Parser_error(instruction_start_index,
1557 instruction_start_index,
1558 "OpStore alignment not implemented");
1559 if((memory_access.value & Memory_access::nontemporal) == Memory_access::nontemporal)
1560 throw Parser_error(instruction_start_index,
1561 instruction_start_index,
1562 "OpStore nontemporal not implemented");
1563 auto &object_value = get_id_state(instruction.object).value.value();
1564 auto &pointer_value = get_id_state(instruction.pointer).value.value();
1565 assert(dynamic_cast<Pointer_type_descriptor *>(pointer_value.type.get()));
1566 auto pointer_type = std::static_pointer_cast<Pointer_type_descriptor>(pointer_value.type);
1567 auto memory_type = pointer_type->get_base_type();
1568 switch(memory_type->get_load_store_implementation_kind())
1569 {
1570 case Type_descriptor::Load_store_implementation_kind::Simple:
1571 ::LLVMSetAlignment(
1572 ::LLVMBuildStore(builder.get(), object_value.value, pointer_value.value),
1573 memory_type->get_or_make_type().alignment);
1574 break;
1575 case Type_descriptor::Load_store_implementation_kind::Transpose_matrix:
1576 {
1577 auto transposed_value = matrix_operations::transpose(context,
1578 builder.get(),
1579 object_value.value,
1580 "");
1581 ::LLVMSetAlignment(
1582 ::LLVMBuildStore(builder.get(), transposed_value, pointer_value.value),
1583 memory_type->get_or_make_type().alignment);
1584 break;
1585 }
1586 }
1587 break;
1588 }
1589 }
1590 }
1591
1592 void Spirv_to_llvm::handle_instruction_op_copy_memory(Op_copy_memory instruction,
1593 std::size_t instruction_start_index)
1594 {
1595 #warning finish
1596 throw Parser_error(instruction_start_index,
1597 instruction_start_index,
1598 "instruction not implemented: "
1599 + std::string(get_enumerant_name(instruction.get_operation())));
1600 }
1601
1602 void Spirv_to_llvm::handle_instruction_op_copy_memory_sized(Op_copy_memory_sized instruction,
1603 std::size_t instruction_start_index)
1604 {
1605 #warning finish
1606 throw Parser_error(instruction_start_index,
1607 instruction_start_index,
1608 "instruction not implemented: "
1609 + std::string(get_enumerant_name(instruction.get_operation())));
1610 }
1611
1612 void Spirv_to_llvm::handle_instruction_op_access_chain(Op_access_chain instruction,
1613 std::size_t instruction_start_index)
1614 {
1615 switch(stage)
1616 {
1617 case Stage::calculate_types:
1618 break;
1619 case Stage::generate_code:
1620 {
1621 auto &state = get_id_state(instruction.result);
1622 if(!state.decorations.empty())
1623 throw Parser_error(instruction_start_index,
1624 instruction_start_index,
1625 "decorations on instruction not implemented: "
1626 + std::string(get_enumerant_name(instruction.get_operation())));
1627 auto base = get_id_state(instruction.base).value.value();
1628 std::string name = get_name(instruction.result);
1629 std::vector<::LLVMValueRef> llvm_indexes;
1630 llvm_indexes.reserve(instruction.indexes.size() + 1);
1631 auto *base_pointer_type = dynamic_cast<const Pointer_type_descriptor *>(base.type.get());
1632 if(!base_pointer_type)
1633 throw Parser_error(instruction_start_index,
1634 instruction_start_index,
1635 "base type is not a pointer for OpAccessChain");
1636 llvm_indexes.push_back(::LLVMConstInt(::LLVMInt32TypeInContext(context), 0, false));
1637 auto current_type = base_pointer_type->get_base_type();
1638 for(std::size_t i = 0; i < instruction.indexes.size(); i++)
1639 {
1640 Id index = instruction.indexes[i];
1641 struct Visitor
1642 {
1643 std::size_t instruction_start_index;
1644 std::shared_ptr<Type_descriptor> &current_type;
1645 std::vector<::LLVMValueRef> &llvm_indexes;
1646 Id index;
1647 Spirv_to_llvm *this_;
1648 void operator()(Simple_type_descriptor &)
1649 {
1650 throw Parser_error(instruction_start_index,
1651 instruction_start_index,
1652 "invalid composite type for OpAccessChain");
1653 }
1654 void operator()(Vector_type_descriptor &type)
1655 {
1656 auto &index_value = this_->get_id_state(index).value.value();
1657 llvm_indexes.push_back(index_value.value);
1658 current_type = type.get_element_type();
1659 }
1660 void operator()(Matrix_type_descriptor &)
1661 {
1662 #warning finish
1663 throw Parser_error(instruction_start_index,
1664 instruction_start_index,
1665 "unimplemented composite type for OpAccessChain");
1666 }
1667 void operator()(Row_major_matrix_type_descriptor &)
1668 {
1669 #warning finish
1670 throw Parser_error(instruction_start_index,
1671 instruction_start_index,
1672 "unimplemented composite type for OpAccessChain");
1673 }
1674 void operator()(Array_type_descriptor &type)
1675 {
1676 auto &index_value = this_->get_id_state(index).value.value();
1677 llvm_indexes.push_back(index_value.value);
1678 current_type = type.get_element_type();
1679 }
1680 void operator()(Pointer_type_descriptor &)
1681 {
1682 throw Parser_error(instruction_start_index,
1683 instruction_start_index,
1684 "invalid composite type for OpAccessChain");
1685 }
1686 void operator()(Function_type_descriptor &)
1687 {
1688 throw Parser_error(instruction_start_index,
1689 instruction_start_index,
1690 "invalid composite type for OpAccessChain");
1691 }
1692 void operator()(Struct_type_descriptor &type)
1693 {
1694 auto index_value = ::LLVMConstIntGetZExtValue(
1695 this_->get_id_state(index).constant->get_or_make_value());
1696 auto &members = type.get_members(true);
1697 if(index_value >= members.size())
1698 throw Parser_error(instruction_start_index,
1699 instruction_start_index,
1700 "index out of range in OpAccessChain");
1701 llvm_indexes.push_back(::LLVMConstInt(::LLVMInt32TypeInContext(this_->context),
1702 members[index_value].llvm_member_index,
1703 false));
1704 current_type = members[index_value].type;
1705 }
1706 };
1707 auto *type = current_type.get();
1708 type->visit(Visitor{instruction_start_index, current_type, llvm_indexes, index, this});
1709 }
1710 state.value = Value(
1711 ::LLVMBuildGEP(
1712 builder.get(), base.value, llvm_indexes.data(), llvm_indexes.size(), name.c_str()),
1713 get_type(instruction.result_type, instruction_start_index));
1714 break;
1715 }
1716 }
1717 }
1718
1719 void Spirv_to_llvm::handle_instruction_op_in_bounds_access_chain(
1720 Op_in_bounds_access_chain instruction, std::size_t instruction_start_index)
1721 {
1722 #warning finish
1723 throw Parser_error(instruction_start_index,
1724 instruction_start_index,
1725 "instruction not implemented: "
1726 + std::string(get_enumerant_name(instruction.get_operation())));
1727 }
1728
1729 void Spirv_to_llvm::handle_instruction_op_ptr_access_chain(Op_ptr_access_chain instruction,
1730 std::size_t instruction_start_index)
1731 {
1732 #warning finish
1733 throw Parser_error(instruction_start_index,
1734 instruction_start_index,
1735 "instruction not implemented: "
1736 + std::string(get_enumerant_name(instruction.get_operation())));
1737 }
1738
1739 void Spirv_to_llvm::handle_instruction_op_array_length(Op_array_length instruction,
1740 std::size_t instruction_start_index)
1741 {
1742 #warning finish
1743 throw Parser_error(instruction_start_index,
1744 instruction_start_index,
1745 "instruction not implemented: "
1746 + std::string(get_enumerant_name(instruction.get_operation())));
1747 }
1748
1749 void Spirv_to_llvm::handle_instruction_op_generic_ptr_mem_semantics(
1750 Op_generic_ptr_mem_semantics instruction, std::size_t instruction_start_index)
1751 {
1752 #warning finish
1753 throw Parser_error(instruction_start_index,
1754 instruction_start_index,
1755 "instruction not implemented: "
1756 + std::string(get_enumerant_name(instruction.get_operation())));
1757 }
1758
1759 void Spirv_to_llvm::handle_instruction_op_in_bounds_ptr_access_chain(
1760 Op_in_bounds_ptr_access_chain instruction, std::size_t instruction_start_index)
1761 {
1762 #warning finish
1763 throw Parser_error(instruction_start_index,
1764 instruction_start_index,
1765 "instruction not implemented: "
1766 + std::string(get_enumerant_name(instruction.get_operation())));
1767 }
1768
1769 void Spirv_to_llvm::handle_instruction_op_decorate(
1770 Op_decorate instruction, [[gnu::unused]] std::size_t instruction_start_index)
1771 {
1772 if(stage == util::Enum_traits<Stage>::values[0])
1773 get_id_state(instruction.target).decorations.push_back(std::move(instruction.decoration));
1774 }
1775
1776 void Spirv_to_llvm::handle_instruction_op_member_decorate(
1777 Op_member_decorate instruction, [[gnu::unused]] std::size_t instruction_start_index)
1778 {
1779 if(stage == util::Enum_traits<Stage>::values[0])
1780 get_id_state(instruction.structure_type)
1781 .member_decorations.push_back(std::move(instruction));
1782 }
1783
1784 void Spirv_to_llvm::handle_instruction_op_decoration_group(Op_decoration_group instruction,
1785 std::size_t instruction_start_index)
1786 {
1787 #warning finish
1788 throw Parser_error(instruction_start_index,
1789 instruction_start_index,
1790 "instruction not implemented: "
1791 + std::string(get_enumerant_name(instruction.get_operation())));
1792 }
1793
1794 void Spirv_to_llvm::handle_instruction_op_group_decorate(Op_group_decorate instruction,
1795 std::size_t instruction_start_index)
1796 {
1797 #warning finish
1798 throw Parser_error(instruction_start_index,
1799 instruction_start_index,
1800 "instruction not implemented: "
1801 + std::string(get_enumerant_name(instruction.get_operation())));
1802 }
1803
1804 void Spirv_to_llvm::handle_instruction_op_group_member_decorate(
1805 Op_group_member_decorate instruction, std::size_t instruction_start_index)
1806 {
1807 #warning finish
1808 throw Parser_error(instruction_start_index,
1809 instruction_start_index,
1810 "instruction not implemented: "
1811 + std::string(get_enumerant_name(instruction.get_operation())));
1812 }
1813
1814 void Spirv_to_llvm::handle_instruction_op_vector_extract_dynamic(
1815 Op_vector_extract_dynamic instruction, std::size_t instruction_start_index)
1816 {
1817 #warning finish
1818 throw Parser_error(instruction_start_index,
1819 instruction_start_index,
1820 "instruction not implemented: "
1821 + std::string(get_enumerant_name(instruction.get_operation())));
1822 }
1823
1824 void Spirv_to_llvm::handle_instruction_op_vector_insert_dynamic(
1825 Op_vector_insert_dynamic instruction, std::size_t instruction_start_index)
1826 {
1827 #warning finish
1828 throw Parser_error(instruction_start_index,
1829 instruction_start_index,
1830 "instruction not implemented: "
1831 + std::string(get_enumerant_name(instruction.get_operation())));
1832 }
1833
1834 void Spirv_to_llvm::handle_instruction_op_vector_shuffle(Op_vector_shuffle instruction,
1835 std::size_t instruction_start_index)
1836 {
1837 #warning finish
1838 throw Parser_error(instruction_start_index,
1839 instruction_start_index,
1840 "instruction not implemented: "
1841 + std::string(get_enumerant_name(instruction.get_operation())));
1842 }
1843
1844 void Spirv_to_llvm::handle_instruction_op_composite_construct(Op_composite_construct instruction,
1845 std::size_t instruction_start_index)
1846 {
1847 switch(stage)
1848 {
1849 case Stage::calculate_types:
1850 break;
1851 case Stage::generate_code:
1852 {
1853 auto &state = get_id_state(instruction.result);
1854 if(!state.decorations.empty())
1855 throw Parser_error(instruction_start_index,
1856 instruction_start_index,
1857 "decorations on instruction not implemented: "
1858 + std::string(get_enumerant_name(instruction.get_operation())));
1859 auto result_type = get_type(instruction.result_type, instruction_start_index);
1860 ::LLVMValueRef result_value = nullptr;
1861 std::string name = get_name(instruction.result);
1862 struct Visitor
1863 {
1864 Op_composite_construct &instruction;
1865 std::size_t instruction_start_index;
1866 Id_state &state;
1867 ::LLVMValueRef &result_value;
1868 std::string &name;
1869 Spirv_to_llvm *this_;
1870 void operator()(Simple_type_descriptor &)
1871 {
1872 throw Parser_error(instruction_start_index,
1873 instruction_start_index,
1874 "invalid result type for OpCompositeConstruct");
1875 }
1876 void operator()(Vector_type_descriptor &type)
1877 {
1878 if(instruction.constituents.size() < 2)
1879 throw Parser_error(instruction_start_index,
1880 instruction_start_index,
1881 "too few inputs to construct a vector");
1882 result_value = ::LLVMGetUndef(type.get_or_make_type().type);
1883 std::uint32_t insert_index = 0;
1884 auto insert_element = [&](::LLVMValueRef element)
1885 {
1886 if(insert_index >= type.get_element_count())
1887 throw Parser_error(
1888 instruction_start_index,
1889 instruction_start_index,
1890 "too many input vector elements to fit in output vector");
1891 result_value = ::LLVMBuildInsertElement(
1892 this_->builder.get(),
1893 result_value,
1894 element,
1895 ::LLVMConstInt(
1896 ::LLVMInt32TypeInContext(this_->context), insert_index, false),
1897 insert_index + 1 == type.get_element_count() ? name.c_str() : "");
1898 insert_index++;
1899 };
1900 for(Id input : instruction.constituents)
1901 {
1902 auto &value = this_->get_id_state(input).value.value();
1903 if(auto *vector_type = dynamic_cast<Vector_type_descriptor *>(value.type.get()))
1904 {
1905 for(std::uint32_t i = 0; i < vector_type->get_element_count(); i++)
1906 {
1907 insert_element(::LLVMBuildExtractElement(
1908 this_->builder.get(),
1909 value.value,
1910 ::LLVMConstInt(
1911 ::LLVMInt32TypeInContext(this_->context), insert_index, false),
1912 ""));
1913 }
1914 }
1915 else
1916 {
1917 insert_element(value.value);
1918 }
1919 }
1920 if(insert_index < type.get_element_count())
1921 throw Parser_error(instruction_start_index,
1922 instruction_start_index,
1923 "too few input vector elements to fill output vector");
1924 }
1925 void operator()(Matrix_type_descriptor &)
1926 {
1927 #warning finish
1928 throw Parser_error(instruction_start_index,
1929 instruction_start_index,
1930 "unimplemented result type for OpCompositeConstruct");
1931 }
1932 void operator()(Row_major_matrix_type_descriptor &)
1933 {
1934 #warning finish
1935 throw Parser_error(instruction_start_index,
1936 instruction_start_index,
1937 "unimplemented result type for OpCompositeConstruct");
1938 }
1939 void operator()(Array_type_descriptor &)
1940 {
1941 #warning finish
1942 throw Parser_error(instruction_start_index,
1943 instruction_start_index,
1944 "unimplemented result type for OpCompositeConstruct");
1945 }
1946 void operator()(Pointer_type_descriptor &)
1947 {
1948 throw Parser_error(instruction_start_index,
1949 instruction_start_index,
1950 "invalid result type for OpCompositeConstruct");
1951 }
1952 void operator()(Function_type_descriptor &)
1953 {
1954 throw Parser_error(instruction_start_index,
1955 instruction_start_index,
1956 "invalid result type for OpCompositeConstruct");
1957 }
1958 void operator()(Struct_type_descriptor &)
1959 {
1960 #warning finish
1961 throw Parser_error(instruction_start_index,
1962 instruction_start_index,
1963 "unimplemented result type for OpCompositeConstruct");
1964 }
1965 };
1966 result_type->visit(
1967 Visitor{instruction, instruction_start_index, state, result_value, name, this});
1968 state.value = Value(result_value, std::move(result_type));
1969 break;
1970 }
1971 }
1972 }
1973
1974 void Spirv_to_llvm::handle_instruction_op_composite_extract(Op_composite_extract instruction,
1975 std::size_t instruction_start_index)
1976 {
1977 switch(stage)
1978 {
1979 case Stage::calculate_types:
1980 break;
1981 case Stage::generate_code:
1982 {
1983 auto &state = get_id_state(instruction.result);
1984 if(!state.decorations.empty())
1985 throw Parser_error(instruction_start_index,
1986 instruction_start_index,
1987 "decorations on instruction not implemented: "
1988 + std::string(get_enumerant_name(instruction.get_operation())));
1989 auto result = get_id_state(instruction.composite).value.value();
1990 std::string name = "";
1991 for(std::size_t i = 0; i < instruction.indexes.size(); i++)
1992 {
1993 std::uint32_t index = instruction.indexes[i];
1994 if(i == instruction.indexes.size() - 1)
1995 name = get_name(instruction.result);
1996 struct Visitor
1997 {
1998 std::size_t instruction_start_index;
1999 Id_state &state;
2000 Value &result;
2001 std::string &name;
2002 std::uint32_t index;
2003 ::LLVMContextRef context;
2004 llvm_wrapper::Builder &builder;
2005 void operator()(Simple_type_descriptor &)
2006 {
2007 throw Parser_error(instruction_start_index,
2008 instruction_start_index,
2009 "invalid composite type for OpCompositeExtract");
2010 }
2011 void operator()(Vector_type_descriptor &type)
2012 {
2013 if(index >= type.get_element_count())
2014 throw Parser_error(instruction_start_index,
2015 instruction_start_index,
2016 "index out of range in OpCompositeExtract");
2017 result =
2018 Value(::LLVMBuildExtractElement(
2019 builder.get(),
2020 result.value,
2021 ::LLVMConstInt(::LLVMInt32TypeInContext(context), index, false),
2022 name.c_str()),
2023 type.get_element_type());
2024 }
2025 void operator()(Matrix_type_descriptor &)
2026 {
2027 #warning finish
2028 throw Parser_error(instruction_start_index,
2029 instruction_start_index,
2030 "unimplemented composite type for OpCompositeExtract");
2031 }
2032 void operator()(Row_major_matrix_type_descriptor &)
2033 {
2034 #warning finish
2035 throw Parser_error(instruction_start_index,
2036 instruction_start_index,
2037 "unimplemented composite type for OpCompositeExtract");
2038 }
2039 void operator()(Array_type_descriptor &)
2040 {
2041 #warning finish
2042 throw Parser_error(instruction_start_index,
2043 instruction_start_index,
2044 "unimplemented composite type for OpCompositeExtract");
2045 }
2046 void operator()(Pointer_type_descriptor &)
2047 {
2048 throw Parser_error(instruction_start_index,
2049 instruction_start_index,
2050 "invalid composite type for OpCompositeExtract");
2051 }
2052 void operator()(Function_type_descriptor &)
2053 {
2054 throw Parser_error(instruction_start_index,
2055 instruction_start_index,
2056 "invalid composite type for OpCompositeExtract");
2057 }
2058 void operator()(Struct_type_descriptor &)
2059 {
2060 #warning finish
2061 throw Parser_error(instruction_start_index,
2062 instruction_start_index,
2063 "unimplemented composite type for OpCompositeExtract");
2064 }
2065 };
2066 auto *type = result.type.get();
2067 type->visit(
2068 Visitor{instruction_start_index, state, result, name, index, context, builder});
2069 }
2070 state.value = result;
2071 break;
2072 }
2073 }
2074 }
2075
2076 void Spirv_to_llvm::handle_instruction_op_composite_insert(Op_composite_insert instruction,
2077 std::size_t instruction_start_index)
2078 {
2079 #warning finish
2080 throw Parser_error(instruction_start_index,
2081 instruction_start_index,
2082 "instruction not implemented: "
2083 + std::string(get_enumerant_name(instruction.get_operation())));
2084 }
2085
2086 void Spirv_to_llvm::handle_instruction_op_copy_object(Op_copy_object instruction,
2087 std::size_t instruction_start_index)
2088 {
2089 #warning finish
2090 throw Parser_error(instruction_start_index,
2091 instruction_start_index,
2092 "instruction not implemented: "
2093 + std::string(get_enumerant_name(instruction.get_operation())));
2094 }
2095
2096 void Spirv_to_llvm::handle_instruction_op_transpose(Op_transpose instruction,
2097 std::size_t instruction_start_index)
2098 {
2099 #warning finish
2100 throw Parser_error(instruction_start_index,
2101 instruction_start_index,
2102 "instruction not implemented: "
2103 + std::string(get_enumerant_name(instruction.get_operation())));
2104 }
2105
2106 void Spirv_to_llvm::handle_instruction_op_sampled_image(Op_sampled_image instruction,
2107 std::size_t instruction_start_index)
2108 {
2109 #warning finish
2110 throw Parser_error(instruction_start_index,
2111 instruction_start_index,
2112 "instruction not implemented: "
2113 + std::string(get_enumerant_name(instruction.get_operation())));
2114 }
2115
2116 void Spirv_to_llvm::handle_instruction_op_image_sample_implicit_lod(
2117 Op_image_sample_implicit_lod instruction, std::size_t instruction_start_index)
2118 {
2119 #warning finish
2120 throw Parser_error(instruction_start_index,
2121 instruction_start_index,
2122 "instruction not implemented: "
2123 + std::string(get_enumerant_name(instruction.get_operation())));
2124 }
2125
2126 void Spirv_to_llvm::handle_instruction_op_image_sample_explicit_lod(
2127 Op_image_sample_explicit_lod instruction, std::size_t instruction_start_index)
2128 {
2129 #warning finish
2130 throw Parser_error(instruction_start_index,
2131 instruction_start_index,
2132 "instruction not implemented: "
2133 + std::string(get_enumerant_name(instruction.get_operation())));
2134 }
2135
2136 void Spirv_to_llvm::handle_instruction_op_image_sample_dref_implicit_lod(
2137 Op_image_sample_dref_implicit_lod instruction, std::size_t instruction_start_index)
2138 {
2139 #warning finish
2140 throw Parser_error(instruction_start_index,
2141 instruction_start_index,
2142 "instruction not implemented: "
2143 + std::string(get_enumerant_name(instruction.get_operation())));
2144 }
2145
2146 void Spirv_to_llvm::handle_instruction_op_image_sample_dref_explicit_lod(
2147 Op_image_sample_dref_explicit_lod instruction, std::size_t instruction_start_index)
2148 {
2149 #warning finish
2150 throw Parser_error(instruction_start_index,
2151 instruction_start_index,
2152 "instruction not implemented: "
2153 + std::string(get_enumerant_name(instruction.get_operation())));
2154 }
2155
2156 void Spirv_to_llvm::handle_instruction_op_image_sample_proj_implicit_lod(
2157 Op_image_sample_proj_implicit_lod instruction, std::size_t instruction_start_index)
2158 {
2159 #warning finish
2160 throw Parser_error(instruction_start_index,
2161 instruction_start_index,
2162 "instruction not implemented: "
2163 + std::string(get_enumerant_name(instruction.get_operation())));
2164 }
2165
2166 void Spirv_to_llvm::handle_instruction_op_image_sample_proj_explicit_lod(
2167 Op_image_sample_proj_explicit_lod instruction, std::size_t instruction_start_index)
2168 {
2169 #warning finish
2170 throw Parser_error(instruction_start_index,
2171 instruction_start_index,
2172 "instruction not implemented: "
2173 + std::string(get_enumerant_name(instruction.get_operation())));
2174 }
2175
2176 void Spirv_to_llvm::handle_instruction_op_image_sample_proj_dref_implicit_lod(
2177 Op_image_sample_proj_dref_implicit_lod instruction, std::size_t instruction_start_index)
2178 {
2179 #warning finish
2180 throw Parser_error(instruction_start_index,
2181 instruction_start_index,
2182 "instruction not implemented: "
2183 + std::string(get_enumerant_name(instruction.get_operation())));
2184 }
2185
2186 void Spirv_to_llvm::handle_instruction_op_image_sample_proj_dref_explicit_lod(
2187 Op_image_sample_proj_dref_explicit_lod instruction, std::size_t instruction_start_index)
2188 {
2189 #warning finish
2190 throw Parser_error(instruction_start_index,
2191 instruction_start_index,
2192 "instruction not implemented: "
2193 + std::string(get_enumerant_name(instruction.get_operation())));
2194 }
2195
2196 void Spirv_to_llvm::handle_instruction_op_image_fetch(Op_image_fetch instruction,
2197 std::size_t instruction_start_index)
2198 {
2199 #warning finish
2200 throw Parser_error(instruction_start_index,
2201 instruction_start_index,
2202 "instruction not implemented: "
2203 + std::string(get_enumerant_name(instruction.get_operation())));
2204 }
2205
2206 void Spirv_to_llvm::handle_instruction_op_image_gather(Op_image_gather instruction,
2207 std::size_t instruction_start_index)
2208 {
2209 #warning finish
2210 throw Parser_error(instruction_start_index,
2211 instruction_start_index,
2212 "instruction not implemented: "
2213 + std::string(get_enumerant_name(instruction.get_operation())));
2214 }
2215
2216 void Spirv_to_llvm::handle_instruction_op_image_dref_gather(Op_image_dref_gather instruction,
2217 std::size_t instruction_start_index)
2218 {
2219 #warning finish
2220 throw Parser_error(instruction_start_index,
2221 instruction_start_index,
2222 "instruction not implemented: "
2223 + std::string(get_enumerant_name(instruction.get_operation())));
2224 }
2225
2226 void Spirv_to_llvm::handle_instruction_op_image_read(Op_image_read instruction,
2227 std::size_t instruction_start_index)
2228 {
2229 #warning finish
2230 throw Parser_error(instruction_start_index,
2231 instruction_start_index,
2232 "instruction not implemented: "
2233 + std::string(get_enumerant_name(instruction.get_operation())));
2234 }
2235
2236 void Spirv_to_llvm::handle_instruction_op_image_write(Op_image_write instruction,
2237 std::size_t instruction_start_index)
2238 {
2239 #warning finish
2240 throw Parser_error(instruction_start_index,
2241 instruction_start_index,
2242 "instruction not implemented: "
2243 + std::string(get_enumerant_name(instruction.get_operation())));
2244 }
2245
2246 void Spirv_to_llvm::handle_instruction_op_image(Op_image instruction,
2247 std::size_t instruction_start_index)
2248 {
2249 #warning finish
2250 throw Parser_error(instruction_start_index,
2251 instruction_start_index,
2252 "instruction not implemented: "
2253 + std::string(get_enumerant_name(instruction.get_operation())));
2254 }
2255
2256 void Spirv_to_llvm::handle_instruction_op_image_query_format(Op_image_query_format instruction,
2257 std::size_t instruction_start_index)
2258 {
2259 #warning finish
2260 throw Parser_error(instruction_start_index,
2261 instruction_start_index,
2262 "instruction not implemented: "
2263 + std::string(get_enumerant_name(instruction.get_operation())));
2264 }
2265
2266 void Spirv_to_llvm::handle_instruction_op_image_query_order(Op_image_query_order instruction,
2267 std::size_t instruction_start_index)
2268 {
2269 #warning finish
2270 throw Parser_error(instruction_start_index,
2271 instruction_start_index,
2272 "instruction not implemented: "
2273 + std::string(get_enumerant_name(instruction.get_operation())));
2274 }
2275
2276 void Spirv_to_llvm::handle_instruction_op_image_query_size_lod(Op_image_query_size_lod instruction,
2277 std::size_t instruction_start_index)
2278 {
2279 #warning finish
2280 throw Parser_error(instruction_start_index,
2281 instruction_start_index,
2282 "instruction not implemented: "
2283 + std::string(get_enumerant_name(instruction.get_operation())));
2284 }
2285
2286 void Spirv_to_llvm::handle_instruction_op_image_query_size(Op_image_query_size instruction,
2287 std::size_t instruction_start_index)
2288 {
2289 #warning finish
2290 throw Parser_error(instruction_start_index,
2291 instruction_start_index,
2292 "instruction not implemented: "
2293 + std::string(get_enumerant_name(instruction.get_operation())));
2294 }
2295
2296 void Spirv_to_llvm::handle_instruction_op_image_query_lod(Op_image_query_lod instruction,
2297 std::size_t instruction_start_index)
2298 {
2299 #warning finish
2300 throw Parser_error(instruction_start_index,
2301 instruction_start_index,
2302 "instruction not implemented: "
2303 + std::string(get_enumerant_name(instruction.get_operation())));
2304 }
2305
2306 void Spirv_to_llvm::handle_instruction_op_image_query_levels(Op_image_query_levels instruction,
2307 std::size_t instruction_start_index)
2308 {
2309 #warning finish
2310 throw Parser_error(instruction_start_index,
2311 instruction_start_index,
2312 "instruction not implemented: "
2313 + std::string(get_enumerant_name(instruction.get_operation())));
2314 }
2315
2316 void Spirv_to_llvm::handle_instruction_op_image_query_samples(Op_image_query_samples instruction,
2317 std::size_t instruction_start_index)
2318 {
2319 #warning finish
2320 throw Parser_error(instruction_start_index,
2321 instruction_start_index,
2322 "instruction not implemented: "
2323 + std::string(get_enumerant_name(instruction.get_operation())));
2324 }
2325
2326 void Spirv_to_llvm::handle_instruction_op_convert_f_to_u(Op_convert_f_to_u instruction,
2327 std::size_t instruction_start_index)
2328 {
2329 switch(stage)
2330 {
2331 case Stage::calculate_types:
2332 break;
2333 case Stage::generate_code:
2334 {
2335 auto &state = get_id_state(instruction.result);
2336 if(!state.decorations.empty())
2337 throw Parser_error(instruction_start_index,
2338 instruction_start_index,
2339 "decorations on instruction not implemented: "
2340 + std::string(get_enumerant_name(instruction.get_operation())));
2341 auto result_type = get_type(instruction.result_type, instruction_start_index);
2342 state.value =
2343 Value(::LLVMBuildFPToUI(builder.get(),
2344 get_id_state(instruction.float_value).value.value().value,
2345 result_type->get_or_make_type().type,
2346 get_name(instruction.result).c_str()),
2347 result_type);
2348 break;
2349 }
2350 }
2351 }
2352
2353 void Spirv_to_llvm::handle_instruction_op_convert_f_to_s(Op_convert_f_to_s instruction,
2354 std::size_t instruction_start_index)
2355 {
2356 #warning finish
2357 throw Parser_error(instruction_start_index,
2358 instruction_start_index,
2359 "instruction not implemented: "
2360 + std::string(get_enumerant_name(instruction.get_operation())));
2361 }
2362
2363 void Spirv_to_llvm::handle_instruction_op_convert_s_to_f(Op_convert_s_to_f instruction,
2364 std::size_t instruction_start_index)
2365 {
2366 switch(stage)
2367 {
2368 case Stage::calculate_types:
2369 break;
2370 case Stage::generate_code:
2371 {
2372 auto &state = get_id_state(instruction.result);
2373 if(!state.decorations.empty())
2374 throw Parser_error(instruction_start_index,
2375 instruction_start_index,
2376 "decorations on instruction not implemented: "
2377 + std::string(get_enumerant_name(instruction.get_operation())));
2378 auto result_type = get_type(instruction.result_type, instruction_start_index);
2379 state.value =
2380 Value(::LLVMBuildSIToFP(builder.get(),
2381 get_id_state(instruction.signed_value).value.value().value,
2382 result_type->get_or_make_type().type,
2383 get_name(instruction.result).c_str()),
2384 result_type);
2385 break;
2386 }
2387 }
2388 }
2389
2390 void Spirv_to_llvm::handle_instruction_op_convert_u_to_f(Op_convert_u_to_f instruction,
2391 std::size_t instruction_start_index)
2392 {
2393 #warning finish
2394 throw Parser_error(instruction_start_index,
2395 instruction_start_index,
2396 "instruction not implemented: "
2397 + std::string(get_enumerant_name(instruction.get_operation())));
2398 }
2399
2400 void Spirv_to_llvm::handle_instruction_op_u_convert(Op_u_convert instruction,
2401 std::size_t instruction_start_index)
2402 {
2403 switch(stage)
2404 {
2405 case Stage::calculate_types:
2406 break;
2407 case Stage::generate_code:
2408 {
2409 auto &state = get_id_state(instruction.result);
2410 if(!state.decorations.empty())
2411 throw Parser_error(instruction_start_index,
2412 instruction_start_index,
2413 "decorations on instruction not implemented: "
2414 + std::string(get_enumerant_name(instruction.get_operation())));
2415 auto result_type = get_type(instruction.result_type, instruction_start_index);
2416 auto result_type_int_width = ::LLVMGetIntTypeWidth(
2417 llvm_wrapper::get_scalar_or_vector_element_type(result_type->get_or_make_type().type));
2418 auto &arg = get_id_state(instruction.unsigned_value).value.value();
2419 auto arg_int_width = ::LLVMGetIntTypeWidth(
2420 llvm_wrapper::get_scalar_or_vector_element_type(arg.type->get_or_make_type().type));
2421 auto opcode = ::LLVMTrunc;
2422 if(result_type_int_width > arg_int_width)
2423 opcode = ::LLVMZExt;
2424 state.value = Value(::LLVMBuildCast(builder.get(),
2425 opcode,
2426 arg.value,
2427 result_type->get_or_make_type().type,
2428 get_name(instruction.result).c_str()),
2429 result_type);
2430 break;
2431 }
2432 }
2433 }
2434
2435 void Spirv_to_llvm::handle_instruction_op_s_convert(Op_s_convert instruction,
2436 std::size_t instruction_start_index)
2437 {
2438 #warning finish
2439 throw Parser_error(instruction_start_index,
2440 instruction_start_index,
2441 "instruction not implemented: "
2442 + std::string(get_enumerant_name(instruction.get_operation())));
2443 }
2444
2445 void Spirv_to_llvm::handle_instruction_op_f_convert(Op_f_convert instruction,
2446 std::size_t instruction_start_index)
2447 {
2448 #warning finish
2449 throw Parser_error(instruction_start_index,
2450 instruction_start_index,
2451 "instruction not implemented: "
2452 + std::string(get_enumerant_name(instruction.get_operation())));
2453 }
2454
2455 void Spirv_to_llvm::handle_instruction_op_quantize_to_f16(Op_quantize_to_f16 instruction,
2456 std::size_t instruction_start_index)
2457 {
2458 #warning finish
2459 throw Parser_error(instruction_start_index,
2460 instruction_start_index,
2461 "instruction not implemented: "
2462 + std::string(get_enumerant_name(instruction.get_operation())));
2463 }
2464
2465 void Spirv_to_llvm::handle_instruction_op_convert_ptr_to_u(Op_convert_ptr_to_u instruction,
2466 std::size_t instruction_start_index)
2467 {
2468 #warning finish
2469 throw Parser_error(instruction_start_index,
2470 instruction_start_index,
2471 "instruction not implemented: "
2472 + std::string(get_enumerant_name(instruction.get_operation())));
2473 }
2474
2475 void Spirv_to_llvm::handle_instruction_op_sat_convert_s_to_u(Op_sat_convert_s_to_u instruction,
2476 std::size_t instruction_start_index)
2477 {
2478 #warning finish
2479 throw Parser_error(instruction_start_index,
2480 instruction_start_index,
2481 "instruction not implemented: "
2482 + std::string(get_enumerant_name(instruction.get_operation())));
2483 }
2484
2485 void Spirv_to_llvm::handle_instruction_op_sat_convert_u_to_s(Op_sat_convert_u_to_s instruction,
2486 std::size_t instruction_start_index)
2487 {
2488 #warning finish
2489 throw Parser_error(instruction_start_index,
2490 instruction_start_index,
2491 "instruction not implemented: "
2492 + std::string(get_enumerant_name(instruction.get_operation())));
2493 }
2494
2495 void Spirv_to_llvm::handle_instruction_op_convert_u_to_ptr(Op_convert_u_to_ptr instruction,
2496 std::size_t instruction_start_index)
2497 {
2498 #warning finish
2499 throw Parser_error(instruction_start_index,
2500 instruction_start_index,
2501 "instruction not implemented: "
2502 + std::string(get_enumerant_name(instruction.get_operation())));
2503 }
2504
2505 void Spirv_to_llvm::handle_instruction_op_ptr_cast_to_generic(Op_ptr_cast_to_generic instruction,
2506 std::size_t instruction_start_index)
2507 {
2508 #warning finish
2509 throw Parser_error(instruction_start_index,
2510 instruction_start_index,
2511 "instruction not implemented: "
2512 + std::string(get_enumerant_name(instruction.get_operation())));
2513 }
2514
2515 void Spirv_to_llvm::handle_instruction_op_generic_cast_to_ptr(Op_generic_cast_to_ptr instruction,
2516 std::size_t instruction_start_index)
2517 {
2518 #warning finish
2519 throw Parser_error(instruction_start_index,
2520 instruction_start_index,
2521 "instruction not implemented: "
2522 + std::string(get_enumerant_name(instruction.get_operation())));
2523 }
2524
2525 void Spirv_to_llvm::handle_instruction_op_generic_cast_to_ptr_explicit(
2526 Op_generic_cast_to_ptr_explicit instruction, std::size_t instruction_start_index)
2527 {
2528 #warning finish
2529 throw Parser_error(instruction_start_index,
2530 instruction_start_index,
2531 "instruction not implemented: "
2532 + std::string(get_enumerant_name(instruction.get_operation())));
2533 }
2534
2535 void Spirv_to_llvm::handle_instruction_op_bitcast(Op_bitcast instruction,
2536 std::size_t instruction_start_index)
2537 {
2538 switch(stage)
2539 {
2540 case Stage::calculate_types:
2541 break;
2542 case Stage::generate_code:
2543 {
2544 auto &state = get_id_state(instruction.result);
2545 if(!state.decorations.empty())
2546 throw Parser_error(instruction_start_index,
2547 instruction_start_index,
2548 "decorations on instruction not implemented: "
2549 + std::string(get_enumerant_name(instruction.get_operation())));
2550 auto result_type = get_type(instruction.result_type, instruction_start_index);
2551 auto &arg = get_id_state(instruction.operand).value.value();
2552 std::size_t result_element_count = 1; // scalar is equivalent to size 1 vector
2553 std::size_t arg_element_count = 1;
2554 if(auto *t = dynamic_cast<const Vector_type_descriptor *>(result_type.get()))
2555 result_element_count = t->get_element_count();
2556 if(auto *t = dynamic_cast<const Vector_type_descriptor *>(result_type.get()))
2557 arg_element_count = t->get_element_count();
2558 if(result_element_count != arg_element_count)
2559 {
2560 // need to bitcast as if on little endian system even on big endian
2561 #warning finish implementing element-count-changing bitcast
2562 throw Parser_error(instruction_start_index,
2563 instruction_start_index,
2564 "element-count-changing OpBitcast is not implemented");
2565 }
2566 state.value = Value(::LLVMBuildBitCast(builder.get(),
2567 arg.value,
2568 result_type->get_or_make_type().type,
2569 get_name(instruction.result).c_str()),
2570 result_type);
2571 break;
2572 }
2573 }
2574 }
2575
2576 void Spirv_to_llvm::handle_instruction_op_s_negate(Op_s_negate instruction,
2577 std::size_t instruction_start_index)
2578 {
2579 #warning finish
2580 throw Parser_error(instruction_start_index,
2581 instruction_start_index,
2582 "instruction not implemented: "
2583 + std::string(get_enumerant_name(instruction.get_operation())));
2584 }
2585
2586 void Spirv_to_llvm::handle_instruction_op_f_negate(Op_f_negate instruction,
2587 std::size_t instruction_start_index)
2588 {
2589 switch(stage)
2590 {
2591 case Stage::calculate_types:
2592 break;
2593 case Stage::generate_code:
2594 {
2595 auto &state = get_id_state(instruction.result);
2596 if(!state.decorations.empty())
2597 throw Parser_error(instruction_start_index,
2598 instruction_start_index,
2599 "decorations on instruction not implemented: "
2600 + std::string(get_enumerant_name(instruction.get_operation())));
2601 auto result_type = get_type(instruction.result_type, instruction_start_index);
2602 auto &arg = get_id_state(instruction.operand).value.value();
2603 state.value =
2604 Value(::LLVMBuildFNeg(builder.get(), arg.value, get_name(instruction.result).c_str()),
2605 result_type);
2606 break;
2607 }
2608 }
2609 }
2610
2611 void Spirv_to_llvm::handle_instruction_op_i_add(Op_i_add instruction,
2612 std::size_t instruction_start_index)
2613 {
2614 #warning finish
2615 throw Parser_error(instruction_start_index,
2616 instruction_start_index,
2617 "instruction not implemented: "
2618 + std::string(get_enumerant_name(instruction.get_operation())));
2619 }
2620
2621 void Spirv_to_llvm::handle_instruction_op_f_add(Op_f_add instruction,
2622 std::size_t instruction_start_index)
2623 {
2624 #warning finish
2625 throw Parser_error(instruction_start_index,
2626 instruction_start_index,
2627 "instruction not implemented: "
2628 + std::string(get_enumerant_name(instruction.get_operation())));
2629 }
2630
2631 void Spirv_to_llvm::handle_instruction_op_i_sub(Op_i_sub instruction,
2632 std::size_t instruction_start_index)
2633 {
2634 #warning finish
2635 throw Parser_error(instruction_start_index,
2636 instruction_start_index,
2637 "instruction not implemented: "
2638 + std::string(get_enumerant_name(instruction.get_operation())));
2639 }
2640
2641 void Spirv_to_llvm::handle_instruction_op_f_sub(Op_f_sub instruction,
2642 std::size_t instruction_start_index)
2643 {
2644 #warning finish
2645 throw Parser_error(instruction_start_index,
2646 instruction_start_index,
2647 "instruction not implemented: "
2648 + std::string(get_enumerant_name(instruction.get_operation())));
2649 }
2650
2651 void Spirv_to_llvm::handle_instruction_op_i_mul(Op_i_mul instruction,
2652 std::size_t instruction_start_index)
2653 {
2654 #warning finish
2655 throw Parser_error(instruction_start_index,
2656 instruction_start_index,
2657 "instruction not implemented: "
2658 + std::string(get_enumerant_name(instruction.get_operation())));
2659 }
2660
2661 void Spirv_to_llvm::handle_instruction_op_f_mul(Op_f_mul instruction,
2662 std::size_t instruction_start_index)
2663 {
2664 switch(stage)
2665 {
2666 case Stage::calculate_types:
2667 break;
2668 case Stage::generate_code:
2669 {
2670 auto &state = get_id_state(instruction.result);
2671 if(!state.decorations.empty())
2672 throw Parser_error(instruction_start_index,
2673 instruction_start_index,
2674 "decorations on instruction not implemented: "
2675 + std::string(get_enumerant_name(instruction.get_operation())));
2676 auto result_type = get_type(instruction.result_type, instruction_start_index);
2677 state.value = Value(::LLVMBuildFMul(builder.get(),
2678 get_id_state(instruction.operand_1).value.value().value,
2679 get_id_state(instruction.operand_2).value.value().value,
2680 get_name(instruction.result).c_str()),
2681 result_type);
2682 break;
2683 }
2684 }
2685 }
2686
2687 void Spirv_to_llvm::handle_instruction_op_u_div(Op_u_div instruction,
2688 std::size_t instruction_start_index)
2689 {
2690 #warning finish
2691 throw Parser_error(instruction_start_index,
2692 instruction_start_index,
2693 "instruction not implemented: "
2694 + std::string(get_enumerant_name(instruction.get_operation())));
2695 }
2696
2697 void Spirv_to_llvm::handle_instruction_op_s_div(Op_s_div instruction,
2698 std::size_t instruction_start_index)
2699 {
2700 #warning finish
2701 throw Parser_error(instruction_start_index,
2702 instruction_start_index,
2703 "instruction not implemented: "
2704 + std::string(get_enumerant_name(instruction.get_operation())));
2705 }
2706
2707 void Spirv_to_llvm::handle_instruction_op_f_div(Op_f_div instruction,
2708 std::size_t instruction_start_index)
2709 {
2710 #warning finish
2711 throw Parser_error(instruction_start_index,
2712 instruction_start_index,
2713 "instruction not implemented: "
2714 + std::string(get_enumerant_name(instruction.get_operation())));
2715 }
2716
2717 void Spirv_to_llvm::handle_instruction_op_u_mod(Op_u_mod instruction,
2718 std::size_t instruction_start_index)
2719 {
2720 switch(stage)
2721 {
2722 case Stage::calculate_types:
2723 break;
2724 case Stage::generate_code:
2725 {
2726 auto &state = get_id_state(instruction.result);
2727 if(!state.decorations.empty())
2728 throw Parser_error(instruction_start_index,
2729 instruction_start_index,
2730 "decorations on instruction not implemented: "
2731 + std::string(get_enumerant_name(instruction.get_operation())));
2732 auto result_type = get_type(instruction.result_type, instruction_start_index);
2733 state.value = Value(::LLVMBuildURem(builder.get(),
2734 get_id_state(instruction.operand_1).value.value().value,
2735 get_id_state(instruction.operand_2).value.value().value,
2736 get_name(instruction.result).c_str()),
2737 result_type);
2738 break;
2739 }
2740 }
2741 }
2742
2743 void Spirv_to_llvm::handle_instruction_op_s_rem(Op_s_rem instruction,
2744 std::size_t instruction_start_index)
2745 {
2746 switch(stage)
2747 {
2748 case Stage::calculate_types:
2749 break;
2750 case Stage::generate_code:
2751 {
2752 auto &state = get_id_state(instruction.result);
2753 if(!state.decorations.empty())
2754 throw Parser_error(instruction_start_index,
2755 instruction_start_index,
2756 "decorations on instruction not implemented: "
2757 + std::string(get_enumerant_name(instruction.get_operation())));
2758 auto result_type = get_type(instruction.result_type, instruction_start_index);
2759 state.value = Value(::LLVMBuildSRem(builder.get(),
2760 get_id_state(instruction.operand_1).value.value().value,
2761 get_id_state(instruction.operand_2).value.value().value,
2762 get_name(instruction.result).c_str()),
2763 result_type);
2764 break;
2765 }
2766 }
2767 }
2768
2769 void Spirv_to_llvm::handle_instruction_op_s_mod(Op_s_mod instruction,
2770 std::size_t instruction_start_index)
2771 {
2772 switch(stage)
2773 {
2774 case Stage::calculate_types:
2775 break;
2776 case Stage::generate_code:
2777 {
2778 auto &state = get_id_state(instruction.result);
2779 if(!state.decorations.empty())
2780 throw Parser_error(instruction_start_index,
2781 instruction_start_index,
2782 "decorations on instruction not implemented: "
2783 + std::string(get_enumerant_name(instruction.get_operation())));
2784 auto result_type = get_type(instruction.result_type, instruction_start_index);
2785 state.value =
2786 Value(builder.build_smod(get_id_state(instruction.operand_1).value.value().value,
2787 get_id_state(instruction.operand_2).value.value().value,
2788 get_name(instruction.result).c_str()),
2789 result_type);
2790 break;
2791 }
2792 }
2793 }
2794
2795 void Spirv_to_llvm::handle_instruction_op_f_rem(Op_f_rem instruction,
2796 std::size_t instruction_start_index)
2797 {
2798 #warning finish
2799 throw Parser_error(instruction_start_index,
2800 instruction_start_index,
2801 "instruction not implemented: "
2802 + std::string(get_enumerant_name(instruction.get_operation())));
2803 }
2804
2805 void Spirv_to_llvm::handle_instruction_op_f_mod(Op_f_mod instruction,
2806 std::size_t instruction_start_index)
2807 {
2808 #warning finish
2809 throw Parser_error(instruction_start_index,
2810 instruction_start_index,
2811 "instruction not implemented: "
2812 + std::string(get_enumerant_name(instruction.get_operation())));
2813 }
2814
2815 void Spirv_to_llvm::handle_instruction_op_vector_times_scalar(Op_vector_times_scalar instruction,
2816 std::size_t instruction_start_index)
2817 {
2818 #warning finish
2819 throw Parser_error(instruction_start_index,
2820 instruction_start_index,
2821 "instruction not implemented: "
2822 + std::string(get_enumerant_name(instruction.get_operation())));
2823 }
2824
2825 void Spirv_to_llvm::handle_instruction_op_matrix_times_scalar(Op_matrix_times_scalar instruction,
2826 std::size_t instruction_start_index)
2827 {
2828 #warning finish
2829 throw Parser_error(instruction_start_index,
2830 instruction_start_index,
2831 "instruction not implemented: "
2832 + std::string(get_enumerant_name(instruction.get_operation())));
2833 }
2834
2835 void Spirv_to_llvm::handle_instruction_op_vector_times_matrix(Op_vector_times_matrix instruction,
2836 std::size_t instruction_start_index)
2837 {
2838 #warning finish
2839 throw Parser_error(instruction_start_index,
2840 instruction_start_index,
2841 "instruction not implemented: "
2842 + std::string(get_enumerant_name(instruction.get_operation())));
2843 }
2844
2845 void Spirv_to_llvm::handle_instruction_op_matrix_times_vector(Op_matrix_times_vector instruction,
2846 std::size_t instruction_start_index)
2847 {
2848 #warning finish
2849 throw Parser_error(instruction_start_index,
2850 instruction_start_index,
2851 "instruction not implemented: "
2852 + std::string(get_enumerant_name(instruction.get_operation())));
2853 }
2854
2855 void Spirv_to_llvm::handle_instruction_op_matrix_times_matrix(Op_matrix_times_matrix instruction,
2856 std::size_t instruction_start_index)
2857 {
2858 #warning finish
2859 throw Parser_error(instruction_start_index,
2860 instruction_start_index,
2861 "instruction not implemented: "
2862 + std::string(get_enumerant_name(instruction.get_operation())));
2863 }
2864
2865 void Spirv_to_llvm::handle_instruction_op_outer_product(Op_outer_product instruction,
2866 std::size_t instruction_start_index)
2867 {
2868 #warning finish
2869 throw Parser_error(instruction_start_index,
2870 instruction_start_index,
2871 "instruction not implemented: "
2872 + std::string(get_enumerant_name(instruction.get_operation())));
2873 }
2874
2875 void Spirv_to_llvm::handle_instruction_op_dot(Op_dot instruction,
2876 std::size_t instruction_start_index)
2877 {
2878 #warning finish
2879 throw Parser_error(instruction_start_index,
2880 instruction_start_index,
2881 "instruction not implemented: "
2882 + std::string(get_enumerant_name(instruction.get_operation())));
2883 }
2884
2885 void Spirv_to_llvm::handle_instruction_op_i_add_carry(Op_i_add_carry instruction,
2886 std::size_t instruction_start_index)
2887 {
2888 #warning finish
2889 throw Parser_error(instruction_start_index,
2890 instruction_start_index,
2891 "instruction not implemented: "
2892 + std::string(get_enumerant_name(instruction.get_operation())));
2893 }
2894
2895 void Spirv_to_llvm::handle_instruction_op_i_sub_borrow(Op_i_sub_borrow instruction,
2896 std::size_t instruction_start_index)
2897 {
2898 #warning finish
2899 throw Parser_error(instruction_start_index,
2900 instruction_start_index,
2901 "instruction not implemented: "
2902 + std::string(get_enumerant_name(instruction.get_operation())));
2903 }
2904
2905 void Spirv_to_llvm::handle_instruction_op_u_mul_extended(Op_u_mul_extended instruction,
2906 std::size_t instruction_start_index)
2907 {
2908 #warning finish
2909 throw Parser_error(instruction_start_index,
2910 instruction_start_index,
2911 "instruction not implemented: "
2912 + std::string(get_enumerant_name(instruction.get_operation())));
2913 }
2914
2915 void Spirv_to_llvm::handle_instruction_op_s_mul_extended(Op_s_mul_extended instruction,
2916 std::size_t instruction_start_index)
2917 {
2918 #warning finish
2919 throw Parser_error(instruction_start_index,
2920 instruction_start_index,
2921 "instruction not implemented: "
2922 + std::string(get_enumerant_name(instruction.get_operation())));
2923 }
2924
2925 void Spirv_to_llvm::handle_instruction_op_any(Op_any instruction,
2926 std::size_t instruction_start_index)
2927 {
2928 #warning finish
2929 throw Parser_error(instruction_start_index,
2930 instruction_start_index,
2931 "instruction not implemented: "
2932 + std::string(get_enumerant_name(instruction.get_operation())));
2933 }
2934
2935 void Spirv_to_llvm::handle_instruction_op_all(Op_all instruction,
2936 std::size_t instruction_start_index)
2937 {
2938 #warning finish
2939 throw Parser_error(instruction_start_index,
2940 instruction_start_index,
2941 "instruction not implemented: "
2942 + std::string(get_enumerant_name(instruction.get_operation())));
2943 }
2944
2945 void Spirv_to_llvm::handle_instruction_op_is_nan(Op_is_nan instruction,
2946 std::size_t instruction_start_index)
2947 {
2948 #warning finish
2949 throw Parser_error(instruction_start_index,
2950 instruction_start_index,
2951 "instruction not implemented: "
2952 + std::string(get_enumerant_name(instruction.get_operation())));
2953 }
2954
2955 void Spirv_to_llvm::handle_instruction_op_is_inf(Op_is_inf instruction,
2956 std::size_t instruction_start_index)
2957 {
2958 #warning finish
2959 throw Parser_error(instruction_start_index,
2960 instruction_start_index,
2961 "instruction not implemented: "
2962 + std::string(get_enumerant_name(instruction.get_operation())));
2963 }
2964
2965 void Spirv_to_llvm::handle_instruction_op_is_finite(Op_is_finite instruction,
2966 std::size_t instruction_start_index)
2967 {
2968 #warning finish
2969 throw Parser_error(instruction_start_index,
2970 instruction_start_index,
2971 "instruction not implemented: "
2972 + std::string(get_enumerant_name(instruction.get_operation())));
2973 }
2974
2975 void Spirv_to_llvm::handle_instruction_op_is_normal(Op_is_normal instruction,
2976 std::size_t instruction_start_index)
2977 {
2978 #warning finish
2979 throw Parser_error(instruction_start_index,
2980 instruction_start_index,
2981 "instruction not implemented: "
2982 + std::string(get_enumerant_name(instruction.get_operation())));
2983 }
2984
2985 void Spirv_to_llvm::handle_instruction_op_sign_bit_set(Op_sign_bit_set instruction,
2986 std::size_t instruction_start_index)
2987 {
2988 #warning finish
2989 throw Parser_error(instruction_start_index,
2990 instruction_start_index,
2991 "instruction not implemented: "
2992 + std::string(get_enumerant_name(instruction.get_operation())));
2993 }
2994
2995 void Spirv_to_llvm::handle_instruction_op_less_or_greater(Op_less_or_greater instruction,
2996 std::size_t instruction_start_index)
2997 {
2998 #warning finish
2999 throw Parser_error(instruction_start_index,
3000 instruction_start_index,
3001 "instruction not implemented: "
3002 + std::string(get_enumerant_name(instruction.get_operation())));
3003 }
3004
3005 void Spirv_to_llvm::handle_instruction_op_ordered(Op_ordered instruction,
3006 std::size_t instruction_start_index)
3007 {
3008 #warning finish
3009 throw Parser_error(instruction_start_index,
3010 instruction_start_index,
3011 "instruction not implemented: "
3012 + std::string(get_enumerant_name(instruction.get_operation())));
3013 }
3014
3015 void Spirv_to_llvm::handle_instruction_op_unordered(Op_unordered instruction,
3016 std::size_t instruction_start_index)
3017 {
3018 #warning finish
3019 throw Parser_error(instruction_start_index,
3020 instruction_start_index,
3021 "instruction not implemented: "
3022 + std::string(get_enumerant_name(instruction.get_operation())));
3023 }
3024
3025 void Spirv_to_llvm::handle_instruction_op_logical_equal(Op_logical_equal instruction,
3026 std::size_t instruction_start_index)
3027 {
3028 #warning finish
3029 throw Parser_error(instruction_start_index,
3030 instruction_start_index,
3031 "instruction not implemented: "
3032 + std::string(get_enumerant_name(instruction.get_operation())));
3033 }
3034
3035 void Spirv_to_llvm::handle_instruction_op_logical_not_equal(Op_logical_not_equal instruction,
3036 std::size_t instruction_start_index)
3037 {
3038 #warning finish
3039 throw Parser_error(instruction_start_index,
3040 instruction_start_index,
3041 "instruction not implemented: "
3042 + std::string(get_enumerant_name(instruction.get_operation())));
3043 }
3044
3045 void Spirv_to_llvm::handle_instruction_op_logical_or(Op_logical_or instruction,
3046 std::size_t instruction_start_index)
3047 {
3048 #warning finish
3049 throw Parser_error(instruction_start_index,
3050 instruction_start_index,
3051 "instruction not implemented: "
3052 + std::string(get_enumerant_name(instruction.get_operation())));
3053 }
3054
3055 void Spirv_to_llvm::handle_instruction_op_logical_and(Op_logical_and instruction,
3056 std::size_t instruction_start_index)
3057 {
3058 #warning finish
3059 throw Parser_error(instruction_start_index,
3060 instruction_start_index,
3061 "instruction not implemented: "
3062 + std::string(get_enumerant_name(instruction.get_operation())));
3063 }
3064
3065 void Spirv_to_llvm::handle_instruction_op_logical_not(Op_logical_not instruction,
3066 std::size_t instruction_start_index)
3067 {
3068 #warning finish
3069 throw Parser_error(instruction_start_index,
3070 instruction_start_index,
3071 "instruction not implemented: "
3072 + std::string(get_enumerant_name(instruction.get_operation())));
3073 }
3074
3075 void Spirv_to_llvm::handle_instruction_op_select(Op_select instruction,
3076 std::size_t instruction_start_index)
3077 {
3078 #warning finish
3079 throw Parser_error(instruction_start_index,
3080 instruction_start_index,
3081 "instruction not implemented: "
3082 + std::string(get_enumerant_name(instruction.get_operation())));
3083 }
3084
3085 void Spirv_to_llvm::handle_instruction_op_i_equal(Op_i_equal instruction,
3086 std::size_t instruction_start_index)
3087 {
3088 #warning finish
3089 throw Parser_error(instruction_start_index,
3090 instruction_start_index,
3091 "instruction not implemented: "
3092 + std::string(get_enumerant_name(instruction.get_operation())));
3093 }
3094
3095 void Spirv_to_llvm::handle_instruction_op_i_not_equal(Op_i_not_equal instruction,
3096 std::size_t instruction_start_index)
3097 {
3098 #warning finish
3099 throw Parser_error(instruction_start_index,
3100 instruction_start_index,
3101 "instruction not implemented: "
3102 + std::string(get_enumerant_name(instruction.get_operation())));
3103 }
3104
3105 void Spirv_to_llvm::handle_instruction_op_u_greater_than(Op_u_greater_than instruction,
3106 std::size_t instruction_start_index)
3107 {
3108 #warning finish
3109 throw Parser_error(instruction_start_index,
3110 instruction_start_index,
3111 "instruction not implemented: "
3112 + std::string(get_enumerant_name(instruction.get_operation())));
3113 }
3114
3115 void Spirv_to_llvm::handle_instruction_op_s_greater_than(Op_s_greater_than instruction,
3116 std::size_t instruction_start_index)
3117 {
3118 #warning finish
3119 throw Parser_error(instruction_start_index,
3120 instruction_start_index,
3121 "instruction not implemented: "
3122 + std::string(get_enumerant_name(instruction.get_operation())));
3123 }
3124
3125 void Spirv_to_llvm::handle_instruction_op_u_greater_than_equal(Op_u_greater_than_equal instruction,
3126 std::size_t instruction_start_index)
3127 {
3128 #warning finish
3129 throw Parser_error(instruction_start_index,
3130 instruction_start_index,
3131 "instruction not implemented: "
3132 + std::string(get_enumerant_name(instruction.get_operation())));
3133 }
3134
3135 void Spirv_to_llvm::handle_instruction_op_s_greater_than_equal(Op_s_greater_than_equal instruction,
3136 std::size_t instruction_start_index)
3137 {
3138 #warning finish
3139 throw Parser_error(instruction_start_index,
3140 instruction_start_index,
3141 "instruction not implemented: "
3142 + std::string(get_enumerant_name(instruction.get_operation())));
3143 }
3144
3145 void Spirv_to_llvm::handle_instruction_op_u_less_than(Op_u_less_than instruction,
3146 std::size_t instruction_start_index)
3147 {
3148 #warning finish
3149 throw Parser_error(instruction_start_index,
3150 instruction_start_index,
3151 "instruction not implemented: "
3152 + std::string(get_enumerant_name(instruction.get_operation())));
3153 }
3154
3155 void Spirv_to_llvm::handle_instruction_op_s_less_than(Op_s_less_than instruction,
3156 std::size_t instruction_start_index)
3157 {
3158 #warning finish
3159 throw Parser_error(instruction_start_index,
3160 instruction_start_index,
3161 "instruction not implemented: "
3162 + std::string(get_enumerant_name(instruction.get_operation())));
3163 }
3164
3165 void Spirv_to_llvm::handle_instruction_op_u_less_than_equal(Op_u_less_than_equal instruction,
3166 std::size_t instruction_start_index)
3167 {
3168 #warning finish
3169 throw Parser_error(instruction_start_index,
3170 instruction_start_index,
3171 "instruction not implemented: "
3172 + std::string(get_enumerant_name(instruction.get_operation())));
3173 }
3174
3175 void Spirv_to_llvm::handle_instruction_op_s_less_than_equal(Op_s_less_than_equal instruction,
3176 std::size_t instruction_start_index)
3177 {
3178 #warning finish
3179 throw Parser_error(instruction_start_index,
3180 instruction_start_index,
3181 "instruction not implemented: "
3182 + std::string(get_enumerant_name(instruction.get_operation())));
3183 }
3184
3185 void Spirv_to_llvm::handle_instruction_op_f_ord_equal(Op_f_ord_equal instruction,
3186 std::size_t instruction_start_index)
3187 {
3188 #warning finish
3189 throw Parser_error(instruction_start_index,
3190 instruction_start_index,
3191 "instruction not implemented: "
3192 + std::string(get_enumerant_name(instruction.get_operation())));
3193 }
3194
3195 void Spirv_to_llvm::handle_instruction_op_f_unord_equal(Op_f_unord_equal instruction,
3196 std::size_t instruction_start_index)
3197 {
3198 #warning finish
3199 throw Parser_error(instruction_start_index,
3200 instruction_start_index,
3201 "instruction not implemented: "
3202 + std::string(get_enumerant_name(instruction.get_operation())));
3203 }
3204
3205 void Spirv_to_llvm::handle_instruction_op_f_ord_not_equal(Op_f_ord_not_equal instruction,
3206 std::size_t instruction_start_index)
3207 {
3208 #warning finish
3209 throw Parser_error(instruction_start_index,
3210 instruction_start_index,
3211 "instruction not implemented: "
3212 + std::string(get_enumerant_name(instruction.get_operation())));
3213 }
3214
3215 void Spirv_to_llvm::handle_instruction_op_f_unord_not_equal(Op_f_unord_not_equal instruction,
3216 std::size_t instruction_start_index)
3217 {
3218 #warning finish
3219 throw Parser_error(instruction_start_index,
3220 instruction_start_index,
3221 "instruction not implemented: "
3222 + std::string(get_enumerant_name(instruction.get_operation())));
3223 }
3224
3225 void Spirv_to_llvm::handle_instruction_op_f_ord_less_than(Op_f_ord_less_than instruction,
3226 std::size_t instruction_start_index)
3227 {
3228 #warning finish
3229 throw Parser_error(instruction_start_index,
3230 instruction_start_index,
3231 "instruction not implemented: "
3232 + std::string(get_enumerant_name(instruction.get_operation())));
3233 }
3234
3235 void Spirv_to_llvm::handle_instruction_op_f_unord_less_than(Op_f_unord_less_than instruction,
3236 std::size_t instruction_start_index)
3237 {
3238 #warning finish
3239 throw Parser_error(instruction_start_index,
3240 instruction_start_index,
3241 "instruction not implemented: "
3242 + std::string(get_enumerant_name(instruction.get_operation())));
3243 }
3244
3245 void Spirv_to_llvm::handle_instruction_op_f_ord_greater_than(Op_f_ord_greater_than instruction,
3246 std::size_t instruction_start_index)
3247 {
3248 #warning finish
3249 throw Parser_error(instruction_start_index,
3250 instruction_start_index,
3251 "instruction not implemented: "
3252 + std::string(get_enumerant_name(instruction.get_operation())));
3253 }
3254
3255 void Spirv_to_llvm::handle_instruction_op_f_unord_greater_than(Op_f_unord_greater_than instruction,
3256 std::size_t instruction_start_index)
3257 {
3258 #warning finish
3259 throw Parser_error(instruction_start_index,
3260 instruction_start_index,
3261 "instruction not implemented: "
3262 + std::string(get_enumerant_name(instruction.get_operation())));
3263 }
3264
3265 void Spirv_to_llvm::handle_instruction_op_f_ord_less_than_equal(
3266 Op_f_ord_less_than_equal instruction, std::size_t instruction_start_index)
3267 {
3268 #warning finish
3269 throw Parser_error(instruction_start_index,
3270 instruction_start_index,
3271 "instruction not implemented: "
3272 + std::string(get_enumerant_name(instruction.get_operation())));
3273 }
3274
3275 void Spirv_to_llvm::handle_instruction_op_f_unord_less_than_equal(
3276 Op_f_unord_less_than_equal instruction, std::size_t instruction_start_index)
3277 {
3278 #warning finish
3279 throw Parser_error(instruction_start_index,
3280 instruction_start_index,
3281 "instruction not implemented: "
3282 + std::string(get_enumerant_name(instruction.get_operation())));
3283 }
3284
3285 void Spirv_to_llvm::handle_instruction_op_f_ord_greater_than_equal(
3286 Op_f_ord_greater_than_equal instruction, std::size_t instruction_start_index)
3287 {
3288 #warning finish
3289 throw Parser_error(instruction_start_index,
3290 instruction_start_index,
3291 "instruction not implemented: "
3292 + std::string(get_enumerant_name(instruction.get_operation())));
3293 }
3294
3295 void Spirv_to_llvm::handle_instruction_op_f_unord_greater_than_equal(
3296 Op_f_unord_greater_than_equal instruction, std::size_t instruction_start_index)
3297 {
3298 #warning finish
3299 throw Parser_error(instruction_start_index,
3300 instruction_start_index,
3301 "instruction not implemented: "
3302 + std::string(get_enumerant_name(instruction.get_operation())));
3303 }
3304
3305 void Spirv_to_llvm::handle_instruction_op_shift_right_logical(Op_shift_right_logical instruction,
3306 std::size_t instruction_start_index)
3307 {
3308 #warning finish
3309 throw Parser_error(instruction_start_index,
3310 instruction_start_index,
3311 "instruction not implemented: "
3312 + std::string(get_enumerant_name(instruction.get_operation())));
3313 }
3314
3315 void Spirv_to_llvm::handle_instruction_op_shift_right_arithmetic(
3316 Op_shift_right_arithmetic instruction, std::size_t instruction_start_index)
3317 {
3318 #warning finish
3319 throw Parser_error(instruction_start_index,
3320 instruction_start_index,
3321 "instruction not implemented: "
3322 + std::string(get_enumerant_name(instruction.get_operation())));
3323 }
3324
3325 void Spirv_to_llvm::handle_instruction_op_shift_left_logical(Op_shift_left_logical instruction,
3326 std::size_t instruction_start_index)
3327 {
3328 #warning finish
3329 throw Parser_error(instruction_start_index,
3330 instruction_start_index,
3331 "instruction not implemented: "
3332 + std::string(get_enumerant_name(instruction.get_operation())));
3333 }
3334
3335 void Spirv_to_llvm::handle_instruction_op_bitwise_or(Op_bitwise_or instruction,
3336 std::size_t instruction_start_index)
3337 {
3338 #warning finish
3339 throw Parser_error(instruction_start_index,
3340 instruction_start_index,
3341 "instruction not implemented: "
3342 + std::string(get_enumerant_name(instruction.get_operation())));
3343 }
3344
3345 void Spirv_to_llvm::handle_instruction_op_bitwise_xor(Op_bitwise_xor instruction,
3346 std::size_t instruction_start_index)
3347 {
3348 #warning finish
3349 throw Parser_error(instruction_start_index,
3350 instruction_start_index,
3351 "instruction not implemented: "
3352 + std::string(get_enumerant_name(instruction.get_operation())));
3353 }
3354
3355 void Spirv_to_llvm::handle_instruction_op_bitwise_and(Op_bitwise_and instruction,
3356 std::size_t instruction_start_index)
3357 {
3358 #warning finish
3359 throw Parser_error(instruction_start_index,
3360 instruction_start_index,
3361 "instruction not implemented: "
3362 + std::string(get_enumerant_name(instruction.get_operation())));
3363 }
3364
3365 void Spirv_to_llvm::handle_instruction_op_not(Op_not instruction,
3366 std::size_t instruction_start_index)
3367 {
3368 #warning finish
3369 throw Parser_error(instruction_start_index,
3370 instruction_start_index,
3371 "instruction not implemented: "
3372 + std::string(get_enumerant_name(instruction.get_operation())));
3373 }
3374
3375 void Spirv_to_llvm::handle_instruction_op_bit_field_insert(Op_bit_field_insert instruction,
3376 std::size_t instruction_start_index)
3377 {
3378 #warning finish
3379 throw Parser_error(instruction_start_index,
3380 instruction_start_index,
3381 "instruction not implemented: "
3382 + std::string(get_enumerant_name(instruction.get_operation())));
3383 }
3384
3385 void Spirv_to_llvm::handle_instruction_op_bit_field_s_extract(Op_bit_field_s_extract instruction,
3386 std::size_t instruction_start_index)
3387 {
3388 #warning finish
3389 throw Parser_error(instruction_start_index,
3390 instruction_start_index,
3391 "instruction not implemented: "
3392 + std::string(get_enumerant_name(instruction.get_operation())));
3393 }
3394
3395 void Spirv_to_llvm::handle_instruction_op_bit_field_u_extract(Op_bit_field_u_extract instruction,
3396 std::size_t instruction_start_index)
3397 {
3398 #warning finish
3399 throw Parser_error(instruction_start_index,
3400 instruction_start_index,
3401 "instruction not implemented: "
3402 + std::string(get_enumerant_name(instruction.get_operation())));
3403 }
3404
3405 void Spirv_to_llvm::handle_instruction_op_bit_reverse(Op_bit_reverse instruction,
3406 std::size_t instruction_start_index)
3407 {
3408 #warning finish
3409 throw Parser_error(instruction_start_index,
3410 instruction_start_index,
3411 "instruction not implemented: "
3412 + std::string(get_enumerant_name(instruction.get_operation())));
3413 }
3414
3415 void Spirv_to_llvm::handle_instruction_op_bit_count(Op_bit_count instruction,
3416 std::size_t instruction_start_index)
3417 {
3418 #warning finish
3419 throw Parser_error(instruction_start_index,
3420 instruction_start_index,
3421 "instruction not implemented: "
3422 + std::string(get_enumerant_name(instruction.get_operation())));
3423 }
3424
3425 void Spirv_to_llvm::handle_instruction_op_d_pdx(Op_d_pdx instruction,
3426 std::size_t instruction_start_index)
3427 {
3428 #warning finish
3429 throw Parser_error(instruction_start_index,
3430 instruction_start_index,
3431 "instruction not implemented: "
3432 + std::string(get_enumerant_name(instruction.get_operation())));
3433 }
3434
3435 void Spirv_to_llvm::handle_instruction_op_d_pdy(Op_d_pdy instruction,
3436 std::size_t instruction_start_index)
3437 {
3438 #warning finish
3439 throw Parser_error(instruction_start_index,
3440 instruction_start_index,
3441 "instruction not implemented: "
3442 + std::string(get_enumerant_name(instruction.get_operation())));
3443 }
3444
3445 void Spirv_to_llvm::handle_instruction_op_fwidth(Op_fwidth instruction,
3446 std::size_t instruction_start_index)
3447 {
3448 #warning finish
3449 throw Parser_error(instruction_start_index,
3450 instruction_start_index,
3451 "instruction not implemented: "
3452 + std::string(get_enumerant_name(instruction.get_operation())));
3453 }
3454
3455 void Spirv_to_llvm::handle_instruction_op_d_pdx_fine(Op_d_pdx_fine instruction,
3456 std::size_t instruction_start_index)
3457 {
3458 #warning finish
3459 throw Parser_error(instruction_start_index,
3460 instruction_start_index,
3461 "instruction not implemented: "
3462 + std::string(get_enumerant_name(instruction.get_operation())));
3463 }
3464
3465 void Spirv_to_llvm::handle_instruction_op_d_pdy_fine(Op_d_pdy_fine instruction,
3466 std::size_t instruction_start_index)
3467 {
3468 #warning finish
3469 throw Parser_error(instruction_start_index,
3470 instruction_start_index,
3471 "instruction not implemented: "
3472 + std::string(get_enumerant_name(instruction.get_operation())));
3473 }
3474
3475 void Spirv_to_llvm::handle_instruction_op_fwidth_fine(Op_fwidth_fine instruction,
3476 std::size_t instruction_start_index)
3477 {
3478 #warning finish
3479 throw Parser_error(instruction_start_index,
3480 instruction_start_index,
3481 "instruction not implemented: "
3482 + std::string(get_enumerant_name(instruction.get_operation())));
3483 }
3484
3485 void Spirv_to_llvm::handle_instruction_op_d_pdx_coarse(Op_d_pdx_coarse instruction,
3486 std::size_t instruction_start_index)
3487 {
3488 #warning finish
3489 throw Parser_error(instruction_start_index,
3490 instruction_start_index,
3491 "instruction not implemented: "
3492 + std::string(get_enumerant_name(instruction.get_operation())));
3493 }
3494
3495 void Spirv_to_llvm::handle_instruction_op_d_pdy_coarse(Op_d_pdy_coarse instruction,
3496 std::size_t instruction_start_index)
3497 {
3498 #warning finish
3499 throw Parser_error(instruction_start_index,
3500 instruction_start_index,
3501 "instruction not implemented: "
3502 + std::string(get_enumerant_name(instruction.get_operation())));
3503 }
3504
3505 void Spirv_to_llvm::handle_instruction_op_fwidth_coarse(Op_fwidth_coarse instruction,
3506 std::size_t instruction_start_index)
3507 {
3508 #warning finish
3509 throw Parser_error(instruction_start_index,
3510 instruction_start_index,
3511 "instruction not implemented: "
3512 + std::string(get_enumerant_name(instruction.get_operation())));
3513 }
3514
3515 void Spirv_to_llvm::handle_instruction_op_emit_vertex(Op_emit_vertex instruction,
3516 std::size_t instruction_start_index)
3517 {
3518 #warning finish
3519 throw Parser_error(instruction_start_index,
3520 instruction_start_index,
3521 "instruction not implemented: "
3522 + std::string(get_enumerant_name(instruction.get_operation())));
3523 }
3524
3525 void Spirv_to_llvm::handle_instruction_op_end_primitive(Op_end_primitive instruction,
3526 std::size_t instruction_start_index)
3527 {
3528 #warning finish
3529 throw Parser_error(instruction_start_index,
3530 instruction_start_index,
3531 "instruction not implemented: "
3532 + std::string(get_enumerant_name(instruction.get_operation())));
3533 }
3534
3535 void Spirv_to_llvm::handle_instruction_op_emit_stream_vertex(Op_emit_stream_vertex instruction,
3536 std::size_t instruction_start_index)
3537 {
3538 #warning finish
3539 throw Parser_error(instruction_start_index,
3540 instruction_start_index,
3541 "instruction not implemented: "
3542 + std::string(get_enumerant_name(instruction.get_operation())));
3543 }
3544
3545 void Spirv_to_llvm::handle_instruction_op_end_stream_primitive(Op_end_stream_primitive instruction,
3546 std::size_t instruction_start_index)
3547 {
3548 #warning finish
3549 throw Parser_error(instruction_start_index,
3550 instruction_start_index,
3551 "instruction not implemented: "
3552 + std::string(get_enumerant_name(instruction.get_operation())));
3553 }
3554
3555 void Spirv_to_llvm::handle_instruction_op_control_barrier(Op_control_barrier instruction,
3556 std::size_t instruction_start_index)
3557 {
3558 #warning finish
3559 throw Parser_error(instruction_start_index,
3560 instruction_start_index,
3561 "instruction not implemented: "
3562 + std::string(get_enumerant_name(instruction.get_operation())));
3563 }
3564
3565 void Spirv_to_llvm::handle_instruction_op_memory_barrier(Op_memory_barrier instruction,
3566 std::size_t instruction_start_index)
3567 {
3568 #warning finish
3569 throw Parser_error(instruction_start_index,
3570 instruction_start_index,
3571 "instruction not implemented: "
3572 + std::string(get_enumerant_name(instruction.get_operation())));
3573 }
3574
3575 void Spirv_to_llvm::handle_instruction_op_atomic_load(Op_atomic_load instruction,
3576 std::size_t instruction_start_index)
3577 {
3578 #warning finish
3579 throw Parser_error(instruction_start_index,
3580 instruction_start_index,
3581 "instruction not implemented: "
3582 + std::string(get_enumerant_name(instruction.get_operation())));
3583 }
3584
3585 void Spirv_to_llvm::handle_instruction_op_atomic_store(Op_atomic_store instruction,
3586 std::size_t instruction_start_index)
3587 {
3588 #warning finish
3589 throw Parser_error(instruction_start_index,
3590 instruction_start_index,
3591 "instruction not implemented: "
3592 + std::string(get_enumerant_name(instruction.get_operation())));
3593 }
3594
3595 void Spirv_to_llvm::handle_instruction_op_atomic_exchange(Op_atomic_exchange instruction,
3596 std::size_t instruction_start_index)
3597 {
3598 #warning finish
3599 throw Parser_error(instruction_start_index,
3600 instruction_start_index,
3601 "instruction not implemented: "
3602 + std::string(get_enumerant_name(instruction.get_operation())));
3603 }
3604
3605 void Spirv_to_llvm::handle_instruction_op_atomic_compare_exchange(
3606 Op_atomic_compare_exchange instruction, std::size_t instruction_start_index)
3607 {
3608 #warning finish
3609 throw Parser_error(instruction_start_index,
3610 instruction_start_index,
3611 "instruction not implemented: "
3612 + std::string(get_enumerant_name(instruction.get_operation())));
3613 }
3614
3615 void Spirv_to_llvm::handle_instruction_op_atomic_compare_exchange_weak(
3616 Op_atomic_compare_exchange_weak instruction, std::size_t instruction_start_index)
3617 {
3618 #warning finish
3619 throw Parser_error(instruction_start_index,
3620 instruction_start_index,
3621 "instruction not implemented: "
3622 + std::string(get_enumerant_name(instruction.get_operation())));
3623 }
3624
3625 void Spirv_to_llvm::handle_instruction_op_atomic_i_increment(Op_atomic_i_increment instruction,
3626 std::size_t instruction_start_index)
3627 {
3628 #warning finish
3629 throw Parser_error(instruction_start_index,
3630 instruction_start_index,
3631 "instruction not implemented: "
3632 + std::string(get_enumerant_name(instruction.get_operation())));
3633 }
3634
3635 void Spirv_to_llvm::handle_instruction_op_atomic_i_decrement(Op_atomic_i_decrement instruction,
3636 std::size_t instruction_start_index)
3637 {
3638 #warning finish
3639 throw Parser_error(instruction_start_index,
3640 instruction_start_index,
3641 "instruction not implemented: "
3642 + std::string(get_enumerant_name(instruction.get_operation())));
3643 }
3644
3645 void Spirv_to_llvm::handle_instruction_op_atomic_i_add(Op_atomic_i_add instruction,
3646 std::size_t instruction_start_index)
3647 {
3648 #warning finish
3649 throw Parser_error(instruction_start_index,
3650 instruction_start_index,
3651 "instruction not implemented: "
3652 + std::string(get_enumerant_name(instruction.get_operation())));
3653 }
3654
3655 void Spirv_to_llvm::handle_instruction_op_atomic_i_sub(Op_atomic_i_sub instruction,
3656 std::size_t instruction_start_index)
3657 {
3658 #warning finish
3659 throw Parser_error(instruction_start_index,
3660 instruction_start_index,
3661 "instruction not implemented: "
3662 + std::string(get_enumerant_name(instruction.get_operation())));
3663 }
3664
3665 void Spirv_to_llvm::handle_instruction_op_atomic_s_min(Op_atomic_s_min instruction,
3666 std::size_t instruction_start_index)
3667 {
3668 #warning finish
3669 throw Parser_error(instruction_start_index,
3670 instruction_start_index,
3671 "instruction not implemented: "
3672 + std::string(get_enumerant_name(instruction.get_operation())));
3673 }
3674
3675 void Spirv_to_llvm::handle_instruction_op_atomic_u_min(Op_atomic_u_min instruction,
3676 std::size_t instruction_start_index)
3677 {
3678 #warning finish
3679 throw Parser_error(instruction_start_index,
3680 instruction_start_index,
3681 "instruction not implemented: "
3682 + std::string(get_enumerant_name(instruction.get_operation())));
3683 }
3684
3685 void Spirv_to_llvm::handle_instruction_op_atomic_s_max(Op_atomic_s_max instruction,
3686 std::size_t instruction_start_index)
3687 {
3688 #warning finish
3689 throw Parser_error(instruction_start_index,
3690 instruction_start_index,
3691 "instruction not implemented: "
3692 + std::string(get_enumerant_name(instruction.get_operation())));
3693 }
3694
3695 void Spirv_to_llvm::handle_instruction_op_atomic_u_max(Op_atomic_u_max instruction,
3696 std::size_t instruction_start_index)
3697 {
3698 #warning finish
3699 throw Parser_error(instruction_start_index,
3700 instruction_start_index,
3701 "instruction not implemented: "
3702 + std::string(get_enumerant_name(instruction.get_operation())));
3703 }
3704
3705 void Spirv_to_llvm::handle_instruction_op_atomic_and(Op_atomic_and instruction,
3706 std::size_t instruction_start_index)
3707 {
3708 #warning finish
3709 throw Parser_error(instruction_start_index,
3710 instruction_start_index,
3711 "instruction not implemented: "
3712 + std::string(get_enumerant_name(instruction.get_operation())));
3713 }
3714
3715 void Spirv_to_llvm::handle_instruction_op_atomic_or(Op_atomic_or instruction,
3716 std::size_t instruction_start_index)
3717 {
3718 #warning finish
3719 throw Parser_error(instruction_start_index,
3720 instruction_start_index,
3721 "instruction not implemented: "
3722 + std::string(get_enumerant_name(instruction.get_operation())));
3723 }
3724
3725 void Spirv_to_llvm::handle_instruction_op_atomic_xor(Op_atomic_xor instruction,
3726 std::size_t instruction_start_index)
3727 {
3728 #warning finish
3729 throw Parser_error(instruction_start_index,
3730 instruction_start_index,
3731 "instruction not implemented: "
3732 + std::string(get_enumerant_name(instruction.get_operation())));
3733 }
3734
3735 void Spirv_to_llvm::handle_instruction_op_phi(Op_phi instruction,
3736 std::size_t instruction_start_index)
3737 {
3738 #warning finish
3739 throw Parser_error(instruction_start_index,
3740 instruction_start_index,
3741 "instruction not implemented: "
3742 + std::string(get_enumerant_name(instruction.get_operation())));
3743 }
3744
3745 void Spirv_to_llvm::handle_instruction_op_loop_merge(Op_loop_merge instruction,
3746 std::size_t instruction_start_index)
3747 {
3748 last_merge_instruction =
3749 Last_merge_instruction(std::move(instruction), instruction_start_index);
3750 }
3751
3752 void Spirv_to_llvm::handle_instruction_op_selection_merge(Op_selection_merge instruction,
3753 std::size_t instruction_start_index)
3754 {
3755 last_merge_instruction =
3756 Last_merge_instruction(std::move(instruction), instruction_start_index);
3757 }
3758
3759 void Spirv_to_llvm::handle_instruction_op_label(Op_label instruction,
3760 std::size_t instruction_start_index)
3761 {
3762 if(current_function_id == 0)
3763 throw Parser_error(instruction_start_index,
3764 instruction_start_index,
3765 "OpLabel not allowed outside a function");
3766 if(current_basic_block_id != 0)
3767 throw Parser_error(instruction_start_index,
3768 instruction_start_index,
3769 "missing block terminator before OpLabel");
3770 current_basic_block_id = instruction.result;
3771 switch(stage)
3772 {
3773 case Stage::calculate_types:
3774 break;
3775 case Stage::generate_code:
3776 {
3777 auto &function = get_id_state(current_function_id).function.value();
3778 if(!get_id_state(current_basic_block_id).decorations.empty())
3779 throw Parser_error(instruction_start_index,
3780 instruction_start_index,
3781 "decorations on label not implemented");
3782 auto block = get_or_make_label(instruction.result);
3783 ::LLVMPositionBuilderAtEnd(builder.get(), block);
3784 if(!function.entry_block)
3785 {
3786 auto io_struct_value = ::LLVMGetParam(function.function, io_struct_argument_index);
3787 auto inputs_struct_value = ::LLVMBuildLoad(
3788 builder.get(),
3789 ::LLVMBuildStructGEP(
3790 builder.get(),
3791 io_struct_value,
3792 io_struct->get_members(true)[this->inputs_member].llvm_member_index,
3793 "inputs_pointer"),
3794 "inputs");
3795 auto outputs_struct_value = ::LLVMBuildLoad(
3796 builder.get(),
3797 ::LLVMBuildStructGEP(
3798 builder.get(),
3799 io_struct_value,
3800 io_struct->get_members(true)[this->outputs_member].llvm_member_index,
3801 "outputs_pointer"),
3802 "outputs");
3803 function.entry_block = Function_state::Entry_block(
3804 block, io_struct_value, inputs_struct_value, outputs_struct_value);
3805 for(auto iter = function_entry_block_handlers.begin();
3806 iter != function_entry_block_handlers.end();)
3807 {
3808 auto fn = *iter++;
3809 // increment before calling in case the hander removes itself
3810 fn();
3811 }
3812 }
3813 break;
3814 }
3815 }
3816 }
3817
3818 void Spirv_to_llvm::handle_instruction_op_branch(
3819 Op_branch instruction, [[gnu::unused]] std::size_t instruction_start_index)
3820 {
3821 auto merge = std::move(last_merge_instruction);
3822 last_merge_instruction.reset();
3823 current_basic_block_id = 0;
3824 switch(stage)
3825 {
3826 case Stage::calculate_types:
3827 break;
3828 case Stage::generate_code:
3829 {
3830 ::LLVMBuildBr(builder.get(), get_or_make_label(instruction.target_label));
3831 break;
3832 }
3833 }
3834 }
3835
3836 void Spirv_to_llvm::handle_instruction_op_branch_conditional(Op_branch_conditional instruction,
3837 std::size_t instruction_start_index)
3838 {
3839 #warning finish
3840 throw Parser_error(instruction_start_index,
3841 instruction_start_index,
3842 "instruction not implemented: "
3843 + std::string(get_enumerant_name(instruction.get_operation())));
3844 }
3845
3846 void Spirv_to_llvm::handle_instruction_op_switch(
3847 Op_switch instruction, [[gnu::unused]] std::size_t instruction_start_index)
3848 {
3849 auto merge = std::move(last_merge_instruction.value());
3850 last_merge_instruction.reset();
3851 current_basic_block_id = 0;
3852 switch(stage)
3853 {
3854 case Stage::calculate_types:
3855 break;
3856 case Stage::generate_code:
3857 {
3858 for(auto &target : instruction.target)
3859 get_or_make_label(target.part_2); // create basic blocks first
3860 auto selector = get_id_state(instruction.selector).value.value();
3861 auto switch_instruction = ::LLVMBuildSwitch(builder.get(),
3862 selector.value,
3863 get_or_make_label(instruction.default_),
3864 instruction.target.size());
3865 for(auto &target : instruction.target)
3866 ::LLVMAddCase(
3867 switch_instruction,
3868 ::LLVMConstInt(selector.type->get_or_make_type().type, target.part_1, false),
3869 get_or_make_label(target.part_2));
3870 break;
3871 }
3872 }
3873 }
3874
3875 void Spirv_to_llvm::handle_instruction_op_kill(Op_kill instruction,
3876 std::size_t instruction_start_index)
3877 {
3878 #warning finish
3879 throw Parser_error(instruction_start_index,
3880 instruction_start_index,
3881 "instruction not implemented: "
3882 + std::string(get_enumerant_name(instruction.get_operation())));
3883 }
3884
3885 void Spirv_to_llvm::handle_instruction_op_return(
3886 [[gnu::unused]] Op_return instruction, [[gnu::unused]] std::size_t instruction_start_index)
3887 {
3888 current_basic_block_id = 0;
3889 switch(stage)
3890 {
3891 case Stage::calculate_types:
3892 break;
3893 case Stage::generate_code:
3894 {
3895 ::LLVMBuildRetVoid(builder.get());
3896 break;
3897 }
3898 }
3899 }
3900
3901 void Spirv_to_llvm::handle_instruction_op_return_value(Op_return_value instruction,
3902 std::size_t instruction_start_index)
3903 {
3904 #warning finish
3905 throw Parser_error(instruction_start_index,
3906 instruction_start_index,
3907 "instruction not implemented: "
3908 + std::string(get_enumerant_name(instruction.get_operation())));
3909 }
3910
3911 void Spirv_to_llvm::handle_instruction_op_unreachable(Op_unreachable instruction,
3912 std::size_t instruction_start_index)
3913 {
3914 #warning finish
3915 throw Parser_error(instruction_start_index,
3916 instruction_start_index,
3917 "instruction not implemented: "
3918 + std::string(get_enumerant_name(instruction.get_operation())));
3919 }
3920
3921 void Spirv_to_llvm::handle_instruction_op_lifetime_start(Op_lifetime_start instruction,
3922 std::size_t instruction_start_index)
3923 {
3924 #warning finish
3925 throw Parser_error(instruction_start_index,
3926 instruction_start_index,
3927 "instruction not implemented: "
3928 + std::string(get_enumerant_name(instruction.get_operation())));
3929 }
3930
3931 void Spirv_to_llvm::handle_instruction_op_lifetime_stop(Op_lifetime_stop instruction,
3932 std::size_t instruction_start_index)
3933 {
3934 #warning finish
3935 throw Parser_error(instruction_start_index,
3936 instruction_start_index,
3937 "instruction not implemented: "
3938 + std::string(get_enumerant_name(instruction.get_operation())));
3939 }
3940
3941 void Spirv_to_llvm::handle_instruction_op_group_async_copy(Op_group_async_copy instruction,
3942 std::size_t instruction_start_index)
3943 {
3944 #warning finish
3945 throw Parser_error(instruction_start_index,
3946 instruction_start_index,
3947 "instruction not implemented: "
3948 + std::string(get_enumerant_name(instruction.get_operation())));
3949 }
3950
3951 void Spirv_to_llvm::handle_instruction_op_group_wait_events(Op_group_wait_events instruction,
3952 std::size_t instruction_start_index)
3953 {
3954 #warning finish
3955 throw Parser_error(instruction_start_index,
3956 instruction_start_index,
3957 "instruction not implemented: "
3958 + std::string(get_enumerant_name(instruction.get_operation())));
3959 }
3960
3961 void Spirv_to_llvm::handle_instruction_op_group_all(Op_group_all instruction,
3962 std::size_t instruction_start_index)
3963 {
3964 #warning finish
3965 throw Parser_error(instruction_start_index,
3966 instruction_start_index,
3967 "instruction not implemented: "
3968 + std::string(get_enumerant_name(instruction.get_operation())));
3969 }
3970
3971 void Spirv_to_llvm::handle_instruction_op_group_any(Op_group_any instruction,
3972 std::size_t instruction_start_index)
3973 {
3974 #warning finish
3975 throw Parser_error(instruction_start_index,
3976 instruction_start_index,
3977 "instruction not implemented: "
3978 + std::string(get_enumerant_name(instruction.get_operation())));
3979 }
3980
3981 void Spirv_to_llvm::handle_instruction_op_group_broadcast(Op_group_broadcast instruction,
3982 std::size_t instruction_start_index)
3983 {
3984 #warning finish
3985 throw Parser_error(instruction_start_index,
3986 instruction_start_index,
3987 "instruction not implemented: "
3988 + std::string(get_enumerant_name(instruction.get_operation())));
3989 }
3990
3991 void Spirv_to_llvm::handle_instruction_op_group_i_add(Op_group_i_add instruction,
3992 std::size_t instruction_start_index)
3993 {
3994 #warning finish
3995 throw Parser_error(instruction_start_index,
3996 instruction_start_index,
3997 "instruction not implemented: "
3998 + std::string(get_enumerant_name(instruction.get_operation())));
3999 }
4000
4001 void Spirv_to_llvm::handle_instruction_op_group_f_add(Op_group_f_add instruction,
4002 std::size_t instruction_start_index)
4003 {
4004 #warning finish
4005 throw Parser_error(instruction_start_index,
4006 instruction_start_index,
4007 "instruction not implemented: "
4008 + std::string(get_enumerant_name(instruction.get_operation())));
4009 }
4010
4011 void Spirv_to_llvm::handle_instruction_op_group_f_min(Op_group_f_min instruction,
4012 std::size_t instruction_start_index)
4013 {
4014 #warning finish
4015 throw Parser_error(instruction_start_index,
4016 instruction_start_index,
4017 "instruction not implemented: "
4018 + std::string(get_enumerant_name(instruction.get_operation())));
4019 }
4020
4021 void Spirv_to_llvm::handle_instruction_op_group_u_min(Op_group_u_min instruction,
4022 std::size_t instruction_start_index)
4023 {
4024 #warning finish
4025 throw Parser_error(instruction_start_index,
4026 instruction_start_index,
4027 "instruction not implemented: "
4028 + std::string(get_enumerant_name(instruction.get_operation())));
4029 }
4030
4031 void Spirv_to_llvm::handle_instruction_op_group_s_min(Op_group_s_min instruction,
4032 std::size_t instruction_start_index)
4033 {
4034 #warning finish
4035 throw Parser_error(instruction_start_index,
4036 instruction_start_index,
4037 "instruction not implemented: "
4038 + std::string(get_enumerant_name(instruction.get_operation())));
4039 }
4040
4041 void Spirv_to_llvm::handle_instruction_op_group_f_max(Op_group_f_max instruction,
4042 std::size_t instruction_start_index)
4043 {
4044 #warning finish
4045 throw Parser_error(instruction_start_index,
4046 instruction_start_index,
4047 "instruction not implemented: "
4048 + std::string(get_enumerant_name(instruction.get_operation())));
4049 }
4050
4051 void Spirv_to_llvm::handle_instruction_op_group_u_max(Op_group_u_max instruction,
4052 std::size_t instruction_start_index)
4053 {
4054 #warning finish
4055 throw Parser_error(instruction_start_index,
4056 instruction_start_index,
4057 "instruction not implemented: "
4058 + std::string(get_enumerant_name(instruction.get_operation())));
4059 }
4060
4061 void Spirv_to_llvm::handle_instruction_op_group_s_max(Op_group_s_max instruction,
4062 std::size_t instruction_start_index)
4063 {
4064 #warning finish
4065 throw Parser_error(instruction_start_index,
4066 instruction_start_index,
4067 "instruction not implemented: "
4068 + std::string(get_enumerant_name(instruction.get_operation())));
4069 }
4070
4071 void Spirv_to_llvm::handle_instruction_op_read_pipe(Op_read_pipe instruction,
4072 std::size_t instruction_start_index)
4073 {
4074 #warning finish
4075 throw Parser_error(instruction_start_index,
4076 instruction_start_index,
4077 "instruction not implemented: "
4078 + std::string(get_enumerant_name(instruction.get_operation())));
4079 }
4080
4081 void Spirv_to_llvm::handle_instruction_op_write_pipe(Op_write_pipe instruction,
4082 std::size_t instruction_start_index)
4083 {
4084 #warning finish
4085 throw Parser_error(instruction_start_index,
4086 instruction_start_index,
4087 "instruction not implemented: "
4088 + std::string(get_enumerant_name(instruction.get_operation())));
4089 }
4090
4091 void Spirv_to_llvm::handle_instruction_op_reserved_read_pipe(Op_reserved_read_pipe instruction,
4092 std::size_t instruction_start_index)
4093 {
4094 #warning finish
4095 throw Parser_error(instruction_start_index,
4096 instruction_start_index,
4097 "instruction not implemented: "
4098 + std::string(get_enumerant_name(instruction.get_operation())));
4099 }
4100
4101 void Spirv_to_llvm::handle_instruction_op_reserved_write_pipe(Op_reserved_write_pipe instruction,
4102 std::size_t instruction_start_index)
4103 {
4104 #warning finish
4105 throw Parser_error(instruction_start_index,
4106 instruction_start_index,
4107 "instruction not implemented: "
4108 + std::string(get_enumerant_name(instruction.get_operation())));
4109 }
4110
4111 void Spirv_to_llvm::handle_instruction_op_reserve_read_pipe_packets(
4112 Op_reserve_read_pipe_packets instruction, std::size_t instruction_start_index)
4113 {
4114 #warning finish
4115 throw Parser_error(instruction_start_index,
4116 instruction_start_index,
4117 "instruction not implemented: "
4118 + std::string(get_enumerant_name(instruction.get_operation())));
4119 }
4120
4121 void Spirv_to_llvm::handle_instruction_op_reserve_write_pipe_packets(
4122 Op_reserve_write_pipe_packets instruction, std::size_t instruction_start_index)
4123 {
4124 #warning finish
4125 throw Parser_error(instruction_start_index,
4126 instruction_start_index,
4127 "instruction not implemented: "
4128 + std::string(get_enumerant_name(instruction.get_operation())));
4129 }
4130
4131 void Spirv_to_llvm::handle_instruction_op_commit_read_pipe(Op_commit_read_pipe instruction,
4132 std::size_t instruction_start_index)
4133 {
4134 #warning finish
4135 throw Parser_error(instruction_start_index,
4136 instruction_start_index,
4137 "instruction not implemented: "
4138 + std::string(get_enumerant_name(instruction.get_operation())));
4139 }
4140
4141 void Spirv_to_llvm::handle_instruction_op_commit_write_pipe(Op_commit_write_pipe instruction,
4142 std::size_t instruction_start_index)
4143 {
4144 #warning finish
4145 throw Parser_error(instruction_start_index,
4146 instruction_start_index,
4147 "instruction not implemented: "
4148 + std::string(get_enumerant_name(instruction.get_operation())));
4149 }
4150
4151 void Spirv_to_llvm::handle_instruction_op_is_valid_reserve_id(Op_is_valid_reserve_id instruction,
4152 std::size_t instruction_start_index)
4153 {
4154 #warning finish
4155 throw Parser_error(instruction_start_index,
4156 instruction_start_index,
4157 "instruction not implemented: "
4158 + std::string(get_enumerant_name(instruction.get_operation())));
4159 }
4160
4161 void Spirv_to_llvm::handle_instruction_op_get_num_pipe_packets(Op_get_num_pipe_packets instruction,
4162 std::size_t instruction_start_index)
4163 {
4164 #warning finish
4165 throw Parser_error(instruction_start_index,
4166 instruction_start_index,
4167 "instruction not implemented: "
4168 + std::string(get_enumerant_name(instruction.get_operation())));
4169 }
4170
4171 void Spirv_to_llvm::handle_instruction_op_get_max_pipe_packets(Op_get_max_pipe_packets instruction,
4172 std::size_t instruction_start_index)
4173 {
4174 #warning finish
4175 throw Parser_error(instruction_start_index,
4176 instruction_start_index,
4177 "instruction not implemented: "
4178 + std::string(get_enumerant_name(instruction.get_operation())));
4179 }
4180
4181 void Spirv_to_llvm::handle_instruction_op_group_reserve_read_pipe_packets(
4182 Op_group_reserve_read_pipe_packets instruction, std::size_t instruction_start_index)
4183 {
4184 #warning finish
4185 throw Parser_error(instruction_start_index,
4186 instruction_start_index,
4187 "instruction not implemented: "
4188 + std::string(get_enumerant_name(instruction.get_operation())));
4189 }
4190
4191 void Spirv_to_llvm::handle_instruction_op_group_reserve_write_pipe_packets(
4192 Op_group_reserve_write_pipe_packets instruction, std::size_t instruction_start_index)
4193 {
4194 #warning finish
4195 throw Parser_error(instruction_start_index,
4196 instruction_start_index,
4197 "instruction not implemented: "
4198 + std::string(get_enumerant_name(instruction.get_operation())));
4199 }
4200
4201 void Spirv_to_llvm::handle_instruction_op_group_commit_read_pipe(
4202 Op_group_commit_read_pipe instruction, std::size_t instruction_start_index)
4203 {
4204 #warning finish
4205 throw Parser_error(instruction_start_index,
4206 instruction_start_index,
4207 "instruction not implemented: "
4208 + std::string(get_enumerant_name(instruction.get_operation())));
4209 }
4210
4211 void Spirv_to_llvm::handle_instruction_op_group_commit_write_pipe(
4212 Op_group_commit_write_pipe instruction, std::size_t instruction_start_index)
4213 {
4214 #warning finish
4215 throw Parser_error(instruction_start_index,
4216 instruction_start_index,
4217 "instruction not implemented: "
4218 + std::string(get_enumerant_name(instruction.get_operation())));
4219 }
4220
4221 void Spirv_to_llvm::handle_instruction_op_enqueue_marker(Op_enqueue_marker instruction,
4222 std::size_t instruction_start_index)
4223 {
4224 #warning finish
4225 throw Parser_error(instruction_start_index,
4226 instruction_start_index,
4227 "instruction not implemented: "
4228 + std::string(get_enumerant_name(instruction.get_operation())));
4229 }
4230
4231 void Spirv_to_llvm::handle_instruction_op_enqueue_kernel(Op_enqueue_kernel instruction,
4232 std::size_t instruction_start_index)
4233 {
4234 #warning finish
4235 throw Parser_error(instruction_start_index,
4236 instruction_start_index,
4237 "instruction not implemented: "
4238 + std::string(get_enumerant_name(instruction.get_operation())));
4239 }
4240
4241 void Spirv_to_llvm::handle_instruction_op_get_kernel_n_drange_sub_group_count(
4242 Op_get_kernel_n_drange_sub_group_count instruction, std::size_t instruction_start_index)
4243 {
4244 #warning finish
4245 throw Parser_error(instruction_start_index,
4246 instruction_start_index,
4247 "instruction not implemented: "
4248 + std::string(get_enumerant_name(instruction.get_operation())));
4249 }
4250
4251 void Spirv_to_llvm::handle_instruction_op_get_kernel_n_drange_max_sub_group_size(
4252 Op_get_kernel_n_drange_max_sub_group_size instruction, std::size_t instruction_start_index)
4253 {
4254 #warning finish
4255 throw Parser_error(instruction_start_index,
4256 instruction_start_index,
4257 "instruction not implemented: "
4258 + std::string(get_enumerant_name(instruction.get_operation())));
4259 }
4260
4261 void Spirv_to_llvm::handle_instruction_op_get_kernel_work_group_size(
4262 Op_get_kernel_work_group_size instruction, std::size_t instruction_start_index)
4263 {
4264 #warning finish
4265 throw Parser_error(instruction_start_index,
4266 instruction_start_index,
4267 "instruction not implemented: "
4268 + std::string(get_enumerant_name(instruction.get_operation())));
4269 }
4270
4271 void Spirv_to_llvm::handle_instruction_op_get_kernel_preferred_work_group_size_multiple(
4272 Op_get_kernel_preferred_work_group_size_multiple instruction,
4273 std::size_t instruction_start_index)
4274 {
4275 #warning finish
4276 throw Parser_error(instruction_start_index,
4277 instruction_start_index,
4278 "instruction not implemented: "
4279 + std::string(get_enumerant_name(instruction.get_operation())));
4280 }
4281
4282 void Spirv_to_llvm::handle_instruction_op_retain_event(Op_retain_event instruction,
4283 std::size_t instruction_start_index)
4284 {
4285 #warning finish
4286 throw Parser_error(instruction_start_index,
4287 instruction_start_index,
4288 "instruction not implemented: "
4289 + std::string(get_enumerant_name(instruction.get_operation())));
4290 }
4291
4292 void Spirv_to_llvm::handle_instruction_op_release_event(Op_release_event instruction,
4293 std::size_t instruction_start_index)
4294 {
4295 #warning finish
4296 throw Parser_error(instruction_start_index,
4297 instruction_start_index,
4298 "instruction not implemented: "
4299 + std::string(get_enumerant_name(instruction.get_operation())));
4300 }
4301
4302 void Spirv_to_llvm::handle_instruction_op_create_user_event(Op_create_user_event instruction,
4303 std::size_t instruction_start_index)
4304 {
4305 #warning finish
4306 throw Parser_error(instruction_start_index,
4307 instruction_start_index,
4308 "instruction not implemented: "
4309 + std::string(get_enumerant_name(instruction.get_operation())));
4310 }
4311
4312 void Spirv_to_llvm::handle_instruction_op_is_valid_event(Op_is_valid_event instruction,
4313 std::size_t instruction_start_index)
4314 {
4315 #warning finish
4316 throw Parser_error(instruction_start_index,
4317 instruction_start_index,
4318 "instruction not implemented: "
4319 + std::string(get_enumerant_name(instruction.get_operation())));
4320 }
4321
4322 void Spirv_to_llvm::handle_instruction_op_set_user_event_status(
4323 Op_set_user_event_status instruction, std::size_t instruction_start_index)
4324 {
4325 #warning finish
4326 throw Parser_error(instruction_start_index,
4327 instruction_start_index,
4328 "instruction not implemented: "
4329 + std::string(get_enumerant_name(instruction.get_operation())));
4330 }
4331
4332 void Spirv_to_llvm::handle_instruction_op_capture_event_profiling_info(
4333 Op_capture_event_profiling_info instruction, std::size_t instruction_start_index)
4334 {
4335 #warning finish
4336 throw Parser_error(instruction_start_index,
4337 instruction_start_index,
4338 "instruction not implemented: "
4339 + std::string(get_enumerant_name(instruction.get_operation())));
4340 }
4341
4342 void Spirv_to_llvm::handle_instruction_op_get_default_queue(Op_get_default_queue instruction,
4343 std::size_t instruction_start_index)
4344 {
4345 #warning finish
4346 throw Parser_error(instruction_start_index,
4347 instruction_start_index,
4348 "instruction not implemented: "
4349 + std::string(get_enumerant_name(instruction.get_operation())));
4350 }
4351
4352 void Spirv_to_llvm::handle_instruction_op_build_nd_range(Op_build_nd_range instruction,
4353 std::size_t instruction_start_index)
4354 {
4355 #warning finish
4356 throw Parser_error(instruction_start_index,
4357 instruction_start_index,
4358 "instruction not implemented: "
4359 + std::string(get_enumerant_name(instruction.get_operation())));
4360 }
4361
4362 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_implicit_lod(
4363 Op_image_sparse_sample_implicit_lod instruction, std::size_t instruction_start_index)
4364 {
4365 #warning finish
4366 throw Parser_error(instruction_start_index,
4367 instruction_start_index,
4368 "instruction not implemented: "
4369 + std::string(get_enumerant_name(instruction.get_operation())));
4370 }
4371
4372 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_explicit_lod(
4373 Op_image_sparse_sample_explicit_lod instruction, std::size_t instruction_start_index)
4374 {
4375 #warning finish
4376 throw Parser_error(instruction_start_index,
4377 instruction_start_index,
4378 "instruction not implemented: "
4379 + std::string(get_enumerant_name(instruction.get_operation())));
4380 }
4381
4382 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_dref_implicit_lod(
4383 Op_image_sparse_sample_dref_implicit_lod instruction, std::size_t instruction_start_index)
4384 {
4385 #warning finish
4386 throw Parser_error(instruction_start_index,
4387 instruction_start_index,
4388 "instruction not implemented: "
4389 + std::string(get_enumerant_name(instruction.get_operation())));
4390 }
4391
4392 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_dref_explicit_lod(
4393 Op_image_sparse_sample_dref_explicit_lod instruction, std::size_t instruction_start_index)
4394 {
4395 #warning finish
4396 throw Parser_error(instruction_start_index,
4397 instruction_start_index,
4398 "instruction not implemented: "
4399 + std::string(get_enumerant_name(instruction.get_operation())));
4400 }
4401
4402 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_proj_implicit_lod(
4403 Op_image_sparse_sample_proj_implicit_lod instruction, std::size_t instruction_start_index)
4404 {
4405 #warning finish
4406 throw Parser_error(instruction_start_index,
4407 instruction_start_index,
4408 "instruction not implemented: "
4409 + std::string(get_enumerant_name(instruction.get_operation())));
4410 }
4411
4412 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_proj_explicit_lod(
4413 Op_image_sparse_sample_proj_explicit_lod instruction, std::size_t instruction_start_index)
4414 {
4415 #warning finish
4416 throw Parser_error(instruction_start_index,
4417 instruction_start_index,
4418 "instruction not implemented: "
4419 + std::string(get_enumerant_name(instruction.get_operation())));
4420 }
4421
4422 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_proj_dref_implicit_lod(
4423 Op_image_sparse_sample_proj_dref_implicit_lod instruction, std::size_t instruction_start_index)
4424 {
4425 #warning finish
4426 throw Parser_error(instruction_start_index,
4427 instruction_start_index,
4428 "instruction not implemented: "
4429 + std::string(get_enumerant_name(instruction.get_operation())));
4430 }
4431
4432 void Spirv_to_llvm::handle_instruction_op_image_sparse_sample_proj_dref_explicit_lod(
4433 Op_image_sparse_sample_proj_dref_explicit_lod instruction, std::size_t instruction_start_index)
4434 {
4435 #warning finish
4436 throw Parser_error(instruction_start_index,
4437 instruction_start_index,
4438 "instruction not implemented: "
4439 + std::string(get_enumerant_name(instruction.get_operation())));
4440 }
4441
4442 void Spirv_to_llvm::handle_instruction_op_image_sparse_fetch(Op_image_sparse_fetch instruction,
4443 std::size_t instruction_start_index)
4444 {
4445 #warning finish
4446 throw Parser_error(instruction_start_index,
4447 instruction_start_index,
4448 "instruction not implemented: "
4449 + std::string(get_enumerant_name(instruction.get_operation())));
4450 }
4451
4452 void Spirv_to_llvm::handle_instruction_op_image_sparse_gather(Op_image_sparse_gather instruction,
4453 std::size_t instruction_start_index)
4454 {
4455 #warning finish
4456 throw Parser_error(instruction_start_index,
4457 instruction_start_index,
4458 "instruction not implemented: "
4459 + std::string(get_enumerant_name(instruction.get_operation())));
4460 }
4461
4462 void Spirv_to_llvm::handle_instruction_op_image_sparse_dref_gather(
4463 Op_image_sparse_dref_gather instruction, std::size_t instruction_start_index)
4464 {
4465 #warning finish
4466 throw Parser_error(instruction_start_index,
4467 instruction_start_index,
4468 "instruction not implemented: "
4469 + std::string(get_enumerant_name(instruction.get_operation())));
4470 }
4471
4472 void Spirv_to_llvm::handle_instruction_op_image_sparse_texels_resident(
4473 Op_image_sparse_texels_resident instruction, std::size_t instruction_start_index)
4474 {
4475 #warning finish
4476 throw Parser_error(instruction_start_index,
4477 instruction_start_index,
4478 "instruction not implemented: "
4479 + std::string(get_enumerant_name(instruction.get_operation())));
4480 }
4481
4482 void Spirv_to_llvm::handle_instruction_op_no_line(Op_no_line instruction,
4483 std::size_t instruction_start_index)
4484 {
4485 #warning finish
4486 throw Parser_error(instruction_start_index,
4487 instruction_start_index,
4488 "instruction not implemented: "
4489 + std::string(get_enumerant_name(instruction.get_operation())));
4490 }
4491
4492 void Spirv_to_llvm::handle_instruction_op_atomic_flag_test_and_set(
4493 Op_atomic_flag_test_and_set instruction, std::size_t instruction_start_index)
4494 {
4495 #warning finish
4496 throw Parser_error(instruction_start_index,
4497 instruction_start_index,
4498 "instruction not implemented: "
4499 + std::string(get_enumerant_name(instruction.get_operation())));
4500 }
4501
4502 void Spirv_to_llvm::handle_instruction_op_atomic_flag_clear(Op_atomic_flag_clear instruction,
4503 std::size_t instruction_start_index)
4504 {
4505 #warning finish
4506 throw Parser_error(instruction_start_index,
4507 instruction_start_index,
4508 "instruction not implemented: "
4509 + std::string(get_enumerant_name(instruction.get_operation())));
4510 }
4511
4512 void Spirv_to_llvm::handle_instruction_op_image_sparse_read(Op_image_sparse_read instruction,
4513 std::size_t instruction_start_index)
4514 {
4515 #warning finish
4516 throw Parser_error(instruction_start_index,
4517 instruction_start_index,
4518 "instruction not implemented: "
4519 + std::string(get_enumerant_name(instruction.get_operation())));
4520 }
4521
4522 void Spirv_to_llvm::handle_instruction_op_size_of(Op_size_of instruction,
4523 std::size_t instruction_start_index)
4524 {
4525 #warning finish
4526 throw Parser_error(instruction_start_index,
4527 instruction_start_index,
4528 "instruction not implemented: "
4529 + std::string(get_enumerant_name(instruction.get_operation())));
4530 }
4531
4532 void Spirv_to_llvm::handle_instruction_op_type_pipe_storage(Op_type_pipe_storage instruction,
4533 std::size_t instruction_start_index)
4534 {
4535 #warning finish
4536 throw Parser_error(instruction_start_index,
4537 instruction_start_index,
4538 "instruction not implemented: "
4539 + std::string(get_enumerant_name(instruction.get_operation())));
4540 }
4541
4542 void Spirv_to_llvm::handle_instruction_op_constant_pipe_storage(
4543 Op_constant_pipe_storage instruction, std::size_t instruction_start_index)
4544 {
4545 #warning finish
4546 throw Parser_error(instruction_start_index,
4547 instruction_start_index,
4548 "instruction not implemented: "
4549 + std::string(get_enumerant_name(instruction.get_operation())));
4550 }
4551
4552 void Spirv_to_llvm::handle_instruction_op_create_pipe_from_pipe_storage(
4553 Op_create_pipe_from_pipe_storage instruction, std::size_t instruction_start_index)
4554 {
4555 #warning finish
4556 throw Parser_error(instruction_start_index,
4557 instruction_start_index,
4558 "instruction not implemented: "
4559 + std::string(get_enumerant_name(instruction.get_operation())));
4560 }
4561
4562 void Spirv_to_llvm::handle_instruction_op_get_kernel_local_size_for_subgroup_count(
4563 Op_get_kernel_local_size_for_subgroup_count instruction, std::size_t instruction_start_index)
4564 {
4565 #warning finish
4566 throw Parser_error(instruction_start_index,
4567 instruction_start_index,
4568 "instruction not implemented: "
4569 + std::string(get_enumerant_name(instruction.get_operation())));
4570 }
4571
4572 void Spirv_to_llvm::handle_instruction_op_get_kernel_max_num_subgroups(
4573 Op_get_kernel_max_num_subgroups instruction, std::size_t instruction_start_index)
4574 {
4575 #warning finish
4576 throw Parser_error(instruction_start_index,
4577 instruction_start_index,
4578 "instruction not implemented: "
4579 + std::string(get_enumerant_name(instruction.get_operation())));
4580 }
4581
4582 void Spirv_to_llvm::handle_instruction_op_type_named_barrier(Op_type_named_barrier instruction,
4583 std::size_t instruction_start_index)
4584 {
4585 #warning finish
4586 throw Parser_error(instruction_start_index,
4587 instruction_start_index,
4588 "instruction not implemented: "
4589 + std::string(get_enumerant_name(instruction.get_operation())));
4590 }
4591
4592 void Spirv_to_llvm::handle_instruction_op_named_barrier_initialize(
4593 Op_named_barrier_initialize instruction, std::size_t instruction_start_index)
4594 {
4595 #warning finish
4596 throw Parser_error(instruction_start_index,
4597 instruction_start_index,
4598 "instruction not implemented: "
4599 + std::string(get_enumerant_name(instruction.get_operation())));
4600 }
4601
4602 void Spirv_to_llvm::handle_instruction_op_memory_named_barrier(Op_memory_named_barrier instruction,
4603 std::size_t instruction_start_index)
4604 {
4605 #warning finish
4606 throw Parser_error(instruction_start_index,
4607 instruction_start_index,
4608 "instruction not implemented: "
4609 + std::string(get_enumerant_name(instruction.get_operation())));
4610 }
4611
4612 void Spirv_to_llvm::handle_instruction_op_module_processed(Op_module_processed instruction,
4613 std::size_t instruction_start_index)
4614 {
4615 #warning finish
4616 throw Parser_error(instruction_start_index,
4617 instruction_start_index,
4618 "instruction not implemented: "
4619 + std::string(get_enumerant_name(instruction.get_operation())));
4620 }
4621
4622 void Spirv_to_llvm::handle_instruction_op_execution_mode_id(Op_execution_mode_id instruction,
4623 std::size_t instruction_start_index)
4624 {
4625 #warning finish
4626 throw Parser_error(instruction_start_index,
4627 instruction_start_index,
4628 "instruction not implemented: "
4629 + std::string(get_enumerant_name(instruction.get_operation())));
4630 }
4631
4632 void Spirv_to_llvm::handle_instruction_op_decorate_id(Op_decorate_id instruction,
4633 std::size_t instruction_start_index)
4634 {
4635 #warning finish
4636 throw Parser_error(instruction_start_index,
4637 instruction_start_index,
4638 "instruction not implemented: "
4639 + std::string(get_enumerant_name(instruction.get_operation())));
4640 }
4641
4642 void Spirv_to_llvm::handle_instruction_op_subgroup_ballot_khr(Op_subgroup_ballot_khr instruction,
4643 std::size_t instruction_start_index)
4644 {
4645 #warning finish
4646 throw Parser_error(instruction_start_index,
4647 instruction_start_index,
4648 "instruction not implemented: "
4649 + std::string(get_enumerant_name(instruction.get_operation())));
4650 }
4651
4652 void Spirv_to_llvm::handle_instruction_op_subgroup_first_invocation_khr(
4653 Op_subgroup_first_invocation_khr instruction, std::size_t instruction_start_index)
4654 {
4655 #warning finish
4656 throw Parser_error(instruction_start_index,
4657 instruction_start_index,
4658 "instruction not implemented: "
4659 + std::string(get_enumerant_name(instruction.get_operation())));
4660 }
4661
4662 void Spirv_to_llvm::handle_instruction_op_subgroup_all_khr(Op_subgroup_all_khr instruction,
4663 std::size_t instruction_start_index)
4664 {
4665 #warning finish
4666 throw Parser_error(instruction_start_index,
4667 instruction_start_index,
4668 "instruction not implemented: "
4669 + std::string(get_enumerant_name(instruction.get_operation())));
4670 }
4671
4672 void Spirv_to_llvm::handle_instruction_op_subgroup_any_khr(Op_subgroup_any_khr instruction,
4673 std::size_t instruction_start_index)
4674 {
4675 #warning finish
4676 throw Parser_error(instruction_start_index,
4677 instruction_start_index,
4678 "instruction not implemented: "
4679 + std::string(get_enumerant_name(instruction.get_operation())));
4680 }
4681
4682 void Spirv_to_llvm::handle_instruction_op_subgroup_all_equal_khr(
4683 Op_subgroup_all_equal_khr instruction, std::size_t instruction_start_index)
4684 {
4685 #warning finish
4686 throw Parser_error(instruction_start_index,
4687 instruction_start_index,
4688 "instruction not implemented: "
4689 + std::string(get_enumerant_name(instruction.get_operation())));
4690 }
4691
4692 void Spirv_to_llvm::handle_instruction_op_subgroup_read_invocation_khr(
4693 Op_subgroup_read_invocation_khr instruction, std::size_t instruction_start_index)
4694 {
4695 #warning finish
4696 throw Parser_error(instruction_start_index,
4697 instruction_start_index,
4698 "instruction not implemented: "
4699 + std::string(get_enumerant_name(instruction.get_operation())));
4700 }
4701 }
4702 }