Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 16 additions & 2 deletions src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
// to the same alignment as __m128, which is supported by the ABI.
alignment = new LayoutInt(8);
}
else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64 || defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64)
{
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
// 16-byte alignment for __m256.
alignment = new LayoutInt(16);
}
else if (defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
{
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
// RISC-V Vector Extenstion Intrinsic Document
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/vector_type_infos.adoc
alignment = new LayoutInt(16);
}
else
{
alignment = new LayoutInt(32);
Expand All @@ -73,12 +80,19 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
// to the same alignment as __m128, which is supported by the ABI.
alignment = new LayoutInt(8);
}
else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64 || defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64)
{
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
// 16-byte alignment for __m256.
alignment = new LayoutInt(16);
}
else if (defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
{
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
// RISC-V Vector Extenstion Intrinsic Document
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/vector_type_infos.adoc
alignment = new LayoutInt(16);
}
else
{
alignment = new LayoutInt(64);
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10051,6 +10051,11 @@ void MethodTableBuilder::CheckForSystemTypes()
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
// 16-byte alignment for __m256.

pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
#elif defined(TARGET_RISCV64)
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
// RISC-V Vector Extenstion Intrinsic Document
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/vector_type_infos.adoc
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
#else
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 32; // sizeof(__m256)
Expand All @@ -10068,6 +10073,12 @@ void MethodTableBuilder::CheckForSystemTypes()
// 16-byte alignment for __m256.

pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;

#elif defined(TARGET_RISCV64)
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
// RISC-V Vector Extenstion Intrinsic Document
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/vector_type_infos.adoc
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
#else
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 64; // sizeof(__m512)
#endif // TARGET_ARM elif TARGET_ARM64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public static unsafe class Vector256
internal const int Alignment = 8;
#elif TARGET_ARM64
internal const int Alignment = 16;
#elif TARGET_RISCV64
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
internal const int Alignment = 16;
#else
internal const int Alignment = 32;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public static unsafe class Vector512
internal const int Alignment = 8;
#elif TARGET_ARM64
internal const int Alignment = 16;
#elif TARGET_RISCV64
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
internal const int Alignment = 16;
#else
internal const int Alignment = 64;
#endif
Expand Down