From cf6bed47a49569a6a78afc13be1d87bf9259a9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Letz?= Date: Mon, 3 Feb 2025 21:58:33 +0100 Subject: [PATCH] Cleanup and formatting. --- compiler/generator/compile_scal.cpp | 8 ++-- compiler/generator/instructions_compiler.cpp | 49 ++++++++++---------- compiler/generator/jsfx/jsfx_instructions.hh | 8 ++-- compiler/generator/struct_manager.hh | 2 +- compiler/global.cpp | 19 ++++---- compiler/transform/sigPromotion.hh | 11 ++--- 6 files changed, 49 insertions(+), 48 deletions(-) diff --git a/compiler/generator/compile_scal.cpp b/compiler/generator/compile_scal.cpp index 22599fd90e..d2357f3d56 100644 --- a/compiler/generator/compile_scal.cpp +++ b/compiler/generator/compile_scal.cpp @@ -2126,8 +2126,8 @@ string ScalarCompiler::generateOD(Tree sig, const tvec& w) // form w = [clock, input1, input2, ..., nil, output1, output2, ...] faustassert(w.size() > 2); Tree clock = w[0]; - tvec inputs; // the input signals (comming from outiside) - tvec outputs; // the output signa outputs; + tvec inputs; // the input signals (coming from outside) + tvec outputs; // the output signals; bool inmode = true; for (unsigned int i = 1; i < w.size(); i++) { if (w[i] == gGlobal->nil) { @@ -2148,11 +2148,11 @@ string ScalarCompiler::generateOD(Tree sig, const tvec& w) // std::cerr << "opening if statement" << std::endl; - // 3/ We the compile the clock signal and open an if statement + // 3/ We then compile the clock signal and open an if statement // fClass->addExecCode(Statement("", subst("if ($0) {", CS(clock)))); fClass->openIFblock(CS(clock)); - // 4/ compute the scheduling of the output signals of the ondemand circuit + // 4/ Compute the scheduling of the output signals of the ondemand circuit std::vector V = ondemandCompilationOrder(outputs); // 5/ We compile the output signals conditionnally inside the if statement diff --git a/compiler/generator/instructions_compiler.cpp b/compiler/generator/instructions_compiler.cpp index 32650f4aab..9bed53bf00 100644 --- a/compiler/generator/instructions_compiler.cpp +++ b/compiler/generator/instructions_compiler.cpp @@ -2187,7 +2187,8 @@ DelayType InstructionsCompiler::analyzeDelayType(Tree sig) if (mxd <= gGlobal->gMaskDelayLineThreshold) { Tree clock; if (!hasClock(sig, clock)) { - std::cerr << "ASSERT : not the expected signal with a clock " << ppsig(sig) << std::endl; + std::cerr << "ASSERT : not the expected signal with a clock " << ppsig(sig) + << std::endl; } faustassert(hasClock(sig, clock)); // std::cerr << "We use MaskRingDelay in clock env: " << clock << ", for sig: " << sig @@ -2768,25 +2769,25 @@ ValueInst* InstructionsCompiler::generateDelayLine(Tree sig, BasicTyped* ctype, return IB::genLoadStackVar(vname); } - /* - case DelayType::kSingleDelay: { - string vname_perm = vname + "State"; - pushDeclare(IB::genLabelInst("// Single Delay")); - pushDeclare(IB::genDecStructVar(vname_perm, ctype)); - pushClearMethod(IB::genStoreStructVar(vname_perm, IB::genTypedZero(ctype))); - pushComputeBlockMethod(IB::genDecArrayStackVar(vname, ctype, mxd + 1)); - pushComputeBlockMethod(IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(1), - IB::genLoadStructVar(vname_perm))); - pushComputeDSPMethod(IB::genControlInst( - ccs, IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(0), exp))); - pushPostComputeDSPMethod( - IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(1), - IB::genLoadArrayStackVar(vname, IB::genInt32NumInst(0)))); - pushPostComputeBlockMethod(IB::genStoreStructVar( - vname_perm, IB::genLoadArrayStackVar(vname, IB::genInt32NumInst(1)))); - return IB::genLoadArrayStackVar(vname, IB::genInt32NumInst(0)); - } - */ + /* + case DelayType::kSingleDelay: { + string vname_perm = vname + "State"; + pushDeclare(IB::genLabelInst("// Single Delay")); + pushDeclare(IB::genDecStructVar(vname_perm, ctype)); + pushClearMethod(IB::genStoreStructVar(vname_perm, IB::genTypedZero(ctype))); + pushComputeBlockMethod(IB::genDecArrayStackVar(vname, ctype, mxd + 1)); + pushComputeBlockMethod(IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(1), + IB::genLoadStructVar(vname_perm))); + pushComputeDSPMethod(IB::genControlInst( + ccs, IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(0), exp))); + pushPostComputeDSPMethod( + IB::genStoreArrayStackVar(vname, IB::genInt32NumInst(1), + IB::genLoadArrayStackVar(vname, + IB::genInt32NumInst(0)))); pushPostComputeBlockMethod(IB::genStoreStructVar( vname_perm, + IB::genLoadArrayStackVar(vname, IB::genInt32NumInst(1)))); return + IB::genLoadArrayStackVar(vname, IB::genInt32NumInst(0)); + } + */ /* case DelayType::kCopyDelay: { @@ -3271,8 +3272,8 @@ ValueInst* InstructionsCompiler::generateOD(Tree sig, const tvec& w) // form w = [clock, input1, input2, ..., nil, output1, output2, ...] faustassert(w.size() > 2); Tree clock = w[0]; - tvec inputs; // the input signals (comming from outiside) - tvec outputs; // the output signa outputs; + tvec inputs; // the input signals (coming from outside) + tvec outputs; // the output signals; bool inmode = true; for (unsigned int i = 1; i < w.size(); i++) { if (w[i] == gGlobal->nil) { @@ -3293,11 +3294,11 @@ ValueInst* InstructionsCompiler::generateOD(Tree sig, const tvec& w) std::cout << "opening if statement" << std::endl; - // 3/ We the compile the clock signal and open an if statement + // 3/ We then compile the clock signal and open an if statement // fClass->addExecCode(Statement("", subst("if ($0) {", CS(clock)))); fContainer->getCurLoop()->openIFblock(CS(clock)); - // 4/ compute the scheduling of the output signals of the ondemand circuit + // 4/ Compute the scheduling of the output signals of the ondemand circuit std::vector V = ondemandCompilationOrder(outputs); // 5/ We compile the output signals conditionnally inside the if statement diff --git a/compiler/generator/jsfx/jsfx_instructions.hh b/compiler/generator/jsfx/jsfx_instructions.hh index 629e345d6c..8ef66b2f0e 100644 --- a/compiler/generator/jsfx/jsfx_instructions.hh +++ b/compiler/generator/jsfx/jsfx_instructions.hh @@ -965,10 +965,10 @@ class JSFXInstVisitor : public TextInstVisitor { // The structure correspond to a "DSP" class representing the Faust code. // This class can be instanciated in MIDI polyphonic context. // The reason of the many conditionals in this method is that JSFX code structure is not object - // oriented by default. Moreover, some variables like fSlow and iSlow have to be put in the class - // (altough it is not the case in C++ backend for example). In C++, these variables are declared - // and defined in the compute method of DSP class, just above the audio loop. In JSFX, scopes - // are handled differently (the @block section is called once for each instances, and the + // oriented by default. Moreover, some variables like fSlow and iSlow have to be put in the + // class (altough it is not the case in C++ backend for example). In C++, these variables are + // declared and defined in the compute method of DSP class, just above the audio loop. In JSFX, + // scopes are handled differently (the @block section is called once for each instances, and the // @sample section too) so these fields had to be moved as class members. virtual void visit(NamedAddress* named) { diff --git a/compiler/generator/struct_manager.hh b/compiler/generator/struct_manager.hh index 6a724d2472..64c7e61606 100644 --- a/compiler/generator/struct_manager.hh +++ b/compiler/generator/struct_manager.hh @@ -264,7 +264,7 @@ struct StructInstVisitor : public DispatchVisitor { void visit(DeclareVarInst* inst) { std::string name = inst->getName(); - + bool is_struct = inst->fAddress->isStruct() || inst->fAddress->isStaticStruct(); ArrayTyped* array_typed = dynamic_cast(inst->fType); diff --git a/compiler/global.cpp b/compiler/global.cpp index d877ba21ba..12cbc91d78 100644 --- a/compiler/global.cpp +++ b/compiler/global.cpp @@ -447,8 +447,8 @@ void global::reset() gHLSUnrollFactor = 0; // [-huf n]: when > 0 generate: `#pragma HLS unroll factor=n` gFirLoopSize = 4; // [-fls n]: inline/loop computation of FIR/IIR values gMaxCopyDelay = 9; // [-mcd n]: copy/iota-dense delay line - gMinCopyLoop = 4; // [-mcl n]: inline/loop samples copy gUseDenseDelay = 1; // [-udd 0/1]: Use dense delay representation instead of IOTA + gMinCopyLoop = 4; // [-mcl n]: inline/loop samples copy gMinDensity = 90; // [-mdy n]: dense/iota delay line density threshold gMaxCacheDelay = 8; // [-mca n]: Maximal delay to use a cache delay line gMaxDenseDelay = 1024; // [-mdd n]: Maximal delay to choose a dense representation @@ -1783,7 +1783,7 @@ bool global::processCmdline(int argc, const char* argv[]) err++; } } - + // ======================== // Adjust related options // ======================== @@ -1795,7 +1795,7 @@ bool global::processCmdline(int argc, const char* argv[]) if (gMemoryManager >= 1) { gWaveformInDSP = true; } - + if (gVectorSwitch) { throw faustexception("ERROR : '-vec' is not yet supported with 'ondemand' primitive\n"); } @@ -2369,7 +2369,7 @@ string global::printHelp() << endl; sstr << tab << "-mcd --max-copy-delay use a copy delay up to max delay and a " - "dense delay (ocpp only) or a ring buffer above (defaut 16 samples)." + "dense delay (ocpp only) or a ring buffer above (defaut 9 samples)." << endl; sstr << tab << "-udd <0|1> --use-dense-delay <0|1> allow use of dense delay instead of short " @@ -2379,16 +2379,19 @@ string global::printHelp() << "-mcl --max-copy-loop when using a copy delay, threshold to switch " "from an inline to a loop based copy of the samples (defaut 4 samples)." << endl; - sstr << tab << "-mls --min-loop-samples loop instead of expanded copy " << endl; sstr << tab << "-mdd --max-dense-delay use a dense delay up to max delay (if " "enough density) and a " "ring " "buffer delay above (ocpp only, default 1024)." << endl; + sstr << tab + << "-mca --max-cache-delay maximal delay to use a cache delay line (ocpp " + "only, default 8)." + << endl; sstr << tab << "-mdy --min-density minimal density (100*number of delays/max " - "delay) to use a dense delays (ocpp only, default 33)." + "delay) to use a dense delays (ocpp only, default 90)." << endl; sstr << tab << "-dlt --delay-line-threshold use a mask-based ring buffer delays up to max " @@ -2438,14 +2441,14 @@ string global::printHelp() "instead of compiling " "a dsp file." << endl; - sstr << tab << "-scal --scalar generate non-vectorized code (default)." + sstr << tab << "-scal --scalar generate non-vectorized code (default)." << endl; sstr << tab << "-inpl --in-place generates code working when input and output " "buffers are the same " "(scalar mode only)." << endl; - sstr << tab << "-vec --vectorize generate easier to vectorize code." + sstr << tab << "-vec --vectorize generate easier to vectorize code." << endl; sstr << tab << "-vs --vec-size size of the vector (default 32 samples)." diff --git a/compiler/transform/sigPromotion.hh b/compiler/transform/sigPromotion.hh index 4e7577f53d..4c91c45261 100644 --- a/compiler/transform/sigPromotion.hh +++ b/compiler/transform/sigPromotion.hh @@ -79,8 +79,8 @@ class SignalChecker final : public SignalVisitor { */ struct SignalClockChecker final : public SignalVisitor { Tree& fClock; - bool fHasClock; - + bool fHasClock; + void visit(Tree sig) override { if (fHasClock) { @@ -91,11 +91,8 @@ struct SignalClockChecker final : public SignalVisitor { SignalVisitor::visit(sig); } } - - SignalClockChecker(Tree L, Tree& clock) : fClock(clock), fHasClock(false) - { - self(L); - } + + SignalClockChecker(Tree L, Tree& clock) : fClock(clock), fHasClock(false) { self(L); } }; bool hasClock(Tree sig, Tree& clock);