在预处理器中检测 ARM-64? [英] Detect ARM-64 in preprocessor?

查看:28
本文介绍了在预处理器中检测 ARM-64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据微软 (这里此处),该公司将在即将发布的 Windows 10 版本中支持 ARMv8/Aarch64 (ARM-64).此外,微软还有 已经提供了预览,所以我猜工具支持已经到位.

According to Microsoft (here and here), the company will support ARMv8/Aarch64 (ARM-64) in upcoming version of Windows 10. Additionally, Microsoft has already supplied previews so I'm guessing tool support is in place.

对于那些不知道的人,文章提供的图片清楚地显示了高通骁龙 410.这是一个 A-53 内核,它的 Aarch64/ARM-64.

For those not aware, the images provided with the article clearly shows a Qualcomm Snapdragon 410. That's an A-53 core, and its Aarch64/ARM-64.

Microsoft 为 ARM-32 定义了 _M_ARM,我们目前使用它来检测 NEON 的可用性.ARMv8 支持可选扩展 CRC32、AES、SHA-1 和 SHA-2.我们已经为 Apple 和 Linux 编写了代码,我们希望为 Microsoft 平台启用它.

Microsoft defines _M_ARM for ARM-32, and we currently use it to detect NEON availability. ARMv8 supports optional extensions CRC32, AES, SHA-1, and SHA-2. We have code for them written already for Apple and Linux, and we'd like to enable it for Microsoft platforms.

微软还有 __M_ARM_FP,但不清楚用它来检测ARM64.我也不清楚 x86 的相关性:

Microsoft also has __M_ARM_FP, but its not clear to use it to detect ARM64. I'm also not clear on the relevance of x86:

扩展为整数文字值,指示哪个/arch 编译器使用了选项:

Expands to an integer literal value indicating which /arch compiler option was used:

  • 如果未指定/arch ARM 选项,则在 30-39 范围内,表示使用了 ARM 的默认架构 (VFPv3).
  • 如果使用了/arch:VFPv4,则范围为 40-49.
  • 有关详细信息,请参阅/arch (x86).

我对可用的 Microsoft 编译器进行了一些快速测试(所有编译器都可以追溯到 VC++ 5.0).他们未能使用 ARMv8 内在函数,这并不奇怪.我猜我需要订阅 MSDN 才能使用最新工具进行测试,但我不再订阅.

I ran some quick tests on the Microsoft compilers I have available (all of them dating back to VC++ 5.0). They failed to consume ARMv8 intrinsics, which is not surprising. I'm guessing I need a MSDN subscription to test with the latest tools, but I no longer have the subscription.

我的问题是:

  • 我们如何在预处理器中检测 ARMv8/Aarch64 (_M_ARM64?)
  • 什么版本的编译器(_MSC_VER)支持 ARMv8 指令
  • How do we detect ARMv8/Aarch64 in the preprocessor (_M_ARM64?)
  • What version of the compiler (_MSC_VER) support ARMv8 instructions

这可能与:什么是WINAPI_FAMILY_ONECORE_APP?

推荐答案

VS从VS2017开始使用_M_ARM64,详情见下文.

VS starting from VS2017 uses _M_ARM64, see below for more details.

以相反的顺序回答:

  • 当前发布的 Visual Studio 版本都不支持 ARMv8/AArch64,它们只支持 ARMv7.尽管 Windows 10 本身显示了 arm64 支持的迹象(有一些 arm64 的可执行文件和库),但据我所知,迄今为止发布的编译器版本都没有真正包含它.(Visual Studio 2015 社区至少没有包含它,几天前发布的新 Visual Studio15"预览版 2 也没有.)很明显它在内部存在,但它没有成为任何的一部分尚未公开发布.

  • None of the currently released Visual Studio versions support ARMv8/AArch64, they only support ARMv7. Even though Windows 10 itself shows signs of arm64 support (there's some executables and libraries for arm64), none of the versions of the compiler that have been released so far actually include it, to my knowledge. (Visual Studio 2015 Community at least doesn't include it, and neither does the new Visual Studio "15" Preview 2 that was released a few days ago.) So clearly it exists internally, but it hasn't been made part of any public release yet.

至于定义寻找什么;这是目前未知的,因为编译器的 arm64 目标版本没有公开文档,因为它还没有发布,也不能凭经验进行测试.

As for what define to look for; this is currently unknown, since there's no public documentation for the arm64 target version of the compiler since it's not been released yet, and one can't test empirically either.

我在您的两个链接中都没有看到 Microsoft 明确声明将支持它,但至少 Windows 10 SDK 确实显示出正在开发的明确迹象.

I don't see any clear statement from Microsoft in either of your links saying that it will be supported, but at least the Windows 10 SDK does show clear signs of it being worked on.

即使编译器不可用,Windows 10 SDK(本身包含 ARM64 库)头文件和 Visual C++ 2015 头文件(没有匹配的 ARM64 库)也包含对此的引用.与_M_ARM 类似,还有_M_ARM64.vc/include/intrin.h 中的一个片段:

Even though the compiler isn't available, the Windows 10 SDK (which itself contains libs for ARM64) headers and Visual C++ 2015 headers (which have no matching ARM64 libs) also contains references to this. Similarly to _M_ARM, there's also _M_ARM64. A snippet from vc/include/intrin.h:

#if defined (_M_ARM)
    #include <armintr.h>
    #include <arm_neon.h>
#endif

#if defined (_M_ARM64)
    #include <arm64intr.h>
    #include <arm64_neon.h>
#endif

<小时>

编辑 2:


虽然还没有面向 arm64 的 Visual C++ 编译器的公共版本可用,但 clang 正在获得对 Windows/arm64 的第一部分支持,并且它们也使用 _M_ARM64:

While no public version of the Visual C++ compiler targeting arm64 is available yet, clang is getting the first parts of support for Windows/arm64, and they also use _M_ARM64:

https://github.com/llvm-project/clang/commit/5b7d7d2b2d0bd7054f51b9d108cdd5299a0ec33e#diff-ed544af3ae6807a8513b1cabb3233941R6576

编辑 3:

随着 Visual Studio 2017 15.4 版的最新更新,ARM64 编译器发布.在安装程序中,可以手动勾选Visual C++ compilers and libraries for ARM64"项(默认不启用).

With the latest update of Visual Studio 2017, version 15.4, the ARM64 compiler is released. In the installer, one can manually check the "Visual C++ compilers and libraries for ARM64" item (it isn't enabled by default).

这样做之后,您可以启动VS 2017 的开发人员命令提示符",并在该 shell 中运行vsdevcmd -arch=arm64 -host_arch=amd64",然后您就可以在路径中找到编译器:

After doing that, you can launch "Developer Command Prompt for VS 2017", and in that shell run "vsdevcmd -arch=arm64 -host_arch=amd64", then you've got the compiler in the path:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.4.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

C:Program Files (x86)Microsoft Visual Studio2017Community>vsdevcmd -arch=arm64 -host_arch=amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.4.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

C:Program Files (x86)Microsoft Visual Studio2017Community>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25547 for ARM64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

C:Program Files (x86)Microsoft Visual Studio2017Community>

而且这个编译器预定义了_M_ARM64,可以让你识别它,从而回答这个问题.

And this compiler predefines _M_ARM64 which allows you to identify it, thus answering this question.

这篇关于在预处理器中检测 ARM-64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆