Skip to content

Commit bf09cf7

Browse files
committed
[LoongArch64] Add some R2R missing codes.
1 parent bc9fc5a commit bf09cf7

File tree

9 files changed

+26
-9
lines changed

9 files changed

+26
-9
lines changed

src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ
9797
if (potentialType.Namespace != "System.Runtime.Intrinsics.Arm")
9898
return "";
9999
}
100+
else if (architecture == TargetArchitecture.LoongArch64)
101+
{
102+
return "";
103+
}
100104
else if (architecture == TargetArchitecture.RiscV64)
101105
{
102106
return "";

src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs

+10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
5858
// 16-byte alignment for __m256.
5959
alignment = new LayoutInt(16);
6060
}
61+
else if (defType.Context.Target.Architecture == TargetArchitecture.LoongArch64)
62+
{
63+
// TODO-LoongArch64: Update alignment to proper value when implement LoongArch64 intrinsic.
64+
alignment = new LayoutInt(16);
65+
}
6166
else if (defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
6267
{
6368
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
@@ -86,6 +91,11 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
8691
// 16-byte alignment for __m256.
8792
alignment = new LayoutInt(16);
8893
}
94+
else if (defType.Context.Target.Architecture == TargetArchitecture.LoongArch64)
95+
{
96+
// TODO-LoongArch64: Update alignment to proper value when implement LoongArch64 intrinsic.
97+
alignment = new LayoutInt(16);
98+
}
8999
else if (defType.Context.Target.Architecture == TargetArchitecture.RiscV64)
90100
{
91101
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,10 @@ private CompilationResult CompileMethodInternal(IMethodNode methodCodeNodeNeedin
415415
if (codeSize < _code.Length)
416416
{
417417
if (_compilation.TypeSystemContext.Target.Architecture != TargetArchitecture.ARM64
418+
&& _compilation.TypeSystemContext.Target.Architecture != TargetArchitecture.LoongArch64
418419
&& _compilation.TypeSystemContext.Target.Architecture != TargetArchitecture.RiscV64)
419420
{
420-
// For xarch/arm32/RiscV64, the generated code is sometimes smaller than the memory allocated.
421+
// For xarch/arm32/LoongArch64/RiscV64, the generated code is sometimes smaller than the memory allocated.
421422
// In that case, trim the codeBlock to the actual value.
422423
//
423424
// For arm64, the allocation request of `hotCodeSize` also includes the roData size

src/coreclr/tools/Common/JitInterface/LoongArch64PassStructInRegister.cs

-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ public static uint GetLoongArch64PassStructInRegisterFlags(TypeDesc typeDesc)
2929
return (uint)StructFloatFieldInfoFlags.STRUCT_NO_FLOAT_FIELD;
3030
}
3131

32-
//// The SIMD Intrinsic types are meant to be handled specially and should not be passed as struct registers
33-
if (typeDesc.IsIntrinsic)
34-
{
35-
throw new NotImplementedException("For LoongArch64, SIMD would be implemented later");
36-
}
37-
3832
MetadataType mdType = typeDesc as MetadataType;
3933
Debug.Assert(mdType != null);
4034

src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private static PerfmapTokensForTarget TranslateTargetDetailsToPerfmapConstants(T
136136
TargetArchitecture.X64 => PerfMapArchitectureToken.X64,
137137
TargetArchitecture.X86 => PerfMapArchitectureToken.X86,
138138
TargetArchitecture.RiscV64 => PerfMapArchitectureToken.RiscV64,
139+
TargetArchitecture.LoongArch64 => PerfMapArchitectureToken.LoongArch64,
139140
_ => throw new NotImplementedException(details.Architecture.ToString())
140141
};
141142

src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum PerfMapArchitectureToken : uint
2020
X64 = 3,
2121
X86 = 4,
2222
RiscV64 = 5,
23+
LoongArch64 = 6,
2324
}
2425

2526
public enum PerfMapOSToken : uint

src/coreclr/vm/methodtablebuilder.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -10051,6 +10051,9 @@ void MethodTableBuilder::CheckForSystemTypes()
1005110051
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
1005210052
// 16-byte alignment for __m256.
1005310053

10054+
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
10055+
#elif defined(TARGET_LOONGARCH64)
10056+
// TODO-LoongArch64: Update alignment to proper value when implement LoongArch64 intrinsic.
1005410057
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
1005510058
#elif defined(TARGET_RISCV64)
1005610059
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
@@ -10074,6 +10077,9 @@ void MethodTableBuilder::CheckForSystemTypes()
1007410077

1007510078
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
1007610079

10080+
#elif defined(TARGET_LOONGARCH64)
10081+
// TODO-LoongArch64: Update alignment to proper value when implement LoongArch64 intrinsic.
10082+
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
1007710083
#elif defined(TARGET_RISCV64)
1007810084
// TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
1007910085
// RISC-V Vector Extenstion Intrinsic Document

src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public ManagedTextSection(
9090
/// If set, the module contains instructions that assume a 64 bit instruction set. For example it may depend on an address being 64 bits.
9191
/// This may be true even if the module contains only IL instructions because of PlatformInvoke and COM interop.
9292
/// </summary>
93-
internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64;
93+
internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64 || Machine == Machine.LoongArch64;
9494

9595
public bool Is32Bit => !Requires64bits;
9696

src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static PEHeaderBuilder CreateLibraryHeader()
105105
return new PEHeaderBuilder(imageCharacteristics: Characteristics.ExecutableImage | Characteristics.Dll);
106106
}
107107

108-
internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64 && Machine != Machine.RiscV64;
108+
internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64 && Machine != Machine.LoongArch64 && Machine != Machine.RiscV64;
109109

110110
internal int ComputeSizeOfPEHeaders(int sectionCount) =>
111111
PEBuilder.DosHeaderSize +

0 commit comments

Comments
 (0)