• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RUNTIME_CALLS_H
17 #define LIBLLVMBACKEND_TRANSFORMS_RUNTIME_CALLS_H
18 
19 #include <llvm/IR/Function.h>
20 #include <llvm/IR/Instructions.h>
21 #include <llvm/IR/IRBuilder.h>
22 
23 namespace ark::llvmbackend {
24 
25 class LLVMArkInterface;
26 
27 }  // namespace ark::llvmbackend
28 
29 namespace ark::llvmbackend::runtime_calls {
30 
31 llvm::Value *GetAddressToTLS(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface, uintptr_t tlsOffset);
32 llvm::Value *LoadTLSValue(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface, uintptr_t tlsOffset,
33                           llvm::Type *type);
34 
35 llvm::FunctionCallee GetPandaRuntimeFunctionCallee(int entrypoint, llvm::FunctionType *functionProto,
36                                                    llvm::IRBuilder<> *builder, llvm::StringRef prefix = "");
37 
38 using EntrypointId = int;
39 llvm::CallInst *CreateEntrypointCallCommon(llvm::IRBuilder<> *builder, llvm::Value *threadRegValue,
40                                            LLVMArkInterface *arkInterface, EntrypointId eid,
41                                            llvm::ArrayRef<llvm::Value *> arguments = llvm::None,
42                                            llvm::ArrayRef<llvm::OperandBundleDef> bundle = llvm::None);
43 
44 llvm::Value *GetThreadRegValue(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface);
45 llvm::Value *GetRealFrameRegValue(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface);
46 
47 }  // namespace ark::llvmbackend::runtime_calls
48 
49 #endif  // LIBLLVMBACKEND_TRANSFORMS_RUNTIME_CALLS_H
50