diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-12-03 09:58:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-03 09:58:59 -0500 |
| commit | 9653dcc2c9d5d20d3d0e8918aaf1d5b09e963060 (patch) | |
| tree | aa1b42132361b2920d9f9301f0b0e44ea82d6b8c /source/slang/slang-ir-link.cpp | |
| parent | a3651d99fb8f3a046365d60751d1f3f806e48f7a (diff) | |
getStringHash on string literals (#1140)
* WIP getStringHash
* Have a use.
* Add slang-string-hash.h/.cpp
* Use StringSlicePool for holding strings for StringHash.
Add outputBuffer to string-literal-hash.slang so value can be tested.
Ignore the GlobalHashedStringLiterals instruction on emit.
* Add all the hashed string literals to ProgramLayout.
* Add reflection support for hashed string literals to reflection test.
* Fix string literal hash test.
* Small fixes to pass test suite.
* Fix issue in serialization where IRUse is not correctly initialized.
* Fix problem initializing IRUse for string hash pass.
Remove hack from slang-ir-specialize - specially handling if user is not null.
* * Use shared builder when replacing getStringHash
* Comments for functions in slang-ir-string-hash
* Do not allow zero length string literals. Could be allowed, but doing so would require StringSlicePool to have a special case (or some other mechanism)
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
| -rw-r--r-- | source/slang/slang-ir-link.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index 59cc625f5..0678b5962 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -4,6 +4,7 @@ #include "slang-ir.h" #include "slang-ir-insts.h" #include "slang-mangle.h" +#include "slang-ir-string-hash.h" namespace Slang { @@ -1374,6 +1375,7 @@ LinkedIR linkIR( }); irModules.addRange(linkage->m_libModules.getBuffer()->readRef(), linkage->m_libModules.getCount()); + // Add any modules that were loaded as libraries for (IRModule* irModule : irModules) { @@ -1387,8 +1389,21 @@ LinkedIR linkIR( // insertGlobalValueSymbols(sharedContext, targetProgram->getExistingIRModuleForLayout()); - auto context = state->getContext(); + + // Combine all of the contents of IRGlobalHashedStringLiterals + { + StringSlicePool pool; + IRBuilder& builder = sharedContext->builderStorage; + for (IRModule* irModule : irModules) + { + findGlobalHashedStringLiterals(irModule, pool); + } + addGlobalHashedStringLiterals(pool, *builder.sharedBuilder); + } + + // Set up shared and builder insert point + context->shared = sharedContext; context->builder = &sharedContext->builderStorage; |
