| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef jit_riscv64_Register_riscv64_h |
| 8 |
#define jit_riscv64_Register_riscv64_h |
| 9 |
|
| 10 |
#include "mozilla/Assertions.h" |
| 11 |
|
| 12 |
#include <stdint.h> |
| 13 |
|
| 14 |
#include "jit/Registers.h" |
| 15 |
#include "jit/RegisterSets.h" |
| 16 |
|
| 17 |
namespace js { |
| 18 |
namespace jit { |
| 19 |
|
| 20 |
static constexpr Register zero{Registers::zero}; |
| 21 |
static constexpr Register ra{Registers::ra}; |
| 22 |
static constexpr Register tp{Registers::tp}; |
| 23 |
static constexpr Register sp{Registers::sp}; |
| 24 |
static constexpr Register gp{Registers::gp}; |
| 25 |
static constexpr Register a0{Registers::a0}; |
| 26 |
static constexpr Register a1{Registers::a1}; |
| 27 |
static constexpr Register a2{Registers::a2}; |
| 28 |
static constexpr Register a3{Registers::a3}; |
| 29 |
static constexpr Register a4{Registers::a4}; |
| 30 |
static constexpr Register a5{Registers::a5}; |
| 31 |
static constexpr Register a6{Registers::a6}; |
| 32 |
static constexpr Register a7{Registers::a7}; |
| 33 |
static constexpr Register t0{Registers::t0}; |
| 34 |
static constexpr Register t1{Registers::t1}; |
| 35 |
static constexpr Register t2{Registers::t2}; |
| 36 |
static constexpr Register t3{Registers::t3}; |
| 37 |
static constexpr Register t4{Registers::t4}; |
| 38 |
static constexpr Register t5{Registers::t5}; |
| 39 |
static constexpr Register t6{Registers::t6}; |
| 40 |
static constexpr Register fp{Registers::fp}; |
| 41 |
static constexpr Register s1{Registers::s1}; |
| 42 |
static constexpr Register s2{Registers::s2}; |
| 43 |
static constexpr Register s3{Registers::s3}; |
| 44 |
static constexpr Register s4{Registers::s4}; |
| 45 |
static constexpr Register s5{Registers::s5}; |
| 46 |
static constexpr Register s6{Registers::s6}; |
| 47 |
static constexpr Register s7{Registers::s7}; |
| 48 |
static constexpr Register s8{Registers::s8}; |
| 49 |
static constexpr Register s9{Registers::s9}; |
| 50 |
static constexpr Register s10{Registers::s10}; |
| 51 |
static constexpr Register s11{Registers::s11}; |
| 52 |
|
| 53 |
static constexpr FloatRegister ft0{FloatRegisters::f0}; |
| 54 |
static constexpr FloatRegister ft1{FloatRegisters::f1}; |
| 55 |
static constexpr FloatRegister ft2{FloatRegisters::f2}; |
| 56 |
static constexpr FloatRegister ft3{FloatRegisters::f3}; |
| 57 |
static constexpr FloatRegister ft4{FloatRegisters::f4}; |
| 58 |
static constexpr FloatRegister ft5{FloatRegisters::f5}; |
| 59 |
static constexpr FloatRegister ft6{FloatRegisters::f6}; |
| 60 |
static constexpr FloatRegister ft7{FloatRegisters::f7}; |
| 61 |
static constexpr FloatRegister fs0{FloatRegisters::f8}; |
| 62 |
static constexpr FloatRegister fs1{FloatRegisters::f9}; |
| 63 |
static constexpr FloatRegister fa0{FloatRegisters::f10}; |
| 64 |
static constexpr FloatRegister fa1{FloatRegisters::f11}; |
| 65 |
static constexpr FloatRegister fa2{FloatRegisters::f12}; |
| 66 |
static constexpr FloatRegister fa3{FloatRegisters::f13}; |
| 67 |
static constexpr FloatRegister fa4{FloatRegisters::f14}; |
| 68 |
static constexpr FloatRegister fa5{FloatRegisters::f15}; |
| 69 |
static constexpr FloatRegister fa6{FloatRegisters::f16}; |
| 70 |
static constexpr FloatRegister fa7{FloatRegisters::f17}; |
| 71 |
static constexpr FloatRegister fs2{FloatRegisters::f18}; |
| 72 |
static constexpr FloatRegister fs3{FloatRegisters::f19}; |
| 73 |
static constexpr FloatRegister fs4{FloatRegisters::f20}; |
| 74 |
static constexpr FloatRegister fs5{FloatRegisters::f21}; |
| 75 |
static constexpr FloatRegister fs6{FloatRegisters::f22}; |
| 76 |
static constexpr FloatRegister fs7{FloatRegisters::f23}; |
| 77 |
static constexpr FloatRegister fs8{FloatRegisters::f24}; |
| 78 |
static constexpr FloatRegister fs9{FloatRegisters::f25}; |
| 79 |
static constexpr FloatRegister fs10{FloatRegisters::f26}; |
| 80 |
static constexpr FloatRegister fs11{FloatRegisters::f27}; |
| 81 |
static constexpr FloatRegister ft8{FloatRegisters::f28}; |
| 82 |
static constexpr FloatRegister ft9{FloatRegisters::f29}; |
| 83 |
static constexpr FloatRegister ft10{FloatRegisters::f30}; |
| 84 |
static constexpr FloatRegister ft11{FloatRegisters::f31}; |
| 85 |
|
| 86 |
static constexpr Register StackPointer{Registers::sp}; |
| 87 |
static constexpr Register FramePointer{Registers::fp}; |
| 88 |
static constexpr Register ReturnReg{Registers::a0}; |
| 89 |
static constexpr Register ScratchRegister{Registers::s11}; |
| 90 |
static constexpr Register64 ReturnReg64(ReturnReg); |
| 91 |
|
| 92 |
static constexpr FloatRegister ReturnFloat32Reg{FloatRegisters::fa0}; |
| 93 |
static constexpr FloatRegister ReturnDoubleReg{FloatRegisters::fa0}; |
| 94 |
#ifdef ENABLE_WASM_SIMD |
| 95 |
static constexpr FloatRegister ReturnSimd128Reg{FloatRegisters::invalid_reg}; |
| 96 |
static constexpr FloatRegister ScratchSimd128Reg{FloatRegisters::invalid_reg}; |
| 97 |
#endif |
| 98 |
static constexpr FloatRegister InvalidFloatReg{}; |
| 99 |
|
| 100 |
static constexpr FloatRegister ScratchFloat32Reg{FloatRegisters::ft10}; |
| 101 |
static constexpr FloatRegister ScratchDoubleReg{FloatRegisters::ft10}; |
| 102 |
static constexpr FloatRegister ScratchDoubleReg2{FloatRegisters::fs11}; |
| 103 |
|
| 104 |
static constexpr Register OsrFrameReg{Registers::a3}; |
| 105 |
static constexpr Register PreBarrierReg{Registers::a1}; |
| 106 |
static constexpr Register InterpreterPCReg{Registers::t0}; |
| 107 |
static constexpr Register CallTempReg0{Registers::t0}; |
| 108 |
static constexpr Register CallTempReg1{Registers::t1}; |
| 109 |
static constexpr Register CallTempReg2{Registers::t2}; |
| 110 |
static constexpr Register CallTempReg3{Registers::t3}; |
| 111 |
static constexpr Register CallTempReg4{Registers::a6}; |
| 112 |
static constexpr Register CallTempReg5{Registers::a7}; |
| 113 |
static constexpr Register InvalidReg{Registers::invalid_reg}; |
| 114 |
static constexpr Register CallTempNonArgRegs[] = {t0, t1, t2, t3}; |
| 115 |
static const uint32_t NumCallTempNonArgRegs = std::size(CallTempNonArgRegs); |
| 116 |
|
| 117 |
static constexpr Register IntArgReg0{Registers::a0}; |
| 118 |
static constexpr Register IntArgReg1{Registers::a1}; |
| 119 |
static constexpr Register IntArgReg2{Registers::a2}; |
| 120 |
static constexpr Register IntArgReg3{Registers::a3}; |
| 121 |
static constexpr Register IntArgReg4{Registers::a4}; |
| 122 |
static constexpr Register IntArgReg5{Registers::a5}; |
| 123 |
static constexpr Register IntArgReg6{Registers::a6}; |
| 124 |
static constexpr Register IntArgReg7{Registers::a7}; |
| 125 |
static constexpr Register HeapReg{Registers::s7}; |
| 126 |
|
| 127 |
// Registers used by RegExpMatcher and RegExpExecMatch stubs (do not use |
| 128 |
// JSReturnOperand). |
| 129 |
static constexpr Register RegExpMatcherRegExpReg = CallTempReg0; |
| 130 |
static constexpr Register RegExpMatcherStringReg = CallTempReg1; |
| 131 |
static constexpr Register RegExpMatcherLastIndexReg = CallTempReg2; |
| 132 |
|
| 133 |
// Registers used by RegExpExecTest stub (do not use ReturnReg). |
| 134 |
static constexpr Register RegExpExecTestRegExpReg = CallTempReg0; |
| 135 |
static constexpr Register RegExpExecTestStringReg = CallTempReg1; |
| 136 |
|
| 137 |
// Registers used by RegExpSearcher stub (do not use ReturnReg). |
| 138 |
static constexpr Register RegExpSearcherRegExpReg = CallTempReg0; |
| 139 |
static constexpr Register RegExpSearcherStringReg = CallTempReg1; |
| 140 |
static constexpr Register RegExpSearcherLastIndexReg = CallTempReg2; |
| 141 |
|
| 142 |
static constexpr Register JSReturnReg_Type{Registers::a3}; |
| 143 |
static constexpr Register JSReturnReg_Data{Registers::s2}; |
| 144 |
static constexpr Register JSReturnReg{Registers::a2}; |
| 145 |
static constexpr ValueOperand JSReturnOperand = ValueOperand(JSReturnReg); |
| 146 |
|
| 147 |
// These registers may be volatile or nonvolatile. |
| 148 |
static constexpr Register ABINonArgReg0{Registers::t0}; |
| 149 |
static constexpr Register ABINonArgReg1{Registers::t1}; |
| 150 |
static constexpr Register ABINonArgReg2{Registers::t2}; |
| 151 |
static constexpr Register ABINonArgReg3{Registers::t3}; |
| 152 |
|
| 153 |
// These registers may be volatile or nonvolatile. |
| 154 |
// Note: these three registers are all guaranteed to be different |
| 155 |
static constexpr Register ABINonArgReturnReg0{Registers::t0}; |
| 156 |
static constexpr Register ABINonArgReturnReg1{Registers::t1}; |
| 157 |
static constexpr Register ABINonVolatileReg{Registers::s1}; |
| 158 |
|
| 159 |
// This register is guaranteed to be clobberable during the prologue and |
| 160 |
// epilogue of an ABI call which must preserve both ABI argument, return |
| 161 |
// and non-volatile registers. |
| 162 |
static constexpr Register ABINonArgReturnVolatileReg{Registers::t0}; |
| 163 |
|
| 164 |
// This register may be volatile or nonvolatile. |
| 165 |
// Avoid ft11 which is the scratch register. |
| 166 |
static constexpr FloatRegister ABINonArgDoubleReg{FloatRegisters::ft11}; |
| 167 |
|
| 168 |
static constexpr Register WasmTableCallScratchReg0{ABINonArgReg0}; |
| 169 |
static constexpr Register WasmTableCallScratchReg1{ABINonArgReg1}; |
| 170 |
static constexpr Register WasmTableCallSigReg{ABINonArgReg2}; |
| 171 |
static constexpr Register WasmTableCallIndexReg{ABINonArgReg3}; |
| 172 |
|
| 173 |
// Instance pointer argument register for WebAssembly functions. This must not |
| 174 |
// alias any other register used for passing function arguments or return |
| 175 |
// values. Preserved by WebAssembly functions. Must be nonvolatile. |
| 176 |
static constexpr Register InstanceReg{Registers::s4}; |
| 177 |
|
| 178 |
static constexpr Register WasmJitEntryReturnScratch{Registers::t1}; |
| 179 |
|
| 180 |
static constexpr Register WasmCallRefCallScratchReg0{ABINonArgReg0}; |
| 181 |
static constexpr Register WasmCallRefCallScratchReg1{ABINonArgReg1}; |
| 182 |
static constexpr Register WasmCallRefCallScratchReg2{ABINonArgReg2}; |
| 183 |
static constexpr Register WasmCallRefReg{ABINonArgReg3}; |
| 184 |
|
| 185 |
static constexpr Register WasmTailCallInstanceScratchReg{ABINonArgReg1}; |
| 186 |
static constexpr Register WasmTailCallRAScratchReg{ra}; |
| 187 |
static constexpr Register WasmTailCallFPScratchReg{ABINonArgReg3}; |
| 188 |
|
| 189 |
} // namespace jit |
| 190 |
} // namespace js |
| 191 |
|
| 192 |
#endif // jit_riscv64_Register_riscv64_h |