[PATCH] D75002: [AArch64] Predefine __AARCH64_CMODEL_*__ as GCC does
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 21 23:28:25 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2e949eed5b4: [AArch64] Predefine __AARCH64_CMODEL_*__ as GCC does (authored by mcgrathr, committed by MaskRay).
Changed prior to commit:
https://reviews.llvm.org/D75002?vs=246060&id=246061#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75002/new/
https://reviews.llvm.org/D75002
Files:
clang/lib/Basic/Targets/AArch64.cpp
clang/test/Preprocessor/init-aarch64.c
Index: clang/test/Preprocessor/init-aarch64.c
===================================================================
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -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
Index: clang/lib/Basic/Targets/AArch64.cpp
===================================================================
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -194,6 +194,13 @@
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");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75002.246061.patch
Type: text/x-patch
Size: 1953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200222/9e833db0/attachment.bin>
More information about the cfe-commits
mailing list