forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wasm] Add intrinsics for clz and ctz instructions (dotnet#77777)
* [wasm] Add intrinsics for clz and ctz instructions Add intrinsics for leading and trailing zero count for wasm. Introduce new internal class WasmBase for non-SIMD wasm intrinsics. These are always used in AOT build, unlike SIMD intrinsics, which are disabled by default. * Fix CI build * Fix CI build again * Review feedback Refactor the code to avoid adding ifdefs * Fix build * Fix build * Fix build * Fix CI build
- Loading branch information
1 parent
62837e5
commit 134968a
Showing
10 changed files
with
268 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ystem.Private.CoreLib/src/System/Runtime/Intrinsics/Wasm/WasmBase.PlatformNotSupported.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Intrinsics; | ||
|
||
namespace System.Runtime.Intrinsics.Wasm | ||
{ | ||
internal abstract class WasmBase | ||
{ | ||
public static bool IsSupported => false; | ||
|
||
/// <summary> | ||
/// i32.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(int value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i32.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(uint value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i64.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(long value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i64.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(ulong value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i32.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(int value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i32.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(uint value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i64.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(long value) { throw new PlatformNotSupportedException(); } | ||
|
||
/// <summary> | ||
/// i64.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(ulong value) { throw new PlatformNotSupportedException(); } | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Wasm/WasmBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Intrinsics; | ||
|
||
namespace System.Runtime.Intrinsics.Wasm | ||
{ | ||
[Intrinsic] | ||
internal abstract class WasmBase | ||
{ | ||
public static bool IsSupported { get; } | ||
|
||
/// <summary> | ||
/// i32.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(int value) => LeadingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i32.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(uint value) => LeadingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i64.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(long value) => LeadingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i64.clz | ||
/// </summary> | ||
public static int LeadingZeroCount(ulong value) => LeadingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i32.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(int value) => TrailingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i32.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(uint value) => TrailingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i64.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(long value) => TrailingZeroCount(value); | ||
|
||
/// <summary> | ||
/// i64.ctz | ||
/// </summary> | ||
public static int TrailingZeroCount(ulong value) => TrailingZeroCount(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.