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

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

问题描述

根据Microsoft(

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.

对于那些不知道的人,本文提供的图片清楚地显示了Qualcomm Snapdragon410.这是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.

Microsoft还具有 __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).
  • In the range 30-39 if no /arch ARM option was specified, indicating the default architecture for ARM was used (VFPv3).
  • In the range 40-49 if /arch:VFPv4 was used.
  • See /arch (x86) for more information.

我对可用的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.

我的问题是:

  • 如何在预处理器(_M_ARM64)中检测ARMv8/Aarch64
  • 哪个版本的编译器(_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?

This may be related: What is WINAPI_FAMILY_ONECORE_APP?

推荐答案

从VS2017开始的VS使用_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 Studio"15" Preview 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.

在您的任何一个链接中我都没有看到微软的明确声明,说它将被支持,但是至少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


Edit2:


虽然尚无面向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 /commit/5b7d7d2b2d0bd7054f51b9d108cdd5299a0ec33e#diff-ed544af3ae6807a8513b1cabb3233941R6576

Edit3:

随着Visual Studio 2017 15.4版的最新更新,发布了ARM64编译器.在安装程序中,您可以手动检查用于ARM64的Visual C ++编译器和库"项(默认情况下未启用).

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 Studio\2017\Community>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 Studio\2017\Community>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 Studio\2017\Community>

此编译器预定义了_M_ARM64,它使您可以识别它,从而回答了这个问题.

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

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

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