[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:01 PST 2020


MaskRay updated this revision to Diff 246060.
MaskRay added a comment.

Add tests

Rebase after -mcmodel cleanups (including fc6057e34fb3b1cfbbfcd5d71ae25ba24eb3ffa3 <https://reviews.llvm.org/rGfc6057e34fb3b1cfbbfcd5d71ae25ba24eb3ffa3>)


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 -E -dM -triple=aarch64 -mcmodel=small -xc /dev/null | FileCheck --check-prefix=CMODEL_SMALL %s
+// RUN: %clang_cc1 -E -dM -triple=aarch64 -mcmodel=tiny -xc /dev/null | FileCheck --check-prefix=CMODEL_TINY %s
+// RUN: %clang_cc1 -E -dM -triple=aarch64 -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.246060.patch
Type: text/x-patch
Size: 1953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200222/736bff44/attachment.bin>


More information about the cfe-commits mailing list