v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
constant-riscv-b.h
Go to the documentation of this file.
1// Copyright 2023 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_CODEGEN_RISCV_CONSTANT_RISCV_B_H_
6#define V8_CODEGEN_RISCV_CONSTANT_RISCV_B_H_
7
9namespace v8 {
10namespace internal {
11
12// Zba
13#ifdef V8_TARGET_ARCH_RISCV64
14constexpr Opcode RO_ADDUW =
15 OP_32 | (0b000 << kFunct3Shift) | (0b0000100 << kFunct7Shift);
16constexpr Opcode RO_SH1ADDUW =
17 OP_32 | (0b010 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
18constexpr Opcode RO_SH2ADDUW =
19 OP_32 | (0b100 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
20constexpr Opcode RO_SH3ADDUW =
21 OP_32 | (0b110 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
22constexpr Opcode RO_SLLIUW =
23 OP_IMM_32 | (0b001 << kFunct3Shift) | (0b000010 << kFunct6Shift);
24#endif
25
26constexpr Opcode RO_SH1ADD =
27 OP | (0b010 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
28constexpr Opcode RO_SH2ADD =
29 OP | (0b100 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
30constexpr Opcode RO_SH3ADD =
31 OP | (0b110 << kFunct3Shift) | (0b0010000 << kFunct7Shift);
32
33// Zbb
34constexpr Opcode RO_ANDN =
35 OP | (0b111 << kFunct3Shift) | (0b0100000 << kFunct7Shift);
36constexpr Opcode RO_ORN =
37 OP | (0b110 << kFunct3Shift) | (0b0100000 << kFunct7Shift);
38constexpr Opcode RO_XNOR =
39 OP | (0b100 << kFunct3Shift) | (0b0100000 << kFunct7Shift);
40
41constexpr Opcode OP_COUNT =
42 OP_IMM | (0b001 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
43constexpr Opcode RO_CLZ = OP_COUNT | (0b00000 << kShamtShift);
44constexpr Opcode RO_CTZ = OP_COUNT | (0b00001 << kShamtShift);
45constexpr Opcode RO_CPOP = OP_COUNT | (0b00010 << kShamtShift);
46#ifdef V8_TARGET_ARCH_RISCV64
47constexpr Opcode OP_COUNTW =
48 OP_IMM_32 | (0b001 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
49constexpr Opcode RO_CLZW = OP_COUNTW | (0b00000 << kShamtShift);
50constexpr Opcode RO_CTZW = OP_COUNTW | (0b00001 << kShamtShift);
51constexpr Opcode RO_CPOPW = OP_COUNTW | (0b00010 << kShamtShift);
52#endif
53
54constexpr Opcode RO_MAX =
55 OP | (0b110 << kFunct3Shift) | (0b0000101 << kFunct7Shift);
56constexpr Opcode RO_MAXU =
57 OP | (0b111 << kFunct3Shift) | (0b0000101 << kFunct7Shift);
58
59constexpr Opcode RO_MIN =
60 OP | (0b100 << kFunct3Shift) | (0b0000101 << kFunct7Shift);
61constexpr Opcode RO_MINU =
62 OP | (0b101 << kFunct3Shift) | (0b0000101 << kFunct7Shift);
63
64constexpr Opcode RO_SEXTB = OP_IMM | (0b001 << kFunct3Shift) |
65 (0b0110000 << kFunct7Shift) |
66 (0b00100 << kShamtShift);
67constexpr Opcode RO_SEXTH = OP_IMM | (0b001 << kFunct3Shift) |
68 (0b0110000 << kFunct7Shift) |
69 (0b00101 << kShamtShift);
70#ifdef V8_TARGET_ARCH_RISCV64
71constexpr Opcode RO_ZEXTH = OP_32 | (0b100 << kFunct3Shift) |
72 (0b0000100 << kFunct7Shift) |
73 (0b00000 << kShamtShift);
74#elif defined(V8_TARGET_ARCH_RISCV32)
75constexpr Opcode RO_ZEXTH = OP | (0b100 << kFunct3Shift) |
76 (0b0000100 << kFunct7Shift) |
77 (0b00000 << kShamtShift);
78#endif
79
80// Zbb: bitwise rotation
81constexpr Opcode RO_ROL =
82 OP | (0b001 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
83constexpr Opcode RO_ROR =
84 OP | (0b101 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
85constexpr Opcode RO_ORCB =
86 OP_IMM | (0b101 << kFunct3Shift) | (0b001010000111 << kImm12Shift);
87
88#ifdef V8_TARGET_ARCH_RISCV64
89constexpr Opcode RO_RORI =
90 OP_IMM | (0b101 << kFunct3Shift) | (0b011000 << kFunct6Shift);
91#elif defined(V8_TARGET_ARCH_RISCV32)
92constexpr Opcode RO_RORI =
93 OP_IMM | (0b101 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
94#endif
95
96#ifdef V8_TARGET_ARCH_RISCV64
97constexpr Opcode RO_ROLW =
98 OP_32 | (0b001 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
99constexpr Opcode RO_RORIW =
100 OP_IMM_32 | (0b101 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
101constexpr Opcode RO_RORW =
102 OP_32 | (0b101 << kFunct3Shift) | (0b0110000 << kFunct7Shift);
103#endif
104
105constexpr Opcode RO_REV8 =
106 OP_IMM | (0b101 << kFunct3Shift) | (0b011010 << kFunct6Shift);
107#ifdef V8_TARGET_ARCH_RISCV64
108constexpr Opcode RO_REV8_IMM12 = 0b011010111000;
109#elif defined(V8_TARGET_ARCH_RISCV32)
110constexpr Opcode RO_REV8_IMM12 = 0b011010011000;
111#endif
112// Zbs
113constexpr Opcode RO_BCLR =
114 OP | (0b001 << kFunct3Shift) | (0b0100100 << kFunct7Shift);
115constexpr Opcode RO_BCLRI =
116 OP_IMM | (0b001 << kFunct3Shift) | (0b010010 << kFunct6Shift);
117
118constexpr Opcode RO_BEXT =
119 OP | (0b101 << kFunct3Shift) | (0b0100100 << kFunct7Shift);
120constexpr Opcode RO_BEXTI =
121 OP_IMM | (0b101 << kFunct3Shift) | (0b010010 << kFunct6Shift);
122
123constexpr Opcode RO_BINV =
124 OP | (0b001 << kFunct3Shift) | (0b0110100 << kFunct7Shift);
125constexpr Opcode RO_BINVI =
126 OP_IMM | (0b001 << kFunct3Shift) | (0b011010 << kFunct6Shift);
127
128constexpr Opcode RO_BSET =
129 OP | (0b001 << kFunct3Shift) | (0b0010100 << kFunct7Shift);
130constexpr Opcode RO_BSETI =
131 OP_IMM | (0b001 << kFunct3Shift) | (0b0010100 << kFunct7Shift);
132
133} // namespace internal
134} // namespace v8
135
136#endif // V8_CODEGEN_RISCV_CONSTANT_RISCV_B_H_
constexpr Opcode RO_MIN
const int kImm12Shift
constexpr Opcode RO_BINV
constexpr Opcode RO_BCLRI
constexpr Opcode RO_REV8
constexpr Opcode RO_CPOP
constexpr Opcode RO_BSET
constexpr Opcode RO_MAX
constexpr Opcode RO_BEXTI
constexpr Opcode RO_ROL
constexpr Opcode RO_BEXT
constexpr Opcode RO_SH2ADD
constexpr Opcode RO_XNOR
constexpr Opcode RO_CTZ
constexpr Opcode RO_ANDN
constexpr Opcode RO_SEXTH
constexpr Opcode RO_SH3ADD
constexpr Opcode RO_CLZ
constexpr Opcode RO_ORN
constexpr Opcode RO_MAXU
constexpr Opcode RO_BCLR
constexpr Opcode RO_ROR
constexpr Opcode RO_ORCB
constexpr Opcode RO_BSETI
constexpr Opcode RO_SH1ADD
constexpr Opcode RO_MINU
constexpr Opcode OP_COUNT
constexpr Opcode RO_SEXTB
constexpr Opcode RO_BINVI