Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Enable R2RDump #97156

Merged
merged 2 commits into from
Jan 27, 2024
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
13 changes: 11 additions & 2 deletions src/coreclr/tools/r2rdump/CoreDisTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum TargetArch
Target_X64,
Target_Thumb,
Target_Arm64,
Target_LoongArch64
Target_LoongArch64,
Target_RiscV64,
};

[DllImport(_dll, CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -77,6 +78,9 @@ public static IntPtr GetDisasm(Machine machine)
case Machine.LoongArch64:
target = TargetArch.Target_LoongArch64;
break;
case Machine.RiscV64:
target = TargetArch.Target_RiscV64;
break;
default:
Program.WriteWarning($"{machine} not supported on CoreDisTools");
return IntPtr.Zero;
Expand Down Expand Up @@ -191,6 +195,10 @@ private void SetIndentations()
// Instructions are dumped as 4-byte hexadecimal integers
Machine.LoongArch64 => 4 * 2 + 1,

// Instructions are dumped as 4-byte hexadecimal integers
// TODO: update once RISC-V runtime supports "C" extension (compressed instructions)
Machine.RiscV64 => 4 * 2 + 1,

_ => throw new NotImplementedException()
};

Expand Down Expand Up @@ -260,7 +268,8 @@ public int GetInstruction(RuntimeFunction rtf, int imageOffset, int rtfOffset, o
}
else
{
if ((_reader.Machine == Machine.Arm64) || (_reader.Machine == Machine.LoongArch64))
// TODO: update once RISC-V runtime supports "C" extension (compressed instructions)
if (_reader.Machine is Machine.Arm64 or Machine.LoongArch64 or Machine.RiscV64)
{
// Replace " hh hh hh hh " byte dump with " hhhhhhhh ".
// CoreDisTools should be fixed to dump bytes this way for ARM64.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/r2rdump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public void Dump(ReadyToRunReader r2r)
Machine.ArmThumb2 => TargetArchitecture.ARM,
Machine.Arm64 => TargetArchitecture.ARM64,
Machine.LoongArch64 => TargetArchitecture.LoongArch64,
Machine.RiscV64 => TargetArchitecture.RiscV64,
_ => throw new NotImplementedException(r2r.Machine.ToString()),
};
TargetOS os = r2r.OperatingSystem switch
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/r2rdump/R2RDump.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<Platforms>x64;x86;arm64;arm;loongarch64</Platforms>
<Platforms>x64;x86;arm64;arm;loongarch64;riscv64</Platforms>
<AssemblyKey>Open</AssemblyKey>
<IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
Expand Down
Loading