• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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 panda::llvmbackend {
29 class LLVMArkInterface;
30 }  // namespace panda::llvmbackend
31 
32 namespace panda::llvmbackend {
33 class LLVMOptimizer {
34 public:
35     void OptimizeModule(llvm::Module *module) const;
36     void ProcessInlineModule(llvm::Module *inlineModule) const;
37 
38     explicit LLVMOptimizer(panda::llvmbackend::LLVMCompilerOptions options, LLVMArkInterface *arkInterface,
39                            std::shared_ptr<llvm::TargetMachine> targetMachine);
40 
41 private:
42     void DoOptimizeModule(llvm::Module *module) const;
43 
44 private:
45     panda::llvmbackend::LLVMCompilerOptions options_;
46     panda::llvmbackend::LLVMArkInterface *arkInterface_;
47     std::shared_ptr<llvm::TargetMachine> targetMachine_;
48 };
49 
50 }  // namespace panda::llvmbackend
51 
52 #endif  // LIBLLVMBACKEND_TRANSFORMS_LLVM_OPTIMIZER_H
53