Skip to content

Commit 03f76a1

Browse files
luyahandanielleadams
authored andcommitted
deps: V8: cherry-pick 77d515484864
Original commit message: [riscv64] Move explicit specialization into .cc file Building with Gcc-10 causes error "explicit specialization in non-namespace scope". This change fixes it. Bug: v8:12649 Change-Id: I36b2b042b336c2dfd32ba5541fdbbdb8dc8b4fd7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3473997 Reviewed-by: ji qiu <[email protected]> Commit-Queue: ji qiu <[email protected]> Cr-Commit-Position: refs/heads/main@{#79185} Refs: v8/v8@77d5154 PR-URL: #42067 Refs: v8/v8@b663343 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Mary Marchini <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Stewart X Addison <[email protected]>
1 parent e2c433f commit 03f76a1

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

deps/v8/src/execution/riscv64/simulator-riscv64.cc

+158
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,164 @@
6060
#include "src/runtime/runtime-utils.h"
6161
#include "src/utils/ostreams.h"
6262

63+
// RVV
64+
// The following code about RVV was based from:
65+
// https://github.com/riscv/riscv-isa-sim
66+
// Copyright (c) 2010-2017, The Regents of the University of California
67+
// (Regents). All Rights Reserved.
68+
69+
// Redistribution and use in source and binary forms, with or without
70+
// modification, are permitted provided that the following conditions are met:
71+
// 1. Redistributions of source code must retain the above copyright
72+
// notice, this list of conditions and the following disclaimer.
73+
// 2. Redistributions in binary form must reproduce the above copyright
74+
// notice, this list of conditions and the following disclaimer in the
75+
// documentation and/or other materials provided with the distribution.
76+
// 3. Neither the name of the Regents nor the
77+
// names of its contributors may be used to endorse or promote products
78+
// derived from this software without specific prior written permission.
79+
80+
// IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
81+
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
82+
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
83+
// REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84+
85+
// REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED
86+
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
87+
// PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
88+
// HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
89+
// MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
90+
template <uint64_t N>
91+
struct type_usew_t;
92+
template <>
93+
struct type_usew_t<8> {
94+
using type = uint8_t;
95+
};
96+
97+
template <>
98+
struct type_usew_t<16> {
99+
using type = uint16_t;
100+
};
101+
102+
template <>
103+
struct type_usew_t<32> {
104+
using type = uint32_t;
105+
};
106+
107+
template <>
108+
struct type_usew_t<64> {
109+
using type = uint64_t;
110+
};
111+
112+
template <>
113+
struct type_usew_t<128> {
114+
using type = __uint128_t;
115+
};
116+
template <uint64_t N>
117+
struct type_sew_t;
118+
119+
template <>
120+
struct type_sew_t<8> {
121+
using type = int8_t;
122+
};
123+
124+
template <>
125+
struct type_sew_t<16> {
126+
using type = int16_t;
127+
};
128+
129+
template <>
130+
struct type_sew_t<32> {
131+
using type = int32_t;
132+
};
133+
134+
template <>
135+
struct type_sew_t<64> {
136+
using type = int64_t;
137+
};
138+
139+
template <>
140+
struct type_sew_t<128> {
141+
using type = __int128_t;
142+
};
143+
144+
#define VV_PARAMS(x) \
145+
type_sew_t<x>::type& vd = \
146+
Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
147+
type_sew_t<x>::type vs1 = Rvvelt<type_sew_t<x>::type>(rvv_vs1_reg(), i); \
148+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i);
149+
150+
#define VV_UPARAMS(x) \
151+
type_usew_t<x>::type& vd = \
152+
Rvvelt<type_usew_t<x>::type>(rvv_vd_reg(), i, true); \
153+
type_usew_t<x>::type vs1 = Rvvelt<type_usew_t<x>::type>(rvv_vs1_reg(), i); \
154+
type_usew_t<x>::type vs2 = Rvvelt<type_usew_t<x>::type>(rvv_vs2_reg(), i);
155+
156+
#define VX_PARAMS(x) \
157+
type_sew_t<x>::type& vd = \
158+
Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
159+
type_sew_t<x>::type rs1 = (type_sew_t<x>::type)(get_register(rs1_reg())); \
160+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i);
161+
162+
#define VX_UPARAMS(x) \
163+
type_usew_t<x>::type& vd = \
164+
Rvvelt<type_usew_t<x>::type>(rvv_vd_reg(), i, true); \
165+
type_usew_t<x>::type rs1 = (type_usew_t<x>::type)(get_register(rs1_reg())); \
166+
type_usew_t<x>::type vs2 = Rvvelt<type_usew_t<x>::type>(rvv_vs2_reg(), i);
167+
168+
#define VI_PARAMS(x) \
169+
type_sew_t<x>::type& vd = \
170+
Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
171+
type_sew_t<x>::type simm5 = (type_sew_t<x>::type)(instr_.RvvSimm5()); \
172+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i);
173+
174+
#define VI_UPARAMS(x) \
175+
type_usew_t<x>::type& vd = \
176+
Rvvelt<type_usew_t<x>::type>(rvv_vd_reg(), i, true); \
177+
type_usew_t<x>::type uimm5 = (type_usew_t<x>::type)(instr_.RvvUimm5()); \
178+
type_usew_t<x>::type vs2 = Rvvelt<type_usew_t<x>::type>(rvv_vs2_reg(), i);
179+
180+
#define VN_PARAMS(x) \
181+
constexpr int half_x = x >> 1; \
182+
type_sew_t<half_x>::type& vd = \
183+
Rvvelt<type_sew_t<half_x>::type>(rvv_vd_reg(), i, true); \
184+
type_sew_t<x>::type uimm5 = (type_sew_t<x>::type)(instr_.RvvUimm5()); \
185+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i);
186+
187+
#define VN_UPARAMS(x) \
188+
constexpr int half_x = x >> 1; \
189+
type_usew_t<half_x>::type& vd = \
190+
Rvvelt<type_usew_t<half_x>::type>(rvv_vd_reg(), i, true); \
191+
type_usew_t<x>::type uimm5 = (type_usew_t<x>::type)(instr_.RvvUimm5()); \
192+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i);
193+
194+
#define VXI_PARAMS(x) \
195+
type_sew_t<x>::type& vd = \
196+
Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
197+
type_sew_t<x>::type vs1 = Rvvelt<type_sew_t<x>::type>(rvv_vs1_reg(), i); \
198+
type_sew_t<x>::type vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i); \
199+
type_sew_t<x>::type rs1 = (type_sew_t<x>::type)(get_register(rs1_reg())); \
200+
type_sew_t<x>::type simm5 = (type_sew_t<x>::type)(instr_.RvvSimm5());
201+
202+
#define VI_XI_SLIDEDOWN_PARAMS(x, off) \
203+
auto& vd = Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
204+
auto vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i + off);
205+
206+
#define VI_XI_SLIDEUP_PARAMS(x, offset) \
207+
auto& vd = Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
208+
auto vs2 = Rvvelt<type_sew_t<x>::type>(rvv_vs2_reg(), i - offset);
209+
210+
/* Vector Integer Extension */
211+
#define VI_VIE_PARAMS(x, scale) \
212+
if ((x / scale) < 8) UNREACHABLE(); \
213+
auto& vd = Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
214+
auto vs2 = Rvvelt<type_sew_t<x / scale>::type>(rvv_vs2_reg(), i);
215+
216+
#define VI_VIE_UPARAMS(x, scale) \
217+
if ((x / scale) < 8) UNREACHABLE(); \
218+
auto& vd = Rvvelt<type_sew_t<x>::type>(rvv_vd_reg(), i, true); \
219+
auto vs2 = Rvvelt<type_usew_t<x / scale>::type>(rvv_vs2_reg(), i);
220+
63221
namespace v8 {
64222
namespace internal {
65223

0 commit comments

Comments
 (0)