summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-link.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-30 17:28:55 -0400
committerGitHub <noreply@github.com>2019-10-30 17:28:55 -0400
commit72f86c8273b196d204213f02e73ba772201f903d (patch)
tree914f750180e75c6d549bf0be80e9877f4f35c8ed /source/slang/slang-ir-link.cpp
parent066bc37f34ab4f72edef2b71fab50b45c3bb627e (diff)
WIP: Simple separate IR module linkage working (#1100)
* Added RiffReadHelper * Move type to fourCC in Chunk simplifies some code. * Make MemoryArena able to track external blocks. Allow ownership of Data to vary. Changed IR serialization to use moved allocations to avoid copies. As it turns out all of the array writes could use unowned data, but doing so requires the IRData to stay in scope longer than IRSerialData, which it does at the moment - but perhaps needs better naming or a control for the feature. * Write out slang-module container. * WIP on -r option. Loading modules - with -r. * Making the serialized-module run (without using imported module). * Split compiling module from the test. * Separate module compilation with a function working. * Remove serialization test as not used. * Fix warning on gcc. * Updated test to have types across module boundary.
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
-rw-r--r--source/slang/slang-ir-link.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 1cdc2cfc9..1102ecb3e 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1339,15 +1339,26 @@ LinkedIR linkIR(
state->irModule = sharedContext->module;
+ auto linkage = compileRequest->getLinkage();
+
// We need to be able to look up IR definitions for any symbols in
// modules that the program depends on (transitively). To
// accelerate lookup, we will create a symbol table for looking
// up IR definitions by their mangled name.
//
+
+ List<IRModule*> irModules;
program->enumerateIRModules([&](IRModule* irModule)
{
- insertGlobalValueSymbols(sharedContext, irModule);
+ irModules.add(irModule);
});
+ irModules.addRange(linkage->m_libModules.getBuffer()->readRef(), linkage->m_libModules.getCount());
+
+ // Add any modules that were loaded as libraries
+ for (IRModule* irModule : irModules)
+ {
+ insertGlobalValueSymbols(sharedContext, irModule);
+ }
// We will also insert the IR global symbols from the IR module
// attached to the `TargetProgram`, since this module is
@@ -1374,7 +1385,6 @@ LinkedIR linkIR(
cloneGlobalValue(context, (IRWitnessTable*)sym.Value->irGlobalValue);
}
-
// Next, we make sure to clone the global value for
// the entry point function itself, and rely on
// this step to recursively copy over anything else
@@ -1401,17 +1411,18 @@ LinkedIR linkIR(
// In the long run we do not want to *ever* iterate over all the
// instructions in all the input modules.
//
- program->enumerateIRModules([&](IRModule* irModule)
+
+ for (IRModule* irModule : irModules)
{
- for(auto inst : irModule->getGlobalInsts())
+ for (auto inst : irModule->getGlobalInsts())
{
auto bindInst = as<IRBindGlobalGenericParam>(inst);
- if(!bindInst)
+ if (!bindInst)
continue;
cloneValue(context, bindInst);
}
- });
+ }
// TODO: *technically* we should consider the case where
// we have global variables with initializers, since