-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Int128 and UInt128 with a base software implementation (#69204)
* Adding barebones Int128 and UInt128 structs * Special case Int128 and UInt128 alignment on x64 Unix and Arm64 * Implementing Int128 and UInt128 * Adding tests for Int128 and UInt128 * Updating Int128/UInt128 to respect the System V ABI ordering * Fixing an issue with UInt128->BigInteger setting the wrong sign * Don't use Unsafe.As in the Int128/UInt128 hex parsing logic * Adding Int128 P/Invoke tests and ensure R2R correctly sets the packing * Fixing some issues with the Int128 interop test for non-Windows * Ensure that floating-point conversions exist for Int128 and UInt128 * Fixing the casing of a couple fields * Revert "Don't use Unsafe.As in the Int128/UInt128 hex parsing logic" This reverts commit 09e8bfc. * Adjusting the Int128/UInt128 generic math tests to have consistent ordering * Responding to PR feedback * Ensure that pNativeLayoutInfo alignment is initialized for Int128/UInt128 * Don't use Unsafe.As in the Int128/UInt128 hex parsing logic * Skip the Interop/PInvoke/Int128 tests on Mono
- Loading branch information
1 parent
d8fe9cd
commit 7f9ed8f
Showing
54 changed files
with
11,141 additions
and
239 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
79 changes: 79 additions & 0 deletions
79
src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.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,79 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Internal.TypeSystem; | ||
|
||
using Debug = System.Diagnostics.Debug; | ||
|
||
namespace ILCompiler | ||
{ | ||
/// <summary> | ||
/// Represents an algorithm that computes field layout for intrinsic integer types (Int128/UInt128). | ||
/// </summary> | ||
public class Int128FieldLayoutAlgorithm : FieldLayoutAlgorithm | ||
{ | ||
private readonly FieldLayoutAlgorithm _fallbackAlgorithm; | ||
|
||
public Int128FieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm) | ||
{ | ||
_fallbackAlgorithm = fallbackAlgorithm; | ||
} | ||
|
||
public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defType, InstanceLayoutKind layoutKind) | ||
{ | ||
Debug.Assert(IsIntegerType(defType)); | ||
|
||
string name = defType.Name; | ||
Debug.Assert((name == "Int128") || (name == "UInt128")); | ||
|
||
ComputedInstanceFieldLayout layoutFromMetadata = _fallbackAlgorithm.ComputeInstanceLayout(defType, layoutKind); | ||
|
||
if (defType.Context.Target.IsWindows || (defType.Context.Target.PointerSize == 4)) | ||
{ | ||
return layoutFromMetadata; | ||
} | ||
|
||
// 64-bit Unix systems follow the System V ABI and have a 16-byte packing requirement for Int128/UInt128 | ||
|
||
return new ComputedInstanceFieldLayout | ||
{ | ||
ByteCountUnaligned = layoutFromMetadata.ByteCountUnaligned, | ||
ByteCountAlignment = layoutFromMetadata.ByteCountAlignment, | ||
FieldAlignment = new LayoutInt(16), | ||
FieldSize = layoutFromMetadata.FieldSize, | ||
Offsets = layoutFromMetadata.Offsets, | ||
LayoutAbiStable = true | ||
}; | ||
} | ||
|
||
public override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind) | ||
{ | ||
return _fallbackAlgorithm.ComputeStaticFieldLayout(defType, layoutKind); | ||
} | ||
|
||
public override bool ComputeContainsGCPointers(DefType type) | ||
{ | ||
Debug.Assert(!_fallbackAlgorithm.ComputeContainsGCPointers(type)); | ||
return false; | ||
} | ||
|
||
public override bool ComputeIsUnsafeValueType(DefType type) | ||
{ | ||
Debug.Assert(!_fallbackAlgorithm.ComputeIsUnsafeValueType(type)); | ||
return false; | ||
} | ||
|
||
public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristics(DefType type) | ||
{ | ||
Debug.Assert(_fallbackAlgorithm.ComputeValueTypeShapeCharacteristics(type) == ValueTypeShapeCharacteristics.None); | ||
return ValueTypeShapeCharacteristics.None; | ||
} | ||
|
||
public static bool IsIntegerType(DefType type) | ||
{ | ||
return type.IsIntrinsic | ||
&& type.Namespace == "System." | ||
&& ((type.Name == "Int128") || (type.Name == "UInt128")); | ||
} | ||
} | ||
} |
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
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.