• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_DEOPTIMIZER_CALLEE_REG_H
17 #define ECMASCRIPT_DEOPTIMIZER_CALLEE_REG_H
18 
19 #include <map>
20 #include "ecmascript/common.h"
21 #include "ecmascript/stackmap/llvm_stackmap_type.h"
22 namespace panda::ecmascript::kungfu {
23 #if defined(PANDA_TARGET_AMD64)
24 static const int MAX_CALLEE_SAVE_REIGISTER_NUM = 32;
25 enum class DwarfReg: LLVMStackMapType::DwarfRegType {
26     RBX = 3,
27     R12 = 12,
28     R13 = 13,
29     R14 = 14,
30     R15 = 15,
31 };
32 #elif defined(PANDA_TARGET_ARM64)
33 static const int MAX_CALLEE_SAVE_REIGISTER_NUM = 32;
34 enum class DwarfReg: LLVMStackMapType::DwarfRegType {
35     D8 = 72,
36     D9 = 73,
37     D10 = 74,
38     D11 = 75,
39     D12 = 76,
40     D13 = 77,
41     D14 = 78,
42     D15 = 79,
43 
44     X19 = 19,
45     X20 = 20,
46     X21 = 21,
47     X22 = 22,
48     X23 = 23,
49     X24 = 24,
50     X25 = 25,
51     X26 = 26,
52     X27 = 27,
53     X28 = 28,
54 };
55 #else
56 static const int MAX_CALLEE_SAVE_REIGISTER_NUM = 16;
57 enum class DwarfReg: LLVMStackMapType::DwarfRegType {
58 };
59 #endif
60 class CalleeReg {
61 public:
62     PUBLIC_API CalleeReg();
63     virtual PUBLIC_API ~CalleeReg() = default;
64     int PUBLIC_API FindCallRegOrder(const LLVMStackMapType::DwarfRegType reg) const;
65     int PUBLIC_API FindCallRegOrder(const DwarfReg reg) const;
66     int PUBLIC_API GetCallRegNum() const;
67 private:
68     std::map<DwarfReg, int> reg2Location_;
69 };
70 } // namespace panda::ecmascript
71 #endif  // ECMASCRIPT_DEOPTIMIZER_CALLEE_REG_H
72