123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
-
- namespace Unity.Burst.Intrinsics
- {
- public unsafe static partial class X86
- {
- /// <summary>
- /// FMA intrinsics
- /// </summary>
- public static class Fma
- {
- /// <summary>
- /// Evaluates to true at compile time if FMA intrinsics are supported.
- ///
- /// Burst ties FMA support to AVX2 support to simplify feature sets to support.
- /// </summary>
- public static bool IsFmaSupported { get { return Avx2.IsAvx2Supported; } }
-
- [DebuggerStepThrough]
- private static float FmaHelper(float a, float b, float c)
- {
- return (float)((((double)a) * b) + c);
- }
-
- [StructLayout(LayoutKind.Explicit)]
- private struct Union
- {
- [FieldOffset(0)]
- public float f;
-
- [FieldOffset(0)]
- public uint u;
- }
-
- [DebuggerStepThrough]
- private static float FnmaHelper(float a, float b, float c)
- {
- return FmaHelper(-a, b, c);
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, add the intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>>
- [DebuggerStepThrough]
- public static v128 fmadd_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, add the intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmadd_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, add the intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmadd_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FmaHelper(a.Float0, b.Float0, c.Float0),
- FmaHelper(a.Float1, b.Float1, c.Float1),
- FmaHelper(a.Float2, b.Float2, c.Float2),
- FmaHelper(a.Float3, b.Float3, c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, add the intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmadd_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FmaHelper(a.Float0, b.Float0, c.Float0),
- FmaHelper(a.Float1, b.Float1, c.Float1),
- FmaHelper(a.Float2, b.Float2, c.Float2),
- FmaHelper(a.Float3, b.Float3, c.Float3),
- FmaHelper(a.Float4, b.Float4, c.Float4),
- FmaHelper(a.Float5, b.Float5, c.Float5),
- FmaHelper(a.Float6, b.Float6, c.Float6),
- FmaHelper(a.Float7, b.Float7, c.Float7));
- }
-
- /// <summary>
- /// Multiply the lower double-precision (64-bit) floating-point elements in a and b, and add the intermediate result to the lower element in c. Store the result in the lower element of dst, and copy the upper element from a to the upper element of dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213sd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmadd_sd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply the lower single-precision (32-bit) floating-point elements in a and b, and add the intermediate result to the lower element in c. Store the result in the lower element of dst, and copy the upper 3 packed elements from a to the upper elements of dst.
- /// </summary>
- /// <remarks>
- /// **** vfmadd213ss xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmadd_ss(v128 a, v128 b, v128 c)
- {
- var result = a;
- result.Float0 = FmaHelper(a.Float0, b.Float0, c.Float0);
- return result;
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, alternatively add and subtract packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmaddsub213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmaddsub_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, alternatively add and subtract packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmaddsub213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmaddsub_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, alternatively add and subtract packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmaddsub213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmaddsub_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FmaHelper(a.Float0, b.Float0, -c.Float0),
- FmaHelper(a.Float1, b.Float1, c.Float1),
- FmaHelper(a.Float2, b.Float2, -c.Float2),
- FmaHelper(a.Float3, b.Float3, c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, alternatively add and subtract packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmaddsub213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmaddsub_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FmaHelper(a.Float0, b.Float0, -c.Float0),
- FmaHelper(a.Float1, b.Float1, c.Float1),
- FmaHelper(a.Float2, b.Float2, -c.Float2),
- FmaHelper(a.Float3, b.Float3, c.Float3),
- FmaHelper(a.Float4, b.Float4, -c.Float4),
- FmaHelper(a.Float5, b.Float5, c.Float5),
- FmaHelper(a.Float6, b.Float6, -c.Float6),
- FmaHelper(a.Float7, b.Float7, c.Float7));
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, subtract packed elements in c from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsub_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, subtract packed elements in c from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmsub_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, subtract packed elements in c from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsub_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FmaHelper(a.Float0, b.Float0, -c.Float0),
- FmaHelper(a.Float1, b.Float1, -c.Float1),
- FmaHelper(a.Float2, b.Float2, -c.Float2),
- FmaHelper(a.Float3, b.Float3, -c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, subtract packed elements in c from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmsub_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FmaHelper(a.Float0, b.Float0, -c.Float0),
- FmaHelper(a.Float1, b.Float1, -c.Float1),
- FmaHelper(a.Float2, b.Float2, -c.Float2),
- FmaHelper(a.Float3, b.Float3, -c.Float3),
- FmaHelper(a.Float4, b.Float4, -c.Float4),
- FmaHelper(a.Float5, b.Float5, -c.Float5),
- FmaHelper(a.Float6, b.Float6, -c.Float6),
- FmaHelper(a.Float7, b.Float7, -c.Float7));
- }
-
- /// <summary>
- /// Multiply the lower double-precision(64-bit) floating-point elements in a and b, and subtract the lower element in c from the intermediate result.Store the result in the lower element of dst, and copy the upper element from a to the upper element of dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213sd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsub_sd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply the lower single-precision (32-bit) floating-point elements in a and b, and subtract the lower element in c from the intermediate result. Store the result in the lower element of dst, and copy the upper 3 packed elements from a to the upper elements of dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsub213ss xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsub_ss(v128 a, v128 b, v128 c)
- {
- var result = a;
- result.Float0 = FmaHelper(a.Float0, b.Float0, -c.Float0);
- return result;
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, alternatively subtract and add packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsubadd213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsubadd_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, alternatively subtract and add packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsubadd213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmsubadd_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, alternatively subtract and add packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsubadd213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fmsubadd_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FmaHelper(a.Float0, b.Float0, c.Float0),
- FmaHelper(a.Float1, b.Float1, -c.Float1),
- FmaHelper(a.Float2, b.Float2, c.Float2),
- FmaHelper(a.Float3, b.Float3, -c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, alternatively subtract and add packed elements in c to/from the intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfmsubadd213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fmsubadd_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FmaHelper(a.Float0, b.Float0, c.Float0),
- FmaHelper(a.Float1, b.Float1, -c.Float1),
- FmaHelper(a.Float2, b.Float2, c.Float2),
- FmaHelper(a.Float3, b.Float3, -c.Float3),
- FmaHelper(a.Float4, b.Float4, c.Float4),
- FmaHelper(a.Float5, b.Float5, -c.Float5),
- FmaHelper(a.Float6, b.Float6, c.Float6),
- FmaHelper(a.Float7, b.Float7, -c.Float7));
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, add the negated intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmadd_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, add the negated intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fnmadd_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, add the negated intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmadd_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FnmaHelper(a.Float0, b.Float0, c.Float0),
- FnmaHelper(a.Float1, b.Float1, c.Float1),
- FnmaHelper(a.Float2, b.Float2, c.Float2),
- FnmaHelper(a.Float3, b.Float3, c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, add the negated intermediate result to packed elements in c, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fnmadd_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FnmaHelper(a.Float0, b.Float0, c.Float0),
- FnmaHelper(a.Float1, b.Float1, c.Float1),
- FnmaHelper(a.Float2, b.Float2, c.Float2),
- FnmaHelper(a.Float3, b.Float3, c.Float3),
- FnmaHelper(a.Float4, b.Float4, c.Float4),
- FnmaHelper(a.Float5, b.Float5, c.Float5),
- FnmaHelper(a.Float6, b.Float6, c.Float6),
- FnmaHelper(a.Float7, b.Float7, c.Float7));
- }
-
- /// <summary>
- /// Multiply the lower double-precision (64-bit) floating-point elements in a and b, and add the negated intermediate result to the lower element in c. Store the result in the lower element of dst, and copy the upper element from a to the upper element of dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213sd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmadd_sd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply the lower single-precision (32-bit) floating-point elements in a and b, and add the negated intermediate result to the lower element in c. Store the result in the lower element of dst, and copy the upper 3 packed elements from a to the upper elements of dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmadd213ss xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmadd_ss(v128 a, v128 b, v128 c)
- {
- var result = a;
- result.Float0 = FnmaHelper(a.Float0, b.Float0, c.Float0);
- return result;
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, subtract packed elements in c from the negated intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213pd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmsub_pd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed double-precision (64-bit) floating-point elements in a and b, subtract packed elements in c from the negated intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213pd ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fnmsub_pd(v256 a, v256 b, v256 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, subtract packed elements in c from the negated intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213ps xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmsub_ps(v128 a, v128 b, v128 c)
- {
- return new v128(FnmaHelper(a.Float0, b.Float0, -c.Float0),
- FnmaHelper(a.Float1, b.Float1, -c.Float1),
- FnmaHelper(a.Float2, b.Float2, -c.Float2),
- FnmaHelper(a.Float3, b.Float3, -c.Float3));
- }
-
- /// <summary>
- /// Multiply packed single-precision (32-bit) floating-point elements in a and b, subtract packed elements in c from the negated intermediate result, and store the results in dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213ps ymm, ymm, ymm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v256 mm256_fnmsub_ps(v256 a, v256 b, v256 c)
- {
- return new v256(FnmaHelper(a.Float0, b.Float0, -c.Float0),
- FnmaHelper(a.Float1, b.Float1, -c.Float1),
- FnmaHelper(a.Float2, b.Float2, -c.Float2),
- FnmaHelper(a.Float3, b.Float3, -c.Float3),
- FnmaHelper(a.Float4, b.Float4, -c.Float4),
- FnmaHelper(a.Float5, b.Float5, -c.Float5),
- FnmaHelper(a.Float6, b.Float6, -c.Float6),
- FnmaHelper(a.Float7, b.Float7, -c.Float7));
- }
-
- /// <summary>
- /// Multiply the lower double-precision(64-bit) floating-point elements in a and b, and subtract the lower element in c from the negated intermediate result.Store the result in the lower element of dst, and copy the upper element from a to the upper element of dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213sd xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmsub_sd(v128 a, v128 b, v128 c)
- {
- throw new Exception("Double-precision FMA not emulated in C#");
- }
-
- /// <summary>
- /// Multiply the lower single-precision (32-bit) floating-point elements in a and b, and subtract the lower element in c from the negated intermediate result. Store the result in the lower element of dst, and copy the upper 3 packed elements from a to the upper elements of dst.
- /// </summary>
- /// <remarks>
- /// **** vfnmsub213ss xmm, xmm, xmm
- /// </remarks>
- /// <param name="a">Vector a</param>
- /// <param name="b">Vector b</param>
- /// <param name="c">Vector c</param>
- /// <returns>Vector</returns>
- [DebuggerStepThrough]
- public static v128 fnmsub_ss(v128 a, v128 b, v128 c)
- {
- var result = a;
- result.Float0 = FnmaHelper(a.Float0, b.Float0, -c.Float0);
- return result;
- }
- }
- }
- }
|