mirror of
https://git.suyu.dev/suyu/sirit.git
synced 2025-12-29 02:36:56 +01:00
Use variant instead of creating an object for literals
This commit is contained in:
parent
8f8115d397
commit
00fc8daf56
12 changed files with 146 additions and 144 deletions
|
|
@ -4,12 +4,13 @@
|
|||
* Lesser General Public License version 2.1 or any later version.
|
||||
*/
|
||||
|
||||
#include "sirit/sirit.h"
|
||||
#include "insts.h"
|
||||
#include "sirit/sirit.h"
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
Ref Module::LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask loop_control,
|
||||
Ref Module::LoopMerge(Ref merge_block, Ref continue_target,
|
||||
spv::LoopControlMask loop_control,
|
||||
const std::vector<Ref>& literals) {
|
||||
auto op{new Op(spv::Op::OpLoopMerge)};
|
||||
op->Add(merge_block);
|
||||
|
|
@ -19,16 +20,15 @@ Ref Module::LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask
|
|||
return AddCode(op);
|
||||
}
|
||||
|
||||
Ref Module::SelectionMerge(Ref merge_block, spv::SelectionControlMask selection_control) {
|
||||
Ref Module::SelectionMerge(Ref merge_block,
|
||||
spv::SelectionControlMask selection_control) {
|
||||
auto op{new Op(spv::Op::OpSelectionMerge)};
|
||||
op->Add(merge_block);
|
||||
AddEnum(op, selection_control);
|
||||
return AddCode(op);
|
||||
}
|
||||
|
||||
Ref Module::Label() {
|
||||
return AddCode(spv::Op::OpLabel, bound++);
|
||||
}
|
||||
Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); }
|
||||
|
||||
Ref Module::Branch(Ref target_label) {
|
||||
auto op{new Op(spv::Op::OpBranch)};
|
||||
|
|
@ -37,20 +37,19 @@ Ref Module::Branch(Ref target_label) {
|
|||
}
|
||||
|
||||
Ref Module::BranchConditional(Ref condition, Ref true_label, Ref false_label,
|
||||
std::uint32_t true_weight, std::uint32_t false_weight) {
|
||||
std::uint32_t true_weight,
|
||||
std::uint32_t false_weight) {
|
||||
auto op{new Op(spv::Op::OpBranchConditional)};
|
||||
op->Add(condition);
|
||||
op->Add(true_label);
|
||||
op->Add(false_label);
|
||||
if (true_weight != 0 || false_weight != 0) {
|
||||
op->Add(Literal(true_weight));
|
||||
op->Add(Literal(false_weight));
|
||||
op->Add(true_weight);
|
||||
op->Add(false_weight);
|
||||
}
|
||||
return AddCode(op);
|
||||
}
|
||||
|
||||
Ref Module::Return() {
|
||||
return AddCode(spv::Op::OpReturn);
|
||||
}
|
||||
Ref Module::Return() { return AddCode(spv::Op::OpReturn); }
|
||||
|
||||
} // namespace Sirit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue