Skip to content

Commit

Permalink
Added intrinsic mappings for BitOperations functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
MoFtZ committed Jul 1, 2022
1 parent 4ef48a5 commit 1bbe77b
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Src/ILGPU/Frontend/Intrinsic/RemappedIntrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static RemappedIntrinsics()

RegisterMathRemappings();
RegisterBitConverterRemappings();
RegisterBitOperationsRemappings();
RegisterCopySignRemappings();
RegisterInterlockedRemappings();
}
Expand Down Expand Up @@ -298,5 +299,62 @@ public static ulong Decrement(ref ulong value) =>
}

#endregion


#region BitOperations remappings

private static void RegisterBitOperationsRemappings()
{
#if !NETFRAMEWORK
var sourceType = typeof(System.Numerics.BitOperations);
var targetType = typeof(IntrinsicMath.BitOperations);

AddRemapping(
sourceType,
targetType,
"LeadingZeroCount",
typeof(uint));
AddRemapping(
sourceType,
targetType,
"LeadingZeroCount",
typeof(ulong));

AddRemapping(
sourceType,
targetType,
"PopCount",
typeof(uint));
AddRemapping(
sourceType,
targetType,
"PopCount",
typeof(ulong));

AddRemapping(
sourceType,
targetType,
"TrailingZeroCount",
typeof(int));
AddRemapping(
sourceType,
targetType,
"TrailingZeroCount",
typeof(long));
AddRemapping(
sourceType,
targetType,
"TrailingZeroCount",
typeof(uint));
AddRemapping(
sourceType,
targetType,
"TrailingZeroCount",
typeof(ulong));
#endif
}

#endregion

}
}

0 comments on commit 1bbe77b

Please sign in to comment.