Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Implement 64-bit-only hardware intrinsic #21264

Merged
merged 6 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static TestStruct Create()

public void RunStructFldScenario(ScalarBinaryOpTest__AndNotUInt64 testClass)
{
var result = Bmi1.AndNot(_fld1, _fld2);
var result = Bmi1.X64.AndNot(_fld1, _fld2);
testClass.ValidateResult(_fld1, _fld2, result);
}
}
Expand Down Expand Up @@ -112,15 +112,15 @@ public ScalarBinaryOpTest__AndNotUInt64()
_data2 = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));

public bool Succeeded { get; set; }

public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

var result = Bmi1.AndNot(
var result = Bmi1.X64.AndNot(
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)),
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2))
);
Expand All @@ -132,7 +132,7 @@ public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));

var result = typeof(Bmi1).GetMethod(nameof(Bmi1.AndNot), new Type[] { typeof(UInt64), typeof(UInt64) })
var result = typeof(Bmi1.X64).GetMethod(nameof(Bmi1.X64.AndNot), new Type[] { typeof(UInt64), typeof(UInt64) })
.Invoke(null, new object[] {
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)),
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2))
Expand All @@ -145,7 +145,7 @@ public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

var result = Bmi1.AndNot(
var result = Bmi1.X64.AndNot(
_clsVar1,
_clsVar2
);
Expand All @@ -159,7 +159,7 @@ public void RunLclVarScenario_UnsafeRead()

var data1 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1));
var data2 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2));
var result = Bmi1.AndNot(data1, data2);
var result = Bmi1.X64.AndNot(data1, data2);

ValidateResult(data1, data2, result);
}
Expand All @@ -169,7 +169,7 @@ public void RunClassLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

var test = new ScalarBinaryOpTest__AndNotUInt64();
var result = Bmi1.AndNot(test._fld1, test._fld2);
var result = Bmi1.X64.AndNot(test._fld1, test._fld2);

ValidateResult(test._fld1, test._fld2, result);
}
Expand All @@ -178,7 +178,7 @@ public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

var result = Bmi1.AndNot(_fld1, _fld2);
var result = Bmi1.X64.AndNot(_fld1, _fld2);
ValidateResult(_fld1, _fld2, result);
}

Expand All @@ -187,7 +187,7 @@ public void RunStructLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

var test = TestStruct.Create();
var result = Bmi1.AndNot(test._fld1, test._fld2);
var result = Bmi1.X64.AndNot(test._fld1, test._fld2);

ValidateResult(test._fld1, test._fld2, result);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMem

if (isUnexpectedResult)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1)}.{nameof(Bmi1.AndNot)}<UInt64>(UInt64, UInt64): AndNot failed:");
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1.X64)}.{nameof(Bmi1.X64.AndNot)}<UInt64>(UInt64, UInt64): AndNot failed:");
TestLibrary.TestFramework.LogInformation($" left: {left}");
TestLibrary.TestFramework.LogInformation($" right: {right}");
TestLibrary.TestFramework.LogInformation($" result: {result}");
Expand Down
40 changes: 40 additions & 0 deletions tests/src/JIT/HardwareIntrinsics/X86/Bmi1.X64/Bmi1.X64_r.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<PropertyGroup>
<DebugType>Embedded</DebugType>
<Optimize></Optimize>
</PropertyGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Compile Include="AndNot.UInt64.cs" />
<Compile Include="ExtractLowestSetBit.UInt64.cs" />
<Compile Include="GetMaskUpToLowestSetBit.UInt64.cs" />
<Compile Include="ResetLowestSetBit.UInt64.cs" />
<Compile Include="TrailingZeroCount.UInt64.cs" />
<Compile Include="Program.Bmi1.X64.cs" />
<Compile Include="..\Shared\Program.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
</Project>
40 changes: 40 additions & 0 deletions tests/src/JIT/HardwareIntrinsics/X86/Bmi1.X64/Bmi1.X64_ro.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<PropertyGroup>
<DebugType>Embedded</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Compile Include="AndNot.UInt64.cs" />
<Compile Include="ExtractLowestSetBit.UInt64.cs" />
<Compile Include="GetMaskUpToLowestSetBit.UInt64.cs" />
<Compile Include="ResetLowestSetBit.UInt64.cs" />
<Compile Include="TrailingZeroCount.UInt64.cs" />
<Compile Include="Program.Bmi1.X64.cs" />
<Compile Include="..\Shared\Program.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static TestStruct Create()

public void RunStructFldScenario(ScalarUnaryOpTest__ExtractLowestSetBitUInt64 testClass)
{
var result = Bmi1.ExtractLowestSetBit(_fld);
var result = Bmi1.X64.ExtractLowestSetBit(_fld);
testClass.ValidateResult(_fld, result);
}
}
Expand All @@ -103,15 +103,15 @@ public ScalarUnaryOpTest__ExtractLowestSetBitUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));

public bool Succeeded { get; set; }

public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

var result = Bmi1.ExtractLowestSetBit(
var result = Bmi1.X64.ExtractLowestSetBit(
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
);

Expand All @@ -122,7 +122,7 @@ public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));

var result = typeof(Bmi1).GetMethod(nameof(Bmi1.ExtractLowestSetBit), new Type[] { typeof(UInt64) })
var result = typeof(Bmi1.X64).GetMethod(nameof(Bmi1.X64.ExtractLowestSetBit), new Type[] { typeof(UInt64) })
.Invoke(null, new object[] {
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
});
Expand All @@ -134,7 +134,7 @@ public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

var result = Bmi1.ExtractLowestSetBit(
var result = Bmi1.X64.ExtractLowestSetBit(
_clsVar
);

Expand All @@ -146,7 +146,7 @@ public void RunLclVarScenario_UnsafeRead()
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));

var data = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data));
var result = Bmi1.ExtractLowestSetBit(data);
var result = Bmi1.X64.ExtractLowestSetBit(data);

ValidateResult(data, result);
}
Expand All @@ -156,7 +156,7 @@ public void RunClassLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

var test = new ScalarUnaryOpTest__ExtractLowestSetBitUInt64();
var result = Bmi1.ExtractLowestSetBit(test._fld);
var result = Bmi1.X64.ExtractLowestSetBit(test._fld);

ValidateResult(test._fld, result);
}
Expand All @@ -165,7 +165,7 @@ public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

var result = Bmi1.ExtractLowestSetBit(_fld);
var result = Bmi1.X64.ExtractLowestSetBit(_fld);
ValidateResult(_fld, result);
}

Expand All @@ -174,7 +174,7 @@ public void RunStructLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

var test = TestStruct.Create();
var result = Bmi1.ExtractLowestSetBit(test._fld);
var result = Bmi1.X64.ExtractLowestSetBit(test._fld);

ValidateResult(test._fld, result);
}
Expand Down Expand Up @@ -216,7 +216,7 @@ private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] strin

if (isUnexpectedResult)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1)}.{nameof(Bmi1.ExtractLowestSetBit)}<UInt64>(UInt64): ExtractLowestSetBit failed:");
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1.X64)}.{nameof(Bmi1.X64.ExtractLowestSetBit)}<UInt64>(UInt64): ExtractLowestSetBit failed:");
TestLibrary.TestFramework.LogInformation($" data: {data}");
TestLibrary.TestFramework.LogInformation($" result: {result}");
TestLibrary.TestFramework.LogInformation(string.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static TestStruct Create()

public void RunStructFldScenario(ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64 testClass)
{
var result = Bmi1.GetMaskUpToLowestSetBit(_fld);
var result = Bmi1.X64.GetMaskUpToLowestSetBit(_fld);
testClass.ValidateResult(_fld, result);
}
}
Expand All @@ -103,15 +103,15 @@ public ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));

public bool Succeeded { get; set; }

public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

var result = Bmi1.GetMaskUpToLowestSetBit(
var result = Bmi1.X64.GetMaskUpToLowestSetBit(
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
);

Expand All @@ -122,7 +122,7 @@ public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));

var result = typeof(Bmi1).GetMethod(nameof(Bmi1.GetMaskUpToLowestSetBit), new Type[] { typeof(UInt64) })
var result = typeof(Bmi1.X64).GetMethod(nameof(Bmi1.X64.GetMaskUpToLowestSetBit), new Type[] { typeof(UInt64) })
.Invoke(null, new object[] {
Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
});
Expand All @@ -134,7 +134,7 @@ public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

var result = Bmi1.GetMaskUpToLowestSetBit(
var result = Bmi1.X64.GetMaskUpToLowestSetBit(
_clsVar
);

Expand All @@ -146,7 +146,7 @@ public void RunLclVarScenario_UnsafeRead()
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));

var data = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data));
var result = Bmi1.GetMaskUpToLowestSetBit(data);
var result = Bmi1.X64.GetMaskUpToLowestSetBit(data);

ValidateResult(data, result);
}
Expand All @@ -156,7 +156,7 @@ public void RunClassLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

var test = new ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64();
var result = Bmi1.GetMaskUpToLowestSetBit(test._fld);
var result = Bmi1.X64.GetMaskUpToLowestSetBit(test._fld);

ValidateResult(test._fld, result);
}
Expand All @@ -165,7 +165,7 @@ public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

var result = Bmi1.GetMaskUpToLowestSetBit(_fld);
var result = Bmi1.X64.GetMaskUpToLowestSetBit(_fld);
ValidateResult(_fld, result);
}

Expand All @@ -174,7 +174,7 @@ public void RunStructLclFldScenario()
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

var test = TestStruct.Create();
var result = Bmi1.GetMaskUpToLowestSetBit(test._fld);
var result = Bmi1.X64.GetMaskUpToLowestSetBit(test._fld);

ValidateResult(test._fld, result);
}
Expand Down Expand Up @@ -216,7 +216,7 @@ private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] strin

if (isUnexpectedResult)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1)}.{nameof(Bmi1.GetMaskUpToLowestSetBit)}<UInt64>(UInt64): GetMaskUpToLowestSetBit failed:");
TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1.X64)}.{nameof(Bmi1.X64.GetMaskUpToLowestSetBit)}<UInt64>(UInt64): GetMaskUpToLowestSetBit failed:");
TestLibrary.TestFramework.LogInformation($" data: {data}");
TestLibrary.TestFramework.LogInformation($" result: {result}");
TestLibrary.TestFramework.LogInformation(string.Empty);
Expand Down
23 changes: 23 additions & 0 deletions tests/src/JIT/HardwareIntrinsics/X86/Bmi1.X64/Program.Bmi1.X64.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;

namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
static Program()
{
TestList = new Dictionary<string, Action>() {
["AndNot.UInt64"] = AndNotUInt64,
["ExtractLowestSetBit.UInt64"] = ExtractLowestSetBitUInt64,
["GetMaskUpToLowestSetBit.UInt64"] = GetMaskUpToLowestSetBitUInt64,
["ResetLowestSetBit.UInt64"] = ResetLowestSetBitUInt64,
["TrailingZeroCount.UInt64"] = TrailingZeroCountUInt64,
};
}
}
}
Loading