Skip to content

Commit

Permalink
Interp backend working.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Aug 30, 2024
1 parent 100d91b commit 53f5006
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
17 changes: 13 additions & 4 deletions compiler/generator/code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,15 @@ void CodeContainer::processFIR(void)
fCurLoop->generateScalarLoop("count"));
endTiming("FIR var checker");
}

#ifdef FIR_BUILD
if (global::isDebug("FIR_PRINTER")) {
stringstream res;
FIRInstVisitor fir_visitor(&res);
flattenFIR()->accept(&fir_visitor);
std::cout << res.str();
}
#endif
}

// Possibly rewrite arrays access using iZone/fZone
Expand Down Expand Up @@ -538,7 +547,7 @@ void CodeContainer::rewriteInZones()
void CodeContainer::mergeSubContainers()
{
BlockInst* sub_ui = new BlockInst();

for (const auto& it : fSubContainers) {
// Merge the subcontainer in the main one
fExtGlobalDeclarationInstructions->merge(it->fExtGlobalDeclarationInstructions);
Expand All @@ -556,9 +565,9 @@ void CodeContainer::mergeSubContainers()
it->fUserInterfaceInstructions->fCode.clear();
it->fStaticInitInstructions->fCode.clear();
}
// Insert subcontainer UIs at the end the top group, just before the last closeBox
fUserInterfaceInstructions->insert(fUserInterfaceInstructions->size()-1, sub_ui);

// Insert subcontainer UIs at the end the top group, just before the last closeBox
fUserInterfaceInstructions->insert(fUserInterfaceInstructions->size() - 1, sub_ui);

// Possibly rewrite access in iZone/fZone
rewriteInZones();
Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/instructions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1008,14 +1008,14 @@ struct BlockInst : public StatementInst {
fCode.push_back(it);
}
}

void mergeFront(BlockInst* inst)
{
for (const auto& it : inst->fCode) {
fCode.push_front(it);
}
}

void insert(int index, BlockInst* inst)
{
auto it = fCode.begin();
Expand Down
4 changes: 4 additions & 0 deletions compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "instructions_compiler.hh"
#include "instructions_compiler1.hh"
#include "instructions_compiler_jax.hh"
#include "interpreter_code_container.hh"
#include "normalform.hh"
#include "prim2.hh"
#include "recursivness.hh"
Expand Down Expand Up @@ -429,6 +430,9 @@ CodeContainer* InstructionsCompiler::signal2Container(const string& name, Tree s
} else if (gGlobal->gOutputLang == "jax") {
InstructionsCompilerJAX C(container);
C.compileSingleSignal(sig);
} else if (gGlobal->gOutputLang == "interp") {
InterpreterInstructionsCompiler C(container);
C.compileSingleSignal(sig);
} else {
// Special compiler for -fx mode
if (gGlobal->gFloatSize == 4) {
Expand Down
1 change: 1 addition & 0 deletions compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,7 @@ string global::printHelp()
<< endl;
sstr << tab << "FAUST_DEBUG = FAUST_LLVM2 print LLVM IR after optimisation."
<< endl;
sstr << tab << "FAUST_DEBUG = FIR_PRINTER print FIR after generation." << endl;
sstr << tab
<< "FAUST_DEBUG = FAUST_LLVM_NO_FM deactivate fast-math optimisation in LLVM IR."
<< endl;
Expand Down

0 comments on commit 53f5006

Please sign in to comment.