1 /* 2 * Copyright (c) 2023-2024 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 LIBLLVMBACKEND_TRANSFORMS_LLVM_OPTIMIZER_H 17 #define LIBLLVMBACKEND_TRANSFORMS_LLVM_OPTIMIZER_H 18 19 #include "llvm_compiler_options.h" 20 21 #include <memory> 22 23 namespace llvm { 24 class Module; 25 class TargetMachine; 26 } // namespace llvm 27 28 namespace ark::llvmbackend { 29 class LLVMArkInterface; 30 } // namespace ark::llvmbackend 31 32 namespace ark::llvmbackend { 33 class LLVMOptimizer { 34 public: 35 void DumpModuleBefore(llvm::Module *module) const; 36 void DumpModuleAfter(llvm::Module *module) const; 37 void OptimizeModule(llvm::Module *module) const; 38 void ProcessInlineModule(llvm::Module *inlineModule) const; 39 40 explicit LLVMOptimizer(ark::llvmbackend::LLVMCompilerOptions options, LLVMArkInterface *arkInterface, 41 const std::unique_ptr<llvm::TargetMachine> &targetMachine); 42 43 private: 44 ark::llvmbackend::LLVMCompilerOptions options_; 45 ark::llvmbackend::LLVMArkInterface *arkInterface_; 46 const std::unique_ptr<llvm::TargetMachine> &targetMachine_; 47 }; 48 49 } // namespace ark::llvmbackend 50 51 #endif // LIBLLVMBACKEND_TRANSFORMS_LLVM_OPTIMIZER_H 52