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
2 changes: 2 additions & 0 deletions src/coreclr/scripts/jitutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ def determine_jit_name(host_os, target_os=None, host_arch=None, target_arch=None
if use_cross_compile_jit or (host_arch != target_arch) or ((target_os is not None) and (host_os != target_os)):
if target_arch.startswith("arm"):
jit_os_name = "universal"
if target_arch.startswith("wasm"):
jit_os_name = "universal"
elif target_os == "windows":
jit_os_name = "win"
elif target_os == "osx" or target_os == "linux":
Expand Down
14 changes: 10 additions & 4 deletions src/coreclr/scripts/superpmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@

host_os_help = "OS (windows, osx, linux). Default: current OS."

arch_help = "Architecture (x64, x86, arm, arm64, loongarch64, riscv64). Default: current architecture."
arch_help = "Architecture (x64, x86, arm, arm64, loongarch64, riscv64, wasm). Default: current architecture."

target_os_help = "Target OS, for use with cross-compilation JIT (windows, osx, linux). Default: current OS."

target_arch_help = "Target architecture, for use with cross-compilation JIT (x64, x86, arm, arm64, loongarch64, riscv64). Passed as asm diffs target to SuperPMI. Default: current architecture."
target_arch_help = "Target architecture, for use with cross-compilation JIT (x64, x86, arm, arm64, loongarch64, riscv64, wasm). Passed as asm diffs target to SuperPMI. Default: current architecture."

mch_arch_help = "Architecture of MCH files to download, used for cross-compilation altjit (x64, x86, arm, arm64, loongarch64, riscv64). Default: target architecture."
mch_arch_help = "Architecture of MCH files to download, used for cross-compilation altjit (x64, x86, arm, arm64, loongarch64, riscv64, wasm). Default: target architecture."

build_type_help = "Build type (Debug, Checked, Release). Default: Checked."

Expand Down Expand Up @@ -4675,7 +4675,7 @@ def verify_target_args():
lambda mch_arch: "Unknown mch_arch {}\nSupported architectures: {}".format(mch_arch, (", ".join(coreclr_args.valid_arches))),
modify_arg=lambda mch_arch: mch_arch if mch_arch is not None else coreclr_args.target_arch) # Default to `target_arch`

# For LoongArch64, RiscV64, assume we are doing altjit cross-compilation and set mch_arch to 'arch', and target_os to Linux.
# For LoongArch64, RiscV64 assume we are doing altjit cross-compilation and set mch_arch to 'arch', and target_os to Linux.
if coreclr_args.target_arch == "loongarch64" or coreclr_args.target_arch == "riscv64":
if coreclr_args.target_os == coreclr_args.host_os and coreclr_args.target_os != "linux":
logging.warning("Overriding 'target_os' to 'linux'")
Expand All @@ -4684,6 +4684,12 @@ def verify_target_args():
logging.warning("Overriding 'mch_arch' to '%s'", coreclr_args.arch)
coreclr_args.mch_arch = coreclr_args.arch

# For wasm assume we are doing altjit cross-compilation and set mch_arch to 'arch'
if coreclr_args.target_arch == "wasm":
if coreclr_args.mch_arch == coreclr_args.target_arch and coreclr_args.mch_arch != coreclr_args.arch:
logging.warning("Overriding 'mch_arch' to '%s'", coreclr_args.arch)
coreclr_args.mch_arch = coreclr_args.arch

def verify_superpmi_common_args():

coreclr_args.verify(args,
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ static SPMI_TARGET_ARCHITECTURE SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTUR
static SPMI_TARGET_ARCHITECTURE SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTURE_LOONGARCH64;
#elif defined(TARGET_RISCV64)
static SPMI_TARGET_ARCHITECTURE SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTURE_RISCV64;
#elif defined(TARGET_WASM32)
static SPMI_TARGET_ARCHITECTURE SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTURE_WASM32;
#else
#error Unsupported architecture
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/tools/superpmi/superpmi-shared/spmiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ enum SPMI_TARGET_ARCHITECTURE
SPMI_TARGET_ARCHITECTURE_ARM64,
SPMI_TARGET_ARCHITECTURE_ARM,
SPMI_TARGET_ARCHITECTURE_LOONGARCH64,
SPMI_TARGET_ARCHITECTURE_RISCV64
SPMI_TARGET_ARCHITECTURE_RISCV64,
SPMI_TARGET_ARCHITECTURE_WASM32,
};

SPMI_TARGET_ARCHITECTURE GetSpmiTargetArchitecture();
Expand All @@ -72,7 +73,8 @@ void SetSpmiTargetArchitecture(SPMI_TARGET_ARCHITECTURE spmiTargetArchitecture);
inline bool IsSpmiTarget32Bit()
{
return (GetSpmiTargetArchitecture() == SPMI_TARGET_ARCHITECTURE_X86) ||
(GetSpmiTargetArchitecture() == SPMI_TARGET_ARCHITECTURE_ARM);
(GetSpmiTargetArchitecture() == SPMI_TARGET_ARCHITECTURE_ARM) ||
(GetSpmiTargetArchitecture() == SPMI_TARGET_ARCHITECTURE_WASM32);
}

inline bool IsSpmiTarget64Bit()
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/tools/superpmi/superpmi/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CommandLine::DumpHelp(const char* program)
printf("\n");
printf(" -target <target>\n");
printf(" Specifies the target architecture if doing cross-compilation.\n");
printf(" Allowed <target> values: x64, x86, arm, arm64, loongarch64, riscv64\n");
printf(" Allowed <target> values: x64, x86, arm, arm64, loongarch64, riscv64, wasm\n");
printf(" Used by the assembly differences calculator; to determine a default JIT dll name;\n");
printf(" and to avoid treating mismatched cross-compilation replay as failure.\n");
printf("\n");
Expand Down Expand Up @@ -689,7 +689,9 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o)
(0 != _stricmp(o->targetArchitecture, "arm")) &&
(0 != _stricmp(o->targetArchitecture, "arm32")) &&
(0 != _stricmp(o->targetArchitecture, "loongarch64")) &&
(0 != _stricmp(o->targetArchitecture, "riscv64")))
(0 != _stricmp(o->targetArchitecture, "riscv64")) &&
(0 != _stricmp(o->targetArchitecture, "wasm")) &&
(0 != _stricmp(o->targetArchitecture, "wasm32")))
{
LogError("Illegal target architecture specified with -target.");
DumpHelp(argv[0]);
Expand Down
16 changes: 10 additions & 6 deletions src/coreclr/tools/superpmi/superpmi/jitinstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,30 +281,34 @@ ReplayResults JitInstance::CompileMethod(MethodContext* MethodToCompile, int mcI

switch (pParam->pThis->mc->repGetExpectedTargetArchitecture())
{
case IMAGE_FILE_MACHINE_AMD64:
case CORINFO_ARCH_X64:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_AMD64);
break;

case IMAGE_FILE_MACHINE_I386:
case CORINFO_ARCH_X86:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_X86);
break;

case IMAGE_FILE_MACHINE_ARMNT:
case CORINFO_ARCH_ARM:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_ARM);
break;

case IMAGE_FILE_MACHINE_ARM64:
case CORINFO_ARCH_ARM64:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_ARM64);
break;

case IMAGE_FILE_MACHINE_LOONGARCH64:
case CORINFO_ARCH_LOONGARCH64:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_LOONGARCH64);
break;

case IMAGE_FILE_MACHINE_RISCV64:
case CORINFO_ARCH_RISCV64:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_RISCV64);
break;

case CORINFO_ARCH_WASM32:
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_WASM32);
break;

default:
LogError("Unknown target architecture");
break;
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/tools/superpmi/superpmi/superpmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ void SetSuperPmiTargetArchitecture(const char* targetArchitecture)
{
SetSpmiTargetArchitecture(SPMI_TARGET_ARCHITECTURE_RISCV64);
}
else if (0 == _stricmp(targetArchitecture, "wasm") || (0 == _stricmp(targetArchitecture, "wasm32")))
{
SetSpmiTargetArchitecture(SPMI_TARGET_ARCHITECTURE_WASM32);
}
else
{
LogError("Illegal target architecture '%s'", targetArchitecture);
Expand Down
Loading