Skip to content

Commit

Permalink
Cleanup and formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Feb 4, 2025
1 parent 52e5184 commit cf6bed4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 48 deletions.
8 changes: 4 additions & 4 deletions compiler/generator/compile_scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<Tree> V = ondemandCompilationOrder(outputs);

// 5/ We compile the output signals conditionnally inside the if statement
Expand Down
49 changes: 25 additions & 24 deletions compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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) {
Expand All @@ -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<Tree> V = ondemandCompilationOrder(outputs);

// 5/ We compile the output signals conditionnally inside the if statement
Expand Down
8 changes: 4 additions & 4 deletions compiler/generator/jsfx/jsfx_instructions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/generator/struct_manager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArrayTyped*>(inst->fType);

Expand Down
19 changes: 11 additions & 8 deletions compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1783,7 +1783,7 @@ bool global::processCmdline(int argc, const char* argv[])
err++;
}
}

// ========================
// Adjust related options
// ========================
Expand All @@ -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");
}
Expand Down Expand Up @@ -2369,7 +2369,7 @@ string global::printHelp()
<< endl;
sstr << tab
<< "-mcd <n> --max-copy-delay <n> use a copy delay up to max delay <n> 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 "
Expand All @@ -2379,16 +2379,19 @@ string global::printHelp()
<< "-mcl <n> --max-copy-loop <n> 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 <n> --min-loop-samples <n> loop instead of expanded copy " << endl;
sstr << tab
<< "-mdd <n> --max-dense-delay <n> use a dense delay up to max delay <n> (if "
"enough density) and a "
"ring "
"buffer delay above (ocpp only, default 1024)."
<< endl;
sstr << tab
<< "-mca <n> --max-cache-delay <n> maximal delay to use a cache delay line (ocpp "
"only, default 8)."
<< endl;
sstr << tab
<< "-mdy <n> --min-density <n> 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 <n> --delay-line-threshold <n> use a mask-based ring buffer delays up to max "
Expand Down Expand Up @@ -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 <n> --vec-size <n> size of the vector (default 32 samples)."
Expand Down
11 changes: 4 additions & 7 deletions compiler/transform/sigPromotion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit cf6bed4

Please sign in to comment.