Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2019-05-28 14:41:46 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2019-05-28 14:44:24 +0300
commit65af09d2d14c4f997c2eaeb467ee8d6d13e12c29 (patch)
tree7437d5b769d8799e9f71838ab9ba6b76ad835e8e /spirv_parser.cpp
parentd2134bbb7103819d4f32fa9e5c2a422dc961071b (diff)
Support emitting OpLine directive.
Facilitates easier mapping from source language to cross-compiled output in tooling.
Diffstat (limited to 'spirv_parser.cpp')
-rw-r--r--spirv_parser.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/spirv_parser.cpp b/spirv_parser.cpp
index 1c0a830f..c75fa1b6 100644
--- a/spirv_parser.cpp
+++ b/spirv_parser.cpp
@@ -162,12 +162,16 @@ void Parser::parse(const Instruction &instruction)
case OpSourceContinued:
case OpSourceExtension:
case OpNop:
- case OpLine:
case OpNoLine:
- case OpString:
case OpModuleProcessed:
break;
+ case OpString:
+ {
+ set<SPIRString>(ops[0], extract_string(ir.spirv, instruction.offset + 1));
+ break;
+ }
+
case OpMemoryModel:
ir.addressing_model = static_cast<AddressingModel>(ops[0]);
ir.memory_model = static_cast<MemoryModel>(ops[1]);
@@ -1030,6 +1034,26 @@ void Parser::parse(const Instruction &instruction)
break;
}
+ case OpLine:
+ {
+ // OpLine might come at global scope, but we don't care about those since they will not be declared in any
+ // meaningful correct order.
+ // For OpLine statements which
+ if (current_block)
+ current_block->ops.push_back(instruction);
+
+ if (current_function) // Line directives may arrive before first OpLabel.
+ {
+ // Store the first one we find and emit it before creating the function prototype.
+ if (current_function->entry_line.file_id == 0)
+ {
+ current_function->entry_line.file_id = ops[0];
+ current_function->entry_line.line_literal = ops[1];
+ }
+ }
+ break;
+ }
+
// Actual opcodes.
default:
{