• 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 ECMASCRIPT_COMPILER_LITECG_CODEGEN_H
17 #define ECMASCRIPT_COMPILER_LITECG_CODEGEN_H
18 
19 #include "ecmascript/compiler/binary_section.h"
20 #include "ecmascript/compiler/codegen/maple/litecg_ir_builder.h"
21 #include "ecmascript/compiler/code_generator.h"
22 
23 namespace panda::ecmascript::kungfu {
24 class CompilerLog;
25 
26 class LiteCGAssembler : public Assembler {
27 public:
28     explicit LiteCGAssembler(LMIRModule &module, CodeInfo::CodeSpaceOnDemand &codeSpaceOnDemand,
29                              const std::vector<std::string> &litecgOptions);
30     virtual ~LiteCGAssembler() = default;
31     void Run(const CompilerLog &log, bool fastCompileMode, bool isJit = false) override;
32     void CollectAnStackMap(CGStackMapInfo &stackMapInfo);
33 
34 private:
35     LMIRModule &lmirModule;
36     const std::vector<std::string> &litecgOptions;
37 };
38 
39 class LiteCGIRGeneratorImpl : public CodeGeneratorImpl {
40 public:
LiteCGIRGeneratorImpl(LMIRModule * module,bool enableLog)41     LiteCGIRGeneratorImpl(LMIRModule *module, bool enableLog) : module_(module), enableLog_(enableLog) {}
42     ~LiteCGIRGeneratorImpl() override = default;
43     void GenerateCodeForStub(Circuit *circuit, const ControlFlowGraph &graph, size_t index,
44                              const CompilationConfig *cfg) override;
45     void GenerateCode(Circuit *circuit, const ControlFlowGraph &graph, const CompilationConfig *cfg,
46                       const MethodLiteral *methodLiteral, const JSPandaFile *jsPandaFile, const std::string &methodName,
47                       const FrameType frameType, bool enableOptInlining, bool enableBranchProfiling) override;
48 
IsLogEnabled()49     bool IsLogEnabled() const
50     {
51         return enableLog_;
52     }
53 
GetModule()54     LMIRModule *GetModule() const
55     {
56         return module_;
57     }
58 
59 private:
60     LMIRModule *module_;
61     bool enableLog_ {false};
62 };
63 }  // namespace panda::ecmascript::kungfu
64 #endif  // ECMASCRIPT_COMPILER_LITECG_CODEGEN_H
65