Blender V5.3
multi_function_procedure.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "BLI_dot_export.hh"
12#include "BLI_stack.hh"
13
14#include <sstream>
15
17
18void InstructionCursor::set_next(Procedure &procedure, Instruction *new_instruction) const
19{
20 switch (type_) {
21 case Type::None: {
22 break;
23 }
24 case Type::Entry: {
25 procedure.set_entry(*new_instruction);
26 break;
27 }
28 case Type::Call: {
29 static_cast<CallInstruction *>(instruction_)->set_next(new_instruction);
30 break;
31 }
32 case Type::Branch: {
33 BranchInstruction &branch_instruction = *static_cast<BranchInstruction *>(instruction_);
34 if (branch_output_) {
35 branch_instruction.set_branch_true(new_instruction);
36 }
37 else {
38 branch_instruction.set_branch_false(new_instruction);
39 }
40 break;
41 }
42 case Type::Destruct: {
43 static_cast<DestructInstruction *>(instruction_)->set_next(new_instruction);
44 break;
45 }
46 case Type::Dummy: {
47 static_cast<DummyInstruction *>(instruction_)->set_next(new_instruction);
48 break;
49 }
50 }
51}
52
54{
55 switch (type_) {
56 case Type::None:
57 return nullptr;
58 case Type::Entry:
59 return procedure.entry();
60 case Type::Call:
61 return static_cast<CallInstruction *>(instruction_)->next();
62 case Type::Branch: {
63 BranchInstruction &branch_instruction = *static_cast<BranchInstruction *>(instruction_);
64 if (branch_output_) {
65 return branch_instruction.branch_true();
66 }
67 return branch_instruction.branch_false();
68 }
69 case Type::Destruct:
70 return static_cast<DestructInstruction *>(instruction_)->next();
71 case Type::Dummy:
72 return static_cast<DummyInstruction *>(instruction_)->next();
73 }
74 return nullptr;
75}
76
77void Variable::set_name(std::string name)
78{
79 name_ = std::move(name);
80}
81
83{
84 if (next_ != nullptr) {
85 next_->prev_.remove_first_occurrence_and_reorder(*this);
86 }
87 if (instruction != nullptr) {
88 instruction->prev_.append(*this);
89 }
90 next_ = instruction;
91}
92
93void CallInstruction::set_param_variable(int param_index, Variable *variable)
94{
95 if (params_[param_index] != nullptr) {
96 params_[param_index]->users_.remove_first_occurrence_and_reorder(this);
97 }
98 if (variable != nullptr) {
99#ifndef NDEBUG
100 const ParamType param_type = fn_->param_type(param_index);
101 BLI_assert(param_type.data_type() == variable->data_type());
102#endif
103 variable->users_.append(this);
104 }
105 params_[param_index] = variable;
106}
107
109{
110 BLI_assert(variables.size() == params_.size());
111 for (const int i : variables.index_range()) {
112 this->set_param_variable(i, variables[i]);
113 }
114}
115
117{
118 if (condition_ != nullptr) {
119 condition_->users_.remove_first_occurrence_and_reorder(this);
120 }
121 if (variable != nullptr) {
122 variable->users_.append(this);
123 }
124 condition_ = variable;
125}
126
128{
129 if (branch_true_ != nullptr) {
130 branch_true_->prev_.remove_first_occurrence_and_reorder({*this, true});
131 }
132 if (instruction != nullptr) {
133 instruction->prev_.append({*this, true});
134 }
135 branch_true_ = instruction;
136}
137
139{
140 if (branch_false_ != nullptr) {
141 branch_false_->prev_.remove_first_occurrence_and_reorder({*this, false});
142 }
143 if (instruction != nullptr) {
144 instruction->prev_.append({*this, false});
145 }
146 branch_false_ = instruction;
147}
148
150{
151 if (variable_ != nullptr) {
152 variable_->users_.remove_first_occurrence_and_reorder(this);
153 }
154 if (variable != nullptr) {
155 variable->users_.append(this);
156 }
157 variable_ = variable;
158}
159
161{
162 if (next_ != nullptr) {
163 next_->prev_.remove_first_occurrence_and_reorder(*this);
164 }
165 if (instruction != nullptr) {
166 instruction->prev_.append(*this);
167 }
168 next_ = instruction;
169}
170
172{
173 if (next_ != nullptr) {
174 next_->prev_.remove_first_occurrence_and_reorder(*this);
175 }
176 if (instruction != nullptr) {
177 instruction->prev_.append(*this);
178 }
179 next_ = instruction;
180}
181
182Variable &Procedure::new_variable(DataType data_type, std::string name)
183{
184 Variable &variable = *allocator_.construct<Variable>().release();
185 variable.name_ = std::move(name);
186 variable.data_type_ = data_type;
187 variable.index_in_graph_ = variables_.size();
188 variables_.append(&variable);
189 return variable;
190}
191
193{
194 CallInstruction &instruction = *allocator_.construct<CallInstruction>().release();
195 instruction.type_ = InstructionType::Call;
196 instruction.fn_ = &fn;
197 instruction.params_ = allocator_.allocate_array<Variable *>(fn.param_amount());
198 instruction.params_.fill(nullptr);
199 call_instructions_.append(&instruction);
200 return instruction;
201}
202
204{
205 BranchInstruction &instruction = *allocator_.construct<BranchInstruction>().release();
206 instruction.type_ = InstructionType::Branch;
207 branch_instructions_.append(&instruction);
208 return instruction;
209}
210
212{
213 DestructInstruction &instruction = *allocator_.construct<DestructInstruction>().release();
214 instruction.type_ = InstructionType::Destruct;
215 destruct_instructions_.append(&instruction);
216 return instruction;
217}
218
220{
221 DummyInstruction &instruction = *allocator_.construct<DummyInstruction>().release();
222 instruction.type_ = InstructionType::Dummy;
223 dummy_instructions_.append(&instruction);
224 return instruction;
225}
226
228{
229 ReturnInstruction &instruction = *allocator_.construct<ReturnInstruction>().release();
230 instruction.type_ = InstructionType::Return;
231 return_instructions_.append(&instruction);
232 return instruction;
233}
234
236{
237 params_.append({interface_type, &variable});
238}
239
241{
242 if (entry_ != nullptr) {
243 entry_->prev_.remove_first_occurrence_and_reorder(InstructionCursor::ForEntry());
244 }
245 entry_ = &entry;
246 entry_->prev_.append(InstructionCursor::ForEntry());
247}
248
250{
251 for (CallInstruction *instruction : call_instructions_) {
252 instruction->~CallInstruction();
253 }
254 for (BranchInstruction *instruction : branch_instructions_) {
255 instruction->~BranchInstruction();
256 }
257 for (DestructInstruction *instruction : destruct_instructions_) {
258 instruction->~DestructInstruction();
259 }
260 for (DummyInstruction *instruction : dummy_instructions_) {
261 instruction->~DummyInstruction();
262 }
263 for (ReturnInstruction *instruction : return_instructions_) {
264 instruction->~ReturnInstruction();
265 }
266 for (Variable *variable : variables_) {
267 variable->~Variable();
268 }
269}
270
272{
273 if (entry_ == nullptr) {
274 return false;
275 }
276 if (!this->validate_all_instruction_pointers_set()) {
277 return false;
278 }
279 if (!this->validate_all_params_provided()) {
280 return false;
281 }
282 if (!this->validate_same_variables_in_one_call()) {
283 return false;
284 }
285 if (!this->validate_parameters()) {
286 return false;
287 }
288 if (!this->validate_initialization()) {
289 return false;
290 }
291 return true;
292}
293
295{
296 for (const CallInstruction *instruction : call_instructions_) {
297 instruction->fn().prepare_for_execution();
298 }
299}
300
301bool Procedure::validate_all_instruction_pointers_set() const
302{
303 for (const CallInstruction *instruction : call_instructions_) {
304 if (instruction->next_ == nullptr) {
305 return false;
306 }
307 }
308 for (const DestructInstruction *instruction : destruct_instructions_) {
309 if (instruction->next_ == nullptr) {
310 return false;
311 }
312 }
313 for (const BranchInstruction *instruction : branch_instructions_) {
314 if (instruction->branch_true_ == nullptr) {
315 return false;
316 }
317 if (instruction->branch_false_ == nullptr) {
318 return false;
319 }
320 }
321 for (const DummyInstruction *instruction : dummy_instructions_) {
322 if (instruction->next_ == nullptr) {
323 return false;
324 }
325 }
326 return true;
327}
328
329bool Procedure::validate_all_params_provided() const
330{
331 for (const CallInstruction *instruction : call_instructions_) {
332 const MultiFunction &fn = instruction->fn();
333 for (const int param_index : fn.param_indices()) {
334 const ParamType param_type = fn.param_type(param_index);
335 if (param_type.category() == ParamCategory::SingleOutput) {
336 /* Single outputs are optional. */
337 continue;
338 }
339 const Variable *variable = instruction->params_[param_index];
340 if (variable == nullptr) {
341 return false;
342 }
343 }
344 }
345 for (const BranchInstruction *instruction : branch_instructions_) {
346 if (instruction->condition_ == nullptr) {
347 return false;
348 }
349 }
350 for (const DestructInstruction *instruction : destruct_instructions_) {
351 if (instruction->variable_ == nullptr) {
352 return false;
353 }
354 }
355 return true;
356}
357
358bool Procedure::validate_same_variables_in_one_call() const
359{
360 for (const CallInstruction *instruction : call_instructions_) {
361 const MultiFunction &fn = *instruction->fn_;
362 for (const int param_index : fn.param_indices()) {
363 const ParamType param_type = fn.param_type(param_index);
364 const Variable *variable = instruction->params_[param_index];
365 if (variable == nullptr) {
366 continue;
367 }
368 for (const int other_param_index : fn.param_indices()) {
369 if (other_param_index == param_index) {
370 continue;
371 }
372 const Variable *other_variable = instruction->params_[other_param_index];
373 if (other_variable != variable) {
374 continue;
375 }
376 if (ELEM(param_type.interface_type(), ParamType::Mutable, ParamType::Output)) {
377 /* When a variable is used as mutable or output parameter, it can only be used once. */
378 return false;
379 }
380 const ParamType other_param_type = fn.param_type(other_param_index);
381 /* A variable is allowed to be used as input more than once. */
382 if (other_param_type.interface_type() != ParamType::Input) {
383 return false;
384 }
385 }
386 }
387 }
388 return true;
389}
390
391bool Procedure::validate_parameters() const
392{
393 Set<const Variable *> variables;
394 for (const Parameter &param : params_) {
395 /* One variable cannot be used as multiple parameters. */
396 if (!variables.add(param.variable)) {
397 return false;
398 }
399 }
400 return true;
401}
402
403bool Procedure::validate_initialization() const
404{
405 /* TODO: Issue warning when it maybe wrongly initialized. */
406 for (const DestructInstruction *instruction : destruct_instructions_) {
407 const Variable &variable = *instruction->variable_;
408 const InitState state = this->find_initialization_state_before_instruction(*instruction,
409 variable);
410 if (!state.can_be_initialized) {
411 return false;
412 }
413 }
414 for (const BranchInstruction *instruction : branch_instructions_) {
415 const Variable &variable = *instruction->condition_;
416 const InitState state = this->find_initialization_state_before_instruction(*instruction,
417 variable);
418 if (!state.can_be_initialized) {
419 return false;
420 }
421 }
422 for (const CallInstruction *instruction : call_instructions_) {
423 const MultiFunction &fn = *instruction->fn_;
424 for (const int param_index : fn.param_indices()) {
425 const ParamType param_type = fn.param_type(param_index);
426 /* If the parameter was an unneeded output, it could be null. */
427 if (!instruction->params_[param_index]) {
428 continue;
429 }
430 const Variable &variable = *instruction->params_[param_index];
431 const InitState state = this->find_initialization_state_before_instruction(*instruction,
432 variable);
433 switch (param_type.interface_type()) {
434 case ParamType::Input:
435 case ParamType::Mutable: {
436 if (!state.can_be_initialized) {
437 return false;
438 }
439 break;
440 }
441 case ParamType::Output: {
442 if (!state.can_be_uninitialized) {
443 return false;
444 }
445 break;
446 }
447 }
448 }
449 }
450 Set<const Variable *> variables_that_should_be_initialized_on_return;
451 for (const Parameter &param : params_) {
452 if (ELEM(param.type, ParamType::Mutable, ParamType::Output)) {
453 variables_that_should_be_initialized_on_return.add_new(param.variable);
454 }
455 }
456 for (const ReturnInstruction *instruction : return_instructions_) {
457 for (const Variable *variable : variables_) {
458 const InitState init_state = this->find_initialization_state_before_instruction(*instruction,
459 *variable);
460 if (variables_that_should_be_initialized_on_return.contains(variable)) {
461 if (!init_state.can_be_initialized) {
462 return false;
463 }
464 }
465 else {
466 if (!init_state.can_be_uninitialized) {
467 return false;
468 }
469 }
470 }
471 }
472 return true;
473}
474
475Procedure::InitState Procedure::find_initialization_state_before_instruction(
476 const Instruction &target_instruction, const Variable &target_variable) const
477{
478 InitState state;
479
480 auto check_entry_instruction = [&]() {
481 bool caller_initialized_variable = false;
482 for (const Parameter &param : params_) {
483 if (param.variable == &target_variable) {
484 if (ELEM(param.type, ParamType::Input, ParamType::Mutable)) {
485 caller_initialized_variable = true;
486 break;
487 }
488 }
489 }
490 if (caller_initialized_variable) {
491 state.can_be_initialized = true;
492 }
493 else {
494 state.can_be_uninitialized = true;
495 }
496 };
497
498 if (&target_instruction == entry_) {
499 check_entry_instruction();
500 }
501
502 Set<const Instruction *> checked_instructions;
503 Stack<const Instruction *> instructions_to_check;
504 for (const InstructionCursor &cursor : target_instruction.prev_) {
505 if (cursor.instruction() != nullptr) {
506 instructions_to_check.push(cursor.instruction());
507 }
508 }
509
510 while (!instructions_to_check.is_empty()) {
511 const Instruction &instruction = *instructions_to_check.pop();
512 if (!checked_instructions.add(&instruction)) {
513 /* Skip if the instruction has been checked already. */
514 continue;
515 }
516 bool state_modified = false;
517 switch (instruction.type_) {
519 const CallInstruction &call_instruction = static_cast<const CallInstruction &>(
520 instruction);
521 const MultiFunction &fn = *call_instruction.fn_;
522 for (const int param_index : fn.param_indices()) {
523 if (call_instruction.params_[param_index] == &target_variable) {
524 const ParamType param_type = fn.param_type(param_index);
525 if (param_type.interface_type() == ParamType::Output) {
526 state.can_be_initialized = true;
527 state_modified = true;
528 break;
529 }
530 }
531 }
532 break;
533 }
535 const DestructInstruction &destruct_instruction = static_cast<const DestructInstruction &>(
536 instruction);
537 if (destruct_instruction.variable_ == &target_variable) {
538 state.can_be_uninitialized = true;
539 state_modified = true;
540 }
541 break;
542 }
546 /* These instruction types don't change the initialization state of variables. */
547 break;
548 }
549 }
550
551 if (!state_modified) {
552 if (&instruction == entry_) {
553 check_entry_instruction();
554 }
555 for (const InstructionCursor &cursor : instruction.prev_) {
556 if (cursor.instruction() != nullptr) {
557 instructions_to_check.push(cursor.instruction());
558 }
559 }
560 }
561 }
562
563 return state;
564}
565
567 private:
568 const Procedure &procedure_;
572
573 public:
574 ProcedureDotExport(const Procedure &procedure) : procedure_(procedure) {}
575
576 std::string generate()
577 {
578 this->create_nodes();
579 this->create_edges();
580 return digraph_.to_dot_string();
581 }
582
584 {
585 Vector<const Instruction *> all_instructions;
586 auto add_instructions = [&](auto instructions) {
587 all_instructions.extend(instructions.begin(), instructions.end());
588 };
589 add_instructions(procedure_.call_instructions_);
590 add_instructions(procedure_.branch_instructions_);
591 add_instructions(procedure_.destruct_instructions_);
592 add_instructions(procedure_.dummy_instructions_);
593 add_instructions(procedure_.return_instructions_);
594
595 Set<const Instruction *> handled_instructions;
596
597 for (const Instruction *representative : all_instructions) {
598 if (handled_instructions.contains(representative)) {
599 continue;
600 }
602 *representative);
603 std::stringstream ss;
604 ss << "<";
605
606 for (const Instruction *current : block_instructions) {
607 handled_instructions.add_new(current);
608 switch (current->type()) {
610 this->instruction_to_string(*static_cast<const CallInstruction *>(current), ss);
611 break;
612 }
614 this->instruction_to_string(*static_cast<const DestructInstruction *>(current), ss);
615 break;
616 }
618 this->instruction_to_string(*static_cast<const DummyInstruction *>(current), ss);
619 break;
620 }
622 this->instruction_to_string(*static_cast<const ReturnInstruction *>(current), ss);
623 break;
624 }
626 this->instruction_to_string(*static_cast<const BranchInstruction *>(current), ss);
627 break;
628 }
629 }
630 ss << R"(<br align="left" />)";
631 }
632 ss << ">";
633
634 dot_export::Node &dot_node = digraph_.new_node(ss.str());
636 dot_nodes_by_begin_.add_new(block_instructions.first(), &dot_node);
637 dot_nodes_by_end_.add_new(block_instructions.last(), &dot_node);
638 }
639 }
640
642 {
643 auto create_edge = [&](dot_export::Node &from_node,
644 const Instruction *to_instruction) -> dot_export::DirectedEdge & {
645 if (to_instruction == nullptr) {
646 dot_export::Node &to_node = digraph_.new_node("missing");
648 return digraph_.new_edge(from_node, to_node);
649 }
650 dot_export::Node &to_node = *dot_nodes_by_begin_.lookup(to_instruction);
651 return digraph_.new_edge(from_node, to_node);
652 };
653
654 for (auto item : dot_nodes_by_end_.items()) {
655 const Instruction &from_instruction = *item.key;
656 dot_export::Node &from_node = *item.value;
657 switch (from_instruction.type()) {
659 const Instruction *to_instruction =
660 static_cast<const CallInstruction &>(from_instruction).next();
661 create_edge(from_node, to_instruction);
662 break;
663 }
665 const Instruction *to_instruction =
666 static_cast<const DestructInstruction &>(from_instruction).next();
667 create_edge(from_node, to_instruction);
668 break;
669 }
671 const Instruction *to_instruction =
672 static_cast<const DummyInstruction &>(from_instruction).next();
673 create_edge(from_node, to_instruction);
674 break;
675 }
677 break;
678 }
680 const BranchInstruction &branch_instruction = static_cast<const BranchInstruction &>(
681 from_instruction);
682 const Instruction *to_true_instruction = branch_instruction.branch_true();
683 const Instruction *to_false_instruction = branch_instruction.branch_false();
684 create_edge(from_node, to_true_instruction).attributes.set("color", "#118811");
685 create_edge(from_node, to_false_instruction).attributes.set("color", "#881111");
686 break;
687 }
688 }
689 }
690
691 dot_export::Node &entry_node = this->create_entry_node();
692 create_edge(entry_node, procedure_.entry());
693 }
694
695 bool has_to_be_block_begin(const Instruction &instruction)
696 {
697 if (instruction.prev().size() != 1) {
698 return true;
699 }
700 if (ELEM(instruction.prev()[0].type(),
703 {
704 return true;
705 }
706 return false;
707 }
708
710 {
711 const Instruction *current = &representative;
712 while (!this->has_to_be_block_begin(*current)) {
713 current = current->prev()[0].instruction();
714 if (current == &representative) {
715 /* There is a loop without entry or exit, just break it up here. */
716 break;
717 }
718 }
719 return *current;
720 }
721
723 const Instruction &block_begin)
724 {
725 const Instruction *next = nullptr;
726 switch (instruction.type()) {
728 next = static_cast<const CallInstruction &>(instruction).next();
729 break;
730 }
732 next = static_cast<const DestructInstruction &>(instruction).next();
733 break;
734 }
736 next = static_cast<const DummyInstruction &>(instruction).next();
737 break;
738 }
741 break;
742 }
743 }
744 if (next == nullptr) {
745 return nullptr;
746 }
747 if (next == &block_begin) {
748 return nullptr;
749 }
750 if (this->has_to_be_block_begin(*next)) {
751 return nullptr;
752 }
753 return next;
754 }
755
757 {
758 Vector<const Instruction *> instructions;
759 const Instruction &begin = this->get_first_instruction_in_block(representative);
760 for (const Instruction *current = &begin; current != nullptr;
761 current = this->get_next_instruction_in_block(*current, begin))
762 {
763 instructions.append(current);
764 }
765 return instructions;
766 }
767
768 void variable_to_string(const Variable *variable, std::stringstream &ss)
769 {
770 if (variable == nullptr) {
771 ss << "null";
772 }
773 else {
774 ss << "$" << variable->index_in_procedure();
775 if (!variable->name().is_empty()) {
776 ss << "(" << variable->name() << ")";
777 }
778 }
779 }
780
781 void instruction_name_format(StringRef name, std::stringstream &ss)
782 {
783 ss << name;
784 }
785
786 void instruction_to_string(const CallInstruction &instruction, std::stringstream &ss)
787 {
788 const MultiFunction &fn = instruction.fn();
789 this->instruction_name_format(fn.debug_name() + ": ", ss);
790 for (const int param_index : fn.param_indices()) {
791 const ParamType param_type = fn.param_type(param_index);
792 const Variable *variable = instruction.params()[param_index];
793 ss << R"(<font color="grey30">)";
794 switch (param_type.interface_type()) {
795 case ParamType::Input: {
796 ss << "in";
797 break;
798 }
799 case ParamType::Mutable: {
800 ss << "mut";
801 break;
802 }
803 case ParamType::Output: {
804 ss << "out";
805 break;
806 }
807 }
808 ss << " </font> ";
809 variable_to_string(variable, ss);
810 if (param_index < fn.param_amount() - 1) {
811 ss << ", ";
812 }
813 }
814 }
815
816 void instruction_to_string(const DestructInstruction &instruction, std::stringstream &ss)
817 {
818 instruction_name_format("Destruct ", ss);
819 variable_to_string(instruction.variable(), ss);
820 }
821
822 void instruction_to_string(const DummyInstruction & /*instruction*/, std::stringstream &ss)
823 {
824 instruction_name_format("Dummy ", ss);
825 }
826
827 void instruction_to_string(const ReturnInstruction & /*instruction*/, std::stringstream &ss)
828 {
829 instruction_name_format("Return ", ss);
830
831 Vector<ConstParameter> outgoing_parameters;
832 for (const ConstParameter &param : procedure_.params()) {
833 if (ELEM(param.type, ParamType::Mutable, ParamType::Output)) {
834 outgoing_parameters.append(param);
835 }
836 }
837 for (const int param_index : outgoing_parameters.index_range()) {
838 const ConstParameter &param = outgoing_parameters[param_index];
839 variable_to_string(param.variable, ss);
840 if (param_index < outgoing_parameters.size() - 1) {
841 ss << ", ";
842 }
843 }
844 }
845
846 void instruction_to_string(const BranchInstruction &instruction, std::stringstream &ss)
847 {
848 instruction_name_format("Branch ", ss);
849 variable_to_string(instruction.condition(), ss);
850 }
851
853 {
854 std::stringstream ss;
855 ss << "Entry: ";
856 Vector<ConstParameter> incoming_parameters;
857 for (const ConstParameter &param : procedure_.params()) {
858 if (ELEM(param.type, ParamType::Input, ParamType::Mutable)) {
859 incoming_parameters.append(param);
860 }
861 }
862 for (const int param_index : incoming_parameters.index_range()) {
863 const ConstParameter &param = incoming_parameters[param_index];
864 variable_to_string(param.variable, ss);
865 if (param_index < incoming_parameters.size() - 1) {
866 ss << ", ";
867 }
868 }
869
870 dot_export::Node &node = digraph_.new_node(ss.str());
872 return node;
873 }
874};
875
876std::string Procedure::to_dot() const
877{
879 return dot_export.generate();
880}
881
882} // namespace blender::fn::multi_function
#define ELEM(...)
bool contains(const Key &key) const
Definition BLI_set.hh:310
void add_new(const Key &key)
Definition BLI_set.hh:233
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
int64_t size() const
void append(const T &value)
const T & last(const int64_t n=0) const
IndexRange index_range() const
void extend(Span< T > array)
const T & first() const
constexpr bool is_empty() const
void set_shape(Attr_shape shape)
void set_param_variable(int param_index, Variable *variable)
void set_next(Procedure &procedure, Instruction *new_instruction) const
Instruction * next(Procedure &procedure) const
void instruction_to_string(const DestructInstruction &instruction, std::stringstream &ss)
void variable_to_string(const Variable *variable, std::stringstream &ss)
void instruction_to_string(const BranchInstruction &instruction, std::stringstream &ss)
const Instruction & get_first_instruction_in_block(const Instruction &representative)
const Instruction * get_next_instruction_in_block(const Instruction &instruction, const Instruction &block_begin)
void instruction_to_string(const ReturnInstruction &, std::stringstream &ss)
void instruction_to_string(const CallInstruction &instruction, std::stringstream &ss)
void instruction_to_string(const DummyInstruction &, std::stringstream &ss)
Vector< const Instruction * > get_instructions_in_block(const Instruction &representative)
void instruction_name_format(StringRef name, std::stringstream &ss)
bool has_to_be_block_begin(const Instruction &instruction)
CallInstruction & new_call_instruction(const MultiFunction &fn)
void add_parameter(ParamType::InterfaceType interface_type, Variable &variable)
Variable & new_variable(DataType data_type, std::string name="")
const int state
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
iter begin(iter)