Skip to content

Commit

Permalink
[NEW] Add -it option to inline rdtable/rwtable code in the main class…
Browse files Browse the repository at this point in the history
…. Set version to 2.65.0.
  • Loading branch information
sletz committed Aug 4, 2023
1 parent 7e791bb commit e14fa86
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/libfaust.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: libfaust

env:
FAUST_VERSION: 2.64.1
FAUST_VERSION: 2.65.0
FAUSTGEN_VERSION: 1.65
LLVM_PACKAGE_VERSION: 15.0.7
CMAKE_OSX_DEPLOYMENT_TARGET: 10.15
Expand Down
2 changes: 1 addition & 1 deletion COPYING.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FAUST compiler, Version 2.64.1
FAUST compiler, Version 2.65.0
Copyright (C) 2003-2019 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version := 2.64.1
version := 2.65.0

system ?= $(shell uname -s)

Expand Down
6 changes: 3 additions & 3 deletions architecture/faust/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#define __export__

// Version as a global string
#define FAUSTVERSION "2.64.1"
#define FAUSTVERSION "2.65.0"

// Version as separated [major,minor,patch] values
#define FAUSTMAJORVERSION 2
#define FAUSTMINORVERSION 64
#define FAUSTPATCHVERSION 1
#define FAUSTMINORVERSION 65
#define FAUSTPATCHVERSION 0

// Use FAUST_API for code that is part of the external API but is also compiled in faust and libfaust
// Use LIBFAUST_API for code that is compiled in faust and libfaust
Expand Down
2 changes: 1 addition & 1 deletion build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project (faust)

#######################################
# versions management
set (VERSION 2.64.1)
set (VERSION 2.65.0)
macro (get_major_minor_patch version)
string( REGEX REPLACE "([0-9]*)\\.([0-9]*)\\.([0-9]*)" "\\1" VERSION_MAJOR ${version} )
string( REGEX REPLACE "([0-9]*)\\.([0-9]*)\\.([0-9]*)" "\\2" VERSION_MINOR ${version} )
Expand Down
2 changes: 1 addition & 1 deletion build/MakeRelease.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

SET VERSION=2.64.1
SET VERSION=2.65.0
SET FAUSTGENVERSION=1.65

SET MYPATH=%cd%
Expand Down
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ system := $(shell echo $(system) | grep MINGW > /dev/null && echo MINGW || echo
# output directories
FAUSTDIR ?= faustdir
IOSDIR := iosdir
VERSION := 2.64.1
VERSION := 2.65.0

#===============================================================
# current generator and backends
Expand Down
4 changes: 3 additions & 1 deletion compiler/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% man(1) Version 2.64.1 (03-August-2023) | Faust man page
% man(1) Version 2.65.0 (04-August-2023) | Faust man page

NAME
====
Expand Down Expand Up @@ -88,6 +88,8 @@ Code generation options:

**-os3** **--one-sample3** generate one sample computation (3 = like 2 but with external memory pointers kept in the DSP struct).

**-it** **--inline-table** inline rdtable/rwtable code in the main class.

**-cm** **--compute-mix** mix in outputs buffers.

**-ct** **--check-table** check rtable/rwtable index range and generate safe access code [0/1: 1 by default].
Expand Down
53 changes: 29 additions & 24 deletions compiler/generator/code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void CodeContainer::processFIR(void)
/*
Create memory layout, to be used in C++ backend and JSON generation.
The description order follows what will be done at allocation time.
Subcontainers are ignored when gGlobal->gInlineTable == true
// Create static tables
mydsp::classInit();
Expand All @@ -421,22 +422,24 @@ void CodeContainer::processFIR(void)
loop->accept(&struct_visitor);

// Subcontainers used in classInit
for (const auto& it : fSubContainers) {
// Check that the subcontainer name appears as a type name in fStaticInitInstructions
SearchSubcontainer search_class(it->getClassName());
fStaticInitInstructions->accept(&search_class);
if (search_class.fFound) {
// Subcontainer size
VariableSizeCounter struct_size(Address::kStruct);
it->generateDeclarations(&struct_size);
fMemoryLayout.push_back(make_tuple(it->getClassName(), "kObj_ptr", 0, struct_size.fSizeBytes, 0, 0));

// Get the associated table size and access
pair<string, int> field = gGlobal->gTablesSize[it->getClassName()];

// Check the table name memory description
MemoryDesc& decs = struct_visitor.getMemoryDesc(field.first);
fMemoryLayout.push_back(make_tuple(field.first, Typed::gTypeString[decs.fType], 0, field.second, decs.fRAccessCount, 0));
if (!gGlobal->gInlineTable) {
for (const auto& it : fSubContainers) {
// Check that the subcontainer name appears as a type name in fStaticInitInstructions
SearchSubcontainer search_class(it->getClassName());
fStaticInitInstructions->accept(&search_class);
if (search_class.fFound) {
// Subcontainer size
VariableSizeCounter struct_size(Address::kStruct);
it->generateDeclarations(&struct_size);
fMemoryLayout.push_back(make_tuple(it->getClassName(), "kObj_ptr", 0, struct_size.fSizeBytes, 0, 0));

// Get the associated table size and access
pair<string, int> field = gGlobal->gTablesSize[it->getClassName()];

// Check the table name memory description
MemoryDesc& decs = struct_visitor.getMemoryDesc(field.first);
fMemoryLayout.push_back(make_tuple(field.first, Typed::gTypeString[decs.fType], 0, field.second, decs.fRAccessCount, 0));
}
}
}
}
Expand Down Expand Up @@ -497,14 +500,16 @@ void CodeContainer::processFIR(void)
}

// Subcontainers used in instanceConstants
for (const auto& it : fSubContainers) {
// Check that the subcontainer name appears as a type name in fInitInstructions
SearchSubcontainer search_class(it->getClassName());
fInitInstructions->accept(&search_class);
if (search_class.fFound) {
VariableSizeCounter struct_size(Address::kStruct);
it->generateDeclarations(&struct_size);
fMemoryLayout.push_back(make_tuple(it->getClassName(), "kObj_ptr", 0, struct_size.fSizeBytes, 0, 0));
if (!gGlobal->gInlineTable) {
for (const auto& it : fSubContainers) {
// Check that the subcontainer name appears as a type name in fInitInstructions
SearchSubcontainer search_class(it->getClassName());
fInitInstructions->accept(&search_class);
if (search_class.fFound) {
VariableSizeCounter struct_size(Address::kStruct);
it->generateDeclarations(&struct_size);
fMemoryLayout.push_back(make_tuple(it->getClassName(), "kObj_ptr", 0, struct_size.fSizeBytes, 0, 0));
}
}
}
}
Expand Down
71 changes: 53 additions & 18 deletions compiler/generator/cpp/cpp_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,24 @@ void CPPCodeContainer::produceInit(int tabs)
tab(tabs, *fOut);
*fOut << genVirtual() << "void init(int sample_rate) {";
tab(tabs + 1, *fOut);
*fOut << "classInit(sample_rate);";
tab(tabs + 1, *fOut);
// Replaced by staticInit called in instanceInit
if (!gGlobal->gInlineTable) {
*fOut << "classInit(sample_rate);";
tab(tabs + 1, *fOut);
}
*fOut << "instanceInit(sample_rate);";
tab(tabs, *fOut);
*fOut << "}";
}

tab(tabs, *fOut);
tab(tabs, *fOut);
*fOut << genVirtual() << "void instanceInit(int sample_rate) {";
tab(tabs + 1, *fOut);
// staticInit has to be called for each instance since the tables are actually not shared between instances
if (gGlobal->gInlineTable) {
*fOut << "staticInit(sample_rate);";
tab(tabs + 1, *fOut);
}
*fOut << "instanceConstants(sample_rate);";
tab(tabs + 1, *fOut);
*fOut << "instanceResetUserInterface();";
Expand Down Expand Up @@ -301,11 +309,16 @@ void CPPCodeContainer::produceClass()
tab(n, *fOut);
*fOut << "namespace " << gGlobal->gNamespace << " {" << endl;
}

generateHeader(n);

// Generate gub containers
generateSubContainers();
if (gGlobal->gInlineTable) {
// Sub containers are merged in the main class
mergeSubContainers();
} else {
// Generate gub containers
generateSubContainers();
}

// Global declarations
tab(n, *fOut);
Expand Down Expand Up @@ -377,12 +390,29 @@ void CPPCodeContainer::produceClass()
*/

tab(n + 1, *fOut);
*fOut << "static void classInit(int sample_rate) {";
tab(n + 2, *fOut);
fCodeProducer->Tab(n + 2);
generateStaticInit(fCodeProducer);
back(1, *fOut);
*fOut << "}";
if (gGlobal->gInlineTable) {
// Dummy classInit
*fOut << "static void classInit(int sample_rate) {}";
tab(n + 1, *fOut);
// To be used in instanceInit
tab(n + 1, *fOut);
*fOut << "void staticInit(int sample_rate) {";
{
tab(n + 2, *fOut);
fCodeProducer->Tab(n + 2);
// Rename 'sig' in 'dsp', remove 'dsp' allocation, inline subcontainers 'instanceInit' and 'fill' function call
inlineSubcontainersFunCalls(fStaticInitInstructions)->accept(fCodeProducer);
}
back(1, *fOut);
*fOut << "}";
} else {
*fOut << "static void classInit(int sample_rate) {";
tab(n + 2, *fOut);
fCodeProducer->Tab(n + 2);
generateStaticInit(fCodeProducer);
back(1, *fOut);
*fOut << "}";
}

if (gGlobal->gMemoryManager) {
tab(n + 1, *fOut);
Expand Down Expand Up @@ -428,7 +458,12 @@ void CPPCodeContainer::produceClass()
*fOut << genVirtual() << "void instanceConstants(int sample_rate) {";
tab(n + 2, *fOut);
fCodeProducer->Tab(n + 2);
generateInit(fCodeProducer);
if (gGlobal->gInlineTable) {
// Rename 'sig' in 'dsp', remove 'dsp' allocation, inline subcontainers 'instanceInit' and 'fill' function call
inlineSubcontainersFunCalls(fInitInstructions)->accept(fCodeProducer);
} else {
generateInit(fCodeProducer);
}
back(1, *fOut);
*fOut << "}";
tab(n + 1, *fOut);
Expand Down Expand Up @@ -484,8 +519,8 @@ void CPPCodeContainer::produceClass()

// Init
produceInit(n + 1);

tab(n + 1, *fOut);

tab(n + 1, *fOut);
*fOut << genVirtual() << fKlassName << "* clone() {";
tab(n + 2, *fOut);
Expand Down Expand Up @@ -715,7 +750,7 @@ void CPPScalarOneSampleCodeContainer1::produceClass()
produceInfoFunctions(n + 1, "", "dsp", true, FunTyped::kVirtual, fCodeProducer);
}

// Dummy
// Dummy classInit
tab(n + 1, *fOut);
*fOut << "static void classInit(int sample_rate) {}";
tab(n + 1, *fOut);
Expand Down Expand Up @@ -940,7 +975,7 @@ void CPPScalarOneSampleCodeContainer2::produceClass()
produceInfoFunctions(n + 1, "", "dsp", true, FunTyped::kVirtual, fCodeProducer);
}

// Dummy
// Dummy classInit
tab(n + 1, *fOut);
*fOut << "static void classInit(int sample_rate) {}";
tab(n + 1, *fOut);
Expand Down Expand Up @@ -1185,7 +1220,7 @@ void CPPScalarOneSampleCodeContainer3::produceClass()
produceInfoFunctions(n + 1, "", "dsp", true, FunTyped::kVirtual, fCodeProducer);
}

// Dummy
// Dummy classInit
tab(n + 1, *fOut);
*fOut << "static void classInit(int sample_rate) {}";
tab(n + 1, *fOut);
Expand Down Expand Up @@ -1452,7 +1487,7 @@ void CPPScalarOneSampleCodeContainer4::produceClass()
produceInfoFunctions(n + 1, "", "dsp", true, FunTyped::kVirtual, fCodeProducer);
}

// Dummy
// Dummy classInit
tab(n + 1, *fOut);
*fOut << "static void classInit(int sample_rate) {}";
tab(n + 1, *fOut);
Expand Down
11 changes: 11 additions & 0 deletions compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ void global::reset()
gRemoveVarAddress = false;
gOneSample = -1;
gOneSampleControl = false;
gInlineTable = false;
gComputeMix = false;
gBool2Int = false;
gFastMathLib = "";
Expand Down Expand Up @@ -1361,6 +1362,10 @@ bool global::processCmdline(int argc, const char* argv[])
gOneSample = 3;
i += 1;

} else if (isCmd(argv[i], "-it", "--inline-table")) {
gInlineTable = true;
i += 1;

} else if (isCmd(argv[i], "-cm", "--compute-mix")) {
gComputeMix = true;
i += 1;
Expand Down Expand Up @@ -1570,6 +1575,11 @@ bool global::processCmdline(int argc, const char* argv[])
"ERROR : '-dlt < INT_MAX' option can only be used in scalar mode and not with the 'ocpp' backend\n");
}

// gInlinetable check
if (gInlineTable && gOutputLang != "cpp") {
throw faustexception("ERROR : -it can only be used with 'cpp' backend\n");
}

// gComputeMix check
if (gComputeMix && gOutputLang == "ocpp") {
throw faustexception("ERROR : -cm cannot be used with the 'ocpp' backend\n");
Expand Down Expand Up @@ -1957,6 +1967,7 @@ static void printHelp()
<< "-os3 --one-sample3 generate one sample computation (3 = like 2 but with external "
"memory pointers kept in the DSP struct)."
<< endl;
cout << tab << "-it --inline-table inline rdtable/rwtable code in the main class." << endl;

cout << tab << "-cm --compute-mix mix in outputs buffers." << endl;
cout << tab << "-ct --check-table check rtable/rwtable index range and generate safe access code [0/1: 1 by default]." << endl;
Expand Down
1 change: 1 addition & 0 deletions compiler/global.hh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ struct global {
bool gRemoveVarAddress; // If use of variable addresses (like &foo or &foo[n]) have to be removed
int gOneSample; // -osX options, generate one sample computation
bool gOneSampleControl; // -osX options, generate one sample computation control structure in DSP module
bool gInlineTable; // -it option, only in -cpp backend, to inline rdtable/rwtable code in the main class.
bool gComputeMix; // -cm option, mix in outputs buffers
bool gBool2Int; // Cast bool binary operations (comparison operations) to int
std::string gNamespace; // Wrapping namespace used with the C++ backend
Expand Down
2 changes: 1 addition & 1 deletion documentation/compiler/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "FAUST compiler"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 2.64.1
PROJECT_NUMBER = 2.65.0

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
2 changes: 1 addition & 1 deletion documentation/libfaust/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = libfaust
PROJECT_NUMBER = 2.64.1
PROJECT_NUMBER = 2.65.0
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
Expand Down
2 changes: 1 addition & 1 deletion documentation/libfaustremote/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = libfaustremote
PROJECT_NUMBER = 2.64.1
PROJECT_NUMBER = 2.65.0
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
Expand Down
4 changes: 3 additions & 1 deletion documentation/man/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% man(1) Version 2.64.1 (03-August-2023) | Faust man page
% man(1) Version 2.65.0 (04-August-2023) | Faust man page

NAME
====
Expand Down Expand Up @@ -88,6 +88,8 @@ Code generation options:

**-os3** **--one-sample3** generate one sample computation (3 = like 2 but with external memory pointers kept in the DSP struct).

**-it** **--inline-table** inline rdtable/rwtable code in the main class.

**-cm** **--compute-mix** mix in outputs buffers.

**-ct** **--check-table** check rtable/rwtable index range and generate safe access code [0/1: 1 by default].
Expand Down
2 changes: 1 addition & 1 deletion documentation/man/man-header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% man(1) Version 2.64.1 (03-August-2023) | Faust man page
% man(1) Version 2.65.0 (04-August-2023) | Faust man page

NAME
====
Expand Down
Loading

0 comments on commit e14fa86

Please sign in to comment.