freebsd-dev/contrib/llvm/patches/patch-16-clang-r221900-freebsd-aarch64.diff

252 lines
13 KiB
Diff
Raw Normal View History

Pull in r221900 from upstream clang trunk (by Ed Maste):
Hook up FreeBSD AArch64 support
Patch from Andrew Turner.
Introduced here: http://svnweb.freebsd.org/changeset/base/275154
Index: tools/clang/test/Driver/freebsd.c
===================================================================
--- tools/clang/test/Driver/freebsd.c
+++ tools/clang/test/Driver/freebsd.c
@@ -1,4 +1,12 @@
// RUN: %clang -no-canonical-prefixes \
+// RUN: -target aarch64-pc-freebsd11 %s \
+// RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ARM64 %s
+// CHECK-ARM64: "-cc1" "-triple" "aarch64-pc-freebsd11"
+// CHECK-ARM64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ARM64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
+// RUN: %clang -no-canonical-prefixes \
// RUN: -target powerpc-pc-freebsd8 %s \
// RUN: --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-PPC %s
Index: tools/clang/test/Preprocessor/init.c
===================================================================
--- tools/clang/test/Preprocessor/init.c
+++ tools/clang/test/Preprocessor/init.c
@@ -802,6 +802,199 @@
// AARCH64-NETBSD:#define __WINT_TYPE__ int
// AARCH64-NETBSD:#define __WINT_WIDTH__ 32
// AARCH64-NETBSD:#define __aarch64__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-freebsd11 < /dev/null | FileCheck -check-prefix AARCH64-FREEBSD %s
+//
+// AARCH64-FREEBSD:#define _LP64 1
+// AARCH64-FREEBSD-NOT:#define __AARCH64EB__ 1
+// AARCH64-FREEBSD:#define __AARCH64EL__ 1
+// AARCH64-FREEBSD-NOT:#define __AARCH_BIG_ENDIAN 1
+// AARCH64-FREEBSD:#define __ARM_64BIT_STATE 1
+// AARCH64-FREEBSD:#define __ARM_ARCH 8
+// AARCH64-FREEBSD:#define __ARM_ARCH_ISA_A64 1
+// AARCH64-FREEBSD-NOT:#define __ARM_BIG_ENDIAN 1
+// AARCH64-FREEBSD:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-FREEBSD:#define __CHAR16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __CHAR32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __CHAR_BIT__ 8
+// AARCH64-FREEBSD:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-FREEBSD:#define __DBL_DIG__ 15
+// AARCH64-FREEBSD:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-FREEBSD:#define __DBL_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __DBL_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __DBL_MANT_DIG__ 53
+// AARCH64-FREEBSD:#define __DBL_MAX_10_EXP__ 308
+// AARCH64-FREEBSD:#define __DBL_MAX_EXP__ 1024
+// AARCH64-FREEBSD:#define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-FREEBSD:#define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-FREEBSD:#define __DBL_MIN_EXP__ (-1021)
+// AARCH64-FREEBSD:#define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-FREEBSD:#define __DECIMAL_DIG__ 36
+// AARCH64-FREEBSD:#define __ELF__ 1
+// AARCH64-FREEBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-FREEBSD:#define __FLT_DIG__ 6
+// AARCH64-FREEBSD:#define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-FREEBSD:#define __FLT_EVAL_METHOD__ 0
+// AARCH64-FREEBSD:#define __FLT_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __FLT_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __FLT_MANT_DIG__ 24
+// AARCH64-FREEBSD:#define __FLT_MAX_10_EXP__ 38
+// AARCH64-FREEBSD:#define __FLT_MAX_EXP__ 128
+// AARCH64-FREEBSD:#define __FLT_MAX__ 3.40282347e+38F
+// AARCH64-FREEBSD:#define __FLT_MIN_10_EXP__ (-37)
+// AARCH64-FREEBSD:#define __FLT_MIN_EXP__ (-125)
+// AARCH64-FREEBSD:#define __FLT_MIN__ 1.17549435e-38F
+// AARCH64-FREEBSD:#define __FLT_RADIX__ 2
+// AARCH64-FREEBSD:#define __FreeBSD__ 11
+// AARCH64-FREEBSD:#define __INT16_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT32_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT64_C_SUFFIX__ L
+// AARCH64-FREEBSD:#define __INT64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT8_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INTMAX_C_SUFFIX__ L
+// AARCH64-FREEBSD:#define __INTMAX_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INTMAX_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INTMAX_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INTMAX_TYPE__ long int
+// AARCH64-FREEBSD:#define __INTMAX_WIDTH__ 64
+// AARCH64-FREEBSD:#define __INTPTR_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INTPTR_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INTPTR_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INTPTR_TYPE__ long int
+// AARCH64-FREEBSD:#define __INTPTR_WIDTH__ 64
+// AARCH64-FREEBSD:#define __INT_FAST16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT_FAST16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT_FAST16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT_FAST16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT_FAST32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT_FAST32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT_FAST32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT_FAST32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT_FAST64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT_FAST64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT_FAST64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT_FAST64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT_FAST8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT_FAST8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT_FAST8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT_FAST8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INT_LEAST16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT_LEAST16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT_LEAST16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT_LEAST16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT_LEAST32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT_LEAST32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT_LEAST32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT_LEAST32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT_LEAST64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT_LEAST64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT_LEAST64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT_LEAST64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT_LEAST8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT_LEAST8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT_LEAST8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INT_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// AARCH64-FREEBSD:#define __LDBL_DIG__ 33
+// AARCH64-FREEBSD:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// AARCH64-FREEBSD:#define __LDBL_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __LDBL_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __LDBL_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __LDBL_MANT_DIG__ 113
+// AARCH64-FREEBSD:#define __LDBL_MAX_10_EXP__ 4932
+// AARCH64-FREEBSD:#define __LDBL_MAX_EXP__ 16384
+// AARCH64-FREEBSD:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// AARCH64-FREEBSD:#define __LDBL_MIN_10_EXP__ (-4931)
+// AARCH64-FREEBSD:#define __LDBL_MIN_EXP__ (-16381)
+// AARCH64-FREEBSD:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// AARCH64-FREEBSD:#define __LITTLE_ENDIAN__ 1
+// AARCH64-FREEBSD:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// AARCH64-FREEBSD:#define __LONG_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __LP64__ 1
+// AARCH64-FREEBSD:#define __POINTER_WIDTH__ 64
+// AARCH64-FREEBSD:#define __PTRDIFF_TYPE__ long int
+// AARCH64-FREEBSD:#define __PTRDIFF_WIDTH__ 64
+// AARCH64-FREEBSD:#define __SCHAR_MAX__ 127
+// AARCH64-FREEBSD:#define __SHRT_MAX__ 32767
+// AARCH64-FREEBSD:#define __SIG_ATOMIC_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __SIG_ATOMIC_WIDTH__ 32
+// AARCH64-FREEBSD:#define __SIZEOF_DOUBLE__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_FLOAT__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_INT128__ 16
+// AARCH64-FREEBSD:#define __SIZEOF_INT__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_LONG_DOUBLE__ 16
+// AARCH64-FREEBSD:#define __SIZEOF_LONG_LONG__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_LONG__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_POINTER__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_PTRDIFF_T__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_SHORT__ 2
+// AARCH64-FREEBSD:#define __SIZEOF_SIZE_T__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_WCHAR_T__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_WINT_T__ 4
+// AARCH64-FREEBSD:#define __SIZE_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __SIZE_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __SIZE_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __UINT16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT32_C_SUFFIX__ U
+// AARCH64-FREEBSD:#define __UINT32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT64_C_SUFFIX__ UL
+// AARCH64-FREEBSD:#define __UINT64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __UINT8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __UINTMAX_C_SUFFIX__ UL
+// AARCH64-FREEBSD:#define __UINTMAX_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINTMAX_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINTMAX_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINTPTR_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINTPTR_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINTPTR_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINT_FAST16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT_FAST16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT_FAST32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT_FAST32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT_FAST64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT_FAST64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT_FAST8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT_FAST8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __UINT_LEAST16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT_LEAST16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT_LEAST32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT_LEAST32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT_LEAST64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT_LEAST8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT_LEAST8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __USER_LABEL_PREFIX__
+// AARCH64-FREEBSD:#define __WCHAR_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __WCHAR_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __WCHAR_UNSIGNED__ 1
+// AARCH64-FREEBSD:#define __WCHAR_WIDTH__ 32
+// AARCH64-FREEBSD:#define __WINT_TYPE__ int
+// AARCH64-FREEBSD:#define __WINT_WIDTH__ 32
+// AARCH64-FREEBSD:#define __aarch64__ 1
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s
//
Index: tools/clang/lib/Basic/Targets.cpp
===================================================================
--- tools/clang/lib/Basic/Targets.cpp
+++ tools/clang/lib/Basic/Targets.cpp
@@ -6036,6 +6036,8 @@ static TargetInfo *AllocateTarget(const llvm::Trip
return new DarwinAArch64TargetInfo(Triple);
switch (os) {
+ case llvm::Triple::FreeBSD:
+ return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple);
case llvm::Triple::NetBSD:
@@ -6047,6 +6049,8 @@ static TargetInfo *AllocateTarget(const llvm::Trip
case llvm::Triple::aarch64_be:
case llvm::Triple::arm64_be:
switch (os) {
+ case llvm::Triple::FreeBSD:
+ return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple);
case llvm::Triple::NetBSD: