Constant-riscv64.h (2566B)
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_constant_Constant_riscv64_h 8 #define jit_riscv64_constant_Constant_riscv64_h 9 10 #include "jit/riscv64/constant/Base-constant-riscv.h" 11 #include "jit/riscv64/constant/Constant-riscv-a.h" 12 #include "jit/riscv64/constant/Constant-riscv-b.h" 13 #include "jit/riscv64/constant/Constant-riscv-c.h" 14 #include "jit/riscv64/constant/Constant-riscv-d.h" 15 #include "jit/riscv64/constant/Constant-riscv-f.h" 16 #include "jit/riscv64/constant/Constant-riscv-i.h" 17 #include "jit/riscv64/constant/Constant-riscv-m.h" 18 #include "jit/riscv64/constant/Constant-riscv-v.h" 19 #include "jit/riscv64/constant/Constant-riscv-zicsr.h" 20 #include "jit/riscv64/constant/Constant-riscv-zifencei.h" 21 22 namespace js { 23 namespace jit { 24 25 // A reasonable (ie, safe) buffer size for the disassembly of a single 26 // instruction. 27 const int ReasonableBufferSize = 256; 28 29 // Difference between address of current opcode and value read from pc 30 // register. 31 static constexpr int kPcLoadDelta = 4; 32 33 // Bits available for offset field in branches 34 static constexpr int kBranchOffsetBits = 13; 35 36 // Bits available for offset field in jump 37 static constexpr int kJumpOffsetBits = 21; 38 39 // Bits available for offset field in compresed jump 40 static constexpr int kCJalOffsetBits = 12; 41 42 // Bits available for offset field in 4 branch 43 static constexpr int kCBranchOffsetBits = 9; 44 45 // Max offset for b instructions with 12-bit offset field (multiple of 2) 46 static constexpr int kMaxBranchOffset = (1 << (kBranchOffsetBits - 1)) - 1; 47 48 static constexpr int kCBranchOffset = (1 << (kCBranchOffsetBits - 1)) - 1; 49 // Max offset for jal instruction with 20-bit offset field (multiple of 2) 50 static constexpr int kMaxJumpOffset = (1 << (kJumpOffsetBits - 1)) - 1; 51 52 static constexpr int kCJumpOffset = (1 << (kCJalOffsetBits - 1)) - 1; 53 54 static constexpr int kTrampolineSlotsSize = 2 * kInstrSize; 55 56 static_assert(kCJalOffsetBits == kOffset12); 57 static_assert(kCBranchOffsetBits == kOffset9); 58 static_assert(kJumpOffsetBits == kOffset21); 59 static_assert(kBranchOffsetBits == kOffset13); 60 // Vector as used by the original code to allow for minimal modification. 61 // Functions exactly like a character array with helper methods. 62 } // namespace jit 63 } // namespace js 64 65 #endif // jit_riscv64_constant_Constant_riscv64_h