OpName returns its target

This commit is contained in:
ReinUsesLisp 2018-08-31 04:55:01 -03:00
parent 4fe98c2902
commit 45555c0e57
3 changed files with 6 additions and 5 deletions

View File

@ -177,7 +177,8 @@ public:
// Debug // Debug
/// Assign a name string to a reference. /// Assign a name string to a reference.
void Name(Ref target, const std::string& name); /// @return target
Ref Name(Ref target, const std::string& name);
// Literals // Literals
static Operand* Literal(std::uint32_t value); static Operand* Literal(std::uint32_t value);

View File

@ -9,11 +9,12 @@
namespace Sirit { namespace Sirit {
void Module::Name(Ref target, const std::string& name) { Ref Module::Name(Ref target, const std::string& name) {
Op* op{new Op(spv::Op::OpName)}; Op* op{new Op(spv::Op::OpName)};
op->Add(target); op->Add(target);
op->Add(name); op->Add(name);
debug.push_back(std::unique_ptr<Op>(op)); debug.push_back(std::unique_ptr<Op>(op));
return target;
} }
} // namespace Sirit } // namespace Sirit

View File

@ -51,9 +51,8 @@ public:
Constant(TypeFloat(32), Literal(50.0f))}); Constant(TypeFloat(32), Literal(50.0f))});
ConstantNull(TypeVector(TypeInt(64, false), 4)); ConstantNull(TypeVector(TypeInt(64, false), 4));
auto cont{Label()}; auto cont{Name(Label(), "cont")};
auto skip{Label()}; auto skip{Name(Label(), "skip")};
Name(skip, "skip");
auto main_type{TypeFunction(TypeVoid())}; auto main_type{TypeFunction(TypeVoid())};
auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};
Emit(Label()); Emit(Label());