FEX icon indicating copy to clipboard operation
FEX copied to clipboard

WIP: Initial RISCV64 support

Open Sonicadvance1 opened this issue 3 years ago • 7 comments

Doesn't work yet.

Sonicadvance1 avatar Mar 23 '22 09:03 Sonicadvance1

Any chance we could throw out the arch-specific defines and instead consolidate them to a single FEX_HOST_ARCH one? That allows us to reliably check for unhandled hostarchs in #if-#elif-#else cascades. Since we have a fair bunch of those across the code base, it seems too easy to slip in an uncaught typo otherwise that's easily avoided with a unified define.

neobrain avatar Mar 24 '22 09:03 neobrain

Any chance we could throw out the arch-specific defines and instead consolidate them to a single FEX_HOST_ARCH one? That allows us to reliably check for unhandled hostarchs in #if-#elif-#else cascades. Since we have a fair bunch of those across the code base, it seems too easy to slip in an uncaught typo otherwise that's easily avoided with a unified define.

How does that change the behaviour or chance of typo?

#if defined(_M_ARM_64)
#warning Do ARM things
#elif defined(_M_X86_64)
#warning Do x86 things
#elif defined (_M_RISCV_64)
#warning Do risky things
#else 
#error Unsupported arch
#endif

Has the same chance to do incorrect logic in the chance of a typo as:

#if FEX_HOST_ARCH == AARCH64
#warning Do ARM things
#elif FEX_HOST_ARCH == X86
#warning Do x86 things
#elif FEX_HOST_ARCH == RISCV
#warning Do risky things
#else 
#error Unsupported arch
#endif

Sonicadvance1 avatar Mar 27 '22 13:03 Sonicadvance1

How does that change the behaviour or chance of typo?

Fair point - I was probably thinking that AARCH64/X86/RISCV are easier to correctly remember (or look up) than the other defines, but as you're pointing out there's no risk in typos if an #else branch is included.

So the really important bit is to have that #else branch consistently rather than using custom defines.

neobrain avatar Mar 28 '22 11:03 neobrain

Adding my view here, I think it'd be useful to prefix those with FEX (FEX_M_ARM_64) to make it easier to lookup. Though, that's more of a general design decision.

Any chance we could throw out the arch-specific defines and instead consolidate them to a single FEX_HOST_ARCH one? That allows us to reliably check for unhandled hostarchs in #if-#elif-#else cascades. Since we have a fair bunch of those across the code base, it seems too easy to slip in an uncaught typo otherwise that's easily avoided with a unified define.

How does that change the behaviour or chance of typo?

#if defined(_M_ARM_64)
#warning Do ARM things
#elif defined(_M_X86_64)
#warning Do x86 things
#elif defined (_M_RISCV_64)
#warning Do risky things
#else 
#error Unsupported arch
#endif

Has the same chance to do incorrect logic in the chance of a typo as:

#if FEX_HOST_ARCH == AARCH64
#warning Do ARM things
#elif FEX_HOST_ARCH == X86
#warning Do x86 things
#elif FEX_HOST_ARCH == RISCV
#warning Do risky things
#else 
#error Unsupported arch
#endif

A question on that, are _M_ARM_64 FEX-specific, or provided by the OS and such?

Any chance we could throw out the arch-specific defines and instead consolidate them to a single FEX_HOST_ARCH one? That allows us to reliably check for unhandled hostarchs in #if-#elif-#else cascades. Since we have a fair bunch of those across the code base, it seems too easy to slip in an uncaught typo otherwise that's easily avoided with a unified define.

How does that change the behaviour or chance of typo?

#if defined(_M_ARM_64)
#warning Do ARM things
#elif defined(_M_X86_64)
#warning Do x86 things
#elif defined (_M_RISCV_64)
#warning Do risky things
#else 
#error Unsupported arch
#endif

Has the same chance to do incorrect logic in the chance of a typo as:

#if FEX_HOST_ARCH == AARCH64
#warning Do ARM things
#elif FEX_HOST_ARCH == X86
#warning Do x86 things
#elif FEX_HOST_ARCH == RISCV
#warning Do risky things
#else 
#error Unsupported arch
#endif

skmp avatar Apr 22 '22 08:04 skmp

Is there anything the community can do to help progress this? Testing on actual hardware etc?

archanox avatar Aug 01 '22 21:08 archanox

Main thing here is that I just need to continue working on this. SIGBUS behaviour differing between qemu and hardware is a bit annoying, but I'll just need to handle that.

Sonicadvance1 avatar Aug 01 '22 21:08 Sonicadvance1

(Converted this to a draft as it is in progress)

skmp avatar Aug 15 '22 09:08 skmp