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_BUILTINS_H 17 #define LIBLLVMBACKEND_TRANSFORMS_BUILTINS_H 18 19 #include <llvm/ADT/Triple.h> 20 #include <llvm/IR/IRBuilder.h> 21 22 namespace ark::llvmbackend { 23 class LLVMArkInterface; 24 } // namespace ark::llvmbackend 25 26 namespace ark::llvmbackend::builtins { 27 llvm::Function *LenArray(llvm::Module *module); 28 llvm::Function *LoadClass(llvm::Module *module); 29 llvm::Function *LoadInitClass(llvm::Module *module); 30 llvm::Function *PreWRB(llvm::Module *module, unsigned addrSpace); 31 llvm::Function *PostWRB(llvm::Module *module, unsigned addrSpace); 32 llvm::Function *LoadString(llvm::Module *module); 33 llvm::Function *ResolveVirtual(llvm::Module *module); 34 llvm::Function *BarrierReturnVoid(llvm::Module *module); 35 llvm::Function *KeepThis(llvm::Module *module); 36 llvm::Value *LowerBuiltin(llvm::IRBuilder<> *builder, llvm::CallInst *inst, 37 ark::llvmbackend::LLVMArkInterface *arkInterface); 38 constexpr auto BUILTIN_SECTION = ".builtins"; 39 constexpr auto LEN_ARRAY_BUILTIN = "__builtin_lenarray"; 40 constexpr auto KEEP_THIS_BUILTIN = "__builtin_keep_this"; 41 constexpr auto LOAD_CLASS_BUILTIN = "__builtin_load_class"; 42 constexpr auto LOAD_INIT_CLASS_BUILTIN = "__builtin_load_init_class"; 43 constexpr auto PRE_WRB_BUILTIN = "__builtin_pre_wrb"; 44 constexpr auto PRE_WRB_GCADR_BUILTIN = "__builtin_pre_wrb_gcadr"; 45 constexpr auto POST_WRB_BUILTIN = "__builtin_post_wrb"; 46 constexpr auto POST_WRB_GCADR_BUILTIN = "__builtin_post_wrb_gcadr"; 47 constexpr auto LOAD_STRING_BUILTIN = "__builtin_load_string"; 48 constexpr auto RESOLVE_VIRTUAL_BUILTIN = "__builtin_resolve_virtual"; 49 constexpr auto BARRIER_RETURN_VOID_BUILTIN = "__builtin_barrier_return_void"; 50 } // namespace ark::llvmbackend::builtins 51 52 #endif // LIBLLVMBACKEND_TRANSFORMS_BUILTINS_H 53