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