[MSVC] workaround mvn macro and detect ARM64 (#407)

Fixed MSVC AArch64 build

* Detect AArch64 target properly when compiling by MSVC
* Workaround the issue caused by MSVC defining a mvn macro

---------

Co-authored-by: Petr Kobalicek <kobalicek.petr@gmail.com>
This commit is contained in:
ZeeWanderer
2023-04-28 02:14:41 +03:00
committed by GitHub
parent 5635cf463a
commit 3577608cab
2 changed files with 14 additions and 1 deletions

View File

@@ -11,6 +11,14 @@
#include "../arm/a64instdb.h"
#include "../arm/a64operand.h"
// MSVC targeting AArch64 defines a lot of macros without underscores clashing
// with AArch64 instruction names. We have to workaround until it's fixed in SDK.
#if defined(_MSC_VER) && defined(mvn)
#define ASMJIT_RESTORE_MSVC_AARCH64_MACROS
#pragma push_macro("mvn")
#undef mvn
#endif
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
#define ASMJIT_INST_0x(NAME, ID) \
@@ -1225,4 +1233,9 @@ class Emitter : public BaseEmitter, public EmitterExplicitT<Emitter> {
ASMJIT_END_SUB_NAMESPACE
// Restore undefined MSVC AArch64 macros.
#if defined(ASMJIT_RESTORE_MSVC_AARCH64_MACROS)
#pragma pop_macro("mvn")
#endif
#endif // ASMJIT_ARM_A64EMITTER_H_INCLUDED

View File

@@ -172,7 +172,7 @@ namespace asmjit {
#define ASMJIT_ARCH_X86 0
#endif
#if defined(__arm64__) || defined(__aarch64__)
#if defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__)
# define ASMJIT_ARCH_ARM 64
#elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__) || defined(__thumb2__)
#define ASMJIT_ARCH_ARM 32