Skip to content

Commit 2bbf4d1

Browse files
committed
LoongArchBase: add CRC-32 and some float operations.
1 parent 9c0c631 commit 2bbf4d1

File tree

3 files changed

+112
-13
lines changed

3 files changed

+112
-13
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/LoongArch/Lasx.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,13 +1982,13 @@ internal Lasx() { }
19821982
/// float32x8_t xvflogb_d(float32x8_t a)
19831983
/// LASX: XVFLOGB.S Xd.8S, Xj.8S
19841984
/// </summary>
1985-
public static Vector256<float> Logarithm2(Vector256<float> value) => Logarithm2(value);
1985+
public static Vector256<float> FloatLogarithm2(Vector256<float> value) => FloatLogarithm2(value);
19861986

19871987
/// <summary>
19881988
/// float64x4_t xvflogb_d(float64x4_t a)
19891989
/// LASX: XVFLOGB.D Xd.4D, Xj.4D
19901990
/// </summary>
1991-
public static Vector256<double> Logarithm2(Vector256<double> value) => Logarithm2(value);
1991+
public static Vector256<double> FloatLogarithm2(Vector256<double> value) => FloatLogarithm2(value);
19921992

19931993
/// <summary>
19941994
/// void xvst(int8x32_t val, int8_t* addr, const short si12)

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/LoongArch/LoongArchBase.cs

Lines changed: 108 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,47 +153,146 @@ internal LoongArch64() { }
153153
/// </summary>
154154
public static ulong ReverseElementBits(ulong value) => ReverseElementBits(value);
155155

156-
// TODO: add crc, ????
156+
/// <summary>
157+
/// LA64: FRECIPE.S fd, fj
158+
/// </summary>
159+
public static float ReciprocalExact(float value) => ReciprocalExact(value);
160+
161+
/// <summary>
162+
/// LA64: FRECIPE.D fd, fj
163+
/// </summary>
164+
public static double ReciprocalExact(double value) => ReciprocalExact(value);
165+
166+
/// <summary>
167+
/// LA64: FRSQRTE.S fd, fj
168+
/// </summary>
169+
public static float ReciprocalSqrtExact(float value) => ReciprocalSqrtExact(value);
170+
171+
/// <summary>
172+
/// LA64: FRSQRTE.D fd, fj
173+
/// </summary>
174+
public static double ReciprocalSqrtExact(double value) => ReciprocalSqrtExact(value);
175+
176+
/// <summary>
177+
/// LA64: CRC.W.B.W rd, rj, rk
178+
/// </summary>
179+
public static long CyclicRedundancyCheckIEEE8023(int crc, byte checks) => CyclicRedundancyCheckIEEE8023(crc, checks);
180+
181+
/// <summary>
182+
/// LA64: CRC.W.H.W rd, rj, rk
183+
/// </summary>
184+
public static long CyclicRedundancyCheckIEEE8023(int crc, ushort checks) => CyclicRedundancyCheckIEEE8023(crc, checks);
185+
186+
/// <summary>
187+
/// LA64: CRC.W.W.W rd, rj, rk
188+
/// </summary>
189+
public static long CyclicRedundancyCheckIEEE8023(int crc, uint checks) => CyclicRedundancyCheckIEEE8023(crc, checks);
190+
191+
/// <summary>
192+
/// LA64: CRC.W.D.W rd, rj, rk
193+
/// </summary>
194+
public static long CyclicRedundancyCheckIEEE8023(int crc, ulong checks) => CyclicRedundancyCheckIEEE8023(crc, checks);
195+
196+
/// <summary>
197+
/// LA64: CRCC.W.B.W rd, rj, rk
198+
/// </summary>
199+
public static long CyclicRedundancyCheckCastagnoli(int crc, byte checks) => CyclicRedundancyCheckCastagnoli(crc, checks);
200+
201+
/// <summary>
202+
/// LA64: CRCC.W.H.W rd, rj, rk
203+
/// </summary>
204+
public static long CyclicRedundancyCheckCastagnoli(int crc, ushort checks) => CyclicRedundancyCheckCastagnoli(crc, checks);
205+
206+
/// <summary>
207+
/// LA64: CRCC.W.W.W rd, rj, rk
208+
/// </summary>
209+
public static long CyclicRedundancyCheckCastagnoli(int crc, uint checks) => CyclicRedundancyCheckCastagnoli(crc, checks);
210+
211+
/// <summary>
212+
/// LA64: CRCC.W.D.W rd, rj, rk
213+
/// </summary>
214+
public static long CyclicRedundancyCheckCastagnoli(int crc, ulong checks) => CyclicRedundancyCheckCastagnoli(crc, checks);
157215
}
158216

159217
/// <summary>
160-
/// LA32: MULH.W rd, rj, rk
218+
/// LA32/LA64: MULH.W rd, rj, rk
161219
/// </summary>
162220
public static long MultiplyHigh(int left, int right) => MultiplyHigh(left, right);
163221

164222
/// <summary>
165-
/// LA32: MULH.WU rd, rj, rk
223+
/// LA32/LA64: MULH.WU rd, rj, rk
166224
/// </summary>
167225
public static ulong MultiplyHigh(uint left, uint right) => MultiplyHigh(left, right);
168226

169227
/// <summary>
170-
/// LA32: FSQRT.S fd, fj
228+
/// LA32/LA64: FSQRT.S fd, fj
171229
/// </summary>
172230
public static float SquareRoot(float value) => SquareRoot(value);
173231

174232
/// <summary>
175-
/// LA32: FSQRT.D fd, fj
233+
/// LA32/LA64: FSQRT.D fd, fj
176234
/// </summary>
177235
public static double SquareRoot(double value) => SquareRoot(value);
178236

179237
/// <summary>
180-
/// LA32: FRECIP.S fd, fj
238+
/// LA32/LA64: FRECIP.S fd, fj
181239
/// </summary>
182240
public static float Reciprocal(float value) => Reciprocal(value);
183241

184242
/// <summary>
185-
/// LA32: FRECIP.D fd, fj
243+
/// LA32/LA64: FRECIP.D fd, fj
186244
/// </summary>
187245
public static double Reciprocal(double value) => Reciprocal(value);
188246

189247
/// <summary>
190-
/// LA32: FRSQRT.S fd, fj
248+
/// LA32/LA64: FRSQRT.S fd, fj
191249
/// </summary>
192250
public static float ReciprocalSqrt(float value) => ReciprocalSqrt(value);
193251

194252
/// <summary>
195-
/// LA32: FRSQRT.D fd, fj
253+
/// LA32/LA64: FRSQRT.D fd, fj
196254
/// </summary>
197255
public static double ReciprocalSqrt(double value) => ReciprocalSqrt(value);
256+
257+
/// <summary>
258+
/// LA32/LA64: FLOGB.S fd, fj
259+
/// </summary>
260+
public static float FloatLogarithm2(float value) => FloatLogarithm2(value);
261+
262+
/// <summary>
263+
/// LA32/LA64: FLOGB.D fd, fj
264+
/// </summary>
265+
public static double FloatLogarithm2(double value) => FloatLogarithm2(value);
266+
267+
/// <summary>
268+
/// LA32/LA64: FSCALEB.S fd, fj, fk
269+
/// </summary>
270+
public static float FloatScaleBinary(float value, int index) => FloatScaleBinary(value, index);
271+
272+
/// <summary>
273+
/// LA32/LA64: FSCALEB.D fd, fj, fk
274+
/// </summary>
275+
public static double FloatScaleBinary(double value, long index) => FloatScaleBinary(value, index);
276+
277+
/// <summary>
278+
/// LA32/LA64: FCOPYSIGN.S fd, fj, fk
279+
/// </summary>
280+
public static float FloatCopySign(float value, float sign) => FloatCopySign(value, sign);
281+
282+
/// <summary>
283+
/// LA32/LA64: FCOPYSIGN.D fd, fj, fk
284+
/// </summary>
285+
public static double FloatCopySign(double value, double sign) => FloatCopySign(value, sign);
286+
287+
/// <summary>
288+
/// LA32/LA64: FCLASS.S fd, fj
289+
/// </summary>
290+
public static float FloatClass(float value) => FloatClass(value);
291+
292+
/// <summary>
293+
/// LA32/LA64: FCLASS.S fd, fj
294+
/// </summary>
295+
public static double FloatClass(double value) => FloatClass(value);
296+
198297
}
199298
}

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/LoongArch/Lsx.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,13 +2152,13 @@ internal Lsx() { }
21522152
/// float32x4_t vflogb_s(float32x4_t a)
21532153
/// LSX: VFLOGB.S Vd.4S, Vj.4S
21542154
/// </summary>
2155-
public static Vector128<float> Logarithm2(Vector128<float> value) => Logarithm2(value);
2155+
public static Vector128<float> FloatLogarithm2(Vector128<float> value) => FloatLogarithm2(value);
21562156

21572157
/// <summary>
21582158
/// float64x2_t vflogb_d(float64x2_t a)
21592159
/// LSX: VFLOGB.D Vd.2D, Vj.2D
21602160
/// </summary>
2161-
public static Vector128<double> Logarithm2(Vector128<double> value) => Logarithm2(value);
2161+
public static Vector128<double> FloatLogarithm2(Vector128<double> value) => FloatLogarithm2(value);
21622162

21632163
/// <summary>
21642164
/// void vst(int8x16_t val, int8_t* addr, const short si12)

0 commit comments

Comments
 (0)