1 /* 2 * Copyright (c) 2021-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 PANDA_PAOC_LLVM_H 17 #define PANDA_PAOC_LLVM_H 18 19 #include "llvm_compiler_creator.h" 20 #include "llvm_options.h" 21 #include "paoc.h" 22 23 namespace ark::compiler { 24 class LLVMAotBuilder; 25 } // namespace ark::compiler 26 27 namespace ark::paoc { 28 29 class PaocLLVM : public Paoc { 30 protected: AddExtraOptions(PandArgParser * parser)31 void AddExtraOptions(PandArgParser *parser) override 32 { 33 ark::llvmbackend::g_options.AddOptions(parser); 34 } 35 void ValidateExtraOptions() override; 36 void Clear(ark::mem::InternalAllocatorPtr allocator) override; 37 LLVMCompilerStatus TryLLVM(CompilingContext *ctx) override; 38 void PrepareLLVM(const ark::Span<const char *> &args) override; 39 bool EndLLVM() override; 40 41 std::unique_ptr<compiler::AotBuilder> CreateAotBuilder() override; 42 43 compiler::LLVMAotBuilder *GetAotBuilder(); 44 45 private: 46 std::unique_ptr<llvmbackend::CompilerInterface> llvmAotCompiler_ {nullptr}; 47 }; 48 49 } // namespace ark::paoc 50 #endif // PANDA_PAOC_LLVM_H 51