Commit 9c8823a5 by Ben Clayton

Pipeline/SpirvShader: Process OpString instructions

Strings are used for debug instructions. Bug: b/145351270 Change-Id: I6bc711c6c8b320bef6e5abbe9c4bda189fdafc0b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39884Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 0771f9b6
...@@ -433,10 +433,13 @@ SpirvShader::SpirvShader( ...@@ -433,10 +433,13 @@ SpirvShader::SpirvShader(
case spv::OpLine: case spv::OpLine:
case spv::OpNoLine: case spv::OpNoLine:
case spv::OpModuleProcessed: case spv::OpModuleProcessed:
case spv::OpString:
// No semantic impact // No semantic impact
break; break;
case spv::OpString:
strings.emplace(insn.word(1), insn.string(2));
break;
case spv::OpFunctionParameter: case spv::OpFunctionParameter:
// These should have all been removed by preprocessing passes. If we see them here, // These should have all been removed by preprocessing passes. If we see them here,
// our assumptions are wrong and we will probably generate wrong code. // our assumptions are wrong and we will probably generate wrong code.
......
...@@ -377,6 +377,9 @@ public: ...@@ -377,6 +377,9 @@ public:
Type::ID result; // return type. Type::ID result; // return type.
}; };
using String = std::string;
using StringID = SpirvID<std::string>;
struct TypeOrObject struct TypeOrObject
{}; // Dummy struct to represent a Type or Object. {}; // Dummy struct to represent a Type or Object.
...@@ -728,6 +731,7 @@ private: ...@@ -728,6 +731,7 @@ private:
HandleMap<Type> types; HandleMap<Type> types;
HandleMap<Object> defs; HandleMap<Object> defs;
HandleMap<Function> functions; HandleMap<Function> functions;
std::unordered_map<StringID, String> strings;
Function::ID entryPoint; Function::ID entryPoint;
const bool robustBufferAccess = true; const bool robustBufferAccess = true;
...@@ -1006,6 +1010,13 @@ private: ...@@ -1006,6 +1010,13 @@ private:
return it->second; return it->second;
} }
String const &getString(StringID id) const
{
auto it = strings.find(id);
ASSERT_MSG(it != strings.end(), "Unknown string %d", id.value());
return it->second;
}
// Returns a SIMD::Pointer to the underlying data for the given pointer // Returns a SIMD::Pointer to the underlying data for the given pointer
// object. // object.
// Handles objects of the following kinds: // Handles objects of the following kinds:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment