1 /************************************************************************ 2 ************************************************************************ 3 FAUST compiler 4 Copyright (C) 2003-2018 GRAME, Centre National de Creation Musicale 5 --------------------------------------------------------------------- 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 ************************************************************************ 20 ************************************************************************/ 21 22 #ifndef LLVM_DYNAMIC_DSP_AUX_H 23 #define LLVM_DYNAMIC_DSP_AUX_H 24 25 #include "llvm_dsp_aux.hh" 26 27 class llvm_dynamic_dsp_factory_aux : public llvm_dsp_factory_aux { 28 private: 29 bool writeDSPFactoryToObjectcodeFileAux(const std::string& object_code_path); 30 31 public: llvm_dynamic_dsp_factory_aux(const std::string & sha_key,llvm::Module * module,llvm::LLVMContext * context,const std::string & target,int opt_level=-1)32 llvm_dynamic_dsp_factory_aux(const std::string& sha_key, llvm::Module* module, llvm::LLVMContext* context, 33 const std::string& target, int opt_level = -1) 34 : llvm_dsp_factory_aux(sha_key, module, context, target, opt_level) 35 { 36 } 37 llvm_dynamic_dsp_factory_aux(const std::string & sha_key,const std::string & machine_code,const std::string & target)38 llvm_dynamic_dsp_factory_aux(const std::string& sha_key, const std::string& machine_code, const std::string& target) 39 : llvm_dsp_factory_aux(sha_key, machine_code, target) 40 { 41 } 42 43 virtual bool initJIT(std::string& error_msg); 44 45 void write(std::ostream* out, bool binary, bool small = false); 46 47 // Bitcode 48 std::string writeDSPFactoryToBitcode(); 49 50 bool writeDSPFactoryToBitcodeFile(const std::string& bit_code_path); 51 52 // IR 53 virtual std::string writeDSPFactoryToIR(); 54 55 virtual bool writeDSPFactoryToIRFile(const std::string& ir_code_path); 56 57 // Object code 58 bool writeDSPFactoryToObjectcodeFile(const std::string& object_code_path, const std::string& target); 59 }; 60 61 EXPORT llvm_dsp_factory* createDSPFactoryFromFile(const std::string& filename, int argc, const char* argv[], 62 const std::string& target, std::string& error_msg, 63 int opt_level = -1); 64 65 EXPORT llvm_dsp_factory* createDSPFactoryFromString(const std::string& name_app, const std::string& dsp_content, 66 int argc, const char* argv[], const std::string& target, 67 std::string& error_msg, int opt_level = -1); 68 69 EXPORT llvm_dsp_factory* createDSPFactoryFromSignals(const std::string& name_app, tvec signals, 70 int argc, const char* argv[], const std::string& target, 71 std::string& error_msg, int opt_level = -1); 72 73 EXPORT llvm_dsp_factory* createDSPFactoryFromBoxes(const std::string& name_app, Tree box, 74 int argc, const char* argv[], const std::string& target, 75 std::string& error_msg, int opt_level = -1); 76 77 // Bitcode <==> string 78 EXPORT llvm_dsp_factory* readDSPFactoryFromBitcode(const std::string& bit_code, const std::string& target, 79 std::string& error_msg, int opt_level = 0); 80 81 EXPORT std::string writeDSPFactoryToBitcode(llvm_dsp_factory* factory); 82 83 // Bitcode <==> file 84 EXPORT llvm_dsp_factory* readDSPFactoryFromBitcodeFile(const std::string& bit_code_path, const std::string& target, 85 std::string& error_msg, int opt_level = 0); 86 87 EXPORT bool writeDSPFactoryToBitcodeFile(llvm_dsp_factory* factory, const std::string& bit_code_path); 88 89 // IR <==> string 90 EXPORT llvm_dsp_factory* readDSPFactoryFromIR(const std::string& ir_code, const std::string& target, 91 std::string& error_msg, int opt_level = 0); 92 93 EXPORT std::string writeDSPFactoryToIR(llvm_dsp_factory* factory); 94 95 // IR <==> file 96 EXPORT llvm_dsp_factory* readDSPFactoryFromIRFile(const std::string& ir_code_path, const std::string& target, 97 std::string& error_msg, int opt_level = 0); 98 99 EXPORT bool writeDSPFactoryToIRFile(llvm_dsp_factory* factory, const std::string& ir_code_path); 100 101 // IR ==> object code 102 EXPORT bool writeDSPFactoryToObjectcodeFile(llvm_dsp_factory* factory, const std::string& object_code_path, 103 const std::string& target); 104 105 #ifdef __cplusplus 106 extern "C" { 107 #endif 108 109 // Public C interface 110 111 EXPORT llvm_dsp_factory* createCDSPFactoryFromFile(const char* filename, int argc, const char* argv[], 112 const char* target, char* error_msg, int opt_level); 113 114 EXPORT llvm_dsp_factory* createCDSPFactoryFromString(const char* name_app, const char* dsp_content, int argc, 115 const char* argv[], const char* target, char* error_msg, 116 int opt_level); 117 118 EXPORT llvm_dsp_factory* createCDSPFactoryFromSignals(const char* name_app, Signal* signals, 119 int argc, const char* argv[], 120 const char* target, 121 char* error_msg, 122 int opt_level = -1); 123 124 EXPORT llvm_dsp_factory* createCDSPFactoryFromBoxes(const char* name_app, 125 Tree box, 126 int argc, const char* argv[], 127 const char* target, 128 char* error_msg, 129 int opt_level = -1); 130 131 EXPORT llvm_dsp_factory* readCDSPFactoryFromBitcode(const char* bit_code, const char* target, char* error_msg, 132 int opt_level); 133 134 EXPORT char* writeCDSPFactoryToBitcode(llvm_dsp_factory* factory); 135 136 EXPORT llvm_dsp_factory* readCDSPFactoryFromBitcodeFile(const char* bit_code_path, const char* target, char* error_msg, 137 int opt_level); 138 139 EXPORT bool writeCDSPFactoryToBitcodeFile(llvm_dsp_factory* factory, const char* bit_code_path); 140 141 EXPORT llvm_dsp_factory* readCDSPFactoryFromIR(const char* ir_code, const char* target, char* error_msg, int opt_level); 142 143 EXPORT char* writeCDSPFactoryToIR(llvm_dsp_factory* factory); 144 145 EXPORT llvm_dsp_factory* readCDSPFactoryFromIRFile(const char* ir_code_path, const char* target, char* error_msg, 146 int opt_level); 147 148 EXPORT bool writeCDSPFactoryToIRFile(llvm_dsp_factory* factory, const char* ir_code_path); 149 150 #ifdef __cplusplus 151 } 152 #endif 153 154 #endif 155