v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
extension-riscv-b.cc
Go to the documentation of this file.
1// Copyright 2022 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.
5
7namespace v8 {
8namespace internal {
9
10// RV32B Standard Extension
12 GenInstrALU_rr(0b0010000, 0b010, rd, rs1, rs2);
13}
15 GenInstrALU_rr(0b0010000, 0b100, rd, rs1, rs2);
16}
18 GenInstrALU_rr(0b0010000, 0b110, rd, rs1, rs2);
19}
20#ifdef V8_TARGET_ARCH_RISCV64
21void AssemblerRISCVB::adduw(Register rd, Register rs1, Register rs2) {
22 GenInstrALUW_rr(0b0000100, 0b000, rd, rs1, rs2);
23}
24void AssemblerRISCVB::sh1adduw(Register rd, Register rs1, Register rs2) {
25 GenInstrALUW_rr(0b0010000, 0b010, rd, rs1, rs2);
26}
27void AssemblerRISCVB::sh2adduw(Register rd, Register rs1, Register rs2) {
28 GenInstrALUW_rr(0b0010000, 0b100, rd, rs1, rs2);
29}
30void AssemblerRISCVB::sh3adduw(Register rd, Register rs1, Register rs2) {
31 GenInstrALUW_rr(0b0010000, 0b110, rd, rs1, rs2);
32}
33void AssemblerRISCVB::slliuw(Register rd, Register rs1, uint8_t shamt) {
34 GenInstrIShift(0b000010, 0b001, OP_IMM_32, rd, rs1, shamt);
35}
36#endif // V8_TARGET_ARCH_RISCV64
37
38
40 GenInstrALU_rr(0b0100000, 0b111, rd, rs1, rs2);
41}
43 GenInstrALU_rr(0b0100000, 0b110, rd, rs1, rs2);
44}
46 GenInstrALU_rr(0b0100000, 0b100, rd, rs1, rs2);
47}
48
50 GenInstrIShiftW(0b0110000, 0b001, OP_IMM, rd, rs, 0);
51}
53 GenInstrIShiftW(0b0110000, 0b001, OP_IMM, rd, rs, 1);
54}
56 GenInstrIShiftW(0b0110000, 0b001, OP_IMM, rd, rs, 2);
57}
58#ifdef V8_TARGET_ARCH_RISCV64
59void AssemblerRISCVB::clzw(Register rd, Register rs) {
60 GenInstrIShiftW(0b0110000, 0b001, OP_IMM_32, rd, rs, 0);
61}
62void AssemblerRISCVB::ctzw(Register rd, Register rs) {
63 GenInstrIShiftW(0b0110000, 0b001, OP_IMM_32, rd, rs, 1);
64}
65void AssemblerRISCVB::cpopw(Register rd, Register rs) {
66 GenInstrIShiftW(0b0110000, 0b001, OP_IMM_32, rd, rs, 2);
67}
68#endif
69
71 GenInstrALU_rr(0b0000101, 0b110, rd, rs1, rs2);
72}
74 GenInstrALU_rr(0b0000101, 0b111, rd, rs1, rs2);
75}
77 GenInstrALU_rr(0b0000101, 0b100, rd, rs1, rs2);
78}
80 GenInstrALU_rr(0b0000101, 0b101, rd, rs1, rs2);
81}
82
84 GenInstrIShiftW(0b0110000, 0b001, OP_IMM, rd, rs, 0b100);
85}
87 GenInstrIShiftW(0b0110000, 0b001, OP_IMM, rd, rs, 0b101);
88}
90#ifdef V8_TARGET_ARCH_RISCV64
91 GenInstrALUW_rr(0b0000100, 0b100, rd, rs, zero_reg);
92#else
93 GenInstrALU_rr(0b0000100, 0b100, rd, rs, zero_reg);
94#endif
95}
96
98 GenInstrR(0b0110000, 0b001, OP, rd, rs1, rs2);
99}
100
102 GenInstrR(0b0110000, 0b101, OP, rd, rs1, rs2);
103}
104
106 GenInstrI(0b101, OP_IMM, rd, rs, 0b001010000111);
107}
108
109void AssemblerRISCVB::rori(Register rd, Register rs1, uint8_t shamt) {
110#ifdef V8_TARGET_ARCH_RISCV64
111 DCHECK(is_uint6(shamt));
112 GenInstrI(0b101, OP_IMM, rd, rs1, 0b011000000000 | shamt);
113#else
114 DCHECK(is_uint5(shamt));
115 GenInstrI(0b101, OP_IMM, rd, rs1, 0b011000000000 | shamt);
116#endif
117}
118
119#ifdef V8_TARGET_ARCH_RISCV64
120void AssemblerRISCVB::rolw(Register rd, Register rs1, Register rs2) {
121 GenInstrR(0b0110000, 0b001, OP_32, rd, rs1, rs2);
122}
123void AssemblerRISCVB::roriw(Register rd, Register rs1, uint8_t shamt) {
124 DCHECK(is_uint5(shamt));
125 GenInstrI(0b101, OP_IMM_32, rd, rs1, 0b011000000000 | shamt);
126}
127void AssemblerRISCVB::rorw(Register rd, Register rs1, Register rs2) {
128 GenInstrR(0b0110000, 0b101, OP_32, rd, rs1, rs2);
129}
130#endif
131
133#ifdef V8_TARGET_ARCH_RISCV64
134 GenInstrI(0b101, OP_IMM, rd, rs, 0b011010111000);
135#else
136 GenInstrI(0b101, OP_IMM, rd, rs, 0b011010011000);
137#endif
138}
139
140
142 GenInstrALU_rr(0b0100100, 0b001, rd, rs1, rs2);
143}
144
145void AssemblerRISCVB::bclri(Register rd, Register rs, uint8_t shamt) {
146#ifdef V8_TARGET_ARCH_RISCV64
147 GenInstrIShift(0b010010, 0b001, OP_IMM, rd, rs, shamt);
148#else
149 GenInstrIShiftW(0b0100100, 0b001, OP_IMM, rd, rs, shamt);
150#endif
151}
153 GenInstrALU_rr(0b0100100, 0b101, rd, rs1, rs2);
154}
155void AssemblerRISCVB::bexti(Register rd, Register rs1, uint8_t shamt) {
156#ifdef V8_TARGET_ARCH_RISCV64
157 GenInstrIShift(0b010010, 0b101, OP_IMM, rd, rs1, shamt);
158#else
159 GenInstrIShiftW(0b0100100, 0b101, OP_IMM, rd, rs1, shamt);
160#endif
161}
163 GenInstrALU_rr(0b0110100, 0b001, rd, rs1, rs2);
164}
165void AssemblerRISCVB::binvi(Register rd, Register rs1, uint8_t shamt) {
166#ifdef V8_TARGET_ARCH_RISCV64
167 GenInstrIShift(0b011010, 0b001, OP_IMM, rd, rs1, shamt);
168#else
169 GenInstrIShiftW(0b0110100, 0b001, OP_IMM, rd, rs1, shamt);
170#endif
171}
173 GenInstrALU_rr(0b0010100, 0b001, rd, rs1, rs2);
174}
175void AssemblerRISCVB::bseti(Register rd, Register rs1, uint8_t shamt) {
176#ifdef V8_TARGET_ARCH_RISCV64
177 GenInstrIShift(0b001010, 0b001, OP_IMM, rd, rs1, shamt);
178#else
179 GenInstrIShiftW(0b0010100, 0b001, OP_IMM, rd, rs1, shamt);
180#endif
181}
182} // namespace internal
183} // namespace v8
void min(Register rd, Register rs1, Register rs2)
void max(Register rd, Register rs1, Register rs2)
void bseti(Register rd, Register rs1, uint8_t shamt)
void andn(Register rd, Register rs1, Register rs2)
void bext(Register rd, Register rs1, Register rs2)
void minu(Register rd, Register rs1, Register rs2)
void xnor(Register rd, Register rs1, Register rs2)
void binv(Register rd, Register rs1, Register rs2)
void bclr(Register rd, Register rs1, Register rs2)
void rol(Register rd, Register rs1, Register rs2)
void sh2add(Register rd, Register rs1, Register rs2)
void bexti(Register rd, Register rs1, uint8_t shamt)
void cpop(Register rd, Register rs)
void ror(Register rd, Register rs1, Register rs2)
void sexth(Register rd, Register rs)
void zexth(Register rd, Register rs)
void sh3add(Register rd, Register rs1, Register rs2)
void orn(Register rd, Register rs1, Register rs2)
void rev8(Register rd, Register rs)
void ctz(Register rd, Register rs)
void binvi(Register rd, Register rs1, uint8_t shamt)
void sextb(Register rd, Register rs)
void bclri(Register rd, Register rs1, uint8_t shamt)
void maxu(Register rd, Register rs1, Register rs2)
void orcb(Register rd, Register rs)
void clz(Register rd, Register rs)
void bset(Register rd, Register rs1, Register rs2)
void sh1add(Register rd, Register rs1, Register rs2)
void rori(Register rd, Register rs1, uint8_t shamt)
void GenInstrIShiftW(uint8_t funct7, uint8_t funct3, BaseOpcode opcode, Register rd, Register rs1, uint8_t shamt)
void GenInstrR(uint8_t funct7, uint8_t funct3, BaseOpcode opcode, Register rd, Register rs1, Register rs2)
void GenInstrALUW_rr(uint8_t funct7, uint8_t funct3, Register rd, Register rs1, Register rs2)
void GenInstrALU_rr(uint8_t funct7, uint8_t funct3, Register rd, Register rs1, Register rs2)
void GenInstrI(uint8_t funct3, BaseOpcode opcode, Register rd, Register rs1, int16_t imm12)
void GenInstrIShift(uint8_t funct7, uint8_t funct3, BaseOpcode opcode, Register rd, Register rs1, uint8_t shamt)
#define DCHECK(condition)
Definition logging.h:482