본문 바로가기

개발 Note/C++11,14 (modern C++)

CPU architecture 구분을 위한 predefined macro 입니다.

반응형


CPU architecture  구분을 위한 predefined macro 입니다.



Please send updates/corrections to predef-contribute.

Alpha

TypeMacroDescription
Identification__alpha__Defined by GNU C
Version__alpha_ev'V'__V = Version
Identification__alphaDefined by DEC C
Identification_M_ALPHADefined by Visual Studio
Example
CPUMacro
Alpha EV4__alpha_ev4__
Alpha EV5__alpha_ev5__
Alpha EV6__alpha_ev6__

AMD64

TypeMacroDescription
Identification__amd64__
__amd64
__x86_64__
__x86_64
Defined by GNU C and Sun Studio
Identification_M_X64
_M_AMD64
Defined by Visual Studio

Notice that x32 can be detected by checking if the CPU uses the ILP32 data model.

ARM

TypeMacroDescription
Identification__arm__Defined by GNU C and RealView
Identification__thumb__Defined by GNU C and RealView in Thumb mode
Version__ARM_ARCH_'V'__V = Version

Defined by GNU C 1
Identification__TARGET_ARCH_ARM
__TARGET_ARCH_THUMB
Defined by RealView
Version__TARGET_ARCH_ARM = V
__TARGET_ARCH_THUMB = V
V = Version
Version__TARGET_ARCH_'VR'VR = Version and Revision
Identification_ARMDefined by ImageCraft C
Identification_M_ARMDefined by Visual Studio
Identification_M_ARMTDefined by Visual Studio in Thumb mode
Version_M_ARM = VV = Version
Example
CPUMacro_M_ARM
ARM 2__ARM_ARCH_2__
ARM 3__ARM_ARCH_3__
__ARM_ARCH_3M__
ARM 4T__ARM_ARCH_4T__
__TARGET_ARM_4T
ARM 5__ARM_ARCH_5__
__ARM_ARCH_5E__
5
ARM 5T__ARM_ARCH_5T__
__ARM_ARCH_5TE__
__ARM_ARCH_5TEJ__
ARM 6__ARM_ARCH_6__
__ARM_ARCH_6J__
__ARM_ARCH_6K__
__ARM_ARCH_6Z__
__ARM_ARCH_6ZK__
6
ARM 6T2__ARM_ARCH_6T2__
ARM 7__ARM_ARCH_7__
__ARM_ARCH_7A__
__ARM_ARCH_7R__
__ARM_ARCH_7M__
__ARM_ARCH_7S__
7

ARM64

TypeMacroDescription
Identification__aarch64__Defined by GNU C 1

Blackfin

TypeMacroDescription
Identification__bfin
__BFIN__
Defined by GNU C

Convex

TypeMacroDescription
Identification__convex__Defined by GNU C
Version__convex_'V'__V = Version
Example
CPUMacro
Convex C1__convex_c1__
Convex C2__convex_c2__
Convex C32xx series__convex_c32__
Convex C34xx series__convex_c34__
Convex C38xx series__convex_c38__

Epiphany

TypeMacro
Identification__epiphany__

HP/PA RISC

TypeMacroDescription
Identification__hppa__Defined by GNU C
Identification__HPPA__Defined by Stratus VOS C
Identification__hppa
Version_PA_RISC'V'_'R'V = Version
R = Revision

See also OpenPA.net.

Example
CPUMacro
PA RISC 1.0_PA_RISC1_0
PA RISC 1.1_PA_RISC1_1
__HPPA11__
__PA7100__
PA RISC 2.0_PA_RISC2_0
__RISC2_0__
__HPPA20__
__PA8000__

Intel x86

TypeMacroFormatDescription
Identificationi386
__i386
__i386__
Defined by GNU C
Version__i386__
__i486__
__i586__
__i686__
Defined by GNU C
Identification__i386Defined by Sun Studio
Identification__i386
__IA32__
Defined by Stratus VOS C
Identification_M_I86Only defined for 16-bits architectures

Defined by Visual Studio, Digital Mars, and Watcom C/C++ (see note below)
Identification_M_IX86Only defined for 32-bits architectures

Defined by Visual Studio, Intel C/C++, Digital Mars, and Watcom C/C++
Version_M_IX86V00V = Version
Identification__X86__Defined by Watcom C/C++
Identification_X86_Defined by MinGW32
Identification__THW_INTEL__Defined by XL C/C++
Identification__I86__Defined by Digital Mars
Version__I86__VV = Version
Identification__INTEL__Defined by CodeWarrior

Notice that Watcom C/C++ defines _M_IX86 for both 16-bits and 32-bits architectures. Use __386__ or _M_I386 to detect 32-bits architectures in this case.

Notice that the Stratus VOS is big-endian on IA32, so these macros cannot be used to detect endianness if __VOS__ is set.

Example
CPU_M_IX86__I86__
803863003
804864004
Pentium5005
Pentium Pro/II6006

Intel Itanium (IA-64)

TypeMacroFormatDescription
Identification__ia64__
_IA64
__IA64__
Defined by GNU C
Identification__ia64Defined by HP aCC
Identification_M_IA64Defined by Visual Studio
Identification_M_IA64Defined by Intel C/C++
Version_M_IA64?
Identification__itanium__Defined by Intel C/C++
Example
CPU_M_IA64 (Intel C/C++)
64100

Motorola 68k

TypeMacroDescription
Identification__m68k__Defined by GNU C
Version__mc'V'__
__mc'V'
mc'V'
V = Version
IdentificationM68000Defined by SAS/C
Identification__MC68K__Defined by Stratus VOS C
Version__MC'V'__V = Version
Example
CPUMacro
68000__mc68000__
__MC68000__
68010__mc68010__
68020__mc68020__
__MC68020__
68030__mc68030__
__MC68030__
68040__mc68040__
68060__mc68060__

MIPS

TypeMacroDescription
Identification__mips__
mips
Defined by GNU C
Version_MIPS_ISA = _MIPS_ISA_MIPS'V'V = MIPS ISA level
Version_R3000
_R4000
_R5900
Identification__mipsDefined by MIPSpro and GNU C
Version__mipsThe value indicates the MIPS ISA (Instruction Set Architecture) level
Version__MIPS_ISA'V'__V = MIPS ISA level
Identification__MIPS__Defined by Metrowerks
Example
CPU_MIPS_ISAGNU C Macro__mipsMIPSpro Macro
R2000_MIPS_ISA_MIPS11
R3000_MIPS_ISA_MIPS1_R30001
R6000_MIPS_ISA_MIPS22__MIPS_ISA2__
R4000_R4000
R4400_MIPS_ISA_MIPS33__MIPS_ISA3__
R8000_MIPS_ISA_MIPS44__MIPS_ISA4__
R10000_MIPS_ISA_MIPS44__MIPS_ISA4__

PowerPC

TypeMacroDescription
Identification__powerpc
__powerpc__
__powerpc64__
__POWERPC__
__ppc__
__ppc64__
Defined by GNU C
Version__ppc'V'__V = Version
Identification_M_PPCDefined by Visual Studio
Version_M_PPC?
Identification_ARCH_PPC
_ARCH_PPC64
Defined by XL C/C++
Version_ARCH_'V'V = Version
Version__PPCGECKO__Gekko

Defined by CodeWarrior
Version__PPCBROADWAY__Broadway

Defined by CodeWarrior
Version_XENONXenon
Example
CPU_M_PPCMacroXL Macro
PowerPC 440_ARCH_440
PowerPC 450_ARCH_450
PowerPC 601601__ppc601___ARCH_601
PowerPC 603603__ppc603___ARCH_603
PowerPC 604604__ppc604___ARCH_604
PowerPC 620620

Pyramid 9810

TypeMacro
Identificationpyr

RS/6000

TypeMacroDescription
Identification__THW_RS6000Defined by XL C/C++
Identification_IBMR2
Identification_POWER
Identification_ARCH_PWR
_ARCH_PWR2
_ARCH_PWR3
_ARCH_PWR4

SPARC

TypeMacroDescription
Identification__sparc__Defined by GNU C
Identification__sparcDefined by Sun Studio
Version__sparcv8
__sparcv9
Defined by Sun Studio
Example
CPUMacro
SPARC v8 (SuperSPARC)__sparcv8
SPARC v9 (UltraSPARC)__sparcv9

SuperH

TypeMacroDescription
Identification__sh__Defined by GNU C
Version__sh1__
__sh2__
__sh3__
__SH3__
__SH4__
__SH5__

SystemZ

TypeMacroDescription
Identification__370__
__THW_370__
Identifies System/370

Defined by XL C/C++
Identification__s390__Identifies System/390

Defined by GNU C
Identification__s390x__Identifies z/Architecture

Defined by GNU C
Identification__zarch__Identifies z/Architecture

Defined by clang
Identification__SYSC_ZARCH__Identifies z/Architecture

Defined by Systems/C

TMS320

TypeMacroDescription
Identification_TMS320C2XX
__TMS320C2000__
C2000 series
Identification_TMS320C5X
__TMS320C55X__
C5000 series
Identification_TMS320C6X
__TMS320C6X__
C6000 series
Example
DSPMacro
C28xx_TMS320C28X
C54x_TMS320C5XX
C55x__TMS320C55X__
C6200_TMS320C6200
C6400_TMS320C6400
C6400+_TMS320C6400_PLUS
C6600_TMS320C6600
C6700_TMS320C6700
C6700+_TMS320C6700_PLUS
C6740_TMS320C6740

TMS470

TypeMacro
Identification__TMS470__