forked from OSchip/llvm-project
[AArch64] Predefine __AARCH64_CMODEL_*__ as GCC does
Make Clang on aarch64 targets predefine `__AARCH64_CMODEL_SMALL__` or `__AARCH64_CMODEL_TINY__`, etc. These are the names that GCC uses for its predefines. Reviewed By: tamur, MaskRay Differential Revision: https://reviews.llvm.org/D75002
This commit is contained in:
parent
fc6057e34f
commit
d2e949eed5
|
@ -194,6 +194,13 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
|
|||
Builder.defineMacro("__LP64__");
|
||||
}
|
||||
|
||||
std::string CodeModel = getTargetOpts().CodeModel;
|
||||
if (CodeModel == "default")
|
||||
CodeModel = "small";
|
||||
for (char &c : CodeModel)
|
||||
c = toupper(c);
|
||||
Builder.defineMacro("__AARCH64_CMODEL_" + CodeModel + "__");
|
||||
|
||||
// ACLE predefines. Many can only have one possible value on v8 AArch64.
|
||||
Builder.defineMacro("__ARM_ACLE", "200");
|
||||
Builder.defineMacro("__ARM_ARCH", "8");
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
// AARCH64: #define _LP64 1
|
||||
// AARCH64_BE-NEXT: #define __AARCH64EB__ 1
|
||||
// AARCH64_BE-NEXT: #define __AARCH64_CMODEL_SMALL__ 1
|
||||
// AARCH64_BE-NEXT: #define __AARCH_BIG_ENDIAN 1
|
||||
// AARCH64_LE-NEXT: #define __AARCH64EL__ 1
|
||||
// AARCH64_LE-NEXT: #define __AARCH64_CMODEL_SMALL__ 1
|
||||
// AARCH64-NEXT: #define __ARM_64BIT_STATE 1
|
||||
// AARCH64-NEXT: #define __ARM_ACLE 200
|
||||
// AARCH64-NEXT: #define __ARM_ALIGN_MAX_STACK_PWR 4
|
||||
|
@ -689,3 +691,11 @@
|
|||
// AARCH64-MSVC: #define __WINT_TYPE__ unsigned short
|
||||
// AARCH64-MSVC: #define __WINT_WIDTH__ 16
|
||||
// AARCH64-MSVC: #define __aarch64__ 1
|
||||
|
||||
// RUN: %clang_cc1 -triple=aarch64 -E -dM -mcmodel=small -xc /dev/null | FileCheck --check-prefix=CMODEL_SMALL %s
|
||||
// RUN: %clang_cc1 -triple=aarch64 -E -dM -mcmodel=tiny -xc /dev/null | FileCheck --check-prefix=CMODEL_TINY %s
|
||||
// RUN: %clang_cc1 -triple=aarch64 -E -dM -mcmodel=large -xc /dev/null | FileCheck --check-prefix=CMODEL_LARGE %s
|
||||
|
||||
// CMODEL_TINY: #define __AARCH64_CMODEL_TINY__ 1
|
||||
// CMODEL_SMALL: #define __AARCH64_CMODEL_SMALL__ 1
|
||||
// CMODEL_LARGE: #define __AARCH64_CMODEL_LARGE__ 1
|
||||
|
|
Loading…
Reference in New Issue