FEX
FEX copied to clipboard
WIP: Initial RISCV64 support
Doesn't work yet.
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.
Any chance we could throw out the arch-specific defines and instead consolidate them to a single
FEX_HOST_ARCHone? That allows us to reliably check for unhandled hostarchs in#if-#elif-#elsecascades. 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
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.
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_ARCHone? That allows us to reliably check for unhandled hostarchs in#if-#elif-#elsecascades. 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 #endifHas 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_ARCHone? That allows us to reliably check for unhandled hostarchs in#if-#elif-#elsecascades. 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 #endifHas 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
Is there anything the community can do to help progress this? Testing on actual hardware etc?
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.
(Converted this to a draft as it is in progress)