Commit 7a53aa91 by Nicolas Capens

Support building with Subzero on Mac OS.

Change-Id: I7979eb2557a6103ad10b7be3c274fadf12d27ae7 Reviewed-on: https://swiftshader-review.googlesource.com/8508Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 9ca48d5c
......@@ -627,7 +627,6 @@ set(SUBZERO_REACTOR_LIST
set(SUBZERO_INCLUDE_DIR
${SUBZERO_DIR}/
${SUBZERO_LLVM_DIR}/include/
${SUBZERO_DIR}/pnacl-llvm/include/
${SOURCE_DIR}/Reactor/SubmoduleCheck/
)
......@@ -637,7 +636,7 @@ if(WIN32)
elseif(LINUX)
list(APPEND SUBZERO_INCLUDE_DIR ${SUBZERO_LLVM_DIR}/build/Linux/include/)
elseif(APPLE)
message(SEND_ERROR "Subzero is not supported yet on Mac OS")
list(APPEND SUBZERO_INCLUDE_DIR ${SUBZERO_LLVM_DIR}/build/MacOS/include/)
endif()
add_library(ReactorSubzero STATIC
......
/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is distributed under the University of Illinois Open Source */
/* License. See LICENSE.TXT for details. */
/* */
/*===----------------------------------------------------------------------===*/
/* This file controls the C++ ABI break introduced in LLVM public header. */
#ifndef LLVM_ABI_BREAKING_CHECKS_H
#define LLVM_ABI_BREAKING_CHECKS_H
/* Define to enable checks that alter the LLVM C++ ABI */
#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0
/* Define to disable the link-time checking of mismatch for
LLVM_ENABLE_ABI_BREAKING_CHECKS */
#define LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 0
#if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
// mismatch with LLVM
#if defined(_MSC_VER)
// Use pragma with MSVC
#define LLVM_XSTR(s) LLVM_STR(s)
#define LLVM_STR(s) #s
#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
#undef LLVM_XSTR
#undef LLVM_STR
#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
// FIXME: Implement checks without weak.
#elif defined(__cplusplus)
namespace llvm {
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
extern int EnableABIBreakingChecks;
__attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks;
#else
extern int DisableABIBreakingChecks;
__attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks;
#endif
}
#endif // _MSC_VER
#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
#endif
#ifndef CONFIG_H
#define CONFIG_H
/* Exported configuration */
#include "llvm/Config/llvm-config.h"
/* Bug report URL. */
#define BUG_REPORT_URL "http://llvm.org/bugs/"
/* Define to 1 to enable backtraces, and to 0 otherwise. */
#define ENABLE_BACKTRACES 1
/* Define to 1 to enable crash overrides, and to 0 otherwise. */
#define ENABLE_CRASH_OVERRIDES 1
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE 1
/* Define to 1 if you have the <CrashReporterClient.h> header file. */
/* #undef HAVE_CRASHREPORTERCLIENT_H */
/* can use __crashreporter_info__ */
#define HAVE_CRASHREPORTER_INFO 1
/* Define to 1 if you have the declaration of `arc4random', and to 0 if you
don't. */
#define HAVE_DECL_ARC4RANDOM 1
/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
don't. */
#define HAVE_DECL_FE_ALL_EXCEPT 1
/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you
don't. */
#define HAVE_DECL_FE_INEXACT 1
/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
don't. */
#define HAVE_DECL_STRERROR_S 0
/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */
#define LLVM_ENABLE_DIA_SDK 0
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define if dlopen() is available on this platform. */
#define HAVE_DLOPEN 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <fenv.h> header file. */
#define HAVE_FENV_H 1
/* Define if libffi is available on this platform. */
/* #undef HAVE_FFI_CALL */
/* Define to 1 if you have the <ffi/ffi.h> header file. */
/* #undef HAVE_FFI_FFI_H */
/* Define to 1 if you have the <ffi.h> header file. */
/* #undef HAVE_FFI_H */
/* Define to 1 if you have the `futimens' function. */
/* #undef HAVE_FUTIMENS */
/* Define to 1 if you have the `futimes' function. */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the `getcwd' function. */
#define HAVE_GETCWD 1
/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1
/* Define to 1 if you have the `getrlimit' function. */
#define HAVE_GETRLIMIT 1
/* Define to 1 if you have the `getrusage' function. */
#define HAVE_GETRUSAGE 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if the system has the type `int64_t'. */
#define HAVE_INT64_T 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `isatty' function. */
#define HAVE_ISATTY 1
/* Define to 1 if you have the `edit' library (-ledit). */
#define HAVE_LIBEDIT 1
/* Define to 1 if you have the `psapi' library (-lpsapi). */
/* #undef HAVE_LIBPSAPI */
/* Define to 1 if you have the `pthread' library (-lpthread). */
#define HAVE_LIBPTHREAD 1
/* Define to 1 if you have the `shell32' library (-lshell32). */
/* #undef HAVE_LIBSHELL32 */
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <link.h> header file. */
/* #undef HAVE_LINK_H */
/* Define to 1 if you have the `lseek64' function. */
/* #undef HAVE_LSEEK64 */
/* Define to 1 if you have the <mach/mach.h> header file. */
#define HAVE_MACH_MACH_H 1
/* Define to 1 if you have the `mallctl' function. */
/* #undef HAVE_MALLCTL */
/* Define to 1 if you have the `mallinfo' function. */
/* #undef HAVE_MALLINFO */
/* Define to 1 if you have the <malloc.h> header file. */
/* #undef HAVE_MALLOC_H */
/* Define to 1 if you have the <malloc/malloc.h> header file. */
#define HAVE_MALLOC_MALLOC_H 1
/* Define to 1 if you have the `malloc_zone_statistics' function. */
#define HAVE_MALLOC_ZONE_STATISTICS 1
/* Define to 1 if you have the `mkdtemp' function. */
#define HAVE_MKDTEMP 1
/* Define to 1 if you have the `mkstemp' function. */
#define HAVE_MKSTEMP 1
/* Define to 1 if you have the `mktemp' function. */
#define HAVE_MKTEMP 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the `posix_fallocate' function. */
/* #undef HAVE_POSIX_FALLOCATE */
/* Define to 1 if you have the `posix_spawn' function. */
#define HAVE_POSIX_SPAWN 1
/* Define to 1 if you have the `pread' function. */
#define HAVE_PREAD 1
/* Have pthread_getspecific */
#define HAVE_PTHREAD_GETSPECIFIC 1
/* Define to 1 if you have the <pthread.h> header file. */
#define HAVE_PTHREAD_H 1
/* Have pthread_mutex_lock */
#define HAVE_PTHREAD_MUTEX_LOCK 1
/* Have pthread_rwlock_init */
#define HAVE_PTHREAD_RWLOCK_INIT 1
/* Define to 1 if you have the `realpath' function. */
#define HAVE_REALPATH 1
/* Define to 1 if you have the `sbrk' function. */
#define HAVE_SBRK 1
/* Define to 1 if you have the `setenv' function. */
#define HAVE_SETENV 1
/* Define to 1 if you have the `setrlimit' function. */
#define HAVE_SETRLIMIT 1
/* Define to 1 if you have the `sigaltstack' function. */
/* #undef HAVE_SIGALTSTACK */
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the `strerror_r' function. */
#define HAVE_STRERROR_R 1
/* Define to 1 if you have the `strtoll' function. */
#define HAVE_STRTOLL 1
/* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#define HAVE_SYS_DIR_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define if the setupterm() function is supported this platform. */
/* #undef HAVE_TERMINFO */
/* Define if the xar_open() function is supported this platform. */
#define HAVE_LIBXAR 1
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
/* Define to 1 if the system has the type `uint64_t'. */
#define HAVE_UINT64_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `u_int64_t'. */
#define HAVE_U_INT64_T 1
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
/* #undef HAVE_VALGRIND_VALGRIND_H */
/* Define to 1 if you have the `writev' function. */
#define HAVE_WRITEV 1
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
/* Have host's _alloca */
/* #undef HAVE__ALLOCA */
/* Define to 1 if you have the `_chsize_s' function. */
/* #undef HAVE__CHSIZE_S */
/* Define to 1 if you have the `_Unwind_Backtrace' function. */
#define HAVE__UNWIND_BACKTRACE 1
/* Have host's __alloca */
/* #undef HAVE___ALLOCA */
/* Have host's __ashldi3 */
/* #undef HAVE___ASHLDI3 */
/* Have host's __ashrdi3 */
/* #undef HAVE___ASHRDI3 */
/* Have host's __chkstk */
/* #undef HAVE___CHKSTK */
/* Have host's __chkstk_ms */
/* #undef HAVE___CHKSTK_MS */
/* Have host's __cmpdi2 */
/* #undef HAVE___CMPDI2 */
/* Have host's __divdi3 */
/* #undef HAVE___DIVDI3 */
/* Have host's __fixdfdi */
/* #undef HAVE___FIXDFDI */
/* Have host's __fixsfdi */
/* #undef HAVE___FIXSFDI */
/* Have host's __floatdidf */
/* #undef HAVE___FLOATDIDF */
/* Have host's __lshrdi3 */
/* #undef HAVE___LSHRDI3 */
/* Have host's __main */
/* #undef HAVE___MAIN */
/* Have host's __moddi3 */
/* #undef HAVE___MODDI3 */
/* Have host's __udivdi3 */
/* #undef HAVE___UDIVDI3 */
/* Have host's __umoddi3 */
/* #undef HAVE___UMODDI3 */
/* Have host's ___chkstk */
/* #undef HAVE____CHKSTK */
/* Have host's ___chkstk_ms */
/* #undef HAVE____CHKSTK_MS */
/* Linker version detected at compile time. */
/* #undef HOST_LINK_VERSION */
/* Define if we link Polly to the tools */
/* #undef LINK_POLLY_INTO_TOOLS */
/* Target triple LLVM will generate code for by default */
/* Doesn't use `cmakedefine` because it is allowed to be empty. */
#define LLVM_DEFAULT_TARGET_TRIPLE "x86_64-apple-darwin16.3.0"
/* Define if threads enabled */
#define LLVM_ENABLE_THREADS 1
/* Define if zlib compression is available */
#define LLVM_ENABLE_ZLIB 1
/* Has gcc/MSVC atomic intrinsics */
#define LLVM_HAS_ATOMICS 1
/* Host triple LLVM will be executed on */
#define LLVM_HOST_TRIPLE "x86_64-apple-darwin16.3.0"
/* LLVM architecture name for the native architecture, if available */
#define LLVM_NATIVE_ARCH X86
/* LLVM name for the native AsmParser init function, if available */
#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser
/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
/* LLVM name for the native Disassembler init function, if available */
#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeX86Disassembler
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
/* LLVM name for the native TargetInfo init function, if available */
#define LLVM_NATIVE_TARGETINFO LLVMInitializeX86TargetInfo
/* LLVM name for the native target MC init function, if available */
#define LLVM_NATIVE_TARGETMC LLVMInitializeX86TargetMC
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
/* Define if this is Win32ish platform */
/* #undef LLVM_ON_WIN32 */
/* Installation prefix directory */
#define LLVM_PREFIX "/usr/local"
/* Define if we have the Intel JIT API runtime support library */
#define LLVM_USE_INTEL_JITEVENTS 0
/* Define if we have the oprofile JIT-support library */
#define LLVM_USE_OPROFILE 0
/* LLVM version information */
/* #undef LLVM_VERSION_INFO */
/* Major version of the LLVM API */
#define LLVM_VERSION_MAJOR 5
/* Minor version of the LLVM API */
#define LLVM_VERSION_MINOR 0
/* Patch version of the LLVM API */
#define LLVM_VERSION_PATCH 0
/* LLVM version string */
#define LLVM_VERSION_STRING "5.0.0svn"
/* Define to the extension used for shared libraries, say, ".so". */
#define LTDL_SHLIB_EXT ".dylib"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "http://llvm.org/bugs/"
/* Define to the full name of this package. */
#define PACKAGE_NAME "LLVM"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "LLVM 5.0.0svn"
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#define PACKAGE_VERSION "5.0.0svn"
/* Define to the vendor of this package. */
/* #undef PACKAGE_VENDOR */
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to a function replacing strtoll */
/* #undef strtoll */
/* Define to a function implementing strtoull */
/* #undef strtoull */
/* Define to a function implementing stricmp */
/* #undef stricmp */
/* Define to a function implementing strdup */
/* #undef strdup */
#endif
/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is distributed under the University of Illinois Open Source */
/* License. See LICENSE.TXT for details. */
/* */
/*===----------------------------------------------------------------------===*/
/* This file enumerates variables from the LLVM configuration so that they
can be in exported headers and won't override package specific directives.
This is a C header that can be included in the llvm-c headers. */
#ifndef LLVM_CONFIG_H
#define LLVM_CONFIG_H
/* Define if we link Polly to the tools */
/* #undef LINK_POLLY_INTO_TOOLS */
/* Target triple LLVM will generate code for by default */
#define LLVM_DEFAULT_TARGET_TRIPLE "x86_64-apple-darwin16.3.0"
/* Define if threads enabled */
#define LLVM_ENABLE_THREADS 1
/* Has gcc/MSVC atomic intrinsics */
#define LLVM_HAS_ATOMICS 1
/* Host triple LLVM will be executed on */
#define LLVM_HOST_TRIPLE "x86_64-apple-darwin16.3.0"
/* LLVM architecture name for the native architecture, if available */
#define LLVM_NATIVE_ARCH X86
/* LLVM name for the native AsmParser init function, if available */
#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser
/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
/* LLVM name for the native Disassembler init function, if available */
#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeX86Disassembler
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
/* LLVM name for the native TargetInfo init function, if available */
#define LLVM_NATIVE_TARGETINFO LLVMInitializeX86TargetInfo
/* LLVM name for the native target MC init function, if available */
#define LLVM_NATIVE_TARGETMC LLVMInitializeX86TargetMC
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
/* Define if this is Win32ish platform */
/* #undef LLVM_ON_WIN32 */
/* Installation prefix directory */
#define LLVM_PREFIX "/usr/local"
/* Define if we have the Intel JIT API runtime support library */
#define LLVM_USE_INTEL_JITEVENTS 0
/* Define if we have the oprofile JIT-support library */
#define LLVM_USE_OPROFILE 0
/* Major version of the LLVM API */
#define LLVM_VERSION_MAJOR 5
/* Minor version of the LLVM API */
#define LLVM_VERSION_MINOR 0
/* Patch version of the LLVM API */
#define LLVM_VERSION_PATCH 0
/* LLVM version string */
#define LLVM_VERSION_STRING "5.0.0svn"
#endif
#ifdef GET_ATTR_ENUM
#undef GET_ATTR_ENUM
Alignment,
AllocSize,
AlwaysInline,
ArgMemOnly,
Builtin,
ByVal,
Cold,
Convergent,
Dereferenceable,
DereferenceableOrNull,
InAlloca,
InReg,
InaccessibleMemOnly,
InaccessibleMemOrArgMemOnly,
InlineHint,
JumpTable,
MinSize,
Naked,
Nest,
NoAlias,
NoBuiltin,
NoCapture,
NoDuplicate,
NoImplicitFloat,
NoInline,
NoRecurse,
NoRedZone,
NoReturn,
NoUnwind,
NonLazyBind,
NonNull,
OptimizeForSize,
OptimizeNone,
ReadNone,
ReadOnly,
Returned,
ReturnsTwice,
SExt,
SafeStack,
SanitizeAddress,
SanitizeMemory,
SanitizeThread,
StackAlignment,
StackProtect,
StackProtectReq,
StackProtectStrong,
StructRet,
SwiftError,
SwiftSelf,
UWTable,
WriteOnly,
ZExt,
#endif
#ifdef GET_ATTR_KIND_FROM_NAME
#undef GET_ATTR_KIND_FROM_NAME
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName) {
return StringSwitch<Attribute::AttrKind>(AttrName)
.Case("align", Attribute::Alignment)
.Case("allocsize", Attribute::AllocSize)
.Case("alwaysinline", Attribute::AlwaysInline)
.Case("argmemonly", Attribute::ArgMemOnly)
.Case("builtin", Attribute::Builtin)
.Case("byval", Attribute::ByVal)
.Case("cold", Attribute::Cold)
.Case("convergent", Attribute::Convergent)
.Case("dereferenceable", Attribute::Dereferenceable)
.Case("dereferenceable_or_null", Attribute::DereferenceableOrNull)
.Case("inalloca", Attribute::InAlloca)
.Case("inreg", Attribute::InReg)
.Case("inaccessiblememonly", Attribute::InaccessibleMemOnly)
.Case("inaccessiblemem_or_argmemonly", Attribute::InaccessibleMemOrArgMemOnly)
.Case("inlinehint", Attribute::InlineHint)
.Case("jumptable", Attribute::JumpTable)
.Case("minsize", Attribute::MinSize)
.Case("naked", Attribute::Naked)
.Case("nest", Attribute::Nest)
.Case("noalias", Attribute::NoAlias)
.Case("nobuiltin", Attribute::NoBuiltin)
.Case("nocapture", Attribute::NoCapture)
.Case("noduplicate", Attribute::NoDuplicate)
.Case("noimplicitfloat", Attribute::NoImplicitFloat)
.Case("noinline", Attribute::NoInline)
.Case("norecurse", Attribute::NoRecurse)
.Case("noredzone", Attribute::NoRedZone)
.Case("noreturn", Attribute::NoReturn)
.Case("nounwind", Attribute::NoUnwind)
.Case("nonlazybind", Attribute::NonLazyBind)
.Case("nonnull", Attribute::NonNull)
.Case("optsize", Attribute::OptimizeForSize)
.Case("optnone", Attribute::OptimizeNone)
.Case("readnone", Attribute::ReadNone)
.Case("readonly", Attribute::ReadOnly)
.Case("returned", Attribute::Returned)
.Case("returns_twice", Attribute::ReturnsTwice)
.Case("signext", Attribute::SExt)
.Case("safestack", Attribute::SafeStack)
.Case("sanitize_address", Attribute::SanitizeAddress)
.Case("sanitize_memory", Attribute::SanitizeMemory)
.Case("sanitize_thread", Attribute::SanitizeThread)
.Case("alignstack", Attribute::StackAlignment)
.Case("ssp", Attribute::StackProtect)
.Case("sspreq", Attribute::StackProtectReq)
.Case("sspstrong", Attribute::StackProtectStrong)
.Case("sret", Attribute::StructRet)
.Case("swifterror", Attribute::SwiftError)
.Case("swiftself", Attribute::SwiftSelf)
.Case("uwtable", Attribute::UWTable)
.Case("writeonly", Attribute::WriteOnly)
.Case("zeroext", Attribute::ZExt)
.Default(Attribute::None);
}
#endif
#ifdef GET_ATTR_COMPAT_FUNC
#undef GET_ATTR_COMPAT_FUNC
struct EnumAttr {
static bool isSet(const Function &Fn,
Attribute::AttrKind Kind) {
return Fn.hasFnAttribute(Kind);
}
static void set(Function &Fn,
Attribute::AttrKind Kind, bool Val) {
if (Val)
Fn.addFnAttr(Kind);
else
Fn.removeFnAttr(Kind);
}
};
struct StrBoolAttr {
static bool isSet(const Function &Fn,
StringRef Kind) {
auto A = Fn.getFnAttribute(Kind);
return A.getValueAsString().equals("true");
}
static void set(Function &Fn,
StringRef Kind, bool Val) {
Fn.addFnAttr(Kind, Val ? "true" : "false");
}
};
// EnumAttr classes
struct AlignmentAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Alignment;
}
};
struct AllocSizeAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::AllocSize;
}
};
struct AlwaysInlineAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::AlwaysInline;
}
};
struct ArgMemOnlyAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ArgMemOnly;
}
};
struct BuiltinAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Builtin;
}
};
struct ByValAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ByVal;
}
};
struct ColdAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Cold;
}
};
struct ConvergentAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Convergent;
}
};
struct DereferenceableAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Dereferenceable;
}
};
struct DereferenceableOrNullAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::DereferenceableOrNull;
}
};
struct InAllocaAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::InAlloca;
}
};
struct InRegAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::InReg;
}
};
struct InaccessibleMemOnlyAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::InaccessibleMemOnly;
}
};
struct InaccessibleMemOrArgMemOnlyAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::InaccessibleMemOrArgMemOnly;
}
};
struct InlineHintAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::InlineHint;
}
};
struct JumpTableAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::JumpTable;
}
};
struct MinSizeAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::MinSize;
}
};
struct NakedAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Naked;
}
};
struct NestAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Nest;
}
};
struct NoAliasAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoAlias;
}
};
struct NoBuiltinAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoBuiltin;
}
};
struct NoCaptureAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoCapture;
}
};
struct NoDuplicateAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoDuplicate;
}
};
struct NoImplicitFloatAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoImplicitFloat;
}
};
struct NoInlineAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoInline;
}
};
struct NoRecurseAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoRecurse;
}
};
struct NoRedZoneAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoRedZone;
}
};
struct NoReturnAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoReturn;
}
};
struct NoUnwindAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NoUnwind;
}
};
struct NonLazyBindAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NonLazyBind;
}
};
struct NonNullAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::NonNull;
}
};
struct OptimizeForSizeAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::OptimizeForSize;
}
};
struct OptimizeNoneAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::OptimizeNone;
}
};
struct ReadNoneAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ReadNone;
}
};
struct ReadOnlyAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ReadOnly;
}
};
struct ReturnedAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::Returned;
}
};
struct ReturnsTwiceAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ReturnsTwice;
}
};
struct SExtAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SExt;
}
};
struct SafeStackAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SafeStack;
}
};
struct SanitizeAddressAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SanitizeAddress;
}
};
struct SanitizeMemoryAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SanitizeMemory;
}
};
struct SanitizeThreadAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SanitizeThread;
}
};
struct StackAlignmentAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::StackAlignment;
}
};
struct StackProtectAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::StackProtect;
}
};
struct StackProtectReqAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::StackProtectReq;
}
};
struct StackProtectStrongAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::StackProtectStrong;
}
};
struct StructRetAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::StructRet;
}
};
struct SwiftErrorAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SwiftError;
}
};
struct SwiftSelfAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::SwiftSelf;
}
};
struct UWTableAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::UWTable;
}
};
struct WriteOnlyAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::WriteOnly;
}
};
struct ZExtAttr : EnumAttr {
static enum Attribute::AttrKind getKind() {
return llvm::Attribute::ZExt;
}
};
// StrBoolAttr classes
struct LessPreciseFPMADAttr : StrBoolAttr {
static StringRef getKind() {
return "less-precise-fpmad";
}
};
struct NoInfsFPMathAttr : StrBoolAttr {
static StringRef getKind() {
return "no-infs-fp-math";
}
};
struct NoJumpTablesAttr : StrBoolAttr {
static StringRef getKind() {
return "no-jump-tables";
}
};
struct NoNansFPMathAttr : StrBoolAttr {
static StringRef getKind() {
return "no-nans-fp-math";
}
};
struct UnsafeFPMathAttr : StrBoolAttr {
static StringRef getKind() {
return "unsafe-fp-math";
}
};
static inline bool hasCompatibleFnAttrs(const Function &Caller,
const Function &Callee) {
bool Ret = true;
Ret &= isEqual<SanitizeAddressAttr>(Caller, Callee);
Ret &= isEqual<SanitizeThreadAttr>(Caller, Callee);
Ret &= isEqual<SanitizeMemoryAttr>(Caller, Callee);
Ret &= isEqual<SafeStackAttr>(Caller, Callee);
return Ret;
}
static inline void mergeFnAttrs(Function &Caller,
const Function &Callee) {
adjustCallerSSPLevel(Caller, Callee);
setAND<LessPreciseFPMADAttr>(Caller, Callee);
setAND<NoInfsFPMathAttr>(Caller, Callee);
setAND<NoNansFPMathAttr>(Caller, Callee);
setAND<UnsafeFPMathAttr>(Caller, Callee);
setOR<NoImplicitFloatAttr>(Caller, Callee);
setOR<NoJumpTablesAttr>(Caller, Callee);
}
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*===-- include/Support/DataTypes.h - Define fixed size types -----*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This file contains definitions to figure out the size of _HOST_ data types.*|
|* This file is important because different host OS's define different macros,*|
|* which makes portability tough. This file exports the following *|
|* definitions: *|
|* *|
|* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*|
|* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *|
|* *|
|* No library is required when using these functions. *|
|* *|
|*===----------------------------------------------------------------------===*/
/* Please leave this file C-compatible. */
#ifndef SUPPORT_DATATYPES_H
#define SUPPORT_DATATYPES_H
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UINT64_T 1
#define HAVE_U_INT64_T 1
#ifdef __cplusplus
#include <cmath>
#else
#include <math.h>
#endif
#ifdef __cplusplus
#include <cinttypes>
#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#endif
#ifdef __cplusplus
#include <cstdint>
#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#error "Compiler must provide an implementation of stdint.h"
#endif
#endif
#ifndef _MSC_VER
#if !defined(UINT32_MAX)
# error "The standard header <cstdint> is not C++11 compliant. Must #define "\
"__STDC_LIMIT_MACROS before #including Support/DataTypes.h"
#endif
#if !defined(UINT32_C)
# error "The standard header <cstdint> is not C++11 compliant. Must #define "\
"__STDC_CONSTANT_MACROS before #including Support/DataTypes.h"
#endif
/* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
#include <sys/types.h>
#ifdef _AIX
// GCC is strict about defining large constants: they must have LL modifier.
#undef INT64_MAX
#undef INT64_MIN
#endif
/* Handle incorrect definition of uint64_t as u_int64_t */
#ifndef HAVE_UINT64_T
#ifdef HAVE_U_INT64_T
typedef u_int64_t uint64_t;
#else
# error "Don't have a definition for uint64_t on this platform"
#endif
#endif
#else /* _MSC_VER */
#ifdef __cplusplus
#include <cstdlib>
#include <cstddef>
#else
#include <stdlib.h>
#include <stddef.h>
#endif
#include <sys/types.h>
#if defined(_WIN64)
typedef signed __int64 ssize_t;
#else
typedef signed int ssize_t;
#endif /* _WIN64 */
#ifndef HAVE_INTTYPES_H
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRId32 "d"
#define PRIi32 "i"
#define PRIo32 "o"
#define PRIu32 "u"
#define PRIx32 "x"
#define PRIX32 "X"
#endif /* HAVE_INTTYPES_H */
#endif /* _MSC_VER */
/* Set defaults for constants which we cannot find. */
#if !defined(INT64_MAX)
# define INT64_MAX 9223372036854775807LL
#endif
#if !defined(INT64_MIN)
# define INT64_MIN ((-INT64_MAX)-1)
#endif
#if !defined(UINT64_MAX)
# define UINT64_MAX 0xffffffffffffffffULL
#endif
#ifndef HUGE_VALF
#define HUGE_VALF (float)HUGE_VAL
#endif
#endif /* SUPPORT_DATATYPES_H */
//===----- lib/Support/Error.cpp - Error and associated utilities ---------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Error.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include <system_error>
using namespace llvm;
namespace {
enum class ErrorErrorCode : int {
MultipleErrors = 1,
InconvertibleError
};
// FIXME: This class is only here to support the transition to llvm::Error. It
// will be removed once this transition is complete. Clients should prefer to
// deal with the Error value directly, rather than converting to error_code.
class ErrorErrorCategory : public std::error_category {
public:
const char *name() const noexcept override { return "Error"; }
std::string message(int condition) const override {
switch (static_cast<ErrorErrorCode>(condition)) {
case ErrorErrorCode::MultipleErrors:
return "Multiple errors";
case ErrorErrorCode::InconvertibleError:
return "Inconvertible error value. An error has occurred that could "
"not be converted to a known std::error_code. Please file a "
"bug.";
}
llvm_unreachable("Unhandled error code");
}
};
}
static ManagedStatic<ErrorErrorCategory> ErrorErrorCat;
namespace llvm {
void ErrorInfoBase::anchor() {}
char ErrorInfoBase::ID = 0;
char ErrorList::ID = 0;
char ECError::ID = 0;
char StringError::ID = 0;
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) {
if (!E)
return;
OS << ErrorBanner;
handleAllErrors(std::move(E), [&](const ErrorInfoBase &EI) {
EI.log(OS);
OS << "\n";
});
}
std::error_code ErrorList::convertToErrorCode() const {
return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
*ErrorErrorCat);
}
std::error_code inconvertibleErrorCode() {
return std::error_code(static_cast<int>(ErrorErrorCode::InconvertibleError),
*ErrorErrorCat);
}
Error errorCodeToError(std::error_code EC) {
if (!EC)
return Error::success();
return Error(llvm::make_unique<ECError>(ECError(EC)));
}
std::error_code errorToErrorCode(Error Err) {
std::error_code EC;
handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
EC = EI.convertToErrorCode();
});
if (EC == inconvertibleErrorCode())
report_fatal_error(EC.message());
return EC;
}
StringError::StringError(const Twine &S, std::error_code EC)
: Msg(S.str()), EC(EC) {}
void StringError::log(raw_ostream &OS) const { OS << Msg; }
std::error_code StringError::convertToErrorCode() const {
return EC;
}
void report_fatal_error(Error Err, bool GenCrashDiag) {
assert(Err && "report_fatal_error called with success value");
std::string ErrMsg;
{
raw_string_ostream ErrStream(ErrMsg);
logAllUnhandledErrors(std::move(Err), ErrStream, "");
}
report_fatal_error(ErrMsg);
}
}
#ifndef _MSC_VER
namespace llvm {
// One of these two variables will be referenced by a symbol defined in
// llvm-config.h. We provide a link-time (or load time for DSO) failure when
// there is a mismatch in the build configuration of the API client and LLVM.
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
int EnableABIBreakingChecks;
#else
int DisableABIBreakingChecks;
#endif
} // end namespace llvm
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment