summaryrefslogtreecommitdiff
path: root/rsov
diff options
context:
space:
mode:
authorI-Jui (Ray) Sung <ijsung@google.com>2017-03-03 17:08:16 -0800
committerI-Jui (Ray) Sung <ijsung@google.com>2017-03-06 11:30:00 -0800
commit877083d07a7fbce460f7f083bc1d5deef4d9ed47 (patch)
tree3e4a4dc78c95e070d60152de331f8959f090fecf /rsov
parent636006e2ae9e26d856124d2c6da478eec9d779dc (diff)
downloadrs-877083d07a7fbce460f7f083bc1d5deef4d9ed47.tar.gz
Added addString() method to android::spirit::Module
MakeString() was in Builder, but Module does not have the counterpart to add an OpString to the Debug Info section. The OpString SPIR-V instruction may be used to carry debugging information and other metadata. This CL also added a test case to verify the result. Bug: 30964317 Test: SPIRIT unit tests (gtest), Change-Id: I5aff827041f5d5e71978a12e366f829d0de819c1
Diffstat (limited to 'rsov')
-rw-r--r--rsov/compiler/spirit/builder_test.cpp2
-rw-r--r--rsov/compiler/spirit/module.cpp14
-rw-r--r--rsov/compiler/spirit/module.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/rsov/compiler/spirit/builder_test.cpp b/rsov/compiler/spirit/builder_test.cpp
index 48030aeb..bb935b66 100644
--- a/rsov/compiler/spirit/builder_test.cpp
+++ b/rsov/compiler/spirit/builder_test.cpp
@@ -44,6 +44,7 @@ TEST(BuilderTest, testBuildAndSerialize) {
m->addSourceExtension("GL_ARB_shading_language_420pack");
m->addSourceExtension("GL_GOOGLE_cpp_style_line_directive");
m->addSourceExtension("GL_GOOGLE_include_directive");
+ m->addString("Foo Bar Baz");
auto FloatTy = m->getFloatType(32);
auto VF4Ty = m->getVectorType(FloatTy, 4);
@@ -178,6 +179,7 @@ TEST(BuilderTest, testBuildAndSerialize) {
EXPECT_EQ(2, countEntity<TypeRuntimeArrayInst>(m));
EXPECT_EQ(2, countEntity<TypeStructInst>(m));
EXPECT_EQ(5, countEntity<TypePointerInst>(m));
+ EXPECT_EQ(1, countEntity<StringInst>(m));
m->consolidateAnnotations();
diff --git a/rsov/compiler/spirit/module.cpp b/rsov/compiler/spirit/module.cpp
index 98001124..9880f780 100644
--- a/rsov/compiler/spirit/module.cpp
+++ b/rsov/compiler/spirit/module.cpp
@@ -214,6 +214,14 @@ Module *Module::addSourceExtension(const char *ext) {
return this;
}
+Module *Module::addString(const char *str) {
+ if (!mDebugInfo) {
+ mDebugInfo.reset(mBuilder->MakeDebugInfoSection());
+ }
+ mDebugInfo->addString(str);
+ return this;
+}
+
Module *Module::addEntryPoint(EntryPointDefinition *entry) {
mEntryPoints.push_back(entry);
auto newModes = entry->getExecutionModes();
@@ -515,6 +523,12 @@ DebugInfoSection *DebugInfoSection::addSourceExtension(const char *ext) {
return this;
}
+DebugInfoSection *DebugInfoSection::addString(const char *str) {
+ StringInst *source = mBuilder->MakeString(str);
+ mSources.push_back(source);
+ return this;
+}
+
Instruction *DebugInfoSection::lookupByName(const char *name) const {
for (auto inst : mNames) {
if (inst->getOpCode() == OpName) {
diff --git a/rsov/compiler/spirit/module.h b/rsov/compiler/spirit/module.h
index a69d255f..33011602 100644
--- a/rsov/compiler/spirit/module.h
+++ b/rsov/compiler/spirit/module.h
@@ -124,6 +124,7 @@ public:
Module *addExtInstImport(const char *extName);
Module *addSource(SourceLanguage lang, int version);
Module *addSourceExtension(const char *ext);
+ Module *addString(const char *ext);
Module *addEntryPoint(EntryPointDefinition *entry);
ExtInstImportInst *getGLExt() const { return mGLExt; }
@@ -312,6 +313,7 @@ public:
DebugInfoSection *addSource(SourceLanguage lang, int version);
DebugInfoSection *addSourceExtension(const char *ext);
+ DebugInfoSection *addString(const char *str);
Instruction *lookupByName(const char *name) const;
const char *lookupNameByInstruction(const Instruction *) const;