From c06e9c63a7236c3d60e1a77e226b3d91c297a08d Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Fri, 16 Apr 2021 10:19:36 +0200 Subject: [PATCH] Improve compilation options pretty printing. --- compiler/generator/c/c_code_container.cpp | 3 --- .../generator/csharp/csharp_code_container.cpp | 3 --- .../generator/dlang/dlang_code_container.cpp | 3 --- .../interpreter/interpreter_code_container.cpp | 3 --- .../generator/java/java_code_container.cpp | 3 --- .../generator/llvm/llvm_code_container.cpp | 3 --- .../generator/rust/rust_code_container.cpp | 3 --- .../generator/wasm/wasm_code_container.cpp | 3 --- .../generator/wasm/wast_code_container.cpp | 3 --- compiler/global.cpp | 18 +++++++++--------- compiler/libcode.cpp | 7 ++++++- 11 files changed, 15 insertions(+), 37 deletions(-) diff --git a/compiler/generator/c/c_code_container.cpp b/compiler/generator/c/c_code_container.cpp index 7b3128b883..268dfac2bb 100644 --- a/compiler/generator/c/c_code_container.cpp +++ b/compiler/generator/c/c_code_container.cpp @@ -55,9 +55,6 @@ CodeContainer* CCodeContainer::createContainer(const string& name, int numInputs gGlobal->gDSPStruct = true; CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for C\n"); - } if (gGlobal->gOpenCLSwitch) { throw faustexception("ERROR : OpenCL not supported for C\n"); } diff --git a/compiler/generator/csharp/csharp_code_container.cpp b/compiler/generator/csharp/csharp_code_container.cpp index 2fc80c0554..e8625adf82 100644 --- a/compiler/generator/csharp/csharp_code_container.cpp +++ b/compiler/generator/csharp/csharp_code_container.cpp @@ -48,9 +48,6 @@ CodeContainer* CSharpCodeContainer::createContainer(const string& name, const st { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for CSharp\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for CSharp\n"); } diff --git a/compiler/generator/dlang/dlang_code_container.cpp b/compiler/generator/dlang/dlang_code_container.cpp index 48ff208535..e714dbab75 100644 --- a/compiler/generator/dlang/dlang_code_container.cpp +++ b/compiler/generator/dlang/dlang_code_container.cpp @@ -49,9 +49,6 @@ CodeContainer* DLangCodeContainer::createContainer(const string& name, const str { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for D\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for D\n"); } diff --git a/compiler/generator/interpreter/interpreter_code_container.cpp b/compiler/generator/interpreter/interpreter_code_container.cpp index b2f5246d79..c88f3621cf 100644 --- a/compiler/generator/interpreter/interpreter_code_container.cpp +++ b/compiler/generator/interpreter/interpreter_code_container.cpp @@ -95,9 +95,6 @@ CodeContainer* InterpreterCodeContainer::createContainer(const string& nam { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for Interpreter\n"); - } if (gGlobal->gOpenCLSwitch) { throw faustexception("ERROR : OpenCL not supported for Interpreter\n"); } diff --git a/compiler/generator/java/java_code_container.cpp b/compiler/generator/java/java_code_container.cpp index 27be48f9f3..1374227bba 100644 --- a/compiler/generator/java/java_code_container.cpp +++ b/compiler/generator/java/java_code_container.cpp @@ -47,9 +47,6 @@ CodeContainer* JAVACodeContainer::createContainer(const string& name, const stri { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for Java\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for Java\n"); } diff --git a/compiler/generator/llvm/llvm_code_container.cpp b/compiler/generator/llvm/llvm_code_container.cpp index d7c8db3c1c..4160a86767 100644 --- a/compiler/generator/llvm/llvm_code_container.cpp +++ b/compiler/generator/llvm/llvm_code_container.cpp @@ -96,9 +96,6 @@ CodeContainer* LLVMCodeContainer::createContainer(const string& name, int numInp gGlobal->gDSPStruct = true; CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for LLVM\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for LLVM\n"); } diff --git a/compiler/generator/rust/rust_code_container.cpp b/compiler/generator/rust/rust_code_container.cpp index 8ede93e938..7a0c5070b6 100644 --- a/compiler/generator/rust/rust_code_container.cpp +++ b/compiler/generator/rust/rust_code_container.cpp @@ -60,9 +60,6 @@ CodeContainer* RustCodeContainer::createContainer(const string& name, int numInp gGlobal->gDSPStruct = true; CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for Rust\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for Rust\n"); } diff --git a/compiler/generator/wasm/wasm_code_container.cpp b/compiler/generator/wasm/wasm_code_container.cpp index b6d2e51317..9e24782d0e 100644 --- a/compiler/generator/wasm/wasm_code_container.cpp +++ b/compiler/generator/wasm/wasm_code_container.cpp @@ -90,9 +90,6 @@ CodeContainer* WASMCodeContainer::createContainer(const string& name, int numInp { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for WebAssembly\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for WebAssembly\n"); } diff --git a/compiler/generator/wasm/wast_code_container.cpp b/compiler/generator/wasm/wast_code_container.cpp index e17c0de5ac..f26fb7f7ac 100644 --- a/compiler/generator/wasm/wast_code_container.cpp +++ b/compiler/generator/wasm/wast_code_container.cpp @@ -87,9 +87,6 @@ CodeContainer* WASTCodeContainer::createContainer(const string& name, int numInp { CodeContainer* container; - if (gGlobal->gMemoryManager) { - throw faustexception("ERROR : -mem not supported for WebAssembly\n"); - } if (gGlobal->gFloatSize == 3) { throw faustexception("ERROR : quad format not supported for WebAssembly\n"); } diff --git a/compiler/global.cpp b/compiler/global.cpp index bba1654362..871519b6da 100644 --- a/compiler/global.cpp +++ b/compiler/global.cpp @@ -596,13 +596,13 @@ static string printFloat() { switch (gGlobal->gFloatSize) { case 1: - return " -single"; + return "-single "; case 2: - return " -double"; + return "-double "; case 3: - return " -quad"; + return "-quad "; case 4: - return " -fp"; + return "-fp "; default: faustassert(false); return ""; @@ -636,12 +636,12 @@ void global::printCompilationOptions(stringstream& dst, bool backend) if (gSchedulerSwitch) dst << "-sch "; if (gOpenMPSwitch) dst << "-omp " << ((gOpenMPLoop) ? "-pl " : ""); if (gVectorSwitch) { - dst << "-vec" - << " -lv " << gVectorLoopVariant << " -vs " << gVecSize << ((gFunTaskSwitch) ? " -fun" : "") - << ((gGroupTaskSwitch) ? " -g" : "") << ((gDeepFirstSwitch) ? " -dfs" : "") - << printFloat() << " -ftz " << gFTZMode << " -mcd " << gGlobal->gMaxCopyDelay; + dst << "-vec " + << "-lv " << gVectorLoopVariant << " " << "-vs " << gVecSize << " " << ((gFunTaskSwitch) ? "-fun " : "") + << ((gGroupTaskSwitch) ? "-g " : "") << ((gDeepFirstSwitch) ? "-dfs " : "") + << printFloat() << "-ftz " << gFTZMode << " " << "-mcd " << gGlobal->gMaxCopyDelay; } else { - dst << printFloat() << " -ftz " << gFTZMode; + dst << printFloat() << "-ftz " << gFTZMode; } // Add 'compile_options' metadata diff --git a/compiler/libcode.cpp b/compiler/libcode.cpp index 257869e0be..43689e5e27 100644 --- a/compiler/libcode.cpp +++ b/compiler/libcode.cpp @@ -670,7 +670,7 @@ static bool processCmdline(int argc, const char* argv[]) // Check options coherency if (gGlobal->gInPlace && gGlobal->gVectorSwitch) { - throw faustexception("ERROR : 'in-place' option can only be used in scalar mode\n"); + throw faustexception("ERROR : '-inpl' option can only be used in scalar mode\n"); } #if 0 @@ -730,6 +730,7 @@ static bool processCmdline(int argc, const char* argv[]) throw faustexception("ERROR : '-dlt < INT_MAX' option can only be used in scalar mode and not with the 'ocpp' backend\n"); } + // gComputeMix check if (gGlobal->gComputeMix && gGlobal->gOutputLang == "ocpp") { throw faustexception("ERROR : -cm cannot be used with the 'ocpp' backend\n"); } @@ -746,6 +747,10 @@ static bool processCmdline(int argc, const char* argv[]) throw faustexception("ERROR : -fx can ony be used with 'c', 'cpp' or 'ocpp' backends\n"); } + if (gGlobal->gMemoryManager && gGlobal->gOutputLang != "cpp" && gGlobal->gOutputLang != "ocpp") { + throw faustexception("ERROR : -mem can ony be used with 'cpp' or 'ocpp' backends\n"); + } + if (gGlobal->gArchFile != "" && ((gGlobal->gOutputLang == "wast") || (gGlobal->gOutputLang == "wasm")