1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_ARCH_RISCV64_REGISTERS_RISCV64_H_ 18 #define ART_RUNTIME_ARCH_RISCV64_REGISTERS_RISCV64_H_ 19 20 #include <iosfwd> 21 22 #include "base/macros.h" 23 24 namespace art HIDDEN { 25 namespace riscv64 { 26 27 enum XRegister { 28 Zero = 0, // X0, hard-wired zero 29 RA = 1, // X1, return address 30 SP = 2, // X2, stack pointer 31 GP = 3, // X3, global pointer (unavailable, used for shadow stack by the compiler / libc) 32 TP = 4, // X4, thread pointer (points to TLS area, not ART-internal thread) 33 34 T0 = 5, // X5, temporary 0 35 T1 = 6, // X6, temporary 1 36 T2 = 7, // X7, temporary 2 37 38 S0 = 8, // X8/FP, callee-saved 0 / frame pointer 39 S1 = 9, // X9, callee-saved 1 / ART thread register 40 41 A0 = 10, // X10, argument 0 / return value 0 42 A1 = 11, // X11, argument 1 / return value 1 43 A2 = 12, // X12, argument 2 44 A3 = 13, // X13, argument 3 45 A4 = 14, // X14, argument 4 46 A5 = 15, // X15, argument 5 47 A6 = 16, // X16, argument 6 48 A7 = 17, // X17, argument 7 49 50 S2 = 18, // X18, callee-saved 2 51 S3 = 19, // X19, callee-saved 3 52 S4 = 20, // X20, callee-saved 4 53 S5 = 21, // X21, callee-saved 5 54 S6 = 22, // X22, callee-saved 6 55 S7 = 23, // X23, callee-saved 7 56 S8 = 24, // X24, callee-saved 8 57 S9 = 25, // X25, callee-saved 9 58 S10 = 26, // X26, callee-saved 10 59 S11 = 27, // X27, callee-saved 11 60 61 T3 = 28, // X28, temporary 3 62 T4 = 29, // X29, temporary 4 63 T5 = 30, // X30, temporary 5 64 T6 = 31, // X31, temporary 6 65 66 kNumberOfXRegisters = 32, 67 kNoXRegister = -1, // Signals an illegal X register. 68 69 // Aliases. 70 TR = S1, // ART Thread Register - managed runtime 71 TMP = T6, // Reserved for special uses, such as assembler macro instructions. 72 TMP2 = T5, // Reserved for special uses, such as assembler macro instructions. 73 }; 74 75 std::ostream& operator<<(std::ostream& os, const XRegister& rhs); 76 77 enum FRegister { 78 FT0 = 0, // F0, temporary 0 79 FT1 = 1, // F1, temporary 1 80 FT2 = 2, // F2, temporary 2 81 FT3 = 3, // F3, temporary 3 82 FT4 = 4, // F4, temporary 4 83 FT5 = 5, // F5, temporary 5 84 FT6 = 6, // F6, temporary 6 85 FT7 = 7, // F7, temporary 7 86 87 FS0 = 8, // F8, callee-saved 0 88 FS1 = 9, // F9, callee-saved 1 89 90 FA0 = 10, // F10, argument 0 / return value 0 91 FA1 = 11, // F11, argument 1 / return value 1 92 FA2 = 12, // F12, argument 2 93 FA3 = 13, // F13, argument 3 94 FA4 = 14, // F14, argument 4 95 FA5 = 15, // F15, argument 5 96 FA6 = 16, // F16, argument 6 97 FA7 = 17, // F17, argument 7 98 99 FS2 = 18, // F18, callee-saved 2 100 FS3 = 19, // F19, callee-saved 3 101 FS4 = 20, // F20, callee-saved 4 102 FS5 = 21, // F21, callee-saved 5 103 FS6 = 22, // F22, callee-saved 6 104 FS7 = 23, // F23, callee-saved 7 105 FS8 = 24, // F24, callee-saved 8 106 FS9 = 25, // F25, callee-saved 9 107 FS10 = 26, // F26, callee-saved 10 108 FS11 = 27, // F27, callee-saved 11 109 110 FT8 = 28, // F28, temporary 8 111 FT9 = 29, // F29, temporary 9 112 FT10 = 30, // F30, temporary 10 113 FT11 = 31, // F31, temporary 11 114 115 kNumberOfFRegisters = 32, 116 kNoFRegister = -1, // Signals an illegal F register. 117 118 FTMP = FT11, // Reserved for special uses, such as assembler macro instructions. 119 }; 120 121 std::ostream& operator<<(std::ostream& os, const FRegister& rhs); 122 123 enum VRegister { 124 V0 = 0, // V0, argument 0 125 V1 = 1, // V1, callee-saved 0 126 V2 = 2, // V2, callee-saved 1 127 V3 = 3, // V3, callee-saved 2 128 V4 = 4, // V4, callee-saved 3 129 V5 = 5, // V5, callee-saved 4 130 V6 = 6, // V6, callee-saved 5 131 V7 = 7, // V7, callee-saved 6 132 133 V8 = 8, // V8, argument 1 134 V9 = 9, // V9, argument 2 135 V10 = 10, // V10, argument 3 136 V11 = 11, // V11, argument 4 137 V12 = 12, // V12, argument 5 138 V13 = 13, // V13, argument 6 139 V14 = 14, // V14, argument 7 140 V15 = 15, // V15, argument 8 141 142 V16 = 16, // V16, argument 9 143 V17 = 17, // V17, argument 10 144 V18 = 18, // V18, argument 11 145 V19 = 19, // V19, argument 12 146 V20 = 20, // V20, argument 13 147 V21 = 21, // V21, argument 14 148 V22 = 22, // V22, argument 15 149 V23 = 23, // V23, argument 16 150 151 V24 = 24, // V24, callee-saved 7 152 V25 = 25, // V25, callee-saved 8 153 V26 = 26, // V26, callee-saved 9 154 V27 = 27, // V27, callee-saved 10 155 V28 = 28, // V28, callee-saved 11 156 V29 = 29, // V29, callee-saved 12 157 V30 = 30, // V30, callee-saved 13 158 V31 = 31, // V31, callee-saved 14 159 160 kNumberOfVRegisters = 32, 161 kNoVRegister = -1, // Signals an illegal V register. 162 }; 163 164 std::ostream& operator<<(std::ostream& os, const VRegister& rhs); 165 166 } // namespace riscv64 167 } // namespace art 168 169 #endif // ART_RUNTIME_ARCH_RISCV64_REGISTERS_RISCV64_H_ 170