diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 9e50877..fc8c721 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -201,7 +201,10 @@ class Module { Id Name(Id target, const std::string& name); /// Assign a Result to a string for use by other debug instructions. - Id OpString(const std::string& string); + Id String(const std::string& string); + + /// Add source-level location information + Id OpLine(Id file, Literal line, Literal column); // Memory diff --git a/src/insts/debug.cpp b/src/insts/debug.cpp index 688862d..d61dec1 100644 --- a/src/insts/debug.cpp +++ b/src/insts/debug.cpp @@ -19,9 +19,19 @@ Id Module::Name(Id target, const std::string& name) { return target; } -Id Module::OpString(const std::string& string) { +Id Module::String(const std::string& string) { auto op{std::make_unique(spv::Op::OpString, bound++)}; op->Add(string); + const auto id = op.get(); + debug.push_back(std::move(op)); + return id; +} + +Id Module::OpLine(Id file, Literal line, Literal column) { + auto op{std::make_unique(spv::Op::OpLine)}; + op->Add(file); + op->Add(line); + op->Add(column); return AddCode(std::move(op)); }