1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MAPLE_IR_INCLUDE_BIN_MPLT_H 17 #define MAPLE_IR_INCLUDE_BIN_MPLT_H 18 #include "mir_module.h" 19 #include "mir_nodes.h" 20 #include "mir_preg.h" 21 #include "parser_opt.h" 22 #include "bin_mpl_export.h" 23 #include "bin_mpl_import.h" 24 25 namespace maple { 26 class BinaryMplt { 27 public: BinaryMplt(MIRModule & md)28 explicit BinaryMplt(MIRModule &md) : mirModule(md), binImport(md), binExport(md) {} 29 30 virtual ~BinaryMplt() = default; 31 32 void Export(const std::string &suffix, std::unordered_set<std::string> *dumpFuncSet = nullptr) 33 { 34 binExport.Export(suffix, dumpFuncSet); 35 } 36 37 bool Import(const std::string &modID, bool readCG = false, bool readSE = false) 38 { 39 importFileName = modID; 40 return binImport.Import(modID, readCG, readSE); 41 } 42 GetMod()43 const MIRModule &GetMod() const 44 { 45 return mirModule; 46 } 47 GetBinImport()48 BinaryMplImport &GetBinImport() 49 { 50 return binImport; 51 } 52 GetBinExport()53 BinaryMplExport &GetBinExport() 54 { 55 return binExport; 56 } 57 GetImportFileName()58 std::string &GetImportFileName() 59 { 60 return importFileName; 61 } 62 SetImportFileName(const std::string & fileName)63 void SetImportFileName(const std::string &fileName) 64 { 65 importFileName = fileName; 66 } 67 68 private: 69 MIRModule &mirModule; 70 BinaryMplImport binImport; 71 BinaryMplExport binExport; 72 std::string importFileName; 73 }; 74 } // namespace maple 75 #endif // MAPLE_IR_INCLUDE_BIN_MPLT_H 76