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
/// 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
static Operand* Literal(std::uint32_t value);

View file

@ -9,11 +9,12 @@
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->Add(target);
op->Add(name);
debug.push_back(std::unique_ptr<Op>(op));
return target;
}
} // namespace Sirit

View file

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