Xbox One Compiler Technology

The compiler for the Xbox One is the Visual C++ x64 complier that ships with Visual Studio 2015 (19.0) or Visual Studio 2017 (19.1). Use of Visual Studio 2015 Update 3 or the latest Visual Studio 2017 update is strongly recommended.

Visual C++ Porting and Upgrading Guide

C++11/C++14 Language Features

The Xbox One Compiler supports a number of C++11/C++14 language features. Here is a comparison of the various recent generations of Visual C++.

C++11/C++14 Language VS 2010Xbox 360 Compiler VS 2012 Xbox One Compiler with VS 2012 VS 2013 VS 2015 VS 2017
nullptr ++++++
static_assert ++++++
override / final* ++++++
Lambda expressions ++++++
Rvalue references ++++++
decltype ++++++
auto ++++++
Strongly typed enumerations  +++++
Forward declared enumerations  +++++
Ranged-based for loops  +++++
Variadic templates    +++
Uniform initialization and initializer lists   +++
Delegating constructors   +++
Raw string literals   +++
Explicit conversion operators   +++
Default template arguments for function templates   +++
Alias templates   +++
Defaulted functions   +++
Deleted functions   +++
Non-static data member initializers (NSDMIs)   +++
Attributes, constexpr, ref-qualifiers, inheriting constructors, char16_t, char32_t, Unicode string literals, user-defined literals, extended sizeof, inline namespaces, unrestricted unions, noexcept, thread_local, magic statics, Universal character names in literals         ++
C99: __func__, long long         ++
Expression SFINAE         Update 1 +
C++14: auto / decltype(auto) trailing return types    ++
C++14: Generalized Lambda Capture (aka init-captures), Generic Lambdas    ++
C++14: Sized deallocation (global delete operator with size)    ++
C++14: Binary literals, Digit separators    ++
C++14: [ [deprecated] ] attributes    ++
C++14: Variable templates    Update 2+
C++14: Extended constexpr, NSDMIs for aggregates     +

As of the March 2017 Xbox One XDK or later, developers may use VS 2017 for Xbox One development which uses the VS 2017 retail compiler. Visual Studio 2015 was supported starting with the August 2015 Xbox One XDK.

Visual C++ Team Blog

C++17 Features And STL Fixes In VS 2017 15.3

C++11/C++14 Standard Library

The Xbox One Compiler includes an implementation of the C++11/C++14 Standard Library. Here is a comparison of the various recent generations of Visual C++.

C++11 Standard Library VS 2010 Xbox 360 Compiler VS 2012 Xbox One Compiler VS 2013 VS 2015 VS 2017
<array>, <memory>, <random>, <regex>, <tuple>, <type_traits>, <unordered_map>, <unordered_set> + + + +++
<stdint.h> + + + +++
unique_ptr<T> + + + +++
cbegin(), cend(), crbegin(), crend() + + + +++
<forward_list> + + + +++
<algorithm> and <exception> updates
  • find_if_not, copy_if, is_sorted,etc.
  • exception_ptr
++++++
<allocators>++++++
<codecvt>++++++
<system_error>++++++
emplace(), emplace_front(), emplace_back(), etc. +++++
<chrono> +++++
<ratio> +++++
<scoped_allocator> +++++
<atomic>, <condition_variable>, <future>, <mutex>, <thread> +++++
<intializer_list>   +++
C99: <stdbool.h>, <complex.h> / <ccomplex>, <fenv.h> / <cfenv>, <inttypes.h> / <cinttypes>, <ctgmath>   +++
C99: <tgmath.h>, <uchar.h> / <cuchar>, some printf format specifiers    ++
C++14: Global cbegin()cend()std::greater<>std::make_unique<T>std::make_move_iterator<T>   +++
C++14: Standard user-defined literals (UDLs)std::make_reverse_iterator<T>std::vector<bool> emplace()emplace_back()std::exchange    ++

Intrinsics

The Visual C++ compiler does not support x64 inline assembly, but supports a wide variety of intrinsics to support inclusion of specialized instruction sets for Xbox One development.

Note: Any use of intrinsics assumes the developer has already verified the instructions are supported by the target platform. Failure to do so will result in runtime ‘invalid instruction’ exceptions. Pay particular attention to the fact that Xbox One supports AVX, but not AVX2 or AVX-512 instructions.

Header Description
intrin.hGeneral intrinsics, notably __cpuid and various intrinsics forms of the CRT routines. Includes ammintrin.h and immintrin.h
ammintrin.hAMD instruction sets: SSE5, FMA4, and XOP instrinsics. Note that FMA4 and XOP are not supported by the Xbox One console.
immintrin.hIntel instruction sets: AVX, FMA3, F16C/CVT16, and AVX2 intrinsics Note that FMA3 and AVX2 are not supported by the Xbox One console family.
xmmintrin.hSSE intrinsics and the __m128 type (single-precision float SIMD)
emmintrin.hSSE2 intrinsics and the __m128i/__m128d types (double-precision float and integer SIMD)
pmmintrin.hSSE3 intrinsics (horizontal adds and subtracts float/double operations, specific 'dup' operations)
tmmintrin.hSSSE3 intrinsics (more horizontal ops, integer abs, 'byte' shuffle to augment SSE2)
smmintrin.hSSE4.1 intrinsics (dot-product, rounding, augmented min/max support for SSE2)
nmmintrin.hSSE4.2 intrinsics
wmmintrin.hAES intrinsics
zmmintrin.hAVX-512 intrinsics Note that AVX-512 intrinsics are not supported by the Xbox One console family.
mmintrin.hIntel MMX intriniscs (including the __m64 type), which are not supported for x64 native applications.
mm3dnow.hAMD 3DNow! instrinsics which are not supported for x64 native applications. Note that _mm_prefetch / _m_prefetchw are supported for x64 native, and are also defined in intrin.h.

Note: Visual Studio 2010 Service Pack 1 and later support the /arch:AVX switch which enables the use of the VEX prefix which is part of the AVX instruction set standard. This switch is recommend for all Xbox One applications.
MSDN: x64 IntrinsicsMSDN: MMX, SSE, and SSE2 IntrinsicsMSDN: Streaming SIMD Extensions 4 InstructionsIntel: AVXGames for Windows and the DirectX SDK blog: DirectXMath series

Calling Conventions

The the older Xbox One 17.1 compiler and Visual Studio 2013 or later support the new __vectorcall calling convention for x86 and x64 code.
Visual C++ Team Blog: Introducing ‘Vector Calling Convention’> Note The __cdecl calling convention doesn’t apply on x64. Calls use the __fastcall calling convention even if __cdecl is specified on XBox One. The default project templates for XBox One specify __cdecl, but the _cdecl attribute will be ignored.

Auto-vectorizer & Auto-parallelizer

The Visual C++ optimizer can change scalar integer or floating-point computations into SIMD instructions via the auto-vectorizer. This is enabled automatically with /O2 or /Ox. You can disable it for specific loops via #pragma loop(no_vector)

These compiler toolsets also support auto-parallelization for loops using threads. This is enabled by /Qpar. You can provide a hint for a specific loop via #pragma (loop(hint_parallel(n)))
MSDN: Auto-Parallelization and Auto-VectorizationParallel Programming in Native Code blog: Auto-Vectorizer in Visual Studio 2012 series

C++/CX Language Extensions

Visual C++ supports C++/CX Language Extensions to simplify coding for Windows Runtime (WinRT) APIs. These extensions are enabled via the /ZW switch and requires C++ Exception Handling (/EHsc) be enabled.
Visual C++ Team Blog: Inside the C++/CX Design
WinRT and C extensions for Xbox One White Paper (Developer Education Materials > All NDA Whitepapers)

C++/WinRT Language Projections

An alternative to using C++/CX for coding against Windows Runtime (WinRT) APIs, is to use the C++/WinRT language projection headers. These do not require the C++/CX (/ZW) as they use standard C++. They do make use of C++17 nested namespaces so use requires /std:c++latest or /std:c++17 to build.

Hats Off! Getting Started with C++/WinRT (Developer Education Materials > All NDA Whitepapers)

Resources

Code Generation for Xbox One: Best Practices (Developer Education Materials > All NDA Whitepapers)AMD Developer Guides & ManualsIntel 64 and IA-32 Architectures Software Developer ManualsWhat’s New for Visual C++ in Visual Studio 2015What’s New for Visual C++ in Visual Studio 2017