Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc] Add compiler, builtin and feature detection
This is a first step to support GCC. This patch adds support for builtin and feature detection. Differential Revision: https://reviews.llvm.org/D139712
- Loading branch information
Showing
13 changed files
with
104 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ add_header_library( | |
bit | ||
HDRS | ||
bit.h | ||
DEPENDS | ||
libc.src.__support.compiler_features | ||
) | ||
|
||
add_header_library( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===-- Compile time compiler detection -------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SUPPORT_COMPILER_FEATURES_H | ||
#define LLVM_LIBC_SUPPORT_COMPILER_FEATURES_H | ||
|
||
#if defined(__clang__) | ||
#define LLVM_LIBC_COMPILER_CLANG | ||
#endif | ||
|
||
#if defined(__GNUC__) && !defined(__clang__) | ||
#define LLVM_LIBC_COMPILER_GCC | ||
#endif | ||
|
||
#if defined(_MSC_VER) | ||
#define LLVM_LIBC_COMPILER_MSC | ||
#endif | ||
|
||
// Compiler builtin-detection. | ||
// clang.llvm.org/docs/LanguageExtensions.html#has-builtin | ||
#if defined(LLVM_LIBC_COMPILER_CLANG) || \ | ||
(defined(LLVM_LIBC_COMPILER_GCC) && (__GNUC__ >= 10)) | ||
#define LLVM_LIBC_HAS_BUILTIN(BUILTIN) __has_builtin(BUILTIN) | ||
#else | ||
#define LLVM_LIBC_HAS_BUILTIN(BUILTIN) 0 | ||
#endif | ||
|
||
// Compiler feature-detection. | ||
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension | ||
#if defined(LLVM_LIBC_COMPILER_CLANG) | ||
#define LLVM_LIBC_HAS_FEATURE(FEATURE) __has_feature(FEATURE) | ||
#else | ||
#define LLVM_LIBC_HAS_FEATURE(FEATURE) 0 | ||
#endif | ||
|
||
#endif // LLVM_LIBC_SUPPORT_COMPILER_FEATURES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters