mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-11 10:31:40 +00:00
Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config, include/llvm/ADT and include/llvm/Support. From here on out, all LLVM public header files must be under include/llvm/. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ed543731fb
commit
551ccae044
@ -8,7 +8,7 @@ dnl Quit if the source directory has already been configured.
|
||||
dnl NOTE: This relies upon undocumented autoconf behavior.
|
||||
if test ${srcdir} != "."
|
||||
then
|
||||
if test -f ${srcdir}/include/Config/config.h
|
||||
if test -f ${srcdir}/include/llvm/Config/config.h
|
||||
then
|
||||
AC_MSG_ERROR([Already configured in ${srcdir}])
|
||||
fi
|
||||
@ -27,15 +27,15 @@ do
|
||||
done
|
||||
|
||||
dnl Configure header files
|
||||
AC_CONFIG_HEADERS(include/Config/config.h)
|
||||
AC_CONFIG_HEADERS(include/llvm/Config/config.h)
|
||||
|
||||
dnl Configure other output file
|
||||
AC_CONFIG_FILES(Makefile.config
|
||||
include/Support/DataTypes.h
|
||||
include/Support/ThreadSupport.h
|
||||
include/Support/hash_map
|
||||
include/Support/hash_set
|
||||
include/Support/iterator)
|
||||
include/llvm/Support/DataTypes.h
|
||||
include/llvm/Support/ThreadSupport.h
|
||||
include/llvm/ADT/hash_map
|
||||
include/llvm/ADT/hash_set
|
||||
include/llvm/ADT/iterator)
|
||||
|
||||
dnl Do special configuration of Makefiles
|
||||
AC_CONFIG_MAKEFILE(Makefile)
|
||||
|
18
configure
vendored
18
configure
vendored
@ -1544,7 +1544,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
|
||||
|
||||
if test ${srcdir} != "."
|
||||
then
|
||||
if test -f ${srcdir}/include/Config/config.h
|
||||
if test -f ${srcdir}/include/llvm/Config/config.h
|
||||
then
|
||||
{ { echo "$as_me:$LINENO: error: Already configured in ${srcdir}" >&5
|
||||
echo "$as_me: error: Already configured in ${srcdir}" >&2;}
|
||||
@ -1566,10 +1566,10 @@ subdirs="$subdirs projects/${i}"
|
||||
fi
|
||||
done
|
||||
|
||||
ac_config_headers="$ac_config_headers include/Config/config.h"
|
||||
ac_config_headers="$ac_config_headers include/llvm/Config/config.h"
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile.config include/Support/DataTypes.h include/Support/ThreadSupport.h include/Support/hash_map include/Support/hash_set include/Support/iterator"
|
||||
ac_config_files="$ac_config_files Makefile.config include/llvm/Support/DataTypes.h include/llvm/Support/ThreadSupport.h include/llvm/ADT/hash_map include/llvm/ADT/hash_set include/llvm/ADT/iterator"
|
||||
|
||||
|
||||
ac_config_commands="$ac_config_commands Makefile"
|
||||
@ -24450,11 +24450,11 @@ do
|
||||
case "$ac_config_target" in
|
||||
# Handling of arguments.
|
||||
"Makefile.config" ) CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
|
||||
"include/Support/DataTypes.h" ) CONFIG_FILES="$CONFIG_FILES include/Support/DataTypes.h" ;;
|
||||
"include/Support/ThreadSupport.h" ) CONFIG_FILES="$CONFIG_FILES include/Support/ThreadSupport.h" ;;
|
||||
"include/Support/hash_map" ) CONFIG_FILES="$CONFIG_FILES include/Support/hash_map" ;;
|
||||
"include/Support/hash_set" ) CONFIG_FILES="$CONFIG_FILES include/Support/hash_set" ;;
|
||||
"include/Support/iterator" ) CONFIG_FILES="$CONFIG_FILES include/Support/iterator" ;;
|
||||
"include/llvm/Support/DataTypes.h" ) CONFIG_FILES="$CONFIG_FILES include/llvm/Support/DataTypes.h" ;;
|
||||
"include/llvm/Support/ThreadSupport.h" ) CONFIG_FILES="$CONFIG_FILES include/llvm/Support/ThreadSupport.h" ;;
|
||||
"include/llvm/ADT/hash_map" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/hash_map" ;;
|
||||
"include/llvm/ADT/hash_set" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/hash_set" ;;
|
||||
"include/llvm/ADT/iterator" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/iterator" ;;
|
||||
"lib/System/platform" ) CONFIG_LINKS="$CONFIG_LINKS lib/System/platform:lib/System/$platform_type" ;;
|
||||
"Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
|
||||
"Makefile.common" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile.common" ;;
|
||||
@ -24507,7 +24507,7 @@ do
|
||||
"tools/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS tools/Makefile" ;;
|
||||
"utils/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS utils/Makefile" ;;
|
||||
"projects/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS projects/Makefile" ;;
|
||||
"include/Config/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/Config/config.h" ;;
|
||||
"include/llvm/Config/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Config/config.h" ;;
|
||||
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
|
||||
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file includes the infamous alloc.h header file if the
|
||||
* autoconf system has found it. It hides all of the autoconf details
|
||||
* from the rest of the application source code.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_ALLOC_H
|
||||
#define _CONFIG_ALLOC_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
/*
|
||||
* This is a modified version of that suggested by the Autoconf manual.
|
||||
* 1) The #pragma is indented so that pre-ANSI C compilers ignore it.
|
||||
* 2) If alloca.h cannot be found, then try stdlib.h. Some platforms
|
||||
* (notably FreeBSD) defined alloca() there.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
/* noop on Visual C++ */
|
||||
#elif defined(HAVE_ALLOCA_H)
|
||||
#include <alloca.h>
|
||||
#elif !defined(__GNUC__)
|
||||
# ifdef _AIX
|
||||
# pragma alloca
|
||||
# else
|
||||
# ifndef alloca
|
||||
char * alloca ();
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# else
|
||||
# error "The function alloca() is required but not found!"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,240 +0,0 @@
|
||||
/* include/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the `backtrace' function. */
|
||||
#undef HAVE_BACKTRACE
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define if dlopen() is available on this platform. */
|
||||
#undef HAVE_DLOPEN
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
#undef HAVE_EXECINFO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if your compiler defines finite in the <ieeefp.h> header file.
|
||||
*/
|
||||
#undef HAVE_FINITE_IN_IEEEFP_H
|
||||
|
||||
/* Define to 1 if you have the `getcwd' function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the `getrusage' function. */
|
||||
#undef HAVE_GETRUSAGE
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if the system has the type `int64_t'. */
|
||||
#undef HAVE_INT64_T
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `isatty' function. */
|
||||
#undef HAVE_ISATTY
|
||||
|
||||
/* Define to 1 if your compiler defines isinf in the <cmath> header file. */
|
||||
#undef HAVE_ISINF_IN_CMATH
|
||||
|
||||
/* Define to 1 if your compiler defines isinf in the <math.h> header file. */
|
||||
#undef HAVE_ISINF_IN_MATH_H
|
||||
|
||||
/* Define to 1 if your compiler defines isnan in the <cmath> header file. */
|
||||
#undef HAVE_ISNAN_IN_CMATH
|
||||
|
||||
/* Define to 1 if your compiler defines isnan in the <math.h> header file. */
|
||||
#undef HAVE_ISNAN_IN_MATH_H
|
||||
|
||||
/* Define to 1 if you have the `elf' library (-lelf). */
|
||||
#undef HAVE_LIBELF
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <link.h> header file. */
|
||||
#undef HAVE_LINK_H
|
||||
|
||||
/* Define if you can use -Wl,-R. to pass -R. to the linker, in order to add
|
||||
the current directory to the dynamic linker search path. */
|
||||
#undef HAVE_LINK_R
|
||||
|
||||
/* Define if mallinfo() is available on this platform. */
|
||||
#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 <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `mkstemp' function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define if mmap() uses MAP_ANONYMOUS to map anonymous pages, or undefine if
|
||||
it uses MAP_ANON */
|
||||
#undef HAVE_MMAP_ANONYMOUS
|
||||
|
||||
/* Define if mmap() can map files into memory */
|
||||
#undef HAVE_MMAP_FILE
|
||||
|
||||
/* define if the compiler implements namespaces */
|
||||
#undef HAVE_NAMESPACES
|
||||
|
||||
/* Define to have the %a format string */
|
||||
#undef HAVE_PRINTF_A
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if your compiler defines std::isinf in the <cmath> header file.
|
||||
*/
|
||||
#undef HAVE_STD_ISINF_IN_CMATH
|
||||
|
||||
/* Define to 1 if your compiler defines std::isnan in the <cmath> header file.
|
||||
*/
|
||||
#undef HAVE_STD_ISNAN_IN_CMATH
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strtoll' function. */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
/* Define to 1 if you have the `strtoq' function. */
|
||||
#undef HAVE_STRTOQ
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if the system has the type `uint64_t'. */
|
||||
#undef HAVE_UINT64_T
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <windows.h> header file. */
|
||||
#undef HAVE_WINDOWS_H
|
||||
|
||||
/* Installation directory for binary executables */
|
||||
#undef LLVM_BINDIR
|
||||
|
||||
/* Time at which LLVM was configured */
|
||||
#undef LLVM_CONFIGTIME
|
||||
|
||||
/* Installation directory for documentation */
|
||||
#undef LLVM_DATADIR
|
||||
|
||||
/* Installation directory for config files */
|
||||
#undef LLVM_ETCDIR
|
||||
|
||||
/* Installation directory for include files */
|
||||
#undef LLVM_INCLUDEDIR
|
||||
|
||||
/* Installation directory for .info files */
|
||||
#undef LLVM_INFODIR
|
||||
|
||||
/* Installation directory for libraries */
|
||||
#undef LLVM_LIBDIR
|
||||
|
||||
/* Installation directory for man pages */
|
||||
#undef LLVM_MANDIR
|
||||
|
||||
/* Installation prefix directory */
|
||||
#undef LLVM_PREFIX
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Extension that shared libraries have, e.g., ".so". */
|
||||
#undef SHLIBEXT
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#undef YYTEXT_POINTER
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for dlfcn.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_DLFCN_H
|
||||
#define _CONFIG_DLFCN_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for fcntl.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_FCNTL_H
|
||||
#define _CONFIG_FCNTL_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for limits.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_LIMITS_H
|
||||
#define _CONFIG_LIMITS_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file includes the infamous malloc.h header file if the
|
||||
* autoconf system has found it. It hides all of the autoconf details
|
||||
* from the rest of the application source code.
|
||||
*/
|
||||
|
||||
#ifndef _SUPPORT_MALLOC_H
|
||||
#define _SUPPORT_MALLOC_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for memory.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_MEMORY_H
|
||||
#define _CONFIG_MEMORY_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* This header file provides a platform-independent way of quering page size.
|
||||
*/
|
||||
|
||||
#ifndef PAGESIZE_H
|
||||
#define PAGESIZE_H
|
||||
|
||||
#include "Config/unistd.h"
|
||||
#include <sys/param.h>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/* Compatibility chart:
|
||||
*
|
||||
* Linux/x86: _SC_PAGESIZE, _SC_PAGE_SIZE
|
||||
* MacOS X/PowerPC: v. 10.2: NBPG,
|
||||
* v. 10.3: _SC_PAGESIZE
|
||||
* Solaris/Sparc: _SC_PAGESIZE, _SC_PAGE_SIZE
|
||||
*/
|
||||
|
||||
/**
|
||||
* GetPageSize - wrapper to return page size in bytes for various
|
||||
* architecture/OS combinations
|
||||
*/
|
||||
unsigned GetPageSize() {
|
||||
#ifdef _SC_PAGESIZE
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
#elif defined(_SC_PAGE_SIZE)
|
||||
return sysconf(_SC_PAGE_SIZE);
|
||||
#elif defined(NBPG)
|
||||
#ifndef CLSIZE
|
||||
#define CLSIZE 1
|
||||
#endif
|
||||
return NBPG * CLSIZE;
|
||||
#else
|
||||
return 4096; /* allocate 4KB as a fall-back */
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for stdint.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_STDINT_H
|
||||
#define _CONFIG_STDINT_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
/*===-- Config/sys/mman.h - Autoconf sys/mman.h wrapper -----------*- C -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*
|
||||
* Description:
|
||||
* This header file includes the headers needed for the mmap() system/
|
||||
* function call. It also defines some macros so that all of our calls
|
||||
* to mmap() can act (more or less) the same, regardless of platform.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_MMAN_H
|
||||
#define _CONFIG_MMAN_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#if defined(HAVE_SYS_MMAN_H) && !defined(_MSC_VER)
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MMAP_ANONYMOUS
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*===-- Config/sys/resource.h -----------------------------------*- C++ -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*
|
||||
* This header file is the autoconf replacement for sys/resource.h (if it
|
||||
* lives on the system).
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_SYS_RESOURCE_H
|
||||
#define _CONFIG_SYS_RESOURCE_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#if defined(HAVE_SYS_RESOURCE_H) && !defined(_MSC_VER)
|
||||
|
||||
/*
|
||||
* In LLVM, we use sys/resource.h to use getrusage() and maybe some other
|
||||
* stuff. Some man pages say that you also need sys/time.h and unistd.h.
|
||||
* So, to be paranoid, we will try to include all three if possible.
|
||||
*/
|
||||
#include "Config/sys/time.h"
|
||||
#include <sys/resource.h>
|
||||
#include "Config/unistd.h"
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,29 +0,0 @@
|
||||
/*===-- Config/sys/stat.h -----------------------------------*- ----C++ -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
* This header file includes the headers needed for the stat() system
|
||||
* call.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_SYS_STAT_H
|
||||
#define _CONFIG_SYS_STAT_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define S_ISREG(X) ((X) & _S_IFREG)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*===-- Config/sys/time.h ---------------------------------------*- C++ -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
* This header file is the autoconf replacement for sys/time.h (if it
|
||||
* lives on the system).
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_SYS_TIME_H
|
||||
#define _CONFIG_SYS_TIME_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#if defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
/*===-- Config/sys/types.h --------------------------------------*- C++ -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
* This header file is the autoconf substitute for sys/types.h. It
|
||||
* includes it for us if it exists on this system.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_SYS_TYPES_H
|
||||
#define _CONFIG_SYS_TYPES_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*===-- Config/sys/wait.h ---------------------------------------*- C++ -*-===//
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
* This header file includes the headers needed for the wait() system
|
||||
* call.
|
||||
*===----------------------------------------------------------------------===//
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_SYS_WAIT_H
|
||||
#define _CONFIG_SYS_WAIT_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for time.h (if it lives
|
||||
* on the system).
|
||||
*
|
||||
* The added benefit of this header file is that it removes the
|
||||
* "time with sys/time" problem.
|
||||
*
|
||||
* According to the autoconf manual, some systems have a sys/time.h that
|
||||
* includes time.h, but time.h is not written to handle multiple
|
||||
* inclusion. This means that a program including sys/time.h cannot
|
||||
* also include time.h.
|
||||
*
|
||||
* This header file fixes that problem.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_TIME_H
|
||||
#define _CONFIG_TIME_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===//
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for unistd.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_UNISTD_H
|
||||
#define _CONFIG_UNISTD_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file was developed by the LLVM research group and is distributed under
|
||||
* the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* This header file is the autoconf replacement for windows.h (if it lives
|
||||
* on the system).
|
||||
*/
|
||||
|
||||
#ifndef LLVM_CONFIG_WINDOWS_H
|
||||
#define LLVM_CONFIG_WINDOWS_H
|
||||
|
||||
#include "Config/config.h"
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,217 +0,0 @@
|
||||
//===-- Support/Annotation.h - Annotation classes ---------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the declarations for two classes: Annotation & Annotable.
|
||||
// Using these two simple classes, anything that derives from Annotable can have
|
||||
// Annotation subclasses attached to them, ready for easy retrieval.
|
||||
//
|
||||
// Annotations are designed to be easily attachable to various classes.
|
||||
//
|
||||
// The AnnotationManager class is essential for using these classes. It is
|
||||
// responsible for turning Annotation name strings into tokens [unique id #'s]
|
||||
// that may be used to search for and create annotations.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_ANNOTATION_H
|
||||
#define SUPPORT_ANNOTATION_H
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AnnotationID;
|
||||
class Annotation;
|
||||
class Annotable;
|
||||
class AnnotationManager;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// AnnotationID - This class is a thin wrapper around an unsigned integer that
|
||||
// is used to hopefully prevent errors using AnnotationID's. They may be copied
|
||||
// freely around and passed byvalue with little or no overhead.
|
||||
//
|
||||
class AnnotationID {
|
||||
friend class AnnotationManager;
|
||||
unsigned ID;
|
||||
|
||||
AnnotationID(); // Default ctor is disabled
|
||||
inline AnnotationID(unsigned i) : ID(i) {} // Only creatable from AnnMgr
|
||||
public:
|
||||
inline AnnotationID(const AnnotationID &A) : ID(A.ID) {}
|
||||
|
||||
inline bool operator==(const AnnotationID &A) const {
|
||||
return A.ID == ID;
|
||||
}
|
||||
inline bool operator<(const AnnotationID &A) const {
|
||||
return ID < A.ID;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Annotation Class - This class serves as a base class for any specific
|
||||
// annotations that you might need. Simply subclass this to add extra
|
||||
// information to the annotations.
|
||||
//
|
||||
class Annotation {
|
||||
friend class Annotable; // Annotable manipulates Next list
|
||||
AnnotationID ID; // ID number, as obtained from AnnotationManager
|
||||
Annotation *Next; // The next annotation in the linked list
|
||||
public:
|
||||
inline Annotation(AnnotationID id) : ID(id), Next(0) {}
|
||||
virtual ~Annotation(); // Designed to be subclassed
|
||||
|
||||
// getID - Return the unique ID# of this annotation
|
||||
inline AnnotationID getID() const { return ID; }
|
||||
|
||||
// getNext - Return the next annotation in the list...
|
||||
inline Annotation *getNext() const { return Next; }
|
||||
};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Annotable - This class is used as a base class for all objects that would
|
||||
// like to have annotation capability. One notable subclass is Value, which
|
||||
// means annotations can be attached to almost everything in LLVM.
|
||||
//
|
||||
// Annotable objects keep their annotation list sorted as annotations are
|
||||
// inserted and deleted. This is used to ensure that annotations with identical
|
||||
// ID#'s are stored sequentially.
|
||||
//
|
||||
class Annotable {
|
||||
mutable Annotation *AnnotationList;
|
||||
|
||||
Annotable(const Annotable &); // Do not implement
|
||||
void operator=(const Annotable &); // Do not implement
|
||||
public:
|
||||
Annotable() : AnnotationList(0) {}
|
||||
~Annotable();
|
||||
|
||||
// getAnnotation - Search the list for annotations of the specified ID. The
|
||||
// pointer returned is either null (if no annotations of the specified ID
|
||||
// exist), or it points to the first element of a potentially list of elements
|
||||
// with identical ID #'s.
|
||||
//
|
||||
Annotation *getAnnotation(AnnotationID ID) const {
|
||||
for (Annotation *A = AnnotationList; A; A = A->getNext())
|
||||
if (A->getID() == ID) return A;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// getOrCreateAnnotation - Search through the annotation list, if there is
|
||||
// no annotation with the specified ID, then use the AnnotationManager to
|
||||
// create one.
|
||||
//
|
||||
inline Annotation *getOrCreateAnnotation(AnnotationID ID) const;
|
||||
|
||||
// addAnnotation - Insert the annotation into the list in a sorted location.
|
||||
//
|
||||
void addAnnotation(Annotation *A) const {
|
||||
assert(A->Next == 0 && "Annotation already in list?!?");
|
||||
|
||||
Annotation **AL = &AnnotationList;
|
||||
while (*AL && (*AL)->ID < A->getID()) // Find where to insert annotation
|
||||
AL = &((*AL)->Next);
|
||||
A->Next = *AL; // Link the annotation in
|
||||
*AL = A;
|
||||
}
|
||||
|
||||
// unlinkAnnotation - Remove the first annotation of the specified ID... and
|
||||
// then return the unlinked annotation. The annotation object is not deleted.
|
||||
//
|
||||
inline Annotation *unlinkAnnotation(AnnotationID ID) const {
|
||||
for (Annotation **A = &AnnotationList; *A; A = &((*A)->Next))
|
||||
if ((*A)->getID() == ID) {
|
||||
Annotation *Ret = *A;
|
||||
*A = Ret->Next;
|
||||
Ret->Next = 0;
|
||||
return Ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// deleteAnnotation - Delete the first annotation of the specified ID in the
|
||||
// list. Unlink unlinkAnnotation, this actually deletes the annotation object
|
||||
//
|
||||
bool deleteAnnotation(AnnotationID ID) const {
|
||||
Annotation *A = unlinkAnnotation(ID);
|
||||
delete A;
|
||||
return A != 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// AnnotationManager - This class is primarily responsible for maintaining a
|
||||
// one-to-one mapping between string Annotation names and Annotation ID numbers.
|
||||
//
|
||||
// Compared to the rest of the Annotation system, these mapping methods are
|
||||
// relatively slow, so they should be avoided by locally caching Annotation
|
||||
// ID #'s. These methods are safe to call at any time, even by static ctors, so
|
||||
// they should be used by static ctors most of the time.
|
||||
//
|
||||
// This class also provides support for annotations that are created on demand
|
||||
// by the Annotable::getOrCreateAnnotation method. To get this to work, simply
|
||||
// register an annotation handler
|
||||
//
|
||||
struct AnnotationManager {
|
||||
typedef Annotation *(*Factory)(AnnotationID, const Annotable *, void*);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Basic ID <-> Name map functionality
|
||||
|
||||
static AnnotationID getID(const std::string &Name); // Name -> ID
|
||||
static const std::string &getName(AnnotationID ID); // ID -> Name
|
||||
|
||||
// getID - Name -> ID + registration of a factory function for demand driven
|
||||
// annotation support.
|
||||
static AnnotationID getID(const std::string &Name, Factory Fact,
|
||||
void *Data = 0);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Annotation creation on demand support...
|
||||
|
||||
// registerAnnotationFactory - This method is used to register a callback
|
||||
// function used to create an annotation on demand if it is needed by the
|
||||
// Annotable::getOrCreateAnnotation method.
|
||||
//
|
||||
static void registerAnnotationFactory(AnnotationID ID, Factory Func,
|
||||
void *ExtraData = 0);
|
||||
|
||||
// createAnnotation - Create an annotation of the specified ID for the
|
||||
// specified object, using a register annotation creation function.
|
||||
//
|
||||
static Annotation *createAnnotation(AnnotationID ID, const Annotable *Obj);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// getOrCreateAnnotation - Search through the annotation list, if there is
|
||||
// no annotation with the specified ID, then use the AnnotationManager to
|
||||
// create one.
|
||||
//
|
||||
inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const {
|
||||
Annotation *A = getAnnotation(ID); // Fast path, check for preexisting ann
|
||||
if (A) return A;
|
||||
|
||||
// No annotation found, ask the annotation manager to create an annotation...
|
||||
A = AnnotationManager::createAnnotation(ID, this);
|
||||
assert(A && "AnnotationManager could not create annotation!");
|
||||
addAnnotation(A);
|
||||
return A;
|
||||
}
|
||||
|
||||
} // End namespace llvm
|
||||
|
||||
#endif
|
@ -1,272 +0,0 @@
|
||||
//===-- BitVectorSet.h - A bit-vector representation of sets ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This is an implementation of the bit-vector representation of sets. Unlike
|
||||
// vector<bool>, this allows much more efficient parallel set operations on
|
||||
// bits, by using the bitset template. The bitset template unfortunately can
|
||||
// only represent sets with a size chosen at compile-time. We therefore use a
|
||||
// vector of bitsets. The maxmimum size of our sets (i.e., the size of the
|
||||
// universal set) can be chosen at creation time.
|
||||
//
|
||||
// External functions:
|
||||
//
|
||||
// bool Disjoint(const BitSetVector& set1, const BitSetVector& set2):
|
||||
// Tests if two sets have an empty intersection.
|
||||
// This is more efficient than !(set1 & set2).any().
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_BITSETVECTOR_H
|
||||
#define SUPPORT_BITSETVECTOR_H
|
||||
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BitSetVector {
|
||||
enum { BITSET_WORDSIZE = sizeof(long)*8 };
|
||||
|
||||
// Types used internal to the representation
|
||||
typedef std::bitset<BITSET_WORDSIZE> bitword;
|
||||
typedef bitword::reference reference;
|
||||
|
||||
// Data used in the representation
|
||||
std::vector<bitword> bitsetVec;
|
||||
unsigned maxSize;
|
||||
|
||||
private:
|
||||
// Utility functions for the representation
|
||||
static unsigned NumWords(unsigned Size) {
|
||||
return (Size+BITSET_WORDSIZE-1)/BITSET_WORDSIZE;
|
||||
}
|
||||
static unsigned LastWordSize(unsigned Size) { return Size % BITSET_WORDSIZE; }
|
||||
|
||||
// Clear the unused bits in the last word.
|
||||
// The unused bits are the high (BITSET_WORDSIZE - LastWordSize()) bits
|
||||
void ClearUnusedBits() {
|
||||
unsigned long usedBits = (1U << LastWordSize(size())) - 1;
|
||||
bitsetVec.back() &= bitword(usedBits);
|
||||
}
|
||||
|
||||
const bitword& getWord(unsigned i) const { return bitsetVec[i]; }
|
||||
bitword& getWord(unsigned i) { return bitsetVec[i]; }
|
||||
|
||||
friend bool Disjoint(const BitSetVector& set1,
|
||||
const BitSetVector& set2);
|
||||
|
||||
BitSetVector(); // do not implement!
|
||||
|
||||
public:
|
||||
class iterator;
|
||||
///
|
||||
/// Constructor: create a set of the maximum size maxSetSize.
|
||||
/// The set is initialized to empty.
|
||||
///
|
||||
BitSetVector(unsigned maxSetSize)
|
||||
: bitsetVec(NumWords(maxSetSize)), maxSize(maxSetSize) { }
|
||||
|
||||
/// size - Return the number of bits tracked by this bit vector...
|
||||
unsigned size() const { return maxSize; }
|
||||
|
||||
///
|
||||
/// Modifier methods: reset, set for entire set, operator[] for one element.
|
||||
///
|
||||
void reset() {
|
||||
for (unsigned i=0, N = bitsetVec.size(); i < N; ++i)
|
||||
bitsetVec[i].reset();
|
||||
}
|
||||
void set() {
|
||||
for (unsigned i=0, N = bitsetVec.size(); i < N; ++i) // skip last word
|
||||
bitsetVec[i].set();
|
||||
ClearUnusedBits();
|
||||
}
|
||||
reference operator[](unsigned n) {
|
||||
assert(n < size() && "BitSetVector: Bit number out of range");
|
||||
unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE;
|
||||
return bitsetVec[ndiv][nmod];
|
||||
}
|
||||
iterator begin() { return iterator::begin(*this); }
|
||||
iterator end() { return iterator::end(*this); }
|
||||
|
||||
///
|
||||
/// Comparison operations: equal, not equal
|
||||
///
|
||||
bool operator == (const BitSetVector& set2) const {
|
||||
assert(maxSize == set2.maxSize && "Illegal == comparison");
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
if (getWord(i) != set2.getWord(i))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator != (const BitSetVector& set2) const {
|
||||
return ! (*this == set2);
|
||||
}
|
||||
|
||||
///
|
||||
/// Set membership operations: single element, any, none, count
|
||||
///
|
||||
bool test(unsigned n) const {
|
||||
assert(n < size() && "BitSetVector: Bit number out of range");
|
||||
unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE;
|
||||
return bitsetVec[ndiv].test(nmod);
|
||||
}
|
||||
bool any() const {
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
if (bitsetVec[i].any())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool none() const {
|
||||
return ! any();
|
||||
}
|
||||
unsigned count() const {
|
||||
unsigned n = 0;
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
n += bitsetVec[i].count();
|
||||
return n;
|
||||
}
|
||||
bool all() const {
|
||||
return (count() == size());
|
||||
}
|
||||
|
||||
///
|
||||
/// Set operations: intersection, union, disjoint union, complement.
|
||||
///
|
||||
BitSetVector operator& (const BitSetVector& set2) const {
|
||||
assert(maxSize == set2.maxSize && "Illegal intersection");
|
||||
BitSetVector result(maxSize);
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
result.getWord(i) = getWord(i) & set2.getWord(i);
|
||||
return result;
|
||||
}
|
||||
BitSetVector operator| (const BitSetVector& set2) const {
|
||||
assert(maxSize == set2.maxSize && "Illegal intersection");
|
||||
BitSetVector result(maxSize);
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
result.getWord(i) = getWord(i) | set2.getWord(i);
|
||||
return result;
|
||||
}
|
||||
BitSetVector operator^ (const BitSetVector& set2) const {
|
||||
assert(maxSize == set2.maxSize && "Illegal intersection");
|
||||
BitSetVector result(maxSize);
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
result.getWord(i) = getWord(i) ^ set2.getWord(i);
|
||||
return result;
|
||||
}
|
||||
BitSetVector operator~ () const {
|
||||
BitSetVector result(maxSize);
|
||||
for (unsigned i = 0; i < bitsetVec.size(); ++i)
|
||||
(result.getWord(i) = getWord(i)).flip();
|
||||
result.ClearUnusedBits();
|
||||
return result;
|
||||
}
|
||||
|
||||
///
|
||||
/// Printing and debugging support
|
||||
///
|
||||
void print(std::ostream &O) const;
|
||||
void dump() const { print(std::cerr); }
|
||||
|
||||
public:
|
||||
//
|
||||
// An iterator to enumerate the bits in a BitSetVector.
|
||||
// Eventually, this needs to inherit from bidirectional_iterator.
|
||||
// But this iterator may not be as useful as I once thought and
|
||||
// may just go away.
|
||||
//
|
||||
class iterator {
|
||||
unsigned currentBit;
|
||||
unsigned currentWord;
|
||||
BitSetVector* bitvec;
|
||||
iterator(unsigned B, unsigned W, BitSetVector& _bitvec)
|
||||
: currentBit(B), currentWord(W), bitvec(&_bitvec) { }
|
||||
public:
|
||||
iterator(BitSetVector& _bitvec)
|
||||
: currentBit(0), currentWord(0), bitvec(&_bitvec) { }
|
||||
iterator(const iterator& I)
|
||||
: currentBit(I.currentBit),currentWord(I.currentWord),bitvec(I.bitvec) { }
|
||||
iterator& operator=(const iterator& I) {
|
||||
currentWord = I.currentWord;
|
||||
currentBit = I.currentBit;
|
||||
bitvec = I.bitvec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Increment and decrement operators (pre and post)
|
||||
iterator& operator++() {
|
||||
if (++currentBit == BITSET_WORDSIZE)
|
||||
{ currentBit = 0; if (currentWord < bitvec->size()) ++currentWord; }
|
||||
return *this;
|
||||
}
|
||||
iterator& operator--() {
|
||||
if (currentBit == 0) {
|
||||
currentBit = BITSET_WORDSIZE-1;
|
||||
currentWord = (currentWord == 0)? bitvec->size() : --currentWord;
|
||||
}
|
||||
else
|
||||
--currentBit;
|
||||
return *this;
|
||||
}
|
||||
iterator operator++(int) { iterator copy(*this); ++*this; return copy; }
|
||||
iterator operator--(int) { iterator copy(*this); --*this; return copy; }
|
||||
|
||||
// Dereferencing operators
|
||||
reference operator*() {
|
||||
assert(currentWord < bitvec->size() &&
|
||||
"Dereferencing iterator past the end of a BitSetVector");
|
||||
return bitvec->getWord(currentWord)[currentBit];
|
||||
}
|
||||
|
||||
// Comparison operator
|
||||
bool operator==(const iterator& I) {
|
||||
return (I.bitvec == bitvec &&
|
||||
I.currentWord == currentWord && I.currentBit == currentBit);
|
||||
}
|
||||
|
||||
protected:
|
||||
static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); }
|
||||
static iterator end(BitSetVector& _bitvec) { return iterator(0,
|
||||
_bitvec.size(), _bitvec); }
|
||||
friend class BitSetVector;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
inline void BitSetVector::print(std::ostream& O) const
|
||||
{
|
||||
for (std::vector<bitword>::const_iterator
|
||||
I=bitsetVec.begin(), E=bitsetVec.end(); I != E; ++I)
|
||||
O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", ");
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& O, const BitSetVector& bset)
|
||||
{
|
||||
bset.print(O);
|
||||
return O;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Optimized versions of fundamental comparison operations
|
||||
///
|
||||
inline bool Disjoint(const BitSetVector& set1,
|
||||
const BitSetVector& set2)
|
||||
{
|
||||
assert(set1.size() == set2.size() && "Illegal intersection");
|
||||
for (unsigned i = 0; i < set1.bitsetVec.size(); ++i)
|
||||
if ((set1.getWord(i) & set2.getWord(i)).any())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
#endif
|
@ -1,301 +0,0 @@
|
||||
//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the isa<X>(), cast<X>(), dyn_cast<X>(), cast_or_null<X>(),
|
||||
// and dyn_cast_or_null<X>() templates.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_CASTING_H
|
||||
#define SUPPORT_CASTING_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// isa<x> Support Templates
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
template<typename FromCl> struct isa_impl_cl;
|
||||
|
||||
// Define a template that can be specialized by smart pointers to reflect the
|
||||
// fact that they are automatically dereferenced, and are not involved with the
|
||||
// template selection process... the default implementation is a noop.
|
||||
//
|
||||
template<typename From> struct simplify_type {
|
||||
typedef From SimpleType; // The real type this represents...
|
||||
|
||||
// An accessor to get the real value...
|
||||
static SimpleType &getSimplifiedValue(From &Val) { return Val; }
|
||||
};
|
||||
|
||||
template<typename From> struct simplify_type<const From> {
|
||||
typedef const From SimpleType;
|
||||
static SimpleType &getSimplifiedValue(const From &Val) {
|
||||
return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// isa<X> - Return true if the parameter to the template is an instance of the
|
||||
// template type argument. Used like this:
|
||||
//
|
||||
// if (isa<Type*>(myVal)) { ... }
|
||||
//
|
||||
template <typename To, typename From>
|
||||
inline bool isa_impl(const From &Val) {
|
||||
return To::classof(&Val);
|
||||
}
|
||||
|
||||
template<typename To, typename From, typename SimpleType>
|
||||
struct isa_impl_wrap {
|
||||
// When From != SimplifiedType, we can simplify the type some more by using
|
||||
// the simplify_type template.
|
||||
static bool doit(const From &Val) {
|
||||
return isa_impl_cl<const SimpleType>::template
|
||||
isa<To>(simplify_type<const From>::getSimplifiedValue(Val));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename To, typename FromTy>
|
||||
struct isa_impl_wrap<To, const FromTy, const FromTy> {
|
||||
// When From == SimpleType, we are as simple as we are going to get.
|
||||
static bool doit(const FromTy &Val) {
|
||||
return isa_impl<To,FromTy>(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// isa_impl_cl - Use class partial specialization to transform types to a single
|
||||
// canonical form for isa_impl.
|
||||
//
|
||||
template<typename FromCl>
|
||||
struct isa_impl_cl {
|
||||
template<class ToCl>
|
||||
static bool isa(const FromCl &Val) {
|
||||
return isa_impl_wrap<ToCl,const FromCl,
|
||||
typename simplify_type<const FromCl>::SimpleType>::doit(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization used to strip const qualifiers off of the FromCl type...
|
||||
template<typename FromCl>
|
||||
struct isa_impl_cl<const FromCl> {
|
||||
template<class ToCl>
|
||||
static bool isa(const FromCl &Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Define pointer traits in terms of base traits...
|
||||
template<class FromCl>
|
||||
struct isa_impl_cl<FromCl*> {
|
||||
template<class ToCl>
|
||||
static bool isa(FromCl *Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(*Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Define reference traits in terms of base traits...
|
||||
template<class FromCl>
|
||||
struct isa_impl_cl<FromCl&> {
|
||||
template<class ToCl>
|
||||
static bool isa(FromCl &Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(&Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
inline bool isa(const Y &Val) {
|
||||
return isa_impl_cl<Y>::template isa<X>(Val);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// cast<x> Support Templates
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
template<class To, class From> struct cast_retty;
|
||||
|
||||
|
||||
// Calculate what type the 'cast' function should return, based on a requested
|
||||
// type of To and a source type of From.
|
||||
template<class To, class From> struct cast_retty_impl {
|
||||
typedef To& ret_type; // Normal case, return Ty&
|
||||
};
|
||||
template<class To, class From> struct cast_retty_impl<To, const From> {
|
||||
typedef const To &ret_type; // Normal case, return Ty&
|
||||
};
|
||||
|
||||
template<class To, class From> struct cast_retty_impl<To, From*> {
|
||||
typedef To* ret_type; // Pointer arg case, return Ty*
|
||||
};
|
||||
|
||||
template<class To, class From> struct cast_retty_impl<To, const From*> {
|
||||
typedef const To* ret_type; // Constant pointer arg case, return const Ty*
|
||||
};
|
||||
|
||||
template<class To, class From> struct cast_retty_impl<To, const From*const> {
|
||||
typedef const To* ret_type; // Constant pointer arg case, return const Ty*
|
||||
};
|
||||
|
||||
|
||||
template<class To, class From, class SimpleFrom>
|
||||
struct cast_retty_wrap {
|
||||
// When the simplified type and the from type are not the same, use the type
|
||||
// simplifier to reduce the type, then reuse cast_retty_impl to get the
|
||||
// resultant type.
|
||||
typedef typename cast_retty<To, SimpleFrom>::ret_type ret_type;
|
||||
};
|
||||
|
||||
template<class To, class FromTy>
|
||||
struct cast_retty_wrap<To, FromTy, FromTy> {
|
||||
// When the simplified type is equal to the from type, use it directly.
|
||||
typedef typename cast_retty_impl<To,FromTy>::ret_type ret_type;
|
||||
};
|
||||
|
||||
template<class To, class From>
|
||||
struct cast_retty {
|
||||
typedef typename cast_retty_wrap<To, From,
|
||||
typename simplify_type<From>::SimpleType>::ret_type ret_type;
|
||||
};
|
||||
|
||||
// Ensure the non-simple values are converted using the simplify_type template
|
||||
// that may be specialized by smart pointers...
|
||||
//
|
||||
template<class To, class From, class SimpleFrom> struct cast_convert_val {
|
||||
// This is not a simple type, use the template to simplify it...
|
||||
static typename cast_retty<To, From>::ret_type doit(const From &Val) {
|
||||
return cast_convert_val<To, SimpleFrom,
|
||||
typename simplify_type<SimpleFrom>::SimpleType>::doit(
|
||||
simplify_type<From>::getSimplifiedValue(Val));
|
||||
}
|
||||
};
|
||||
|
||||
template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
|
||||
// This _is_ a simple type, just cast it.
|
||||
static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
|
||||
return reinterpret_cast<typename cast_retty<To, FromTy>::ret_type>(
|
||||
const_cast<FromTy&>(Val));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// cast<X> - Return the argument parameter cast to the specified type. This
|
||||
// casting operator asserts that the type is correct, so it does not return null
|
||||
// on failure. But it will correctly return NULL when the input is NULL.
|
||||
// Used Like this:
|
||||
//
|
||||
// cast<Instruction>(myVal)->getParent()
|
||||
//
|
||||
template <class X, class Y>
|
||||
inline typename cast_retty<X, Y>::ret_type cast(const Y &Val) {
|
||||
assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!");
|
||||
return cast_convert_val<X, Y,
|
||||
typename simplify_type<Y>::SimpleType>::doit(Val);
|
||||
}
|
||||
|
||||
// cast_or_null<X> - Functionally identical to cast, except that a null value is
|
||||
// accepted.
|
||||
//
|
||||
template <class X, class Y>
|
||||
inline typename cast_retty<X, Y*>::ret_type cast_or_null(Y *Val) {
|
||||
if (Val == 0) return 0;
|
||||
assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!");
|
||||
return cast<X>(Val);
|
||||
}
|
||||
|
||||
|
||||
// dyn_cast<X> - Return the argument parameter cast to the specified type. This
|
||||
// casting operator returns null if the argument is of the wrong type, so it can
|
||||
// be used to test for a type as well as cast if successful. This should be
|
||||
// used in the context of an if statement like this:
|
||||
//
|
||||
// if (const Instruction *I = dyn_cast<Instruction>(myVal)) { ... }
|
||||
//
|
||||
|
||||
template <class X, class Y>
|
||||
inline typename cast_retty<X, Y>::ret_type dyn_cast(Y Val) {
|
||||
return isa<X>(Val) ? cast<X, Y>(Val) : 0;
|
||||
}
|
||||
|
||||
// dyn_cast_or_null<X> - Functionally identical to dyn_cast, except that a null
|
||||
// value is accepted.
|
||||
//
|
||||
template <class X, class Y>
|
||||
inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(Y Val) {
|
||||
return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_CAST_OPERATORS
|
||||
#include <iostream>
|
||||
|
||||
struct bar {
|
||||
bar() {}
|
||||
private:
|
||||
bar(const bar &);
|
||||
};
|
||||
struct foo {
|
||||
void ext() const;
|
||||
/* static bool classof(const bar *X) {
|
||||
cerr << "Classof: " << X << "\n";
|
||||
return true;
|
||||
}*/
|
||||
};
|
||||
|
||||
template <> inline bool isa_impl<foo,bar>(const bar &Val) {
|
||||
cerr << "Classof: " << &Val << "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bar *fub();
|
||||
void test(bar &B1, const bar *B2) {
|
||||
// test various configurations of const
|
||||
const bar &B3 = B1;
|
||||
const bar *const B4 = B2;
|
||||
|
||||
// test isa
|
||||
if (!isa<foo>(B1)) return;
|
||||
if (!isa<foo>(B2)) return;
|
||||
if (!isa<foo>(B3)) return;
|
||||
if (!isa<foo>(B4)) return;
|
||||
|
||||
// test cast
|
||||
foo &F1 = cast<foo>(B1);
|
||||
const foo *F3 = cast<foo>(B2);
|
||||
const foo *F4 = cast<foo>(B2);
|
||||
const foo &F8 = cast<foo>(B3);
|
||||
const foo *F9 = cast<foo>(B4);
|
||||
foo *F10 = cast<foo>(fub());
|
||||
|
||||
// test cast_or_null
|
||||
const foo *F11 = cast_or_null<foo>(B2);
|
||||
const foo *F12 = cast_or_null<foo>(B2);
|
||||
const foo *F13 = cast_or_null<foo>(B4);
|
||||
const foo *F14 = cast_or_null<foo>(fub()); // Shouldn't print.
|
||||
|
||||
// These lines are errors...
|
||||
//foo *F20 = cast<foo>(B2); // Yields const foo*
|
||||
//foo &F21 = cast<foo>(B3); // Yields const foo&
|
||||
//foo *F22 = cast<foo>(B4); // Yields const foo*
|
||||
//foo &F23 = cast_or_null<foo>(B1);
|
||||
//const foo &F24 = cast_or_null<foo>(B3);
|
||||
}
|
||||
|
||||
bar *fub() { return 0; }
|
||||
void main() {
|
||||
bar B;
|
||||
test(B, &B);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,102 +0,0 @@
|
||||
//===-- Support/DotGraphTraits.h - Customize .dot output --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a template class that can be used to customize dot output
|
||||
// graphs generated by the GraphWriter.h file. The default implementation of
|
||||
// this file will produce a simple, but not very polished graph. By
|
||||
// specializing this template, lots of customization opportunities are possible.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DOTGRAPHTRAITS_H
|
||||
#define SUPPORT_DOTGRAPHTRAITS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// DefaultDOTGraphTraits - This class provides the default implementations of
|
||||
/// all of the DOTGraphTraits methods. If a specialization does not need to
|
||||
/// override all methods here it should inherit so that it can get the default
|
||||
/// implementations.
|
||||
///
|
||||
struct DefaultDOTGraphTraits {
|
||||
/// getGraphName - Return the label for the graph as a whole. Printed at the
|
||||
/// top of the graph.
|
||||
///
|
||||
static std::string getGraphName(const void *Graph) { return ""; }
|
||||
|
||||
/// getGraphProperties - Return any custom properties that should be included
|
||||
/// in the top level graph structure for dot.
|
||||
///
|
||||
static std::string getGraphProperties(const void *Graph) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// getNodeLabel - Given a node and a pointer to the top level graph, return
|
||||
/// the label to print in the node.
|
||||
static std::string getNodeLabel(const void *Node, const void *Graph) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// If you want to specify custom node attributes, this is the place to do so
|
||||
///
|
||||
static std::string getNodeAttributes(const void *Node) { return ""; }
|
||||
|
||||
/// If you want to override the dot attributes printed for a particular edge,
|
||||
/// override this method.
|
||||
template<typename EdgeIter>
|
||||
static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// getEdgeSourceLabel - If you want to label the edge source itself,
|
||||
/// implement this method.
|
||||
template<typename EdgeIter>
|
||||
static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// edgeTargetsEdgeSource - This method returns true if this outgoing edge
|
||||
/// should actually target another edge source, not a node. If this method is
|
||||
/// implemented, getEdgeTarget should be implemented.
|
||||
template<typename EdgeIter>
|
||||
static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is
|
||||
/// called to determine which outgoing edge of Node is the target of this
|
||||
/// edge.
|
||||
template<typename EdgeIter>
|
||||
static EdgeIter getEdgeTarget(const void *Node, EdgeIter I) {
|
||||
return I;
|
||||
}
|
||||
|
||||
/// addCustomGraphFeatures - If a graph is made up of more than just
|
||||
/// straight-forward nodes and edges, this is the place to put all of the
|
||||
/// custom stuff necessary. The GraphWriter object, instantiated with your
|
||||
/// GraphType is passed in as an argument. You may call arbitrary methods on
|
||||
/// it to add things to the output graph.
|
||||
///
|
||||
template<typename GraphWriter>
|
||||
static void addCustomGraphFeatures(const void *Graph, GraphWriter &GW) {}
|
||||
};
|
||||
|
||||
|
||||
/// DOTGraphTraits - Template class that can be specialized to customize how
|
||||
/// graphs are converted to 'dot' graphs. When specializing, you may inherit
|
||||
/// from DefaultDOTGraphTraits if you don't need to override everything.
|
||||
///
|
||||
template <typename Ty>
|
||||
class DOTGraphTraits : public DefaultDOTGraphTraits {};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,64 +0,0 @@
|
||||
//===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and 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 functinons.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DATATYPES_H
|
||||
#define SUPPORT_DATATYPES_H
|
||||
|
||||
// Note that this header's correct operation depends on __STDC_LIMIT_MACROS
|
||||
// being defined. We would define it here, but in order to prevent Bad Things
|
||||
// happening when system headers or C++ STL headers include stdint.h before
|
||||
// we define it here, we define it on the g++ command line (in Makefile.rules).
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
// Note that <inttypes.h> includes <stdint.h>, if this is a C99 system.
|
||||
@INCLUDE_INTTYPES_H@
|
||||
@INCLUDE_SYS_TYPES_H@
|
||||
@INCLUDE_STDINT_H@
|
||||
#else
|
||||
// Visual C++ doesn't provide standard integer headers, but it does provide
|
||||
// built-in data types.
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed int ssize_t;
|
||||
#define INT8_MAX 127
|
||||
#define INT8_MIN -128
|
||||
#define UINT8_MAX 255
|
||||
#define INT16_MAX 32767
|
||||
#define INT16_MIN -32768
|
||||
#define UINT16_MAX 65535
|
||||
#define INT32_MAX 2147483647
|
||||
#define INT32_MIN -2147483648
|
||||
#define UINT32_MAX 4294967295U
|
||||
#endif
|
||||
|
||||
#if !defined(INT64_MAX)
|
||||
/* We couldn't determine INT64_MAX; default it. */
|
||||
# define INT64_MAX 9223372036854775807LL
|
||||
#endif
|
||||
#if !defined(UINT64_MAX)
|
||||
# define UINT64_MAX 0xffffffffffffffffULL
|
||||
#endif
|
||||
|
||||
#endif /* SUPPORT_DATATYPES_H */
|
@ -1,67 +0,0 @@
|
||||
//===- Debug.h - An easy way to add debug output to your code ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements a handle way of adding debugging information to your
|
||||
// code, without it being enabled all of the time, and without having to add
|
||||
// command line options to enable it.
|
||||
//
|
||||
// In particular, just wrap your code with the DEBUG() macro, and it will be
|
||||
// enabled automatically if you specify '-debug' on the command-line.
|
||||
// Alternatively, you can also use the SET_DEBUG_TYPE("foo") macro to specify
|
||||
// that your debug code belongs to class "foo". Then, on the command line, you
|
||||
// can specify '-debug-only=foo' to enable JUST the debug information for the
|
||||
// foo class.
|
||||
//
|
||||
// When compiling in release mode, the -debug-* options and all code in DEBUG()
|
||||
// statements disappears, so it does not effect the runtime of the code.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DEBUG_H
|
||||
#define SUPPORT_DEBUG_H
|
||||
|
||||
// Unsurprisingly, most users of this macro use std::cerr too.
|
||||
#include <iostream>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// DebugFlag - This boolean is set to true if the '-debug' command line option
|
||||
// is specified. This should probably not be referenced directly, instead, use
|
||||
// the DEBUG macro below.
|
||||
//
|
||||
extern bool DebugFlag;
|
||||
|
||||
// isCurrentDebugType - Return true if the specified string is the debug type
|
||||
// specified on the command line, or if none was specified on the command line
|
||||
// with the -debug-only=X option.
|
||||
//
|
||||
bool isCurrentDebugType(const char *Type);
|
||||
|
||||
// DEBUG macro - This macro should be used by passes to emit debug information.
|
||||
// In the '-debug' option is specified on the commandline, and if this is a
|
||||
// debug build, then the code specified as the option to the macro will be
|
||||
// executed. Otherwise it will not be. Example:
|
||||
//
|
||||
// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
|
||||
//
|
||||
|
||||
#ifndef DEBUG_TYPE
|
||||
#define DEBUG_TYPE ""
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DEBUG(X)
|
||||
#else
|
||||
#define DEBUG(X) \
|
||||
do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0)
|
||||
#endif
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements a dense map. A dense map template takes two
|
||||
// types. The first is the mapped type and the second is a functor
|
||||
// that maps its argument to a size_t. On instantiation a "null" value
|
||||
// can be provided to be used as a "does not exist" indicator in the
|
||||
// map. A member function grow() is provided that given the value of
|
||||
// the maximally indexed key (the argument of the functor) makes sure
|
||||
// the map has enough space for it.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DENSEMAP_H
|
||||
#define SUPPORT_DENSEMAP_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
struct IdentityFunctor : std::unary_function<unsigned, unsigned> {
|
||||
unsigned operator()(unsigned Index) const {
|
||||
return Index;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename ToIndexT = IdentityFunctor>
|
||||
class DenseMap {
|
||||
typedef typename ToIndexT::argument_type IndexT;
|
||||
typedef std::vector<T> StorageT;
|
||||
StorageT storage_;
|
||||
T nullVal_;
|
||||
ToIndexT toIndex_;
|
||||
|
||||
public:
|
||||
DenseMap() : nullVal_(T()) { }
|
||||
|
||||
explicit DenseMap(const T& val) : nullVal_(val) { }
|
||||
|
||||
typename StorageT::reference operator[](IndexT n) {
|
||||
assert(toIndex_(n) < storage_.size() && "index out of bounds!");
|
||||
return storage_[toIndex_(n)];
|
||||
}
|
||||
|
||||
typename StorageT::const_reference operator[](IndexT n) const {
|
||||
assert(toIndex_(n) < storage_.size() && "index out of bounds!");
|
||||
return storage_[toIndex_(n)];
|
||||
}
|
||||
|
||||
void clear() {
|
||||
storage_.clear();
|
||||
}
|
||||
|
||||
void grow(IndexT n) {
|
||||
unsigned NewSize = toIndex_(n) + 1;
|
||||
if (NewSize > storage_.size())
|
||||
storage_.resize(NewSize, nullVal_);
|
||||
}
|
||||
|
||||
typename StorageT::size_type size() const {
|
||||
return storage_.size();
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,230 +0,0 @@
|
||||
//===- Support/DepthFirstIterator.h - Depth First iterator ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file builds on the Support/GraphTraits.h file to build generic depth
|
||||
// first graph iterator. This file exposes the following functions/types:
|
||||
//
|
||||
// df_begin/df_end/df_iterator
|
||||
// * Normal depth-first iteration - visit a node and then all of its children.
|
||||
//
|
||||
// idf_begin/idf_end/idf_iterator
|
||||
// * Depth-first iteration on the 'inverse' graph.
|
||||
//
|
||||
// df_ext_begin/df_ext_end/df_ext_iterator
|
||||
// * Normal depth-first iteration - visit a node and then all of its children.
|
||||
// This iterator stores the 'visited' set in an external set, which allows
|
||||
// it to be more efficient, and allows external clients to use the set for
|
||||
// other purposes.
|
||||
//
|
||||
// idf_ext_begin/idf_ext_end/idf_ext_iterator
|
||||
// * Depth-first iteration on the 'inverse' graph.
|
||||
// This iterator stores the 'visited' set in an external set, which allows
|
||||
// it to be more efficient, and allows external clients to use the set for
|
||||
// other purposes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DEPTHFIRSTITERATOR_H
|
||||
#define SUPPORT_DEPTHFIRSTITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// df_iterator_storage - A private class which is used to figure out where to
|
||||
// store the visited set.
|
||||
template<class SetType, bool External> // Non-external set
|
||||
class df_iterator_storage {
|
||||
public:
|
||||
SetType Visited;
|
||||
};
|
||||
|
||||
template<class SetType>
|
||||
class df_iterator_storage<SetType, true> {
|
||||
public:
|
||||
df_iterator_storage(SetType &VSet) : Visited(VSet) {}
|
||||
df_iterator_storage(const df_iterator_storage &S) : Visited(S.Visited) {}
|
||||
SetType &Visited;
|
||||
};
|
||||
|
||||
|
||||
// Generic Depth First Iterator
|
||||
template<class GraphT, class SetType =
|
||||
std::set<typename GraphTraits<GraphT>::NodeType*>,
|
||||
bool ExtStorage = false, class GT = GraphTraits<GraphT> >
|
||||
class df_iterator : public forward_iterator<typename GT::NodeType, ptrdiff_t>,
|
||||
public df_iterator_storage<SetType, ExtStorage> {
|
||||
typedef forward_iterator<typename GT::NodeType, ptrdiff_t> super;
|
||||
|
||||
typedef typename GT::NodeType NodeType;
|
||||
typedef typename GT::ChildIteratorType ChildItTy;
|
||||
|
||||
// VisitStack - Used to maintain the ordering. Top = current block
|
||||
// First element is node pointer, second is the 'next child' to visit
|
||||
std::vector<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||
private:
|
||||
inline df_iterator(NodeType *Node) {
|
||||
this->Visited.insert(Node);
|
||||
VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node)));
|
||||
}
|
||||
inline df_iterator() { /* End is when stack is empty */ }
|
||||
|
||||
inline df_iterator(NodeType *Node, SetType &S)
|
||||
: df_iterator_storage<SetType, ExtStorage>(S) {
|
||||
if (!S.count(Node)) {
|
||||
this->Visited.insert(Node);
|
||||
VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node)));
|
||||
}
|
||||
}
|
||||
inline df_iterator(SetType &S)
|
||||
: df_iterator_storage<SetType, ExtStorage>(S) {
|
||||
// End is when stack is empty
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename super::pointer pointer;
|
||||
typedef df_iterator<GraphT, SetType, ExtStorage, GT> _Self;
|
||||
|
||||
// Provide static begin and end methods as our public "constructors"
|
||||
static inline _Self begin(GraphT G) {
|
||||
return _Self(GT::getEntryNode(G));
|
||||
}
|
||||
static inline _Self end(GraphT G) { return _Self(); }
|
||||
|
||||
// Static begin and end methods as our public ctors for external iterators
|
||||
static inline _Self begin(GraphT G, SetType &S) {
|
||||
return _Self(GT::getEntryNode(G), S);
|
||||
}
|
||||
static inline _Self end(GraphT G, SetType &S) { return _Self(S); }
|
||||
|
||||
inline bool operator==(const _Self& x) const {
|
||||
return VisitStack.size() == x.VisitStack.size() &&
|
||||
VisitStack == x.VisitStack;
|
||||
}
|
||||
inline bool operator!=(const _Self& x) const { return !operator==(x); }
|
||||
|
||||
inline pointer operator*() const {
|
||||
return VisitStack.back().first;
|
||||
}
|
||||
|
||||
// This is a nonstandard operator-> that dereferences the pointer an extra
|
||||
// time... so that you can actually call methods ON the Node, because
|
||||
// the contained type is a pointer. This allows BBIt->getTerminator() f.e.
|
||||
//
|
||||
inline NodeType *operator->() const { return operator*(); }
|
||||
|
||||
inline _Self& operator++() { // Preincrement
|
||||
do {
|
||||
std::pair<NodeType *, ChildItTy> &Top = VisitStack.back();
|
||||
NodeType *Node = Top.first;
|
||||
ChildItTy &It = Top.second;
|
||||
|
||||
while (It != GT::child_end(Node)) {
|
||||
NodeType *Next = *It++;
|
||||
if (!this->Visited.count(Next)) { // Has our next sibling been visited?
|
||||
// No, do it now.
|
||||
this->Visited.insert(Next);
|
||||
VisitStack.push_back(std::make_pair(Next, GT::child_begin(Next)));
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Oops, ran out of successors... go up a level on the stack.
|
||||
VisitStack.pop_back();
|
||||
} while (!VisitStack.empty());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline _Self operator++(int) { // Postincrement
|
||||
_Self tmp = *this; ++*this; return tmp;
|
||||
}
|
||||
|
||||
// nodeVisited - return true if this iterator has already visited the
|
||||
// specified node. This is public, and will probably be used to iterate over
|
||||
// nodes that a depth first iteration did not find: ie unreachable nodes.
|
||||
//
|
||||
inline bool nodeVisited(NodeType *Node) const {
|
||||
return this->Visited.count(Node) != 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Provide global constructors that automatically figure out correct types...
|
||||
//
|
||||
template <class T>
|
||||
df_iterator<T> df_begin(T G) {
|
||||
return df_iterator<T>::begin(G);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
df_iterator<T> df_end(T G) {
|
||||
return df_iterator<T>::end(G);
|
||||
}
|
||||
|
||||
// Provide global definitions of external depth first iterators...
|
||||
template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeType*> >
|
||||
struct df_ext_iterator : public df_iterator<T, SetTy, true> {
|
||||
df_ext_iterator(const df_iterator<T, SetTy, true> &V)
|
||||
: df_iterator<T, SetTy, true>(V) {}
|
||||
};
|
||||
|
||||
template <class T, class SetTy>
|
||||
df_ext_iterator<T, SetTy> df_ext_begin(T G, SetTy &S) {
|
||||
return df_ext_iterator<T, SetTy>::begin(G, S);
|
||||
}
|
||||
|
||||
template <class T, class SetTy>
|
||||
df_ext_iterator<T, SetTy> df_ext_end(T G, SetTy &S) {
|
||||
return df_ext_iterator<T, SetTy>::end(G, S);
|
||||
}
|
||||
|
||||
|
||||
// Provide global definitions of inverse depth first iterators...
|
||||
template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeType*>,
|
||||
bool External = false>
|
||||
struct idf_iterator : public df_iterator<Inverse<T>, SetTy, External> {
|
||||
idf_iterator(const df_iterator<Inverse<T>, SetTy, External> &V)
|
||||
: df_iterator<Inverse<T>, SetTy, External>(V) {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
idf_iterator<T> idf_begin(T G) {
|
||||
return idf_iterator<T>::begin(G);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
idf_iterator<T> idf_end(T G){
|
||||
return idf_iterator<T>::end(G);
|
||||
}
|
||||
|
||||
// Provide global definitions of external inverse depth first iterators...
|
||||
template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeType*> >
|
||||
struct idf_ext_iterator : public idf_iterator<T, SetTy, true> {
|
||||
idf_ext_iterator(const idf_iterator<T, SetTy, true> &V)
|
||||
: idf_iterator<T, SetTy, true>(V) {}
|
||||
idf_ext_iterator(const df_iterator<Inverse<T>, SetTy, true> &V)
|
||||
: idf_iterator<T, SetTy, true>(V) {}
|
||||
};
|
||||
|
||||
template <class T, class SetTy>
|
||||
idf_ext_iterator<T, SetTy> idf_ext_begin(T G, SetTy &S) {
|
||||
return idf_ext_iterator<T, SetTy>::begin(G, S);
|
||||
}
|
||||
|
||||
template <class T, class SetTy>
|
||||
idf_ext_iterator<T, SetTy> idf_ext_end(T G, SetTy &S) {
|
||||
return idf_ext_iterator<T, SetTy>::end(G, S);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
//===-- DynamicLinker.h - System-indep. DynamicLinker interface -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Lightweight interface to dynamic library linking and loading, and dynamic
|
||||
// symbol lookup functionality, in whatever form the operating system
|
||||
// provides it.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DYNAMICLINKER_H
|
||||
#define SUPPORT_DYNAMICLINKER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// LinkDynamicObject - Load the named file as a dynamic library
|
||||
/// and link it with the currently running process. Returns false
|
||||
/// on success, true if there is an error (and sets ErrorMessage
|
||||
/// if it is not NULL). Analogous to dlopen().
|
||||
///
|
||||
bool LinkDynamicObject (const char *filename, std::string *ErrorMessage);
|
||||
|
||||
/// GetAddressOfSymbol - Returns the address of the named symbol in
|
||||
/// the currently running process, as reported by the dynamic linker,
|
||||
/// or NULL if the symbol does not exist or some other error has
|
||||
/// occurred.
|
||||
///
|
||||
void *GetAddressOfSymbol (const char *symbolName);
|
||||
void *GetAddressOfSymbol (const std::string &symbolName);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif // SUPPORT_DYNAMICLINKER_H
|
@ -1,295 +0,0 @@
|
||||
//===-- Support/ELF.h - ELF constants and data structures -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This header contains common, non-processor-specific data structures and
|
||||
// constants for the ELF file format.
|
||||
//
|
||||
// The details of the ELF32 bits in this file are largely based on
|
||||
// the Tool Interface Standard (TIS) Executable and Linking Format
|
||||
// (ELF) Specification Version 1.2, May 1995. The ELF64 stuff is not
|
||||
// standardized, as far as I can tell. It was largely based on information
|
||||
// I found in OpenBSD header files.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Support/DataTypes.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace ELF {
|
||||
|
||||
typedef uint32_t Elf32_Addr; // Program address
|
||||
typedef uint16_t Elf32_Half;
|
||||
typedef uint32_t Elf32_Off; // File offset
|
||||
typedef int32_t Elf32_Sword;
|
||||
typedef uint32_t Elf32_Word;
|
||||
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef uint64_t Elf64_Off;
|
||||
typedef int32_t Elf64_Shalf;
|
||||
typedef int32_t Elf64_Sword;
|
||||
typedef uint32_t Elf64_Word;
|
||||
typedef int64_t Elf64_Sxword;
|
||||
typedef uint64_t Elf64_Xword;
|
||||
typedef uint32_t Elf64_Half;
|
||||
typedef uint16_t Elf64_Quarter;
|
||||
|
||||
// Object file magic string.
|
||||
static const char ElfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
|
||||
|
||||
struct Elf32_Ehdr {
|
||||
unsigned char e_ident[16]; // ELF Identification bytes
|
||||
Elf32_Half e_type; // Type of file (see ET_* below)
|
||||
Elf32_Half e_machine; // Required architecture for this file (see EM_*)
|
||||
Elf32_Word e_version; // Must be equal to 1
|
||||
Elf32_Addr e_entry; // Address to jump to in order to start program
|
||||
Elf32_Off e_phoff; // Program header table's file offset, in bytes
|
||||
Elf32_Off e_shoff; // Section header table's file offset, in bytes
|
||||
Elf32_Word e_flags; // Processor-specific flags
|
||||
Elf32_Half e_ehsize; // Size of ELF header, in bytes
|
||||
Elf32_Half e_phentsize; // Size of an entry in the program header table
|
||||
Elf32_Half e_phnum; // Number of entries in the program header table
|
||||
Elf32_Half e_shentsize; // Size of an entry in the section header table
|
||||
Elf32_Half e_shnum; // Number of entries in the section header table
|
||||
Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table
|
||||
bool checkMagic () const {
|
||||
return (memcmp (e_ident, ElfMagic, strlen (ElfMagic))) == 0;
|
||||
}
|
||||
unsigned char getFileClass () const { return e_ident[4]; }
|
||||
unsigned char getDataEncoding () { return e_ident[5]; }
|
||||
};
|
||||
|
||||
// 64-bit ELF header. Fields are the same as for ELF32, but with different
|
||||
// types (see above).
|
||||
struct Elf64_Ehdr {
|
||||
unsigned char e_ident[16];
|
||||
Elf64_Quarter e_type;
|
||||
Elf64_Quarter e_machine;
|
||||
Elf64_Half e_version;
|
||||
Elf64_Addr e_entry;
|
||||
Elf64_Off e_phoff;
|
||||
Elf64_Off e_shoff;
|
||||
Elf64_Half e_flags;
|
||||
Elf64_Quarter e_ehsize;
|
||||
Elf64_Quarter e_phentsize;
|
||||
Elf64_Quarter e_phnum;
|
||||
Elf64_Quarter e_shentsize;
|
||||
Elf64_Quarter e_shnum;
|
||||
Elf64_Quarter e_shstrndx;
|
||||
};
|
||||
|
||||
// File types
|
||||
enum {
|
||||
ET_NONE = 0, // No file type
|
||||
ET_REL = 1, // Relocatable file
|
||||
ET_EXEC = 2, // Executable file
|
||||
ET_DYN = 3, // Shared object file
|
||||
ET_CORE = 4, // Core file
|
||||
ET_LOPROC = 0xff00, // Beginning of processor-specific codes
|
||||
ET_HIPROC = 0xffff // Processor-specific
|
||||
};
|
||||
|
||||
// Machine architectures
|
||||
enum {
|
||||
EM_NONE = 0, // No machine
|
||||
EM_M32 = 1, // AT&T WE 32100
|
||||
EM_SPARC = 2, // SPARC
|
||||
EM_386 = 3, // Intel 386
|
||||
EM_68K = 4, // Motorola 68000
|
||||
EM_88K = 5, // Motorola 88000
|
||||
EM_486 = 6, // Intel 486 (deprecated)
|
||||
EM_860 = 7, // Intel 80860
|
||||
EM_MIPS = 8, // MIPS R3000
|
||||
EM_PPC = 20, // PowerPC
|
||||
EM_ARM = 40, // ARM
|
||||
EM_ALPHA = 41, // DEC Alpha
|
||||
EM_SPARCV9 = 43 // SPARC V9
|
||||
};
|
||||
|
||||
// Object file classes.
|
||||
enum {
|
||||
ELFCLASS32 = 1, // 32-bit object file
|
||||
ELFCLASS64 = 2 // 64-bit object file
|
||||
};
|
||||
|
||||
// Object file byte orderings.
|
||||
enum {
|
||||
ELFDATA2LSB = 1, // Little-endian object file
|
||||
ELFDATA2MSB = 2 // Big-endian object file
|
||||
};
|
||||
|
||||
// Section header.
|
||||
struct Elf32_Shdr {
|
||||
Elf32_Word sh_name; // Section name (index into string table)
|
||||
Elf32_Word sh_type; // Section type (SHT_*)
|
||||
Elf32_Word sh_flags; // Section flags (SHF_*)
|
||||
Elf32_Addr sh_addr; // Address where section is to be loaded
|
||||
Elf32_Off sh_offset; // File offset of section data, in bytes
|
||||
Elf32_Word sh_size; // Size of section, in bytes
|
||||
Elf32_Word sh_link; // Section type-specific header table index link
|
||||
Elf32_Word sh_info; // Section type-specific extra information
|
||||
Elf32_Word sh_addralign; // Section address alignment
|
||||
Elf32_Word sh_entsize; // Size of records contained within the section
|
||||
};
|
||||
|
||||
// Section header for ELF64 - same fields as ELF32, different types.
|
||||
struct Elf64_Shdr {
|
||||
Elf64_Half sh_name;
|
||||
Elf64_Half sh_type;
|
||||
Elf64_Xword sh_flags;
|
||||
Elf64_Addr sh_addr;
|
||||
Elf64_Off sh_offset;
|
||||
Elf64_Xword sh_size;
|
||||
Elf64_Half sh_link;
|
||||
Elf64_Half sh_info;
|
||||
Elf64_Xword sh_addralign;
|
||||
Elf64_Xword sh_entsize;
|
||||
};
|
||||
|
||||
// Special section indices.
|
||||
enum {
|
||||
SHN_UNDEF = 0, // Undefined, missing, irrelevant, or meaningless
|
||||
SHN_LORESERVE = 0xff00, // Lowest reserved index
|
||||
SHN_LOPROC = 0xff00, // Lowest processor-specific index
|
||||
SHN_HIPROC = 0xff1f, // Highest processor-specific index
|
||||
SHN_ABS = 0xfff1, // Symbol has absolute value; does not need relocation
|
||||
SHN_COMMON = 0xfff2, // FORTRAN COMMON or C external global variables
|
||||
SHN_HIRESERVE = 0xffff // Highest reserved index
|
||||
};
|
||||
|
||||
// Section types.
|
||||
enum {
|
||||
SHT_NULL = 0, // No associated section (inactive entry).
|
||||
SHT_PROGBITS = 1, // Program-defined contents.
|
||||
SHT_SYMTAB = 2, // Symbol table.
|
||||
SHT_STRTAB = 3, // String table.
|
||||
SHT_RELA = 4, // Relocation entries; explicit addends.
|
||||
SHT_HASH = 5, // Symbol hash table.
|
||||
SHT_DYNAMIC = 6, // Information for dynamic linking.
|
||||
SHT_NOTE = 7, // Information about the file.
|
||||
SHT_NOBITS = 8, // Data occupies no space in the file.
|
||||
SHT_REL = 9, // Relocation entries; no explicit addends.
|
||||
SHT_SHLIB = 10, // Reserved.
|
||||
SHT_DYNSYM = 11, // Symbol table.
|
||||
SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type.
|
||||
SHT_HIPROC = 0x7fffffff, // Highest processor architecture-specific type.
|
||||
SHT_LOUSER = 0x80000000, // Lowest type reserved for applications.
|
||||
SHT_HIUSER = 0xffffffff // Highest type reserved for applications.
|
||||
};
|
||||
|
||||
// Section flags.
|
||||
enum {
|
||||
SHF_WRITE = 0x1, // Section data should be writable during execution.
|
||||
SHF_ALLOC = 0x2, // Section occupies memory during program execution.
|
||||
SHF_EXECINSTR = 0x4, // Section contains executable machine instructions.
|
||||
SHF_MASKPROC = 0xf0000000 // Bits indicating processor-specific flags.
|
||||
};
|
||||
|
||||
// Symbol table entries.
|
||||
struct Elf32_Sym {
|
||||
Elf32_Word st_name; // Symbol name (index into string table)
|
||||
Elf32_Addr st_value; // Value or address associated with the symbol
|
||||
Elf32_Word st_size; // Size of the symbol
|
||||
unsigned char st_info; // Symbol's type and binding attributes
|
||||
unsigned char st_other; // Must be zero; reserved
|
||||
Elf32_Half st_shndx; // Which section (header table index) it's defined in
|
||||
|
||||
// These accessors and mutators correspond to the ELF32_ST_BIND,
|
||||
// ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
|
||||
unsigned char getBinding () const { return st_info >> 4; }
|
||||
unsigned char getType () const { return st_info & 0x0f; }
|
||||
void setBinding (unsigned char b) { setBindingAndType (b, getType ()); }
|
||||
void setType (unsigned char t) { setBindingAndType (getBinding (), t); }
|
||||
void setBindingAndType (unsigned char b, unsigned char t) {
|
||||
st_info = (b << 4) + (t & 0x0f);
|
||||
}
|
||||
};
|
||||
|
||||
// Symbol bindings.
|
||||
enum {
|
||||
STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def
|
||||
STB_GLOBAL = 1, // Global symbol, visible to all object files being combined
|
||||
STB_WEAK = 2, // Weak symbol, like global but lower-precedence
|
||||
STB_LOPROC = 13, // Lowest processor-specific binding type
|
||||
STB_HIPROC = 15 // Highest processor-specific binding type
|
||||
};
|
||||
|
||||
// Symbol types.
|
||||
enum {
|
||||
STT_NOTYPE = 0, // Symbol's type is not specified
|
||||
STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.)
|
||||
STT_FUNC = 2, // Symbol is executable code (function, etc.)
|
||||
STT_SECTION = 3, // Symbol refers to a section
|
||||
STT_FILE = 4, // Local, absolute symbol that refers to a file
|
||||
STT_LOPROC = 13, // Lowest processor-specific symbol type
|
||||
STT_HIPROC = 15 // Highest processor-specific symbol type
|
||||
};
|
||||
|
||||
// Relocation entry, without explicit addend.
|
||||
struct Elf32_Rel {
|
||||
Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
|
||||
Elf32_Word r_info; // Symbol table index and type of relocation to apply
|
||||
|
||||
// These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
|
||||
// and ELF32_R_INFO macros defined in the ELF specification:
|
||||
Elf32_Word getSymbol () const { return (r_info >> 8); }
|
||||
unsigned char getType () const { return (unsigned char) (r_info & 0x0ff); }
|
||||
void setSymbol (Elf32_Word s) { setSymbolAndType (s, getType ()); }
|
||||
void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); }
|
||||
void setSymbolAndType (Elf32_Word s, unsigned char t) {
|
||||
r_info = (s << 8) + t;
|
||||
};
|
||||
};
|
||||
|
||||
// Relocation entry with explicit addend.
|
||||
struct Elf32_Rela {
|
||||
Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
|
||||
Elf32_Word r_info; // Symbol table index and type of relocation to apply
|
||||
Elf32_Sword r_addend; // Compute value for relocatable field by adding this
|
||||
|
||||
// These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
|
||||
// and ELF32_R_INFO macros defined in the ELF specification:
|
||||
Elf32_Word getSymbol () const { return (r_info >> 8); }
|
||||
unsigned char getType () const { return (unsigned char) (r_info & 0x0ff); }
|
||||
void setSymbol (Elf32_Word s) { setSymbolAndType (s, getType ()); }
|
||||
void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); }
|
||||
void setSymbolAndType (Elf32_Word s, unsigned char t) {
|
||||
r_info = (s << 8) + t;
|
||||
};
|
||||
};
|
||||
|
||||
// Program header.
|
||||
struct Elf32_Phdr {
|
||||
Elf32_Word p_type; // Type of segment
|
||||
Elf32_Off p_offset; // File offset where segment is located, in bytes
|
||||
Elf32_Addr p_vaddr; // Virtual address of beginning of segment
|
||||
Elf32_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
|
||||
Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
|
||||
Elf32_Word p_memsz; // Num. of bytes in mem image of segment (may be zero)
|
||||
Elf32_Word p_flags; // Segment flags
|
||||
Elf32_Word p_align; // Segment alignment constraint
|
||||
};
|
||||
|
||||
enum {
|
||||
PT_NULL = 0, // Unused segment.
|
||||
PT_LOAD = 1, // Loadable segment.
|
||||
PT_DYNAMIC = 2, // Dynamic linking information.
|
||||
PT_INTERP = 3, // Interpreter pathname.
|
||||
PT_NOTE = 4, // Auxiliary information.
|
||||
PT_SHLIB = 5, // Reserved.
|
||||
PT_PHDR = 6, // The program header table itself.
|
||||
PT_LOPROC = 0x70000000, // Lowest processor-specific program hdr entry type.
|
||||
PT_HIPROC = 0x7fffffff // Highest processor-specific program hdr entry type.
|
||||
};
|
||||
|
||||
} // end namespace ELF
|
||||
|
||||
} // end namespace llvm
|
@ -1,116 +0,0 @@
|
||||
//===-- Support/EquivalenceClasses.h ----------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Generic implementation of equivalence classes and implementation of
|
||||
// union-find algorithms A not-so-fancy implementation: 2 level tree i.e root
|
||||
// and one more level Overhead of a union = size of the equivalence class being
|
||||
// attached Overhead of a find = 1.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_EQUIVALENCECLASSES_H
|
||||
#define SUPPORT_EQUIVALENCECLASSES_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template <class ElemTy>
|
||||
class EquivalenceClasses {
|
||||
// Maps each element to the element that is the leader of its
|
||||
// equivalence class.
|
||||
std::map<ElemTy, ElemTy> Elem2LeaderMap;
|
||||
|
||||
// Maintains the set of leaders
|
||||
std::set<ElemTy> LeaderSet;
|
||||
|
||||
// Caches the equivalence class for each leader
|
||||
std::map<ElemTy, std::set<ElemTy> > LeaderToEqClassMap;
|
||||
|
||||
// Make Element2 the leader of the union of classes Element1 and Element2
|
||||
// Element1 and Element2 are presumed to be leaders of their respective
|
||||
// equivalence classes.
|
||||
void attach(ElemTy Element1, ElemTy Element2) {
|
||||
for (typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||
Elem2LeaderMap.begin(), ElemE = Elem2LeaderMap.end();
|
||||
ElemI != ElemE; ++ElemI) {
|
||||
if (ElemI->second == Element1)
|
||||
Elem2LeaderMap[ElemI->first] = Element2;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
// If an element has not yet in any class, make it a separate new class.
|
||||
// Return the leader of the class containing the element.
|
||||
ElemTy addElement (ElemTy NewElement) {
|
||||
typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||
Elem2LeaderMap.find(NewElement);
|
||||
if (ElemI == Elem2LeaderMap.end()) {
|
||||
Elem2LeaderMap[NewElement] = NewElement;
|
||||
LeaderSet.insert(NewElement);
|
||||
return NewElement;
|
||||
}
|
||||
else
|
||||
return ElemI->second;
|
||||
}
|
||||
|
||||
ElemTy findClass(ElemTy Element) const {
|
||||
typename std::map<ElemTy, ElemTy>::const_iterator I =
|
||||
Elem2LeaderMap.find(Element);
|
||||
return (I == Elem2LeaderMap.end())? (ElemTy) 0 : I->second;
|
||||
}
|
||||
|
||||
/// Attach the set with Element1 to the set with Element2 adding Element1 and
|
||||
/// Element2 to the set of equivalence classes if they are not there already.
|
||||
/// Implication: Make Element1 the element in the smaller set.
|
||||
/// Take Leader[Element1] out of the set of leaders.
|
||||
void unionSetsWith(ElemTy Element1, ElemTy Element2) {
|
||||
// If either Element1 or Element2 does not already exist, include it
|
||||
const ElemTy& leader1 = addElement(Element1);
|
||||
const ElemTy& leader2 = addElement(Element2);
|
||||
assert(leader1 != (ElemTy) 0 && leader2 != (ElemTy) 0);
|
||||
if (leader1 != leader2) {
|
||||
attach(leader1, leader2);
|
||||
LeaderSet.erase(leader1);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a vector containing all the elements in the equivalence class
|
||||
// including Element1
|
||||
const std::set<ElemTy> & getEqClass(ElemTy Element1) {
|
||||
assert(Elem2LeaderMap.find(Element1) != Elem2LeaderMap.end());
|
||||
const ElemTy classLeader = Elem2LeaderMap[Element1];
|
||||
|
||||
std::set<ElemTy> & EqClass = LeaderToEqClassMap[classLeader];
|
||||
|
||||
// If the EqClass vector is empty, it has not been computed yet: do it now
|
||||
if (EqClass.empty()) {
|
||||
for (typename std::map<ElemTy, ElemTy>::iterator
|
||||
ElemI = Elem2LeaderMap.begin(), ElemE = Elem2LeaderMap.end();
|
||||
ElemI != ElemE; ++ElemI)
|
||||
if (ElemI->second == classLeader)
|
||||
EqClass.insert(ElemI->first);
|
||||
assert(! EqClass.empty()); // must at least include the leader
|
||||
}
|
||||
|
||||
return EqClass;
|
||||
}
|
||||
|
||||
std::set<ElemTy>& getLeaderSet() { return LeaderSet; }
|
||||
const std::set<ElemTy>& getLeaderSet() const { return LeaderSet; }
|
||||
|
||||
std::map<ElemTy, ElemTy>& getLeaderMap() { return Elem2LeaderMap;}
|
||||
const std::map<ElemTy, ElemTy>& getLeaderMap() const { return Elem2LeaderMap;}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,170 +0,0 @@
|
||||
//===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a family of utility functions which are useful for doing
|
||||
// various things with files.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_FILEUTILITIES_H
|
||||
#define SUPPORT_FILEUTILITIES_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
|
||||
/// name a readable file.
|
||||
///
|
||||
bool CheckMagic (const std::string &FN, const std::string &Magic);
|
||||
|
||||
/// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
|
||||
/// archive. The file named FN must exist.
|
||||
///
|
||||
bool IsArchive (const std::string &FN);
|
||||
|
||||
/// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
|
||||
/// bytecode file. The file named FN must exist.
|
||||
///
|
||||
bool IsBytecode (const std::string &FN);
|
||||
|
||||
/// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
|
||||
/// object with an ELF header. The file named FN must exist.
|
||||
///
|
||||
bool IsSharedObject(const std::string &FN);
|
||||
|
||||
/// FileOpenable - Returns true IFF Filename names an existing regular file
|
||||
/// which we can successfully open.
|
||||
///
|
||||
bool FileOpenable(const std::string &Filename);
|
||||
|
||||
/// DiffFiles - Compare the two files specified, returning true if they are
|
||||
/// different or if there is a file error. If you specify a string to fill in
|
||||
/// for the error option, it will set the string to an error message if an error
|
||||
/// occurs, allowing the caller to distinguish between a failed diff and a file
|
||||
/// system error.
|
||||
///
|
||||
bool DiffFiles(const std::string &FileA, const std::string &FileB,
|
||||
std::string *Error = 0);
|
||||
|
||||
/// CopyFile - Copy the specified source file to the specified destination,
|
||||
/// overwriting destination if it exists. This returns true on failure.
|
||||
///
|
||||
bool CopyFile(const std::string &Dest, const std::string &Src);
|
||||
|
||||
/// MoveFileOverIfUpdated - If the file specified by New is different than Old,
|
||||
/// or if Old does not exist, move the New file over the Old file. Otherwise,
|
||||
/// remove the New file.
|
||||
///
|
||||
void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
|
||||
|
||||
/// removeFile - Delete the specified file.
|
||||
///
|
||||
void removeFile(const std::string &Filename);
|
||||
|
||||
/// getUniqueFilename - Return a filename with the specified prefix. If the
|
||||
/// file does not exist yet, return it, otherwise add a suffix to make it
|
||||
/// unique.
|
||||
///
|
||||
std::string getUniqueFilename(const std::string &FilenameBase);
|
||||
|
||||
/// MakeFileExecutable - This method turns on whatever access attributes are
|
||||
/// needed to make the specified file executable. It returns true on success.
|
||||
/// In case of failure, the file's access attributes are unspecified.
|
||||
///
|
||||
bool MakeFileExecutable(const std::string &Filename);
|
||||
|
||||
/// MakeFileReadable - This method turns on whatever access attributes are
|
||||
/// needed to make the specified file readable. It returns true on success.
|
||||
/// In case of failure, the file's access attributes are unspecified.
|
||||
///
|
||||
bool MakeFileReadable(const std::string &Filename);
|
||||
|
||||
/// getFileSize - Return the size of the specified file in bytes, or -1 if the
|
||||
/// file cannot be read or does not exist.
|
||||
long long getFileSize(const std::string &Filename);
|
||||
|
||||
|
||||
/// getFileTimestamp - Get the last modified time for the specified file in an
|
||||
/// unspecified format. This is useful to allow checking to see if a file was
|
||||
/// updated since that last time the timestampt was aquired. If the file does
|
||||
/// not exist or there is an error getting the time-stamp, zero is returned.
|
||||
unsigned long long getFileTimestamp(const std::string &Filename);
|
||||
|
||||
/// ReadFileIntoAddressSpace - Attempt to map the specific file into the
|
||||
/// address space of the current process for reading. If this succeeds,
|
||||
/// return the address of the buffer and the length of the file mapped. On
|
||||
/// failure, return null.
|
||||
void *ReadFileIntoAddressSpace(const std::string &Filename, unsigned &Length);
|
||||
|
||||
/// UnmapFileFromAddressSpace - Remove the specified file from the current
|
||||
/// address space.
|
||||
void UnmapFileFromAddressSpace(void *Buffer, unsigned Length);
|
||||
|
||||
|
||||
/// FDHandle - Simple handle class to make sure a file descriptor gets closed
|
||||
/// when the object is destroyed. This handle acts similarly to an
|
||||
/// std::auto_ptr, in that the copy constructor and assignment operators
|
||||
/// transfer ownership of the handle. This means that FDHandle's do not have
|
||||
/// value semantics.
|
||||
///
|
||||
class FDHandle {
|
||||
int FD;
|
||||
public:
|
||||
FDHandle() : FD(-1) {}
|
||||
FDHandle(int fd) : FD(fd) {}
|
||||
FDHandle(FDHandle &RHS) : FD(RHS.FD) {
|
||||
RHS.FD = -1; // Transfer ownership
|
||||
}
|
||||
|
||||
~FDHandle() throw();
|
||||
|
||||
/// get - Get the current file descriptor, without releasing ownership of it.
|
||||
int get() const { return FD; }
|
||||
operator int() const { return FD; }
|
||||
|
||||
FDHandle &operator=(int fd) throw();
|
||||
|
||||
FDHandle &operator=(FDHandle &RHS) {
|
||||
int fd = RHS.FD;
|
||||
RHS.FD = -1; // Transfer ownership
|
||||
return operator=(fd);
|
||||
}
|
||||
|
||||
/// release - Take ownership of the file descriptor away from the FDHandle
|
||||
/// object, so that the file is not closed when the FDHandle is destroyed.
|
||||
int release() {
|
||||
int Ret = FD;
|
||||
FD = -1;
|
||||
return Ret;
|
||||
}
|
||||
};
|
||||
|
||||
/// FileRemover - This class is a simple object meant to be stack allocated.
|
||||
/// If an exception is thrown from a region, the object removes the filename
|
||||
/// specified (if deleteIt is true).
|
||||
///
|
||||
class FileRemover {
|
||||
std::string Filename;
|
||||
bool DeleteIt;
|
||||
public:
|
||||
FileRemover(const std::string &filename, bool deleteIt = true)
|
||||
: Filename(filename), DeleteIt(deleteIt) {}
|
||||
|
||||
~FileRemover() {
|
||||
if (DeleteIt) removeFile(Filename);
|
||||
}
|
||||
|
||||
/// releaseFile - Take ownership of the file away from the FileRemover so it
|
||||
/// will not be removed when the object is destroyed.
|
||||
void releaseFile() { DeleteIt = false; }
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,83 +0,0 @@
|
||||
//===-- Support/GraphTraits.h - Graph traits template -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the little GraphTraits<X> template class that should be
|
||||
// specialized by classes that want to be iteratable by generic graph iterators.
|
||||
//
|
||||
// This file also defines the marker class Inverse that is used to iterate over
|
||||
// graphs in a graph defined, inverse ordering...
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_GRAPHTRAITS_H
|
||||
#define SUPPORT_GRAPHTRAITS_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// GraphTraits - This class should be specialized by different graph types...
|
||||
// which is why the default version is empty.
|
||||
//
|
||||
template<class GraphType>
|
||||
struct GraphTraits {
|
||||
// Elements to provide:
|
||||
|
||||
// typedef NodeType - Type of Node in the graph
|
||||
// typedef ChildIteratorType - Type used to iterate over children in graph
|
||||
|
||||
// static NodeType *getEntryNode(GraphType *)
|
||||
// Return the entry node of the graph
|
||||
|
||||
// static ChildIteratorType child_begin(NodeType *)
|
||||
// static ChildIteratorType child_end (NodeType *)
|
||||
// Return iterators that point to the beginning and ending of the child
|
||||
// node list for the specified node.
|
||||
//
|
||||
|
||||
|
||||
// typedef ...iterator nodes_iterator;
|
||||
// static nodes_iterator nodes_begin(GraphType *G)
|
||||
// static nodes_iterator nodes_end (GraphType *G)
|
||||
//
|
||||
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
|
||||
|
||||
|
||||
// If anyone tries to use this class without having an appropriate
|
||||
// specialization, make an error. If you get this error, it's because you
|
||||
// need to include the appropriate specialization of GraphTraits<> for your
|
||||
// graph, or you need to define it for a new graph type. Either that or
|
||||
// your argument to XXX_begin(...) is unknown or needs to have the proper .h
|
||||
// file #include'd.
|
||||
//
|
||||
typedef typename GraphType::UnknownGraphTypeError NodeType;
|
||||
};
|
||||
|
||||
|
||||
// Inverse - This class is used as a little marker class to tell the graph
|
||||
// iterator to iterate over the graph in a graph defined "Inverse" ordering.
|
||||
// Not all graphs define an inverse ordering, and if they do, it depends on
|
||||
// the graph exactly what that is. Here's an example of usage with the
|
||||
// df_iterator:
|
||||
//
|
||||
// idf_iterator<Method*> I = idf_begin(M), E = idf_end(M);
|
||||
// for (; I != E; ++I) { ... }
|
||||
//
|
||||
// Which is equivalent to:
|
||||
// df_iterator<Inverse<Method*> > I = idf_begin(M), E = idf_end(M);
|
||||
// for (; I != E; ++I) { ... }
|
||||
//
|
||||
template <class GraphType>
|
||||
struct Inverse {
|
||||
GraphType &Graph;
|
||||
|
||||
inline Inverse(GraphType &G) : Graph(G) {}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,216 +0,0 @@
|
||||
//===-- Support/GraphWriter.h - Write a graph to a .dot file ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a simple interface that can be used to print out generic
|
||||
// LLVM graphs to ".dot" files. "dot" is a tool that is part of the AT&T
|
||||
// graphviz package (http://www.research.att.com/sw/tools/graphviz/) which can
|
||||
// be used to turn the files output by this interface into a variety of
|
||||
// different graphics formats.
|
||||
//
|
||||
// Graphs do not need to implement any interface past what is already required
|
||||
// by the GraphTraits template, but they can choose to implement specializations
|
||||
// of the DOTGraphTraits template if they want to customize the graphs output in
|
||||
// any way.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_GRAPHWRITER_H
|
||||
#define SUPPORT_GRAPHWRITER_H
|
||||
|
||||
#include "Support/DOTGraphTraits.h"
|
||||
#include "Support/GraphTraits.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace DOT { // Private functions...
|
||||
inline std::string EscapeString(const std::string &Label) {
|
||||
std::string Str(Label);
|
||||
for (unsigned i = 0; i != Str.length(); ++i)
|
||||
switch (Str[i]) {
|
||||
case '\n':
|
||||
Str.insert(Str.begin()+i, '\\'); // Escape character...
|
||||
++i;
|
||||
Str[i] = 'n';
|
||||
break;
|
||||
case '\t':
|
||||
Str.insert(Str.begin()+i, ' '); // Convert to two spaces
|
||||
++i;
|
||||
Str[i] = ' ';
|
||||
break;
|
||||
case '\\':
|
||||
if (i+1 != Str.length() && Str[i+1] == 'l')
|
||||
break; // don't disturb \l
|
||||
case '{': case '}':
|
||||
case '<': case '>':
|
||||
case '"':
|
||||
Str.insert(Str.begin()+i, '\\'); // Escape character...
|
||||
++i; // don't infinite loop
|
||||
break;
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename GraphType>
|
||||
class GraphWriter {
|
||||
std::ostream &O;
|
||||
const GraphType &G;
|
||||
|
||||
typedef DOTGraphTraits<GraphType> DOTTraits;
|
||||
typedef GraphTraits<GraphType> GTraits;
|
||||
typedef typename GTraits::NodeType NodeType;
|
||||
typedef typename GTraits::nodes_iterator node_iterator;
|
||||
typedef typename GTraits::ChildIteratorType child_iterator;
|
||||
public:
|
||||
GraphWriter(std::ostream &o, const GraphType &g) : O(o), G(g) {}
|
||||
|
||||
void writeHeader(const std::string &Name) {
|
||||
if (Name.empty())
|
||||
O << "digraph foo {\n"; // Graph name doesn't matter
|
||||
else
|
||||
O << "digraph " << Name << " {\n";
|
||||
|
||||
std::string GraphName = DOTTraits::getGraphName(G);
|
||||
if (!GraphName.empty())
|
||||
O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n";
|
||||
O << DOTTraits::getGraphProperties(G);
|
||||
O << "\n";
|
||||
}
|
||||
|
||||
void writeFooter() {
|
||||
// Finish off the graph
|
||||
O << "}\n";
|
||||
}
|
||||
|
||||
void writeNodes() {
|
||||
// Loop over the graph, printing it out...
|
||||
for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G);
|
||||
I != E; ++I)
|
||||
writeNode(&*I);
|
||||
}
|
||||
|
||||
void writeNode(NodeType *Node) {
|
||||
std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
|
||||
|
||||
O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
|
||||
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
|
||||
O << "label=\"{"
|
||||
<< DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
|
||||
|
||||
// Print out the fields of the current node...
|
||||
child_iterator EI = GTraits::child_begin(Node);
|
||||
child_iterator EE = GTraits::child_end(Node);
|
||||
if (EI != EE) {
|
||||
O << "|{";
|
||||
|
||||
for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) {
|
||||
if (i) O << "|";
|
||||
O << "<g" << i << ">" << DOTTraits::getEdgeSourceLabel(Node, EI);
|
||||
}
|
||||
|
||||
if (EI != EE)
|
||||
O << "|<g64>truncated...";
|
||||
O << "}";
|
||||
}
|
||||
O << "}\"];\n"; // Finish printing the "node" line
|
||||
|
||||
// Output all of the edges now
|
||||
EI = GTraits::child_begin(Node);
|
||||
for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i)
|
||||
writeEdge(Node, i, EI);
|
||||
for (; EI != EE; ++EI)
|
||||
writeEdge(Node, 64, EI);
|
||||
}
|
||||
|
||||
void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {
|
||||
if (NodeType *TargetNode = *EI) {
|
||||
int DestPort = -1;
|
||||
if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) {
|
||||
child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI);
|
||||
|
||||
// Figure out which edge this targets...
|
||||
unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
|
||||
TargetIt);
|
||||
DestPort = static_cast<int>(Offset);
|
||||
}
|
||||
|
||||
emitEdge(reinterpret_cast<const void*>(Node), edgeidx,
|
||||
reinterpret_cast<const void*>(TargetNode), DestPort,
|
||||
DOTTraits::getEdgeAttributes(Node, EI));
|
||||
}
|
||||
}
|
||||
|
||||
/// emitSimpleNode - Outputs a simple (non-record) node
|
||||
void emitSimpleNode(const void *ID, const std::string &Attr,
|
||||
const std::string &Label, unsigned NumEdgeSources = 0,
|
||||
const std::vector<std::string> *EdgeSourceLabels = 0) {
|
||||
O << "\tNode" << ID << "[ ";
|
||||
if (!Attr.empty())
|
||||
O << Attr << ",";
|
||||
O << " label =\"";
|
||||
if (NumEdgeSources) O << "{";
|
||||
O << DOT::EscapeString(Label);
|
||||
if (NumEdgeSources) {
|
||||
O << "|{";
|
||||
|
||||
for (unsigned i = 0; i != NumEdgeSources; ++i) {
|
||||
if (i) O << "|";
|
||||
O << "<g" << i << ">";
|
||||
if (EdgeSourceLabels) O << (*EdgeSourceLabels)[i];
|
||||
}
|
||||
O << "}}";
|
||||
}
|
||||
O << "\"];\n";
|
||||
}
|
||||
|
||||
/// emitEdge - Output an edge from a simple node into the graph...
|
||||
void emitEdge(const void *SrcNodeID, int SrcNodePort,
|
||||
const void *DestNodeID, int DestNodePort,
|
||||
const std::string &Attrs) {
|
||||
if (SrcNodePort > 64) return; // Eminating from truncated part?
|
||||
if (DestNodePort > 64) DestNodePort = 64; // Targetting the truncated part?
|
||||
|
||||
O << "\tNode" << SrcNodeID;
|
||||
if (SrcNodePort >= 0)
|
||||
O << ":g" << SrcNodePort;
|
||||
O << " -> Node" << reinterpret_cast<const void*>(DestNodeID);
|
||||
if (DestNodePort >= 0)
|
||||
O << ":g" << DestNodePort;
|
||||
|
||||
if (!Attrs.empty())
|
||||
O << "[" << Attrs << "]";
|
||||
O << ";\n";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename GraphType>
|
||||
std::ostream &WriteGraph(std::ostream &O, const GraphType &G,
|
||||
const std::string &Name = "") {
|
||||
// Start the graph emission process...
|
||||
GraphWriter<GraphType> W(O, G);
|
||||
|
||||
// Output the header for the graph...
|
||||
W.writeHeader(Name);
|
||||
|
||||
// Emit all of the nodes in the graph...
|
||||
W.writeNodes();
|
||||
|
||||
// Output any customizations on the graph
|
||||
DOTGraphTraits<GraphType>::addCustomGraphFeatures(G, W);
|
||||
|
||||
// Output the end of the graph
|
||||
W.writeFooter();
|
||||
return O;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,41 +0,0 @@
|
||||
//===-- HashExtras.h - Useful functions for STL hash containers -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains some templates that are useful if you are working with the
|
||||
// STL Hashed containers.
|
||||
//
|
||||
// No library is required when using these functinons.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASHEXTRAS_H
|
||||
#define SUPPORT_HASHEXTRAS_H
|
||||
|
||||
#include "Support/hash_map"
|
||||
#include <string>
|
||||
|
||||
// Cannot specialize hash template from outside of the std namespace.
|
||||
namespace HASH_NAMESPACE {
|
||||
|
||||
template <> struct hash<std::string> {
|
||||
size_t operator()(std::string const &str) const {
|
||||
return hash<char const *>()(str.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
// Provide a hash function for arbitrary pointers...
|
||||
template <class T> struct hash<T *> {
|
||||
inline size_t operator()(const T *Val) const {
|
||||
return reinterpret_cast<size_t>(Val);
|
||||
}
|
||||
};
|
||||
|
||||
} // End namespace std
|
||||
|
||||
#endif
|
@ -1,91 +0,0 @@
|
||||
//===-- Support/LeakDetector.h - Provide simple leak detection --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a class that can be used to provide very simple memory leak
|
||||
// checks for an API. Basically LLVM uses this to make sure that Instructions,
|
||||
// for example, are deleted when they are supposed to be, and not leaked away.
|
||||
//
|
||||
// When compiling with NDEBUG (Release build), this class does nothing, thus
|
||||
// adding no checking overhead to release builds. Note that this class is
|
||||
// implemented in a very simple way, requiring completely manual manipulation
|
||||
// and checking for garbage, but this is intentional: users should not be using
|
||||
// this API, only other APIs should.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_LEAKDETECTOR_H
|
||||
#define SUPPORT_LEAKDETECTOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Value;
|
||||
|
||||
struct LeakDetector {
|
||||
/// addGarbageObject - Add a pointer to the internal set of "garbage" object
|
||||
/// pointers. This should be called when objects are created, or if they are
|
||||
/// taken out of an owning collection.
|
||||
///
|
||||
static void addGarbageObject(void *Object) {
|
||||
#ifndef NDEBUG
|
||||
addGarbageObjectImpl(Object);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// removeGarbageObject - Remove a pointer from our internal representation of
|
||||
/// our "garbage" objects. This should be called when an object is added to
|
||||
/// an "owning" collection.
|
||||
///
|
||||
static void removeGarbageObject(void *Object) {
|
||||
#ifndef NDEBUG
|
||||
removeGarbageObjectImpl(Object);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// checkForGarbage - Traverse the internal representation of garbage
|
||||
/// pointers. If there are any pointers that have been add'ed, but not
|
||||
/// remove'd, big obnoxious warnings about memory leaks are issued.
|
||||
///
|
||||
/// The specified message will be printed indicating when the check was
|
||||
/// performed.
|
||||
///
|
||||
static void checkForGarbage(const std::string &Message) {
|
||||
#ifndef NDEBUG
|
||||
checkForGarbageImpl(Message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Overload the normal methods to work better with Value*'s because they are
|
||||
/// by far the most common in LLVM. This does not affect the actual
|
||||
/// functioning of this class, it just makes the warning messages nicer.
|
||||
///
|
||||
static void addGarbageObject(const Value *Object) {
|
||||
#ifndef NDEBUG
|
||||
addGarbageObjectImpl(Object);
|
||||
#endif
|
||||
}
|
||||
static void removeGarbageObject(const Value *Object) {
|
||||
#ifndef NDEBUG
|
||||
removeGarbageObjectImpl(Object);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
// If we are debugging, the actual implementations will be called...
|
||||
static void addGarbageObjectImpl(const Value *Object);
|
||||
static void removeGarbageObjectImpl(const Value *Object);
|
||||
static void addGarbageObjectImpl(void *Object);
|
||||
static void removeGarbageObjectImpl(void *Object);
|
||||
static void checkForGarbageImpl(const std::string &Message);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,85 +0,0 @@
|
||||
//===-- Support/MallocAllocator.h - Allocator using malloc/free -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines MallocAllocator class, an STL compatible allocator which
|
||||
// just uses malloc/free to get and release memory. The default allocator uses
|
||||
// the STL pool allocator runtime library, this explicitly avoids it.
|
||||
//
|
||||
// This file is used for variety of purposes, including the pool allocator
|
||||
// project and testing, regardless of whether or not it's used directly in the
|
||||
// LLVM code, so don't delete this from CVS if you think it's unused!
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_MALLOCALLOCATOR_H
|
||||
#define SUPPORT_MALLOCALLOCATOR_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template<typename T>
|
||||
struct MallocAllocator {
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T value_type;
|
||||
template <class U> struct rebind {
|
||||
typedef MallocAllocator<U> other;
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
MallocAllocator(const MallocAllocator<R> &) {}
|
||||
MallocAllocator() {}
|
||||
|
||||
pointer address(reference x) const { return &x; }
|
||||
const_pointer address(const_reference x) const { return &x; }
|
||||
size_type max_size() const { return ~0 / sizeof(T); }
|
||||
|
||||
static pointer allocate(size_t n, void* hint = 0) {
|
||||
return static_cast<pointer>(malloc(n*sizeof(T)));
|
||||
}
|
||||
|
||||
static void deallocate(pointer p, size_t n) {
|
||||
free(static_cast<void*>(p));
|
||||
}
|
||||
|
||||
void construct(pointer p, const T &val) {
|
||||
new(static_cast<void*>(p)) T(val);
|
||||
}
|
||||
void destroy(pointer p) {
|
||||
p->~T();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool operator==(const MallocAllocator<T> &, const MallocAllocator<T> &) {
|
||||
return true;
|
||||
}
|
||||
template<typename T>
|
||||
inline bool operator!=(const MallocAllocator<T>&, const MallocAllocator<T>&) {
|
||||
return false;
|
||||
}
|
||||
} // End llvm namespace
|
||||
|
||||
namespace std {
|
||||
template<typename Type, typename Type2>
|
||||
struct _Alloc_traits<Type, ::llvm::MallocAllocator<Type2> > {
|
||||
static const bool _S_instanceless = true;
|
||||
typedef ::llvm::MallocAllocator<Type> base_alloc_type;
|
||||
typedef ::llvm::MallocAllocator<Type> _Alloc_type;
|
||||
typedef ::llvm::MallocAllocator<Type> allocator_type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,59 +0,0 @@
|
||||
//===-- Support/MathExtras.h - Useful math functions ------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains some functions that are useful for math stuff.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_MATHEXTRAS_H
|
||||
#define SUPPORT_MATHEXTRAS_H
|
||||
|
||||
#include "Support/DataTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
#if defined(log2)
|
||||
# undef log2
|
||||
#endif
|
||||
|
||||
inline unsigned log2(uint64_t C) {
|
||||
unsigned getPow;
|
||||
for (getPow = 0; C > 1; ++getPow)
|
||||
C >>= 1;
|
||||
return getPow;
|
||||
}
|
||||
|
||||
inline unsigned log2(unsigned C) {
|
||||
unsigned getPow;
|
||||
for (getPow = 0; C > 1; ++getPow)
|
||||
C >>= 1;
|
||||
return getPow;
|
||||
}
|
||||
|
||||
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
|
||||
if (C < 0) C = -C;
|
||||
if (C > 0 && C == (C & ~(C - 1))) {
|
||||
getPow = log2(static_cast<uint64_t>(C));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Platform-independent wrappers for the C99 isnan() function.
|
||||
int IsNAN (float f);
|
||||
int IsNAN (double d);
|
||||
|
||||
// Platform-independent wrappers for the C99 isinf() function.
|
||||
int IsInf (float f);
|
||||
int IsInf (double d);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
//===-- Support/PluginLoader.h - Provide -load option to tool ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// A tool can #include this file to get a -load option that allows the user to
|
||||
// load arbitrary shared objects into the tool's address space. Note that this
|
||||
// header can only be included by a program ONCE, so it should never to used by
|
||||
// library authors.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_PLUGINLOADER_H
|
||||
#define SUPPORT_PLUGINLOADER_H
|
||||
|
||||
#include "Support/CommandLine.h"
|
||||
|
||||
namespace llvm {
|
||||
struct PluginLoader {
|
||||
void operator=(const std::string &Filename);
|
||||
};
|
||||
|
||||
#ifndef DONT_GET_PLUGIN_LOADER_OPTION
|
||||
// This causes operator= above to be invoked for every -load option.
|
||||
static cl::opt<PluginLoader, false, cl::parser<std::string> >
|
||||
LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"),
|
||||
cl::desc("Load the specified plugin"));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -1,156 +0,0 @@
|
||||
//===- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file builds on the Support/GraphTraits.h file to build a generic graph
|
||||
// post order iterator. This should work over any graph type that has a
|
||||
// GraphTraits specialization.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_POSTORDERITERATOR_H
|
||||
#define SUPPORT_POSTORDERITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include <stack>
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template<class GraphT, class GT = GraphTraits<GraphT> >
|
||||
class po_iterator : public forward_iterator<typename GT::NodeType, ptrdiff_t> {
|
||||
typedef forward_iterator<typename GT::NodeType, ptrdiff_t> super;
|
||||
typedef typename GT::NodeType NodeType;
|
||||
typedef typename GT::ChildIteratorType ChildItTy;
|
||||
|
||||
std::set<NodeType *> Visited; // All of the blocks visited so far...
|
||||
// VisitStack - Used to maintain the ordering. Top = current block
|
||||
// First element is basic block pointer, second is the 'next child' to visit
|
||||
std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||
|
||||
void traverseChild() {
|
||||
while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
|
||||
NodeType *BB = *VisitStack.top().second++;
|
||||
if (!Visited.count(BB)) { // If the block is not visited...
|
||||
Visited.insert(BB);
|
||||
VisitStack.push(make_pair(BB, GT::child_begin(BB)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline po_iterator(NodeType *BB) {
|
||||
Visited.insert(BB);
|
||||
VisitStack.push(make_pair(BB, GT::child_begin(BB)));
|
||||
traverseChild();
|
||||
}
|
||||
inline po_iterator() { /* End is when stack is empty */ }
|
||||
public:
|
||||
typedef typename super::pointer pointer;
|
||||
typedef po_iterator<GraphT, GT> _Self;
|
||||
|
||||
// Provide static "constructors"...
|
||||
static inline _Self begin(GraphT G) { return _Self(GT::getEntryNode(G)); }
|
||||
static inline _Self end (GraphT G) { return _Self(); }
|
||||
|
||||
inline bool operator==(const _Self& x) const {
|
||||
return VisitStack == x.VisitStack;
|
||||
}
|
||||
inline bool operator!=(const _Self& x) const { return !operator==(x); }
|
||||
|
||||
inline pointer operator*() const {
|
||||
return VisitStack.top().first;
|
||||
}
|
||||
|
||||
// This is a nonstandard operator-> that dereferences the pointer an extra
|
||||
// time... so that you can actually call methods ON the BasicBlock, because
|
||||
// the contained type is a pointer. This allows BBIt->getTerminator() f.e.
|
||||
//
|
||||
inline NodeType *operator->() const { return operator*(); }
|
||||
|
||||
inline _Self& operator++() { // Preincrement
|
||||
VisitStack.pop();
|
||||
if (!VisitStack.empty())
|
||||
traverseChild();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline _Self operator++(int) { // Postincrement
|
||||
_Self tmp = *this; ++*this; return tmp;
|
||||
}
|
||||
};
|
||||
|
||||
// Provide global constructors that automatically figure out correct types...
|
||||
//
|
||||
template <class T>
|
||||
po_iterator<T> po_begin(T G) { return po_iterator<T>::begin(G); }
|
||||
template <class T>
|
||||
po_iterator<T> po_end (T G) { return po_iterator<T>::end(G); }
|
||||
|
||||
// Provide global definitions of inverse post order iterators...
|
||||
template <class T>
|
||||
struct ipo_iterator : public po_iterator<Inverse<T> > {
|
||||
ipo_iterator(const po_iterator<Inverse<T> > &V) :po_iterator<Inverse<T> >(V){}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
ipo_iterator<T> ipo_begin(T G, bool Reverse = false) {
|
||||
return ipo_iterator<T>::begin(G, Reverse);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
ipo_iterator<T> ipo_end(T G){
|
||||
return ipo_iterator<T>::end(G);
|
||||
}
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Reverse Post Order CFG iterator code
|
||||
//===--------------------------------------------------------------------===//
|
||||
//
|
||||
// This is used to visit basic blocks in a method in reverse post order. This
|
||||
// class is awkward to use because I don't know a good incremental algorithm to
|
||||
// computer RPO from a graph. Because of this, the construction of the
|
||||
// ReversePostOrderTraversal object is expensive (it must walk the entire graph
|
||||
// with a postorder iterator to build the data structures). The moral of this
|
||||
// story is: Don't create more ReversePostOrderTraversal classes than necessary.
|
||||
//
|
||||
// This class should be used like this:
|
||||
// {
|
||||
// ReversePostOrderTraversal<Function*> RPOT(FuncPtr); // Expensive to create
|
||||
// for (rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) {
|
||||
// ...
|
||||
// }
|
||||
// for (rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) {
|
||||
// ...
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
template<class GraphT, class GT = GraphTraits<GraphT> >
|
||||
class ReversePostOrderTraversal {
|
||||
typedef typename GT::NodeType NodeType;
|
||||
std::vector<NodeType*> Blocks; // Block list in normal PO order
|
||||
inline void Initialize(NodeType *BB) {
|
||||
copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
|
||||
}
|
||||
public:
|
||||
typedef typename std::vector<NodeType*>::reverse_iterator rpo_iterator;
|
||||
|
||||
inline ReversePostOrderTraversal(GraphT G) {
|
||||
Initialize(GT::getEntryNode(G));
|
||||
}
|
||||
|
||||
// Because we want a reverse post order, use reverse iterators from the vector
|
||||
inline rpo_iterator begin() { return Blocks.rbegin(); }
|
||||
inline rpo_iterator end() { return Blocks.rend(); }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,199 +0,0 @@
|
||||
//===-- Support/SCCIterator.h - SCC iterator --------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This builds on the Support/GraphTraits.h file to find the strongly connected
|
||||
// components (SCCs) of a graph in O(N+E) time using Tarjan's DFS algorithm.
|
||||
//
|
||||
// The SCC iterator has the important property that if a node in SCC S1 has an
|
||||
// edge to a node in SCC S2, then it visits S1 *after* S2.
|
||||
//
|
||||
// To visit S1 *before* S2, use the scc_iterator on the Inverse graph.
|
||||
// (NOTE: This requires some simple wrappers and is not supported yet.)
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SCCITERATOR_H
|
||||
#define SUPPORT_SCCITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
///
|
||||
/// scc_iterator - Enumerate the SCCs of a directed graph, in
|
||||
/// reverse topological order of the SCC DAG.
|
||||
///
|
||||
template<class GraphT, class GT = GraphTraits<GraphT> >
|
||||
class scc_iterator
|
||||
: public forward_iterator<std::vector<typename GT::NodeType>, ptrdiff_t> {
|
||||
typedef typename GT::NodeType NodeType;
|
||||
typedef typename GT::ChildIteratorType ChildItTy;
|
||||
typedef std::vector<NodeType*> SccTy;
|
||||
typedef forward_iterator<SccTy, ptrdiff_t> super;
|
||||
typedef typename super::reference reference;
|
||||
typedef typename super::pointer pointer;
|
||||
|
||||
// The visit counters used to detect when a complete SCC is on the stack.
|
||||
// visitNum is the global counter.
|
||||
// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
|
||||
unsigned visitNum;
|
||||
std::map<NodeType *, unsigned> nodeVisitNumbers;
|
||||
|
||||
// SCCNodeStack - Stack holding nodes of the SCC.
|
||||
std::vector<NodeType *> SCCNodeStack;
|
||||
|
||||
// CurrentSCC - The current SCC, retrieved using operator*().
|
||||
SccTy CurrentSCC;
|
||||
|
||||
// VisitStack - Used to maintain the ordering. Top = current block
|
||||
// First element is basic block pointer, second is the 'next child' to visit
|
||||
std::vector<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||
|
||||
// MinVistNumStack - Stack holding the "min" values for each node in the DFS.
|
||||
// This is used to track the minimum uplink values for all children of
|
||||
// the corresponding node on the VisitStack.
|
||||
std::vector<unsigned> MinVisitNumStack;
|
||||
|
||||
// A single "visit" within the non-recursive DFS traversal.
|
||||
void DFSVisitOne(NodeType* N) {
|
||||
++visitNum; // Global counter for the visit order
|
||||
nodeVisitNumbers[N] = visitNum;
|
||||
SCCNodeStack.push_back(N);
|
||||
MinVisitNumStack.push_back(visitNum);
|
||||
VisitStack.push_back(std::make_pair(N, GT::child_begin(N)));
|
||||
//DEBUG(std::cerr << "TarjanSCC: Node " << N <<
|
||||
// " : visitNum = " << visitNum << "\n");
|
||||
}
|
||||
|
||||
// The stack-based DFS traversal; defined below.
|
||||
void DFSVisitChildren() {
|
||||
assert(!VisitStack.empty());
|
||||
while (VisitStack.back().second != GT::child_end(VisitStack.back().first)) {
|
||||
// TOS has at least one more child so continue DFS
|
||||
NodeType *childN = *VisitStack.back().second++;
|
||||
if (!nodeVisitNumbers.count(childN)) {
|
||||
// this node has never been seen
|
||||
DFSVisitOne(childN);
|
||||
} else {
|
||||
unsigned childNum = nodeVisitNumbers[childN];
|
||||
if (MinVisitNumStack.back() > childNum)
|
||||
MinVisitNumStack.back() = childNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the next SCC using the DFS traversal.
|
||||
void GetNextSCC() {
|
||||
assert(VisitStack.size() == MinVisitNumStack.size());
|
||||
CurrentSCC.clear(); // Prepare to compute the next SCC
|
||||
while (!VisitStack.empty()) {
|
||||
DFSVisitChildren();
|
||||
assert(VisitStack.back().second ==GT::child_end(VisitStack.back().first));
|
||||
NodeType* visitingN = VisitStack.back().first;
|
||||
unsigned minVisitNum = MinVisitNumStack.back();
|
||||
VisitStack.pop_back();
|
||||
MinVisitNumStack.pop_back();
|
||||
if (!MinVisitNumStack.empty() && MinVisitNumStack.back() > minVisitNum)
|
||||
MinVisitNumStack.back() = minVisitNum;
|
||||
|
||||
//DEBUG(std::cerr << "TarjanSCC: Popped node " << visitingN <<
|
||||
// " : minVisitNum = " << minVisitNum << "; Node visit num = " <<
|
||||
// nodeVisitNumbers[visitingN] << "\n");
|
||||
|
||||
if (minVisitNum == nodeVisitNumbers[visitingN]) {
|
||||
// A full SCC is on the SCCNodeStack! It includes all nodes below
|
||||
// visitingN on the stack. Copy those nodes to CurrentSCC,
|
||||
// reset their minVisit values, and return (this suspends
|
||||
// the DFS traversal till the next ++).
|
||||
do {
|
||||
CurrentSCC.push_back(SCCNodeStack.back());
|
||||
SCCNodeStack.pop_back();
|
||||
nodeVisitNumbers[CurrentSCC.back()] = ~0UL;
|
||||
} while (CurrentSCC.back() != visitingN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline scc_iterator(NodeType *entryN) : visitNum(0) {
|
||||
DFSVisitOne(entryN);
|
||||
GetNextSCC();
|
||||
}
|
||||
inline scc_iterator() { /* End is when DFS stack is empty */ }
|
||||
|
||||
public:
|
||||
typedef scc_iterator<GraphT, GT> _Self;
|
||||
|
||||
// Provide static "constructors"...
|
||||
static inline _Self begin(GraphT& G) { return _Self(GT::getEntryNode(G)); }
|
||||
static inline _Self end (GraphT& G) { return _Self(); }
|
||||
|
||||
// Direct loop termination test (I.fini() is more efficient than I == end())
|
||||
inline bool fini() const {
|
||||
assert(!CurrentSCC.empty() || VisitStack.empty());
|
||||
return CurrentSCC.empty();
|
||||
}
|
||||
|
||||
inline bool operator==(const _Self& x) const {
|
||||
return VisitStack == x.VisitStack && CurrentSCC == x.CurrentSCC;
|
||||
}
|
||||
inline bool operator!=(const _Self& x) const { return !operator==(x); }
|
||||
|
||||
// Iterator traversal: forward iteration only
|
||||
inline _Self& operator++() { // Preincrement
|
||||
GetNextSCC();
|
||||
return *this;
|
||||
}
|
||||
inline _Self operator++(int) { // Postincrement
|
||||
_Self tmp = *this; ++*this; return tmp;
|
||||
}
|
||||
|
||||
// Retrieve a reference to the current SCC
|
||||
inline const SccTy &operator*() const {
|
||||
assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
|
||||
return CurrentSCC;
|
||||
}
|
||||
inline SccTy &operator*() {
|
||||
assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
|
||||
return CurrentSCC;
|
||||
}
|
||||
|
||||
// hasLoop() -- Test if the current SCC has a loop. If it has more than one
|
||||
// node, this is trivially true. If not, it may still contain a loop if the
|
||||
// node has an edge back to itself.
|
||||
bool hasLoop() const {
|
||||
assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
|
||||
if (CurrentSCC.size() > 1) return true;
|
||||
NodeType *N = CurrentSCC.front();
|
||||
for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI)
|
||||
if (*CI == N)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Global constructor for the SCC iterator.
|
||||
template <class T>
|
||||
scc_iterator<T> scc_begin(T G) {
|
||||
return scc_iterator<T>::begin(G);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
scc_iterator<T> scc_end(T G) {
|
||||
return scc_iterator<T>::end(G);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,310 +0,0 @@
|
||||
//===- STLExtras.h - Useful functions when working with the STL -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains some templates that are useful if you are working with the
|
||||
// STL at all.
|
||||
//
|
||||
// No library is required when using these functinons.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STLEXTRAS_H
|
||||
#define SUPPORT_STLEXTRAS_H
|
||||
|
||||
#include <functional>
|
||||
#include <utility> // for std::pair
|
||||
#include "Support/iterator"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Extra additions to <functional>
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// bind_obj - Often times you want to apply the member function of an object
|
||||
// as a unary functor. This macro is shorthand that makes it happen less
|
||||
// verbosely.
|
||||
//
|
||||
// Example:
|
||||
// struct Summer { void accumulate(int x); }
|
||||
// vector<int> Numbers;
|
||||
// Summer MyS;
|
||||
// for_each(Numbers.begin(), Numbers.end(),
|
||||
// bind_obj(&MyS, &Summer::accumulate));
|
||||
//
|
||||
// TODO: When I get lots of extra time, convert this from an evil macro
|
||||
//
|
||||
#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ)
|
||||
|
||||
|
||||
// bitwise_or - This is a simple functor that applys operator| on its two
|
||||
// arguments to get a boolean result.
|
||||
//
|
||||
template<class Ty>
|
||||
struct bitwise_or : public std::binary_function<Ty, Ty, bool> {
|
||||
bool operator()(const Ty& left, const Ty& right) const {
|
||||
return left | right;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Ty>
|
||||
struct less_ptr : public std::binary_function<Ty, Ty, bool> {
|
||||
bool operator()(const Ty* left, const Ty* right) const {
|
||||
return *left < *right;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Ty>
|
||||
struct greater_ptr : public std::binary_function<Ty, Ty, bool> {
|
||||
bool operator()(const Ty* left, const Ty* right) const {
|
||||
return *right < *left;
|
||||
}
|
||||
};
|
||||
|
||||
// deleter - Very very very simple method that is used to invoke operator
|
||||
// delete on something. It is used like this:
|
||||
//
|
||||
// for_each(V.begin(), B.end(), deleter<Interval>);
|
||||
//
|
||||
template <class T>
|
||||
static inline void deleter(T *Ptr) {
|
||||
delete Ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Extra additions to <iterator>
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// mapped_iterator - This is a simple iterator adapter that causes a function to
|
||||
// be dereferenced whenever operator* is invoked on the iterator.
|
||||
//
|
||||
template <class RootIt, class UnaryFunc>
|
||||
class mapped_iterator {
|
||||
RootIt current;
|
||||
UnaryFunc Fn;
|
||||
public:
|
||||
typedef typename std::iterator_traits<RootIt>::iterator_category
|
||||
iterator_category;
|
||||
typedef typename std::iterator_traits<RootIt>::difference_type
|
||||
difference_type;
|
||||
typedef typename UnaryFunc::result_type value_type;
|
||||
|
||||
typedef void pointer;
|
||||
//typedef typename UnaryFunc::result_type *pointer;
|
||||
typedef void reference; // Can't modify value returned by fn
|
||||
|
||||
typedef RootIt iterator_type;
|
||||
typedef mapped_iterator<RootIt, UnaryFunc> _Self;
|
||||
|
||||
inline RootIt &getCurrent() const { return current; }
|
||||
|
||||
inline explicit mapped_iterator(const RootIt &I, UnaryFunc F)
|
||||
: current(I), Fn(F) {}
|
||||
inline mapped_iterator(const mapped_iterator &It)
|
||||
: current(It.current), Fn(It.Fn) {}
|
||||
|
||||
inline value_type operator*() const { // All this work to do this
|
||||
return Fn(*current); // little change
|
||||
}
|
||||
|
||||
_Self& operator++() { ++current; return *this; }
|
||||
_Self& operator--() { --current; return *this; }
|
||||
_Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; }
|
||||
_Self operator--(int) { _Self __tmp = *this; --current; return __tmp; }
|
||||
_Self operator+ (difference_type n) const { return _Self(current + n); }
|
||||
_Self& operator+= (difference_type n) { current += n; return *this; }
|
||||
_Self operator- (difference_type n) const { return _Self(current - n); }
|
||||
_Self& operator-= (difference_type n) { current -= n; return *this; }
|
||||
reference operator[](difference_type n) const { return *(*this + n); }
|
||||
|
||||
inline bool operator!=(const _Self &X) const { return !operator==(X); }
|
||||
inline bool operator==(const _Self &X) const { return current == X.current; }
|
||||
inline bool operator< (const _Self &X) const { return current < X.current; }
|
||||
|
||||
inline difference_type operator-(const _Self &X) const {
|
||||
return current - X.current;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Iterator, class Func>
|
||||
inline mapped_iterator<_Iterator, Func>
|
||||
operator+(typename mapped_iterator<_Iterator, Func>::difference_type N,
|
||||
const mapped_iterator<_Iterator, Func>& X) {
|
||||
return mapped_iterator<_Iterator, Func>(X.getCurrent() - N);
|
||||
}
|
||||
|
||||
|
||||
// map_iterator - Provide a convenient way to create mapped_iterators, just like
|
||||
// make_pair is useful for creating pairs...
|
||||
//
|
||||
template <class ItTy, class FuncTy>
|
||||
inline mapped_iterator<ItTy, FuncTy> map_iterator(const ItTy &I, FuncTy F) {
|
||||
return mapped_iterator<ItTy, FuncTy>(I, F);
|
||||
}
|
||||
|
||||
|
||||
// next/prior - These functions unlike std::advance do not modify the
|
||||
// passed iterator but return a copy.
|
||||
//
|
||||
// next(myIt) returns copy of myIt incremented once
|
||||
// next(myIt, n) returns copy of myIt incremented n times
|
||||
// prior(myIt) returns copy of myIt decremented once
|
||||
// prior(myIt, n) returns copy of myIt decremented n times
|
||||
|
||||
template <typename ItTy, typename Dist>
|
||||
inline ItTy next(ItTy it, Dist n)
|
||||
{
|
||||
std::advance(it, n);
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename ItTy>
|
||||
inline ItTy next(ItTy it)
|
||||
{
|
||||
std::advance(it, 1);
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename ItTy, typename Dist>
|
||||
inline ItTy prior(ItTy it, Dist n)
|
||||
{
|
||||
std::advance(it, -n);
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename ItTy>
|
||||
inline ItTy prior(ItTy it)
|
||||
{
|
||||
std::advance(it, -1);
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Extra additions to <algorithm>
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// apply_until - Apply a functor to a sequence continually, unless the
|
||||
// functor returns true. Return true if the functor returned true, return false
|
||||
// if the functor never returned true.
|
||||
//
|
||||
template <class InputIt, class Function>
|
||||
bool apply_until(InputIt First, InputIt Last, Function Func) {
|
||||
for ( ; First != Last; ++First)
|
||||
if (Func(*First)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// reduce - Reduce a sequence values into a single value, given an initial
|
||||
// value and an operator.
|
||||
//
|
||||
template <class InputIt, class Function, class ValueType>
|
||||
ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) {
|
||||
for ( ; First != Last; ++First)
|
||||
Value = Func(*First, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
#if 1 // This is likely to be more efficient
|
||||
|
||||
// reduce_apply - Reduce the result of applying a function to each value in a
|
||||
// sequence, given an initial value, an operator, a function, and a sequence.
|
||||
//
|
||||
template <class InputIt, class Function, class ValueType, class TransFunc>
|
||||
inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func,
|
||||
ValueType Value, TransFunc XForm) {
|
||||
for ( ; First != Last; ++First)
|
||||
Value = Func(XForm(*First), Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
#else // This is arguably more elegant
|
||||
|
||||
// reduce_apply - Reduce the result of applying a function to each value in a
|
||||
// sequence, given an initial value, an operator, a function, and a sequence.
|
||||
//
|
||||
template <class InputIt, class Function, class ValueType, class TransFunc>
|
||||
inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func,
|
||||
ValueType Value, TransFunc XForm) {
|
||||
return reduce(map_iterator(First, XForm), map_iterator(Last, XForm),
|
||||
Func, Value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// reduce_apply_bool - Reduce the result of applying a (bool returning) function
|
||||
// to each value in a sequence. All of the bools returned by the mapped
|
||||
// function are bitwise or'd together, and the result is returned.
|
||||
//
|
||||
template <class InputIt, class Function>
|
||||
inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) {
|
||||
return reduce_apply(First, Last, bitwise_or<bool>(), false, Func);
|
||||
}
|
||||
|
||||
|
||||
// map - This function maps the specified input sequence into the specified
|
||||
// output iterator, applying a unary function in between.
|
||||
//
|
||||
template <class InIt, class OutIt, class Functor>
|
||||
inline OutIt mapto(InIt Begin, InIt End, OutIt Dest, Functor F) {
|
||||
return copy(map_iterator(Begin, F), map_iterator(End, F), Dest);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Extra additions to <utility>
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// tie - this function ties two objects and returns a temporary object
|
||||
// that is assignable from a std::pair. This can be used to make code
|
||||
// more readable when using values returned from functions bundled in
|
||||
// a std::pair. Since an example is worth 1000 words:
|
||||
//
|
||||
// typedef std::map<int, int> Int2IntMap;
|
||||
//
|
||||
// Int2IntMap myMap;
|
||||
// Int2IntMap::iterator where;
|
||||
// bool inserted;
|
||||
// tie(where, inserted) = myMap.insert(std::make_pair(123,456));
|
||||
//
|
||||
// if (inserted)
|
||||
// // do stuff
|
||||
// else
|
||||
// // do other stuff
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T1, typename T2>
|
||||
struct tier {
|
||||
typedef T1 &first_type;
|
||||
typedef T2 &second_type;
|
||||
|
||||
first_type first;
|
||||
second_type second;
|
||||
|
||||
tier(first_type f, second_type s) : first(f), second(s) { }
|
||||
tier& operator=(const std::pair<T1, T2>& p) {
|
||||
first = p.first;
|
||||
second = p.second;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline tier<T1, T2> tie(T1& f, T2& s) {
|
||||
return tier<T1, T2>(f, s);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,71 +0,0 @@
|
||||
//===-- Support/SetOperations.h - Generic Set Operations --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines generic set operations that may be used on set's of
|
||||
// different types, and different element types.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SETOPERATIONS_H
|
||||
#define SUPPORT_SETOPERATIONS_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// set_union(A, B) - Compute A := A u B, return whether A changed.
|
||||
//
|
||||
template <class S1Ty, class S2Ty>
|
||||
bool set_union(S1Ty &S1, const S2Ty &S2) {
|
||||
bool Changed = false;
|
||||
|
||||
for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
|
||||
SI != SE; ++SI)
|
||||
if (S1.insert(*SI).second)
|
||||
Changed = true;
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
// set_intersect(A, B) - Compute A := A ^ B
|
||||
// Identical to set_intersection, except that it works on set<>'s and
|
||||
// is nicer to use. Functionally, this iterates through S1, removing
|
||||
// elements that are not contained in S2.
|
||||
//
|
||||
template <template<class S1ElTy> class S1Ty, class ETy, class S2Ty>
|
||||
void set_intersect(S1Ty<ETy> &S1, const S2Ty &S2) {
|
||||
for (typename S1Ty<ETy>::iterator I = S1.begin(); I != S1.end();) {
|
||||
const ETy &E = *I;
|
||||
++I;
|
||||
if (!S2.count(E)) S1.erase(E); // Erase element if not in S2
|
||||
}
|
||||
}
|
||||
|
||||
// set_difference(A, B) - Return A - B
|
||||
//
|
||||
template <class S1Ty, class S2Ty>
|
||||
S1Ty set_difference(const S1Ty &S1, const S2Ty &S2) {
|
||||
S1Ty Result;
|
||||
for (typename S1Ty::const_iterator SI = S1.begin(), SE = S1.end();
|
||||
SI != SE; ++SI)
|
||||
if (!S2.count(*SI)) // if the element is not in set2
|
||||
Result.insert(*SI);
|
||||
return Result;
|
||||
}
|
||||
|
||||
// set_subtract(A, B) - Compute A := A - B
|
||||
//
|
||||
template <class S1Ty, class S2Ty>
|
||||
void set_subtract(S1Ty &S1, const S2Ty &S2) {
|
||||
for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
|
||||
SI != SE; ++SI)
|
||||
S1.erase(*SI);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,138 +0,0 @@
|
||||
//===- SetVector.h - A set with insertion order iteration -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements a set that has insertion order iteration
|
||||
// characteristics. This is useful for keeping a set of things that need to be
|
||||
// visited later but in a deterministic order (insertion order). The interface
|
||||
// is purposefully minimal.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SETVECTOR_H
|
||||
#define SUPPORT_SETVECTOR_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// This class provides a way to keep a set of things that also has the
|
||||
/// property of a deterministic iteration order. The order of iteration is the
|
||||
/// order of insertion.
|
||||
/// @brief A vector that has set insertion semantics.
|
||||
template <typename T>
|
||||
class SetVector {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T key_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef std::set<value_type> set_type;
|
||||
typedef std::vector<value_type> vector_type;
|
||||
typedef typename vector_type::iterator iterator;
|
||||
typedef typename vector_type::const_iterator const_iterator;
|
||||
typedef typename vector_type::size_type size_type;
|
||||
|
||||
/// @brief Construct an empty SetVector
|
||||
SetVector() {}
|
||||
|
||||
/// @brief Initialize a SetVector with a range of elements
|
||||
template<typename It>
|
||||
SetVector(It Start, It End) {
|
||||
insert(Start, End);
|
||||
}
|
||||
|
||||
/// @brief Determine if the SetVector is empty or not.
|
||||
bool empty() const {
|
||||
return vector_.empty();
|
||||
}
|
||||
|
||||
/// @brief Determine the number of elements in the SetVector.
|
||||
size_type size() const {
|
||||
return vector_.size();
|
||||
}
|
||||
|
||||
/// @brief Get an iterator to the beginning of the SetVector.
|
||||
iterator begin() {
|
||||
return vector_.begin();
|
||||
}
|
||||
|
||||
/// @brief Get a const_iterator to the beginning of the SetVector.
|
||||
const_iterator begin() const {
|
||||
return vector_.begin();
|
||||
}
|
||||
|
||||
/// @brief Get an iterator to the end of the SetVector.
|
||||
iterator end() {
|
||||
return vector_.end();
|
||||
}
|
||||
|
||||
/// @brief Get a const_iterator to the end of the SetVector.
|
||||
const_iterator end() const {
|
||||
return vector_.end();
|
||||
}
|
||||
|
||||
/// @brief Return the last element of the SetVector.
|
||||
const T &back() const {
|
||||
assert(!empty() && "Cannot call back() on empty SetVector!");
|
||||
return vector_.back();
|
||||
}
|
||||
|
||||
/// @brief Index into the SetVector.
|
||||
const_reference operator[](size_type n) const {
|
||||
assert(n < vector_.size() && "SetVector access out of range!");
|
||||
return vector_[n];
|
||||
}
|
||||
|
||||
/// @returns true iff the element was inserted into the SetVector.
|
||||
/// @brief Insert a new element into the SetVector.
|
||||
bool insert(const value_type &X) {
|
||||
bool result = set_.insert(X).second;
|
||||
if (result)
|
||||
vector_.push_back(X);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Insert a range of elements into the SetVector.
|
||||
template<typename It>
|
||||
void insert(It Start, It End) {
|
||||
for (; Start != End; ++Start)
|
||||
if (set_.insert(*Start).second)
|
||||
vector_.push_back(*Start);
|
||||
}
|
||||
|
||||
/// @returns 0 if the element is not in the SetVector, 1 if it is.
|
||||
/// @brief Count the number of elements of a given key in the SetVector.
|
||||
size_type count(const key_type &key) const {
|
||||
return set_.count(key);
|
||||
}
|
||||
|
||||
/// @brief Completely clear the SetVector
|
||||
void clear() {
|
||||
set_.clear();
|
||||
vector_.clear();
|
||||
}
|
||||
|
||||
/// @brief Remove the last element of the SetVector.
|
||||
void pop_back() {
|
||||
assert(!empty() && "Cannot remove an element from an empty SetVector!");
|
||||
set_.erase(back());
|
||||
vector_.pop_back();
|
||||
}
|
||||
|
||||
private:
|
||||
set_type set_; ///< The set.
|
||||
vector_type vector_; ///< The vector.
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
// vim: sw=2 ai
|
||||
#endif
|
@ -1,65 +0,0 @@
|
||||
//===- SlowOperationInformer.h - Keep the user informed ---------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a simple object which can be used to let the user know what
|
||||
// is going on when a slow operation is happening, and gives them the ability to
|
||||
// cancel it. Potentially slow operations can stack allocate one of these
|
||||
// objects, and periodically call the "progress" method to update the progress
|
||||
// bar. If the operation takes more than 1 second to complete, the progress bar
|
||||
// is automatically shown and updated. As such, the slow operation should not
|
||||
// print stuff to the screen, and should not be confused if an extra line
|
||||
// appears on the screen (ie, the cursor should be at the start of the line).
|
||||
//
|
||||
// If the user presses CTRL-C during the operation, the next invocation of the
|
||||
// progress method with throw an std::string object indicating that the
|
||||
// operation was cancelled. As such, client code must be exception safe around
|
||||
// the progress method.
|
||||
//
|
||||
// Because SlowOperationInformers fiddle around with signals, they cannot be
|
||||
// nested, and interact poorly with threads. The SIGALRM handler is set back to
|
||||
// SIGDFL, but the SIGINT signal handler is restored when the
|
||||
// SlowOperationInformer is destroyed.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SLOW_OPERATION_INFORMER_H
|
||||
#define SUPPORT_SLOW_OPERATION_INFORMER_H
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
class SlowOperationInformer {
|
||||
std::string OperationName;
|
||||
unsigned LastPrintAmount;
|
||||
|
||||
SlowOperationInformer(const SlowOperationInformer&); // DO NOT IMPLEMENT
|
||||
void operator=(const SlowOperationInformer&); // DO NOT IMPLEMENT
|
||||
public:
|
||||
SlowOperationInformer(const std::string &Name);
|
||||
~SlowOperationInformer();
|
||||
|
||||
/// progress - Clients should periodically call this method when they are in
|
||||
/// an exception-safe state. The Amount variable should indicate how far
|
||||
/// along the operation is, given in 1/10ths of a percent (in other words,
|
||||
/// Amount should range from 0 to 1000).
|
||||
void progress(unsigned Amount);
|
||||
|
||||
/// progress - Same as the method above, but this performs the division for
|
||||
/// you, and helps you avoid overflow if you are dealing with largish
|
||||
/// numbers.
|
||||
void progress(unsigned Current, unsigned Maximum) {
|
||||
assert(Maximum != 0 &&
|
||||
"Shouldn't be doing work if there is nothing to do!");
|
||||
progress(Current*1000ULL/Maximum);
|
||||
}
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif /* SLOW_OPERATION_INFORMER_H */
|
@ -1,89 +0,0 @@
|
||||
//===-- Support/Statistic.h - Easy way to expose stats ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the 'Statistic' class, which is designed to be an easy way
|
||||
// to expose various success metrics from passes. These statistics are printed
|
||||
// at the end of a run, when the -stats command line option is enabled on the
|
||||
// command line.
|
||||
//
|
||||
// This is useful for reporting information like the number of instructions
|
||||
// simplified, optimized or removed by various transformations, like this:
|
||||
//
|
||||
// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed");
|
||||
//
|
||||
// Later, in the code: ++NumInstsKilled;
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STATISTIC_H
|
||||
#define SUPPORT_STATISTIC_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// StatisticBase - Nontemplated base class for Statistic<> class...
|
||||
class StatisticBase {
|
||||
const char *Name;
|
||||
const char *Desc;
|
||||
static unsigned NumStats;
|
||||
protected:
|
||||
StatisticBase(const char *name, const char *desc) : Name(name), Desc(desc) {
|
||||
++NumStats; // Keep track of how many stats are created...
|
||||
}
|
||||
virtual ~StatisticBase() {}
|
||||
|
||||
// destroy - Called by subclass dtor so that we can still invoke virtual
|
||||
// functions on the subclass.
|
||||
void destroy() const;
|
||||
|
||||
// printValue - Overridden by template class to print out the value type...
|
||||
virtual void printValue(std::ostream &o) const = 0;
|
||||
|
||||
// hasSomeData - Return true if some data has been aquired. Avoid printing
|
||||
// lots of zero counts.
|
||||
//
|
||||
virtual bool hasSomeData() const = 0;
|
||||
};
|
||||
|
||||
// Statistic Class - templated on the data type we are monitoring...
|
||||
template <typename DataType=unsigned>
|
||||
class Statistic : private StatisticBase {
|
||||
DataType Value;
|
||||
|
||||
virtual void printValue(std::ostream &o) const { o << Value; }
|
||||
virtual bool hasSomeData() const { return Value != DataType(); }
|
||||
public:
|
||||
// Normal constructor, default initialize data item...
|
||||
Statistic(const char *name, const char *desc)
|
||||
: StatisticBase(name, desc), Value(DataType()) {}
|
||||
|
||||
// Constructor to provide an initial value...
|
||||
Statistic(const DataType &Val, const char *name, const char *desc)
|
||||
: StatisticBase(name, desc), Value(Val) {}
|
||||
|
||||
// Print information when destroyed, iff command line option is specified
|
||||
~Statistic() { destroy(); }
|
||||
|
||||
// Allow use of this class as the value itself...
|
||||
operator DataType() const { return Value; }
|
||||
const Statistic &operator=(DataType Val) { Value = Val; return *this; }
|
||||
const Statistic &operator++() { ++Value; return *this; }
|
||||
DataType operator++(int) { return Value++; }
|
||||
const Statistic &operator--() { --Value; return *this; }
|
||||
DataType operator--(int) { return Value--; }
|
||||
const Statistic &operator+=(const DataType &V) { Value += V; return *this; }
|
||||
const Statistic &operator-=(const DataType &V) { Value -= V; return *this; }
|
||||
const Statistic &operator*=(const DataType &V) { Value *= V; return *this; }
|
||||
const Statistic &operator/=(const DataType &V) { Value /= V; return *this; }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,125 +0,0 @@
|
||||
//===-- Support/StringExtras.h - Useful string functions --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains some functions that are useful when dealing with strings.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STRINGEXTRAS_H
|
||||
#define SUPPORT_STRINGEXTRAS_H
|
||||
|
||||
#include "Support/DataTypes.h"
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
static inline std::string utohexstr(uint64_t X) {
|
||||
char Buffer[40];
|
||||
char *BufPtr = Buffer+39;
|
||||
|
||||
*BufPtr = 0; // Null terminate buffer...
|
||||
if (X == 0) *--BufPtr = '0'; // Handle special case...
|
||||
|
||||
while (X) {
|
||||
unsigned char Mod = (unsigned char)X & 15;
|
||||
if (Mod < 10)
|
||||
*--BufPtr = '0' + Mod;
|
||||
else
|
||||
*--BufPtr = 'A' + Mod-10;
|
||||
X >>= 4;
|
||||
}
|
||||
return std::string(BufPtr);
|
||||
}
|
||||
|
||||
static inline std::string utostr(unsigned long long X, bool isNeg = false) {
|
||||
char Buffer[40];
|
||||
char *BufPtr = Buffer+39;
|
||||
|
||||
*BufPtr = 0; // Null terminate buffer...
|
||||
if (X == 0) *--BufPtr = '0'; // Handle special case...
|
||||
|
||||
while (X) {
|
||||
*--BufPtr = '0' + char(X % 10);
|
||||
X /= 10;
|
||||
}
|
||||
|
||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||
return std::string(BufPtr);
|
||||
}
|
||||
|
||||
static inline std::string utostr(unsigned long X, bool isNeg = false) {
|
||||
return utostr(static_cast<unsigned long long>(X), isNeg);
|
||||
}
|
||||
|
||||
static inline std::string utostr(unsigned X, bool isNeg = false) {
|
||||
char Buffer[20];
|
||||
char *BufPtr = Buffer+19;
|
||||
|
||||
*BufPtr = 0; // Null terminate buffer...
|
||||
if (X == 0) *--BufPtr = '0'; // Handle special case...
|
||||
|
||||
while (X) {
|
||||
*--BufPtr = '0' + char(X % 10);
|
||||
X /= 10;
|
||||
}
|
||||
|
||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||
|
||||
return std::string(BufPtr);
|
||||
}
|
||||
|
||||
static inline std::string itostr(long long X) {
|
||||
if (X < 0)
|
||||
return utostr(static_cast<uint64_t>(-X), true);
|
||||
else
|
||||
return utostr(static_cast<uint64_t>(X));
|
||||
}
|
||||
|
||||
static inline std::string itostr(long X) {
|
||||
if (X < 0)
|
||||
return utostr(static_cast<uint64_t>(-X), true);
|
||||
else
|
||||
return utostr(static_cast<uint64_t>(X));
|
||||
}
|
||||
|
||||
static inline std::string itostr(int X) {
|
||||
if (X < 0)
|
||||
return utostr(static_cast<unsigned>(-X), true);
|
||||
else
|
||||
return utostr(static_cast<unsigned>(X));
|
||||
}
|
||||
|
||||
static inline std::string ftostr(double V) {
|
||||
char Buffer[200];
|
||||
sprintf(Buffer, "%20.6e", V);
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
static inline std::string LowercaseString(const std::string &S) {
|
||||
std::string result(S);
|
||||
for (unsigned i = 0; i < S.length(); ++i)
|
||||
if (isupper(result[i]))
|
||||
result[i] = (char)tolower(result[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// getToken - This function extracts one token from source, ignoring any
|
||||
/// leading characters that appear in the Delimiters string, and ending the
|
||||
/// token at any of the characters that appear in the Delimiters string. If
|
||||
/// there are no tokens in the source string, an empty string is returned.
|
||||
/// The Source source string is updated in place to remove the returned string
|
||||
/// and any delimiter prefix from it.
|
||||
std::string getToken(std::string &Source,
|
||||
const char *Delimiters = " \t\n\v\f\r");
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,65 +0,0 @@
|
||||
//===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains functions used to do a variety of low-level, often
|
||||
// system-specific, tasks.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SYSTEMUTILS_H
|
||||
#define SYSTEMUTILS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// isExecutableFile - This function returns true if the filename specified
|
||||
/// exists and is executable.
|
||||
///
|
||||
bool isExecutableFile(const std::string &ExeFileName);
|
||||
|
||||
/// isStandardOutAConsole - Return true if we can tell that the standard output
|
||||
/// stream goes to a terminal window or console.
|
||||
bool isStandardOutAConsole();
|
||||
|
||||
/// FindExecutable - Find a named executable, giving the argv[0] of program
|
||||
/// being executed. This allows us to find another LLVM tool if it is built into
|
||||
/// the same directory, but that directory is neither the current directory, nor
|
||||
/// in the PATH. If the executable cannot be found, return an empty string.
|
||||
///
|
||||
std::string FindExecutable(const std::string &ExeName,
|
||||
const std::string &ProgramPath);
|
||||
|
||||
/// RunProgramWithTimeout - This function executes the specified program, with
|
||||
/// the specified null-terminated argument array, with the stdin/out/err fd's
|
||||
/// redirected, with a timeout specified by the last argument. This terminates
|
||||
/// the calling program if there is an error executing the specified program.
|
||||
/// It returns the return value of the program, or -1 if a timeout is detected.
|
||||
///
|
||||
int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
|
||||
const std::string &StdInFile = "",
|
||||
const std::string &StdOutFile = "",
|
||||
const std::string &StdErrFile = "",
|
||||
unsigned NumSeconds = 0);
|
||||
|
||||
/// ExecWait - Execute a program with the given arguments and environment and
|
||||
/// wait for it to terminate.
|
||||
///
|
||||
int ExecWait (const char * const argv[], const char * const envp[]);
|
||||
|
||||
/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
|
||||
/// permissions. This is typically used for JIT applications where we want
|
||||
/// to emit code to the memory then jump to it. Getting this type of memory
|
||||
/// is very OS specific.
|
||||
///
|
||||
void *AllocateRWXMemory(unsigned NumBytes);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
//===-- Support/ThreadSupport-NoSupport.h - Generic impl --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a generic ThreadSupport implementation used when there is
|
||||
// no supported threading mechanism on the current system. Users should never
|
||||
// #include this file directly!
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Users should never #include this file directly! As such, no include guards
|
||||
// are needed.
|
||||
|
||||
#ifndef SUPPORT_THREADSUPPORT_H
|
||||
#error "Code should not #include Support/ThreadSupport-NoSupport.h directly!"
|
||||
#endif
|
||||
|
||||
namespace llvm {
|
||||
/// Mutex - This class allows user code to protect variables shared between
|
||||
/// threads. It implements a "recursive" mutex, to simplify user code.
|
||||
///
|
||||
/// Since there is no platform support for _creating threads_, the non-thread
|
||||
/// implementation of this class is a noop.
|
||||
///
|
||||
struct Mutex {
|
||||
void acquire () {}
|
||||
void release () {}
|
||||
};
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
//===-- Support/ThreadSupport-PThreads.h - PThreads support -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines pthreads implementations of the generic threading
|
||||
// mechanisms. Users should never #include this file directly!
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Users should never #include this file directly! As such, no include guards
|
||||
// are needed.
|
||||
|
||||
#ifndef SUPPORT_THREADSUPPORT_H
|
||||
#error "Code should not #include Support/ThreadSupport/PThreads.h directly!"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// Mutex - This class allows user code to protect variables shared between
|
||||
/// threads. It implements a "recursive" mutex, to simplify user code.
|
||||
///
|
||||
class Mutex {
|
||||
pthread_mutex_t mutex;
|
||||
Mutex(const Mutex &); // DO NOT IMPLEMENT
|
||||
void operator=(const Mutex &); // DO NOT IMPLEMENT
|
||||
public:
|
||||
Mutex() {
|
||||
pthread_mutexattr_t Attr;
|
||||
pthread_mutex_init(&mutex, &Attr);
|
||||
}
|
||||
~Mutex() { pthread_mutex_destroy(&mutex); }
|
||||
void acquire () { pthread_mutex_lock (&mutex); }
|
||||
void release () { pthread_mutex_unlock (&mutex); }
|
||||
};
|
||||
} // end namespace llvm
|
@ -1,40 +0,0 @@
|
||||
//===-- Support/ThreadSupport.h - Generic threading support -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines platform-agnostic interfaces that can be used to write
|
||||
// multi-threaded programs. Autoconf is used to chose the correct
|
||||
// implementation of these interfaces, or default to a non-thread-capable system
|
||||
// if no matching system support is available.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_THREADSUPPORT_H
|
||||
#define SUPPORT_THREADSUPPORT_H
|
||||
|
||||
#if @HAVE_PTHREAD_MUTEX_LOCK@
|
||||
#include "Support/ThreadSupport-PThreads.h"
|
||||
#else
|
||||
#include "Support/ThreadSupport-NoSupport.h"
|
||||
#endif // If no system support is available
|
||||
|
||||
namespace llvm {
|
||||
/// MutexLocker - Instances of this class acquire a given Lock when
|
||||
/// constructed and hold that lock until destruction.
|
||||
///
|
||||
class MutexLocker {
|
||||
Mutex &M;
|
||||
MutexLocker(const MutexLocker &); // DO NOT IMPLEMENT
|
||||
void operator=(const MutexLocker &); // DO NOT IMPLEMENT
|
||||
public:
|
||||
MutexLocker(Mutex &m) : M(m) { M.acquire(); }
|
||||
~MutexLocker() { M.release(); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SUPPORT_THREADSUPPORT_H
|
@ -1,164 +0,0 @@
|
||||
//===-- Support/Timer.h - Interval Timing Support ---------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines three classes: Timer, TimeRegion, and TimerGroup,
|
||||
// documented below.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_TIMER_H
|
||||
#define SUPPORT_TIMER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class TimerGroup;
|
||||
|
||||
/// Timer - This class is used to track the amount of time spent between
|
||||
/// invocations of it's startTimer()/stopTimer() methods. Given appropriate OS
|
||||
/// support it can also keep track of the RSS of the program at various points.
|
||||
/// By default, the Timer will print the amount of time it has captured to
|
||||
/// standard error when the laster timer is destroyed, otherwise it is printed
|
||||
/// when it's TimerGroup is destroyed. Timer's do not print their information
|
||||
/// if they are never started.
|
||||
///
|
||||
class Timer {
|
||||
double Elapsed; // Wall clock time elapsed in seconds
|
||||
double UserTime; // User time elapsed
|
||||
double SystemTime; // System time elapsed
|
||||
long MemUsed; // Memory allocated (in bytes)
|
||||
long PeakMem; // Peak memory used
|
||||
long PeakMemBase; // Temporary for peak calculation...
|
||||
std::string Name; // The name of this time variable
|
||||
bool Started; // Has this time variable ever been started?
|
||||
TimerGroup *TG; // The TimerGroup this Timer is in.
|
||||
public:
|
||||
Timer(const std::string &N);
|
||||
Timer(const std::string &N, TimerGroup &tg);
|
||||
Timer(const Timer &T);
|
||||
~Timer();
|
||||
|
||||
double getProcessTime() const { return UserTime+SystemTime; }
|
||||
double getWallTime() const { return Elapsed; }
|
||||
long getMemUsed() const { return MemUsed; }
|
||||
long getPeakMem() const { return PeakMem; }
|
||||
std::string getName() const { return Name; }
|
||||
|
||||
const Timer &operator=(const Timer &T) {
|
||||
Elapsed = T.Elapsed;
|
||||
UserTime = T.UserTime;
|
||||
SystemTime = T.SystemTime;
|
||||
MemUsed = T.MemUsed;
|
||||
PeakMem = T.PeakMem;
|
||||
PeakMemBase = T.PeakMemBase;
|
||||
Name = T.Name;
|
||||
Started = T.Started;
|
||||
assert(TG == T.TG && "Can only assign timers in the same TimerGroup!");
|
||||
return *this;
|
||||
}
|
||||
|
||||
// operator< - Allow sorting...
|
||||
bool operator<(const Timer &T) const {
|
||||
// Sort by Wall Time elapsed, as it is the only thing really accurate
|
||||
return Elapsed < T.Elapsed;
|
||||
}
|
||||
bool operator>(const Timer &T) const { return T.operator<(*this); }
|
||||
|
||||
/// startTimer - Start the timer running. Time between calls to
|
||||
/// startTimer/stopTimer is counted by the Timer class. Note that these calls
|
||||
/// must be correctly paired.
|
||||
///
|
||||
void startTimer();
|
||||
|
||||
/// stopTimer - Stop the timer.
|
||||
///
|
||||
void stopTimer();
|
||||
|
||||
/// addPeakMemoryMeasurement - This method should be called whenever memory
|
||||
/// usage needs to be checked. It adds a peak memory measurement to the
|
||||
/// currently active timers, which will be printed when the timer group prints
|
||||
///
|
||||
static void addPeakMemoryMeasurement();
|
||||
|
||||
/// print - Print the current timer to standard error, and reset the "Started"
|
||||
/// flag.
|
||||
void print(const Timer &Total, std::ostream &OS);
|
||||
|
||||
private:
|
||||
friend class TimerGroup;
|
||||
|
||||
// Copy ctor, initialize with no TG member.
|
||||
Timer(bool, const Timer &T);
|
||||
|
||||
/// sum - Add the time accumulated in the specified timer into this timer.
|
||||
///
|
||||
void sum(const Timer &T);
|
||||
};
|
||||
|
||||
|
||||
/// The TimeRegion class is used as a helper class to call the startTimer() and
|
||||
/// stopTimer() methods of the Timer class. When the object is constructed, it
|
||||
/// starts the timer specified as it's argument. When it is destroyed, it stops
|
||||
/// the relevant timer. This makes it easy to time a region of code.
|
||||
///
|
||||
class TimeRegion {
|
||||
Timer &T;
|
||||
TimeRegion(const TimeRegion &); // DO NOT IMPLEMENT
|
||||
public:
|
||||
TimeRegion(Timer &t) : T(t) {
|
||||
T.startTimer();
|
||||
}
|
||||
~TimeRegion() {
|
||||
T.stopTimer();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// NamedRegionTimer - This class is basically a combination of TimeRegion and
|
||||
/// Timer. It allows you to declare a new timer, AND specify the region to
|
||||
/// time, all in one statement. All timers with the same name are merged. This
|
||||
/// is primarily used for debugging and for hunting performance problems.
|
||||
///
|
||||
struct NamedRegionTimer : public TimeRegion {
|
||||
NamedRegionTimer(const std::string &Name);
|
||||
};
|
||||
|
||||
|
||||
/// The TimerGroup class is used to group together related timers into a single
|
||||
/// report that is printed when the TimerGroup is destroyed. It is illegal to
|
||||
/// destroy a TimerGroup object before all of the Timers in it are gone. A
|
||||
/// TimerGroup can be specified for a newly created timer in its constructor.
|
||||
///
|
||||
class TimerGroup {
|
||||
std::string Name;
|
||||
unsigned NumTimers;
|
||||
std::vector<Timer> TimersToPrint;
|
||||
public:
|
||||
TimerGroup(const std::string &name) : Name(name), NumTimers(0) {}
|
||||
~TimerGroup() {
|
||||
assert(NumTimers == 0 &&
|
||||
"TimerGroup destroyed before all contained timers!");
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Timer;
|
||||
void addTimer() { ++NumTimers; }
|
||||
void removeTimer();
|
||||
void addTimerToPrint(const Timer &T) {
|
||||
TimersToPrint.push_back(Timer(true, T));
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,62 +0,0 @@
|
||||
//===- Support/Tree.h - Generic n-way tree structure ------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class defines a generic N way tree node structure. The tree structure
|
||||
// is immutable after creation, but the payload contained within it is not.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_TREE_H
|
||||
#define SUPPORT_TREE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template<class ConcreteTreeNode, class Payload>
|
||||
class Tree {
|
||||
std::vector<ConcreteTreeNode*> Children; // This nodes children, if any
|
||||
ConcreteTreeNode *Parent; // Parent of this node...
|
||||
Payload Data; // Data held in this node...
|
||||
|
||||
protected:
|
||||
void setChildren(const std::vector<ConcreteTreeNode*> &children) {
|
||||
Children = children;
|
||||
}
|
||||
public:
|
||||
inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
|
||||
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||
ConcreteTreeNode *par) : Children(children), Parent(par) {}
|
||||
|
||||
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||
ConcreteTreeNode *par, const Payload &data)
|
||||
: Children(children), Parent(par), Data(data) {}
|
||||
|
||||
// Tree dtor - Free all children
|
||||
inline ~Tree() {
|
||||
for (unsigned i = Children.size(); i > 0; --i)
|
||||
delete Children[i-1];
|
||||
}
|
||||
|
||||
// Tree manipulation/walking routines...
|
||||
inline ConcreteTreeNode *getParent() const { return Parent; }
|
||||
inline unsigned getNumChildren() const { return Children.size(); }
|
||||
inline ConcreteTreeNode *getChild(unsigned i) const {
|
||||
assert(i < Children.size() && "Tree::getChild with index out of range!");
|
||||
return Children[i];
|
||||
}
|
||||
|
||||
// Payload access...
|
||||
inline Payload &getTreeData() { return Data; }
|
||||
inline const Payload &getTreeData() const { return Data; }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,76 +0,0 @@
|
||||
//===- Support/TypeInfo.h - Support class for type_info objects -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class makes std::type_info objects behave like first class objects that
|
||||
// can be put in maps and hashtables. This code is based off of code in the
|
||||
// Loki C++ library from the Modern C++ Design book.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_TYPEINFO_H
|
||||
#define SUPPORT_TYPEINFO_H
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
struct TypeInfo {
|
||||
TypeInfo() { // needed for containers
|
||||
struct Nil {}; // Anonymous class distinct from all others...
|
||||
Info = &typeid(Nil);
|
||||
}
|
||||
|
||||
TypeInfo(const std::type_info &ti) : Info(&ti) { // non-explicit
|
||||
}
|
||||
|
||||
// Access for the wrapped std::type_info
|
||||
const std::type_info &get() const {
|
||||
return *Info;
|
||||
}
|
||||
|
||||
// Compatibility functions
|
||||
bool before(const TypeInfo &rhs) const {
|
||||
return Info->before(*rhs.Info) != 0;
|
||||
}
|
||||
const char *getClassName() const {
|
||||
return Info->name();
|
||||
}
|
||||
|
||||
private:
|
||||
const std::type_info *Info;
|
||||
};
|
||||
|
||||
// Comparison operators
|
||||
inline bool operator==(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return lhs.get() == rhs.get();
|
||||
}
|
||||
|
||||
inline bool operator<(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return lhs.before(rhs);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator>(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
inline bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
inline bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs) {
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
//===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains helper functions which are useful for working with the
|
||||
// std::vector class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_VECTOREXTRAS_H
|
||||
#define SUPPORT_VECTOREXTRAS_H
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// make_vector - Helper function which is useful for building temporary vectors
|
||||
/// to pass into type construction of CallInst ctors. This turns a null
|
||||
/// terminated list of pointers (or other value types) into a real live vector.
|
||||
///
|
||||
template<typename T>
|
||||
inline std::vector<T> make_vector(T A, ...) {
|
||||
va_list Args;
|
||||
va_start(Args, A);
|
||||
std::vector<T> Result;
|
||||
Result.push_back(A);
|
||||
while (T Val = va_arg(Args, T))
|
||||
Result.push_back(Val);
|
||||
va_end(Args);
|
||||
return Result;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
//===-- Support/hash_map - "Portable" wrapper around hash_map ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file provides a wrapper around the mysterious <hash_map> header file
|
||||
// that seems to move around between GCC releases into and out of namespaces at
|
||||
// will. #including this header will cause hash_map to be available in the
|
||||
// global namespace.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASH_MAP
|
||||
#define SUPPORT_HASH_MAP
|
||||
|
||||
// Compiler Support Matrix
|
||||
//
|
||||
// Version Namespace Header File
|
||||
// 2.95.x :: hash_map
|
||||
// 3.0.4 std ext/hash_map
|
||||
// 3.1 __gnu_cxx ext/hash_map
|
||||
//
|
||||
|
||||
#if @HAVE_GNU_EXT_HASH_MAP@
|
||||
// This is for GCC-3.1+ which puts hash in ext/hash_map
|
||||
# include <ext/hash_map>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE __gnu_cxx
|
||||
# endif
|
||||
|
||||
// GCC 3.0.x puts hash_map in <ext/hash_map> and in the std namespace.
|
||||
#elif @HAVE_STD_EXT_HASH_MAP@
|
||||
# include <ext/hash_map>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE std
|
||||
# endif
|
||||
|
||||
// Older compilers such as GCC before version 3.0 do not keep
|
||||
// extensions in the `ext' directory, and ignore the `std' namespace.
|
||||
#elif @HAVE_GLOBAL_HASH_MAP@
|
||||
# include <hash_map>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE std
|
||||
# endif
|
||||
|
||||
// Give a warning if we couldn't find it, instead of (or in addition to)
|
||||
// randomly doing something dumb.
|
||||
#else
|
||||
# warning "Autoconfiguration failed to find the hash_map header file."
|
||||
#endif
|
||||
|
||||
using HASH_NAMESPACE::hash_map;
|
||||
using HASH_NAMESPACE::hash_multimap;
|
||||
using HASH_NAMESPACE::hash;
|
||||
|
||||
// Include vector because ext/hash_map includes stl_vector.h and leaves
|
||||
// out specializations like stl_bvector.h, causing link conflicts.
|
||||
#include <vector>
|
||||
|
||||
#include <Support/HashExtras.h>
|
||||
|
||||
#endif
|
@ -1,67 +0,0 @@
|
||||
//===-- Support/hash_set - "Portable" wrapper around hash_set ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// vim:ft=cpp
|
||||
//
|
||||
// This file provides a wrapper around the mysterious <hash_set> header file
|
||||
// that seems to move around between GCC releases into and out of namespaces at
|
||||
// will. #including this header will cause hash_set to be available in the
|
||||
// global namespace.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASH_SET
|
||||
#define SUPPORT_HASH_SET
|
||||
|
||||
// Compiler Support Matrix
|
||||
//
|
||||
// Version Namespace Header File
|
||||
// 2.95.x :: hash_set
|
||||
// 3.0.4 std ext/hash_set
|
||||
// 3.1 __gnu_cxx ext/hash_set
|
||||
//
|
||||
|
||||
// GCC versions 3.1 and later put hash_set in <ext/hash_set> and in
|
||||
// the __gnu_cxx namespace.
|
||||
#if @HAVE_GNU_EXT_HASH_SET@
|
||||
# include <ext/hash_set>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE __gnu_cxx
|
||||
# endif
|
||||
|
||||
// GCC 3.0.x puts hash_set in <ext/hash_set> and in the std namespace.
|
||||
#elif @HAVE_STD_EXT_HASH_SET@
|
||||
# include <ext/hash_set>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE std
|
||||
# endif
|
||||
|
||||
// Older compilers such as GCC before version 3.0 do not keep
|
||||
// extensions in the `ext' directory, and ignore the `std' namespace.
|
||||
#elif @HAVE_GLOBAL_HASH_SET@
|
||||
# include <hash_set>
|
||||
# ifndef HASH_NAMESPACE
|
||||
# define HASH_NAMESPACE std
|
||||
# endif
|
||||
|
||||
// Give a warning if we couldn't find it, instead of (or in addition to)
|
||||
// randomly doing something dumb.
|
||||
#else
|
||||
# warning "Autoconfiguration failed to find the hash_set header file."
|
||||
#endif
|
||||
|
||||
using HASH_NAMESPACE::hash_set;
|
||||
using HASH_NAMESPACE::hash;
|
||||
|
||||
// Include vector because ext/hash_set includes stl_vector.h and leaves
|
||||
// out specializations like stl_bvector.h, causing link conflicts.
|
||||
#include <vector>
|
||||
|
||||
#include <Support/HashExtras.h>
|
||||
|
||||
#endif
|
@ -1,638 +0,0 @@
|
||||
//===-- Support/ilist - Intrusive Linked List Template ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines classes to implement an intrusive doubly linked list class
|
||||
// (ie each node of the list must contain a next and previous field for the
|
||||
// list.
|
||||
//
|
||||
// The ilist_traits trait class is used to gain access to the next and previous
|
||||
// fields of the node type that the list is instantiated with. If it is not
|
||||
// specialized, the list defaults to using the getPrev(), getNext() method calls
|
||||
// to get the next and previous pointers.
|
||||
//
|
||||
// The ilist class itself, should be a plug in replacement for list, assuming
|
||||
// that the nodes contain next/prev pointers. This list replacement does not
|
||||
// provides a constant time size() method, so be careful to use empty() when you
|
||||
// really want to know if it's empty.
|
||||
//
|
||||
// The ilist class is implemented by allocating a 'tail' node when the list is
|
||||
// created (using ilist_traits<>::createEndMarker()). This tail node is
|
||||
// absolutely required because the user must be able to compute end()-1. Because
|
||||
// of this, users of the direct next/prev links will see an extra link on the
|
||||
// end of the list, which should be ignored.
|
||||
//
|
||||
// Requirements for a user of this list:
|
||||
//
|
||||
// 1. The user must provide {g|s}et{Next|Prev} methods, or specialize
|
||||
// ilist_traits to provide an alternate way of getting and setting next and
|
||||
// prev links.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_ILIST
|
||||
#define SUPPORT_ILIST
|
||||
|
||||
#include <Support/iterator>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template<typename NodeTy, typename Traits> class iplist;
|
||||
template<typename NodeTy> class ilist_iterator;
|
||||
|
||||
// Template traits for intrusive list. By specializing this template class, you
|
||||
// can change what next/prev fields are used to store the links...
|
||||
template<typename NodeTy>
|
||||
struct ilist_traits {
|
||||
static NodeTy *getPrev(NodeTy *N) { return N->getPrev(); }
|
||||
static NodeTy *getNext(NodeTy *N) { return N->getNext(); }
|
||||
static const NodeTy *getPrev(const NodeTy *N) { return N->getPrev(); }
|
||||
static const NodeTy *getNext(const NodeTy *N) { return N->getNext(); }
|
||||
|
||||
static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); }
|
||||
static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); }
|
||||
|
||||
static NodeTy *createNode() { return new NodeTy(); }
|
||||
static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
|
||||
|
||||
|
||||
void addNodeToList(NodeTy *NTy) {}
|
||||
void removeNodeFromList(NodeTy *NTy) {}
|
||||
void transferNodesFromList(iplist<NodeTy, ilist_traits> &L2,
|
||||
ilist_iterator<NodeTy> first,
|
||||
ilist_iterator<NodeTy> last) {}
|
||||
};
|
||||
|
||||
// Const traits are the same as nonconst traits...
|
||||
template<typename Ty>
|
||||
struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ilist_iterator<Node> - Iterator for intrusive list.
|
||||
//
|
||||
template<typename NodeTy>
|
||||
class ilist_iterator
|
||||
: public bidirectional_iterator<NodeTy, ptrdiff_t> {
|
||||
typedef ilist_traits<NodeTy> Traits;
|
||||
typedef bidirectional_iterator<NodeTy, ptrdiff_t> super;
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef typename super::pointer pointer;
|
||||
typedef typename super::reference reference;
|
||||
private:
|
||||
pointer NodePtr;
|
||||
public:
|
||||
|
||||
ilist_iterator(pointer NP) : NodePtr(NP) {}
|
||||
ilist_iterator(reference NR) : NodePtr(&NR) {}
|
||||
ilist_iterator() : NodePtr(0) {}
|
||||
|
||||
// This is templated so that we can allow constructing a const iterator from
|
||||
// a nonconst iterator...
|
||||
template<class node_ty>
|
||||
ilist_iterator(const ilist_iterator<node_ty> &RHS)
|
||||
: NodePtr(RHS.getNodePtrUnchecked()) {}
|
||||
|
||||
// This is templated so that we can allow assigning to a const iterator from
|
||||
// a nonconst iterator...
|
||||
template<class node_ty>
|
||||
const ilist_iterator &operator=(const ilist_iterator<node_ty> &RHS) {
|
||||
NodePtr = RHS.getNodePtrUnchecked();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Accessors...
|
||||
operator pointer() const {
|
||||
assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
|
||||
return NodePtr;
|
||||
}
|
||||
|
||||
reference operator*() const {
|
||||
assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
|
||||
return *NodePtr;
|
||||
}
|
||||
pointer operator->() { return &operator*(); }
|
||||
const pointer operator->() const { return &operator*(); }
|
||||
|
||||
// Comparison operators
|
||||
bool operator==(const ilist_iterator &RHS) const {
|
||||
return NodePtr == RHS.NodePtr;
|
||||
}
|
||||
bool operator!=(const ilist_iterator &RHS) const {
|
||||
return NodePtr != RHS.NodePtr;
|
||||
}
|
||||
|
||||
// Increment and decrement operators...
|
||||
ilist_iterator &operator--() { // predecrement - Back up
|
||||
NodePtr = Traits::getPrev(NodePtr);
|
||||
assert(NodePtr && "--'d off the beginning of an ilist!");
|
||||
return *this;
|
||||
}
|
||||
ilist_iterator &operator++() { // preincrement - Advance
|
||||
NodePtr = Traits::getNext(NodePtr);
|
||||
assert(NodePtr && "++'d off the end of an ilist!");
|
||||
return *this;
|
||||
}
|
||||
ilist_iterator operator--(int) { // postdecrement operators...
|
||||
ilist_iterator tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
ilist_iterator operator++(int) { // postincrement operators...
|
||||
ilist_iterator tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// Internal interface, do not use...
|
||||
pointer getNodePtrUnchecked() const { return NodePtr; }
|
||||
};
|
||||
|
||||
// do not implement. this is to catch errors when people try to use
|
||||
// them as random access iterators
|
||||
template<typename T>
|
||||
void operator-(int, ilist_iterator<T>);
|
||||
template<typename T>
|
||||
void operator-(ilist_iterator<T>,int);
|
||||
|
||||
template<typename T>
|
||||
void operator+(int, ilist_iterator<T>);
|
||||
template<typename T>
|
||||
void operator+(ilist_iterator<T>,int);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ilist_compat_iterator<Node> - Compatibility iterator for intrusive list.
|
||||
// This makes an ilist<X> act like an std::list<X*>, where you have to
|
||||
// dereference stuff multiple times. This should only be used for temporary
|
||||
// migration purposes. Because we don't support "changing the pointer", we only
|
||||
// expose constant pointers.
|
||||
//
|
||||
template<typename NodeTy>
|
||||
class ilist_compat_iterator
|
||||
: public bidirectional_iterator<NodeTy* const, ptrdiff_t> {
|
||||
typedef ilist_traits<NodeTy> Traits;
|
||||
typedef bidirectional_iterator<NodeTy* const, ptrdiff_t> super;
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef typename super::pointer pointer;
|
||||
typedef typename super::reference reference;
|
||||
private:
|
||||
NodeTy *NodePtr;
|
||||
public:
|
||||
|
||||
ilist_compat_iterator(NodeTy *NP) : NodePtr(NP) {}
|
||||
ilist_compat_iterator() : NodePtr(0) {}
|
||||
|
||||
// This is templated so that we can allow constructing a const iterator from
|
||||
// a nonconst iterator...
|
||||
template<class node_ty>
|
||||
ilist_compat_iterator(const ilist_compat_iterator<node_ty> &RHS)
|
||||
: NodePtr(RHS.getNodePtrUnchecked()) {}
|
||||
|
||||
// This is templated so that we can allow assigning to a const iterator from
|
||||
// a nonconst iterator...
|
||||
template<class node_ty>
|
||||
const ilist_compat_iterator &operator=(const
|
||||
ilist_compat_iterator<node_ty> &RHS) {
|
||||
NodePtr = RHS.getNodePtrUnchecked();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Accessors...
|
||||
operator pointer() const {
|
||||
assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
|
||||
return &NodePtr;
|
||||
}
|
||||
|
||||
reference operator*() const {
|
||||
assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
|
||||
return NodePtr;
|
||||
}
|
||||
pointer operator->() { return &operator*(); }
|
||||
const pointer operator->() const { return &operator*(); }
|
||||
|
||||
// Comparison operators
|
||||
bool operator==(const ilist_compat_iterator &RHS) const {
|
||||
return NodePtr == RHS.NodePtr;
|
||||
}
|
||||
bool operator!=(const ilist_compat_iterator &RHS) const {
|
||||
return NodePtr != RHS.NodePtr;
|
||||
}
|
||||
|
||||
// Increment and decrement operators...
|
||||
ilist_compat_iterator &operator--() { // predecrement - Back up
|
||||
NodePtr = Traits::getPrev(NodePtr);
|
||||
assert(NodePtr && "--'d off the beginning of an ilist!");
|
||||
return *this;
|
||||
}
|
||||
ilist_compat_iterator &operator++() { // preincrement - Advance
|
||||
NodePtr = Traits::getNext(NodePtr);
|
||||
assert(NodePtr && "++'d off the end of an ilist!");
|
||||
return *this;
|
||||
}
|
||||
ilist_compat_iterator operator--(int) { // postdecrement operators...
|
||||
ilist_compat_iterator tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
ilist_compat_iterator operator++(int) { // postincrement operators...
|
||||
ilist_compat_iterator tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// Internal interface, do not use...
|
||||
pointer getNodePtrUnchecked() const { return NodePtr; }
|
||||
};
|
||||
|
||||
|
||||
// Allow ilist_iterators to convert into pointers to a node automatically when
|
||||
// used by the dyn_cast, cast, isa mechanisms...
|
||||
|
||||
template<typename From> struct simplify_type;
|
||||
|
||||
template<typename NodeTy> struct simplify_type<ilist_iterator<NodeTy> > {
|
||||
typedef NodeTy* SimpleType;
|
||||
|
||||
static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) {
|
||||
return &*Node;
|
||||
}
|
||||
};
|
||||
template<typename NodeTy> struct simplify_type<const ilist_iterator<NodeTy> > {
|
||||
typedef NodeTy* SimpleType;
|
||||
|
||||
static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) {
|
||||
return &*Node;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// iplist - The subset of list functionality that can safely be used on nodes of
|
||||
// polymorphic types, ie a heterogeneus list with a common base class that holds
|
||||
// the next/prev pointers...
|
||||
//
|
||||
template<typename NodeTy, typename Traits=ilist_traits<NodeTy> >
|
||||
class iplist : public Traits {
|
||||
NodeTy *Head, *Tail;
|
||||
|
||||
static bool op_less(NodeTy &L, NodeTy &R) { return L < R; }
|
||||
static bool op_equal(NodeTy &L, NodeTy &R) { return L == R; }
|
||||
public:
|
||||
typedef NodeTy *pointer;
|
||||
typedef const NodeTy *const_pointer;
|
||||
typedef NodeTy &reference;
|
||||
typedef const NodeTy &const_reference;
|
||||
typedef NodeTy value_type;
|
||||
typedef ilist_iterator<NodeTy> iterator;
|
||||
typedef ilist_iterator<const NodeTy> const_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
|
||||
iplist() : Head(Traits::createNode()), Tail(Head) {
|
||||
setNext(Head, 0);
|
||||
setPrev(Head, 0);
|
||||
}
|
||||
~iplist() { clear(); delete Tail; }
|
||||
|
||||
// Iterator creation methods.
|
||||
iterator begin() { return iterator(Head); }
|
||||
const_iterator begin() const { return const_iterator(Head); }
|
||||
iterator end() { return iterator(Tail); }
|
||||
const_iterator end() const { return const_iterator(Tail); }
|
||||
|
||||
// reverse iterator creation methods.
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const {return const_reverse_iterator(begin());}
|
||||
|
||||
|
||||
// "compatibility" iterator creation methods.
|
||||
typedef ilist_compat_iterator<NodeTy> compat_iterator;
|
||||
compat_iterator compat_begin() const { return compat_iterator(Head); }
|
||||
compat_iterator compat_end() const { return compat_iterator(Tail); }
|
||||
|
||||
// Miscellaneous inspection routines.
|
||||
size_type max_size() const { return size_type(-1); }
|
||||
bool empty() const { return Head == Tail; }
|
||||
|
||||
// Front and back accessor functions...
|
||||
reference front() {
|
||||
assert(!empty() && "Called front() on empty list!");
|
||||
return *Head;
|
||||
}
|
||||
const_reference front() const {
|
||||
assert(!empty() && "Called front() on empty list!");
|
||||
return *Head;
|
||||
}
|
||||
reference back() {
|
||||
assert(!empty() && "Called back() on empty list!");
|
||||
return *getPrev(Tail);
|
||||
}
|
||||
const_reference back() const {
|
||||
assert(!empty() && "Called back() on empty list!");
|
||||
return *getPrev(Tail);
|
||||
}
|
||||
|
||||
void swap(iplist &RHS) {
|
||||
abort(); // Swap does not use list traits callback correctly yet!
|
||||
std::swap(Head, RHS.Head);
|
||||
std::swap(Tail, RHS.Tail);
|
||||
}
|
||||
|
||||
iterator insert(iterator where, NodeTy *New) {
|
||||
NodeTy *CurNode = where.getNodePtrUnchecked(), *PrevNode = getPrev(CurNode);
|
||||
setNext(New, CurNode);
|
||||
setPrev(New, PrevNode);
|
||||
|
||||
if (PrevNode)
|
||||
setNext(PrevNode, New);
|
||||
else
|
||||
Head = New;
|
||||
setPrev(CurNode, New);
|
||||
|
||||
addNodeToList(New); // Notify traits that we added a node...
|
||||
return New;
|
||||
}
|
||||
|
||||
NodeTy *remove(iterator &IT) {
|
||||
assert(IT != end() && "Cannot remove end of list!");
|
||||
NodeTy *Node = &*IT;
|
||||
NodeTy *NextNode = getNext(Node);
|
||||
NodeTy *PrevNode = getPrev(Node);
|
||||
|
||||
if (PrevNode)
|
||||
setNext(PrevNode, NextNode);
|
||||
else
|
||||
Head = NextNode;
|
||||
setPrev(NextNode, PrevNode);
|
||||
IT = NextNode;
|
||||
removeNodeFromList(Node); // Notify traits that we removed a node...
|
||||
return Node;
|
||||
}
|
||||
|
||||
NodeTy *remove(const iterator &IT) {
|
||||
iterator MutIt = IT;
|
||||
return remove(MutIt);
|
||||
}
|
||||
|
||||
// erase - remove a node from the controlled sequence... and delete it.
|
||||
iterator erase(iterator where) {
|
||||
delete remove(where);
|
||||
return where;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// transfer - The heart of the splice function. Move linked list nodes from
|
||||
// [first, last) into position.
|
||||
//
|
||||
void transfer(iterator position, iplist &L2, iterator first, iterator last) {
|
||||
assert(first != last && "Should be checked by callers");
|
||||
if (position != last) {
|
||||
// Remove [first, last) from its old position.
|
||||
NodeTy *First = &*first, *Prev = getPrev(First);
|
||||
NodeTy *Next = last.getNodePtrUnchecked(), *Last = getPrev(Next);
|
||||
if (Prev)
|
||||
setNext(Prev, Next);
|
||||
else
|
||||
L2.Head = Next;
|
||||
setPrev(Next, Prev);
|
||||
|
||||
// Splice [first, last) into its new position.
|
||||
NodeTy *PosNext = position.getNodePtrUnchecked();
|
||||
NodeTy *PosPrev = getPrev(PosNext);
|
||||
|
||||
// Fix head of list...
|
||||
if (PosPrev)
|
||||
setNext(PosPrev, First);
|
||||
else
|
||||
Head = First;
|
||||
setPrev(First, PosPrev);
|
||||
|
||||
// Fix end of list...
|
||||
setNext(Last, PosNext);
|
||||
setPrev(PosNext, Last);
|
||||
|
||||
transferNodesFromList(L2, First, PosNext);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//===----------------------------------------------------------------------===
|
||||
// Functionality derived from other functions defined above...
|
||||
//
|
||||
|
||||
size_type size() const {
|
||||
#if __GNUC__ == 2
|
||||
// GCC 2.95 has a broken std::distance
|
||||
size_type Result = 0;
|
||||
std::distance(begin(), end(), Result);
|
||||
return Result;
|
||||
#else
|
||||
return std::distance(begin(), end());
|
||||
#endif
|
||||
}
|
||||
|
||||
iterator erase(iterator first, iterator last) {
|
||||
while (first != last)
|
||||
first = erase(first);
|
||||
return last;
|
||||
}
|
||||
|
||||
void clear() { erase(begin(), end()); }
|
||||
|
||||
// Front and back inserters...
|
||||
void push_front(NodeTy *val) { insert(begin(), val); }
|
||||
void push_back(NodeTy *val) { insert(end(), val); }
|
||||
void pop_front() {
|
||||
assert(!empty() && "pop_front() on empty list!");
|
||||
erase(begin());
|
||||
}
|
||||
void pop_back() {
|
||||
assert(!empty() && "pop_back() on empty list!");
|
||||
iterator t = end(); erase(--t);
|
||||
}
|
||||
|
||||
// Special forms of insert...
|
||||
template<class InIt> void insert(iterator where, InIt first, InIt last) {
|
||||
for (; first != last; ++first) insert(where, *first);
|
||||
}
|
||||
|
||||
// Splice members - defined in terms of transfer...
|
||||
void splice(iterator where, iplist &L2) {
|
||||
if (!L2.empty())
|
||||
transfer(where, L2, L2.begin(), L2.end());
|
||||
}
|
||||
void splice(iterator where, iplist &L2, iterator first) {
|
||||
iterator last = first; ++last;
|
||||
if (where == first || where == last) return; // No change
|
||||
transfer(where, L2, first, last);
|
||||
}
|
||||
void splice(iterator where, iplist &L2, iterator first, iterator last) {
|
||||
if (first != last) transfer(where, L2, first, last);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===
|
||||
// High-Level Functionality that shouldn't really be here, but is part of list
|
||||
//
|
||||
|
||||
// These two functions are actually called remove/remove_if in list<>, but
|
||||
// they actually do the job of erase, rename them accordingly.
|
||||
//
|
||||
void erase(const NodeTy &val) {
|
||||
for (iterator I = begin(), E = end(); I != E; ) {
|
||||
iterator next = I; ++next;
|
||||
if (*I == val) erase(I);
|
||||
I = next;
|
||||
}
|
||||
}
|
||||
template<class Pr1> void erase_if(Pr1 pred) {
|
||||
for (iterator I = begin(), E = end(); I != E; ) {
|
||||
iterator next = I; ++next;
|
||||
if (pred(*I)) erase(I);
|
||||
I = next;
|
||||
}
|
||||
}
|
||||
|
||||
template<class Pr2> void unique(Pr2 pred) {
|
||||
if (empty()) return;
|
||||
for (iterator I = begin(), E = end(), Next = begin(); ++Next != E;) {
|
||||
if (pred(*I))
|
||||
erase(Next);
|
||||
else
|
||||
I = Next;
|
||||
Next = I;
|
||||
}
|
||||
}
|
||||
void unique() { unique(op_equal); }
|
||||
|
||||
template<class Pr3> void merge(iplist &right, Pr3 pred) {
|
||||
iterator first1 = begin(), last1 = end();
|
||||
iterator first2 = right.begin(), last2 = right.end();
|
||||
while (first1 != last1 && first2 != last2)
|
||||
if (pred(*first2, *first1)) {
|
||||
iterator next = first2;
|
||||
transfer(first1, right, first2, ++next);
|
||||
first2 = next;
|
||||
} else {
|
||||
++first1;
|
||||
}
|
||||
if (first2 != last2) transfer(last1, right, first2, last2);
|
||||
}
|
||||
void merge(iplist &right) { return merge(right, op_less); }
|
||||
|
||||
template<class Pr3> void sort(Pr3 pred);
|
||||
void sort() { sort(op_less); }
|
||||
void reverse();
|
||||
};
|
||||
|
||||
|
||||
template<typename NodeTy>
|
||||
struct ilist : public iplist<NodeTy> {
|
||||
typedef typename iplist<NodeTy>::size_type size_type;
|
||||
typedef typename iplist<NodeTy>::iterator iterator;
|
||||
|
||||
ilist() {}
|
||||
ilist(const ilist &right) {
|
||||
insert(this->begin(), right.begin(), right.end());
|
||||
}
|
||||
explicit ilist(size_type count) {
|
||||
insert(this->begin(), count, NodeTy());
|
||||
}
|
||||
ilist(size_type count, const NodeTy &val) {
|
||||
insert(this->begin(), count, val);
|
||||
}
|
||||
template<class InIt> ilist(InIt first, InIt last) {
|
||||
insert(this->begin(), first, last);
|
||||
}
|
||||
|
||||
|
||||
// Forwarding functions: A workaround for GCC 2.95 which does not correctly
|
||||
// support 'using' declarations to bring a hidden member into scope.
|
||||
//
|
||||
iterator insert(iterator a, NodeTy *b){ return iplist<NodeTy>::insert(a, b); }
|
||||
void push_front(NodeTy *a) { iplist<NodeTy>::push_front(a); }
|
||||
void push_back(NodeTy *a) { iplist<NodeTy>::push_back(a); }
|
||||
|
||||
|
||||
// Main implementation here - Insert for a node passed by value...
|
||||
iterator insert(iterator where, const NodeTy &val) {
|
||||
return insert(where, createNode(val));
|
||||
}
|
||||
|
||||
|
||||
// Front and back inserters...
|
||||
void push_front(const NodeTy &val) { insert(this->begin(), val); }
|
||||
void push_back(const NodeTy &val) { insert(this->end(), val); }
|
||||
|
||||
// Special forms of insert...
|
||||
template<class InIt> void insert(iterator where, InIt first, InIt last) {
|
||||
for (; first != last; ++first) insert(where, *first);
|
||||
}
|
||||
void insert(iterator where, size_type count, const NodeTy &val) {
|
||||
for (; count != 0; --count) insert(where, val);
|
||||
}
|
||||
|
||||
// Assign special forms...
|
||||
void assign(size_type count, const NodeTy &val) {
|
||||
iterator I = this->begin();
|
||||
for (; I != this->end() && count != 0; ++I, --count)
|
||||
*I = val;
|
||||
if (count != 0)
|
||||
insert(this->end(), val, val);
|
||||
else
|
||||
erase(I, this->end());
|
||||
}
|
||||
template<class InIt> void assign(InIt first1, InIt last1) {
|
||||
iterator first2 = this->begin(), last2 = this->end();
|
||||
for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
|
||||
*first1 = *first2;
|
||||
if (first2 == last2)
|
||||
erase(first1, last1);
|
||||
else
|
||||
insert(last1, first2, last2);
|
||||
}
|
||||
|
||||
|
||||
// Resize members...
|
||||
void resize(size_type newsize, NodeTy val) {
|
||||
iterator i = this->begin();
|
||||
size_type len = 0;
|
||||
for ( ; i != this->end() && len < newsize; ++i, ++len) /* empty*/ ;
|
||||
|
||||
if (len == newsize)
|
||||
erase(i, this->end());
|
||||
else // i == end()
|
||||
insert(this->end(), newsize - len, val);
|
||||
}
|
||||
void resize(size_type newsize) { resize(newsize, NodeTy()); }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
namespace std {
|
||||
// Ensure that swap uses the fast list swap...
|
||||
template<class Ty>
|
||||
void swap(llvm::iplist<Ty> &Left, llvm::iplist<Ty> &Right) {
|
||||
Left.swap(Right);
|
||||
}
|
||||
} // End 'std' extensions...
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
//===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file provides a wrapper around the mysterious <iterator> header file.
|
||||
// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
|
||||
// friends), instead of the standard iterator class. In GCC 3.1, the
|
||||
// bidirectional_iterator class got moved out and the new, standards compliant,
|
||||
// iterator<> class was added. Because there is nothing that we can do to get
|
||||
// correct behavior on both compilers, we have this header with #ifdef's. Gross
|
||||
// huh?
|
||||
//
|
||||
// By #includ'ing this file, you get the contents of <iterator> plus the
|
||||
// following classes in the global namespace:
|
||||
//
|
||||
// 1. bidirectional_iterator
|
||||
// 2. forward_iterator
|
||||
//
|
||||
// The #if directives' expressions are filled in by Autoconf.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_ITERATOR
|
||||
#define SUPPORT_ITERATOR
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#if !@HAVE_BI_ITERATOR@
|
||||
# if @HAVE_STD_ITERATOR@
|
||||
/// If the bidirectional iterator is not defined, we attempt to define it in
|
||||
/// terms of the C++ standard iterator. Otherwise, we import it with a "using"
|
||||
/// statement.
|
||||
///
|
||||
template<class Ty, class PtrDiffTy>
|
||||
struct bidirectional_iterator
|
||||
: public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
|
||||
};
|
||||
# else
|
||||
# error "Need to have standard iterator to define bidirectional iterator!"
|
||||
# endif
|
||||
#else
|
||||
using std::bidirectional_iterator;
|
||||
#endif
|
||||
|
||||
#if !@HAVE_FWD_ITERATOR@
|
||||
# if @HAVE_STD_ITERATOR@
|
||||
/// If the forward iterator is not defined, attempt to define it in terms of
|
||||
/// the C++ standard iterator. Otherwise, we import it with a "using" statement.
|
||||
///
|
||||
template<class Ty, class PtrDiffTy>
|
||||
struct forward_iterator
|
||||
: public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
|
||||
};
|
||||
# else
|
||||
# error "Need to have standard iterator to define forward iterator!"
|
||||
# endif
|
||||
#else
|
||||
using std::forward_iterator;
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,54 +0,0 @@
|
||||
//===- Support/type_traits.h - Simplfied type traits ------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file provides a template class that determines if a type is a class or
|
||||
// not. The basic mechanism, based on using the pointer to member function of
|
||||
// a zero argument to a function was "boosted" from the boost type_traits
|
||||
// library. See http://www.boost.org/ for all the gory details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_TYPE_TRAITS_H
|
||||
#define LLVM_SUPPORT_TYPE_TRAITS_H
|
||||
|
||||
// This is actually the conforming implementation which works with abstract
|
||||
// classes. However, enough compilers have trouble with it that most will use
|
||||
// the one in boost/type_traits/object_traits.hpp. This implementation actually
|
||||
// works with VC7.0, but other interactions seem to fail when we use it.
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace dont_use
|
||||
{
|
||||
// These two functions should never be used. They are helpers to
|
||||
// the is_class template below. They cannot be located inside
|
||||
// is_class because doing so causes at least GCC to think that
|
||||
// the value of the "value" enumerator is not constant. Placing
|
||||
// them out here (for some strange reason) allows the sizeof
|
||||
// operator against them to magically be constant. This is
|
||||
// important to make the is_class<T>::value idiom zero cost. it
|
||||
// evaluates to a constant 1 or 0 depending on whether the
|
||||
// parameter T is a class or not (respectively).
|
||||
template<typename T> char is_class_helper(void(T::*)(void));
|
||||
template<typename T> double is_class_helper(...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_class
|
||||
{
|
||||
// is_class<> metafunction due to Paul Mensonides (leavings@attbi.com). For
|
||||
// more details:
|
||||
// http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1
|
||||
public:
|
||||
enum { value = sizeof(char) == sizeof(dont_use::is_class_helper<T>(0)) };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
//===-- BitVectorSet.h - A bit-vector representation of sets ----*- C++ -*-===//
|
||||
//===-- llvm/ADT/BitVectorSet.h - A bit-vector rep. of sets -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -22,8 +22,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_BITSETVECTOR_H
|
||||
#define SUPPORT_BITSETVECTOR_H
|
||||
#ifndef LLVM_ADT_BITSETVECTOR_H
|
||||
#define LLVM_ADT_BITSETVECTOR_H
|
||||
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===//
|
||||
//===- llvm/ADT/DenseMap.h - A dense map implmentation ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -17,8 +17,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DENSEMAP_H
|
||||
#define SUPPORT_DENSEMAP_H
|
||||
#ifndef LLVM_ADT_DENSEMAP_H
|
||||
#define LLVM_ADT_DENSEMAP_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- Support/DepthFirstIterator.h - Depth First iterator ------*- C++ -*-===//
|
||||
//===- llvm/ADT/DepthFirstIterator.h - Depth First iterator -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file builds on the Support/GraphTraits.h file to build generic depth
|
||||
// This file builds on the ADT/GraphTraits.h file to build generic depth
|
||||
// first graph iterator. This file exposes the following functions/types:
|
||||
//
|
||||
// df_begin/df_end/df_iterator
|
||||
@ -30,11 +30,11 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DEPTHFIRSTITERATOR_H
|
||||
#define SUPPORT_DEPTHFIRSTITERATOR_H
|
||||
#ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H
|
||||
#define LLVM_ADT_DEPTHFIRSTITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/EquivalenceClasses.h ----------------------------*- C++ -*-===//
|
||||
//===-- llvm/ADT/EquivalenceClasses.h - Generic Equiv. Classes --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,8 +14,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_EQUIVALENCECLASSES_H
|
||||
#define SUPPORT_EQUIVALENCECLASSES_H
|
||||
#ifndef LLVM_ADT_EQUIVALENCECLASSES_H
|
||||
#define LLVM_ADT_EQUIVALENCECLASSES_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/GraphTraits.h - Graph traits template -----------*- C++ -*-===//
|
||||
//===-- llvm/ADT/GraphTraits.h - Graph traits template ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -15,8 +15,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_GRAPHTRAITS_H
|
||||
#define SUPPORT_GRAPHTRAITS_H
|
||||
#ifndef LLVM_ADT_GRAPHTRAITS_H
|
||||
#define LLVM_ADT_GRAPHTRAITS_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- HashExtras.h - Useful functions for STL hash containers -*- C++ -*-===//
|
||||
//===-- llvm/ADT/HashExtras.h - Useful functions for STL hash ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,10 +14,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASHEXTRAS_H
|
||||
#define SUPPORT_HASHEXTRAS_H
|
||||
#ifndef LLVM_ADT_HASHEXTRAS_H
|
||||
#define LLVM_ADT_HASHEXTRAS_H
|
||||
|
||||
#include "Support/hash_map"
|
||||
#include "llvm/ADT/hash_map"
|
||||
#include <string>
|
||||
|
||||
// Cannot specialize hash template from outside of the std namespace.
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===//
|
||||
//===- llvm/ADT/DenseMap.h - A dense map implmentation ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -17,8 +17,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_DENSEMAP_H
|
||||
#define SUPPORT_DENSEMAP_H
|
||||
#ifndef LLVM_ADT_DENSEMAP_H
|
||||
#define LLVM_ADT_DENSEMAP_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*-===//
|
||||
//===- llvm/ADT/PostOrderIterator.h - PostOrder iterator --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,17 +7,17 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file builds on the Support/GraphTraits.h file to build a generic graph
|
||||
// This file builds on the ADT/GraphTraits.h file to build a generic graph
|
||||
// post order iterator. This should work over any graph type that has a
|
||||
// GraphTraits specialization.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_POSTORDERITERATOR_H
|
||||
#define SUPPORT_POSTORDERITERATOR_H
|
||||
#ifndef LLVM_ADT_POSTORDERITERATOR_H
|
||||
#define LLVM_ADT_POSTORDERITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include <stack>
|
||||
#include <set>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/SCCIterator.h - SCC iterator --------------------*- C++ -*-===//
|
||||
//===-- Support/SCCIterator.h - Strongly Connected Comp. Iter. --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This builds on the Support/GraphTraits.h file to find the strongly connected
|
||||
// This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected
|
||||
// components (SCCs) of a graph in O(N+E) time using Tarjan's DFS algorithm.
|
||||
//
|
||||
// The SCC iterator has the important property that if a node in SCC S1 has an
|
||||
@ -18,11 +18,11 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SCCITERATOR_H
|
||||
#define SUPPORT_SCCITERATOR_H
|
||||
#ifndef LLVM_ADT_SCCITERATOR_H
|
||||
#define LLVM_ADT_SCCITERATOR_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- STLExtras.h - Useful functions when working with the STL -*- C++ -*-===//
|
||||
//===- llvm/ADT/STLExtras.h - Useful STL related functions ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,12 +14,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STLEXTRAS_H
|
||||
#define SUPPORT_STLEXTRAS_H
|
||||
#ifndef LLVM_ADT_STLEXTRAS_H
|
||||
#define LLVM_ADT_STLEXTRAS_H
|
||||
|
||||
#include <functional>
|
||||
#include <utility> // for std::pair
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/iterator"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/SetOperations.h - Generic Set Operations --------*- C++ -*-===//
|
||||
//===-- llvm/ADT/SetOperations.h - Generic Set Operations -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SETOPERATIONS_H
|
||||
#define SUPPORT_SETOPERATIONS_H
|
||||
#ifndef LLVM_ADT_SETOPERATIONS_H
|
||||
#define LLVM_ADT_SETOPERATIONS_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- SetVector.h - A set with insertion order iteration -------*- C++ -*-===//
|
||||
//===- llvm/ADT/SetVector.h - Set with insert order iteration ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,8 +14,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_SETVECTOR_H
|
||||
#define SUPPORT_SETVECTOR_H
|
||||
#ifndef LLVM_ADT_SETVECTOR_H
|
||||
#define LLVM_ADT_SETVECTOR_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/Statistic.h - Easy way to expose stats ----------*- C++ -*-===//
|
||||
//===-- llvm/ADT/Statistic.h - Easy way to expose stats ---------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -21,8 +21,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STATISTIC_H
|
||||
#define SUPPORT_STATISTIC_H
|
||||
#ifndef LLVM_ADT_STATISTIC_H
|
||||
#define LLVM_ADT_STATISTIC_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/StringExtras.h - Useful string functions --------*- C++ -*-===//
|
||||
//===-- llvm/ADT/StringExtras.h - Useful string functions -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -11,10 +11,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_STRINGEXTRAS_H
|
||||
#define SUPPORT_STRINGEXTRAS_H
|
||||
#ifndef LLVM_ADT_STRINGEXTRAS_H
|
||||
#define LLVM_ADT_STRINGEXTRAS_H
|
||||
|
||||
#include "Support/DataTypes.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- Support/Tree.h - Generic n-way tree structure ------------*- C++ -*-===//
|
||||
//===- llvm/ADT/Tree.h - Generic n-way tree structure -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_TREE_H
|
||||
#define SUPPORT_TREE_H
|
||||
#ifndef LLVM_ADT_TREE_H
|
||||
#define LLVM_ADT_TREE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
|
||||
//===-- llvm/ADT/VectorExtras.h - Helpers for std::vector -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_VECTOREXTRAS_H
|
||||
#define SUPPORT_VECTOREXTRAS_H
|
||||
#ifndef LLVM_ADT_VECTOREXTRAS_H
|
||||
#define LLVM_ADT_VECTOREXTRAS_H
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/hash_map - "Portable" wrapper around hash_map ---*- C++ -*-===//
|
||||
//===-- llvm/ADT/hash_map - "Portable" wrapper around hash_map --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,8 +14,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASH_MAP
|
||||
#define SUPPORT_HASH_MAP
|
||||
#ifndef LLVM_ADT_HASH_MAP
|
||||
#define LLVM_ADT_HASH_MAP
|
||||
|
||||
// Compiler Support Matrix
|
||||
//
|
||||
@ -61,6 +61,6 @@ using HASH_NAMESPACE::hash;
|
||||
// out specializations like stl_bvector.h, causing link conflicts.
|
||||
#include <vector>
|
||||
|
||||
#include <Support/HashExtras.h>
|
||||
#include <llvm/ADT/HashExtras.h>
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/hash_set - "Portable" wrapper around hash_set ---*- C++ -*-===//
|
||||
//===-- llvm/ADT/hash_set - "Portable" wrapper around hash_set --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -15,8 +15,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_HASH_SET
|
||||
#define SUPPORT_HASH_SET
|
||||
#ifndef LLVM_ADT_HASH_SET
|
||||
#define LLVM_ADT_HASH_SET
|
||||
|
||||
// Compiler Support Matrix
|
||||
//
|
||||
@ -62,6 +62,6 @@ using HASH_NAMESPACE::hash;
|
||||
// out specializations like stl_bvector.h, causing link conflicts.
|
||||
#include <vector>
|
||||
|
||||
#include <Support/HashExtras.h>
|
||||
#include <llvm/ADT/HashExtras.h>
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/ilist - Intrusive Linked List Template ----------*- C++ -*-===//
|
||||
//===-- llvm/ADT/ilist - Intrusive Linked List Template ---------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -35,10 +35,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_ILIST
|
||||
#define SUPPORT_ILIST
|
||||
#ifndef LLVM_ADT_ILIST
|
||||
#define LLVM_ADT_ILIST
|
||||
|
||||
#include <Support/iterator>
|
||||
#include <llvm/ADT/iterator>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
|
||||
//===-- llvm/ADT/iterator - Portable wrapper around <iterator> --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -25,8 +25,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SUPPORT_ITERATOR
|
||||
#define SUPPORT_ITERATOR
|
||||
#ifndef LLVM_ADT_ITERATOR
|
||||
#define LLVM_ADT_ITERATOR
|
||||
|
||||
#include <iterator>
|
||||
|
||||
|
@ -18,9 +18,9 @@
|
||||
#define LLVM_ANALYSIS_ALIASSETTRACKER_H
|
||||
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "Support/iterator"
|
||||
#include "Support/hash_map"
|
||||
#include "Support/ilist"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include "llvm/ADT/hash_map"
|
||||
#include "llvm/ADT/ilist"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -51,8 +51,8 @@
|
||||
#ifndef LLVM_ANALYSIS_CALLGRAPH_H
|
||||
#define LLVM_ANALYSIS_CALLGRAPH_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/STLExtras.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
namespace llvm {
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "llvm/Support/InstIterator.h"
|
||||
#include "llvm/Instruction.h"
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/iterator"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
#define LLVM_ANALYSIS_DSGRAPHTRAITS_H
|
||||
|
||||
#include "llvm/Analysis/DataStructure/DSGraph.h"
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/iterator"
|
||||
#include "Support/STLExtras.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#define LLVM_ANALYSIS_DSSUPPORT_H
|
||||
|
||||
#include <functional>
|
||||
#include "Support/hash_set"
|
||||
#include "llvm/ADT/hash_set"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
|
||||
namespace llvm {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "Support/hash_set"
|
||||
#include "llvm/ADT/hash_set"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef LLVM_INTERVAL_H
|
||||
#define LLVM_INTERVAL_H
|
||||
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#define LLVM_ANALYSIS_LOOP_INFO_H
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/SymbolTableListTraits.h"
|
||||
#include "Support/ilist"
|
||||
#include "llvm/ADT/ilist"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
|
||||
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "Support/GraphTraits.h"
|
||||
#include "Support/ilist"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/ilist"
|
||||
#include <iosfwd>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -18,7 +18,7 @@
|
||||
#define LLVM_CODEGEN_MACHINECODEEMITTER_H
|
||||
|
||||
#include <string>
|
||||
#include "Support/DataTypes.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define LLVM_CODEGEN_MACHINEFUNCTION_H
|
||||
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "Support/Annotation.h"
|
||||
#include "llvm/Support/Annotation.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#ifndef LLVM_CODEGEN_MACHINEINSTR_H
|
||||
#define LLVM_CODEGEN_MACHINEINSTR_H
|
||||
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
@ -18,7 +18,7 @@
|
||||
#define LLVM_CODEGEN_SSAREGMAP_H
|
||||
|
||||
#include "llvm/Target/MRegisterInfo.h"
|
||||
#include "Support/DenseMap.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
|
||||
|
||||
#include "llvm/Value.h"
|
||||
#include "Support/iterator"
|
||||
#include "llvm/ADT/iterator"
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define LLVM_CODEGEN_SELECTIONDAG_H
|
||||
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include "Support/DataTypes.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
@ -15,7 +15,7 @@
|
||||
#ifndef _CONFIG_ALLOC_H
|
||||
#define _CONFIG_ALLOC_H
|
||||
|
||||
#include "Config/config.h"
|
||||
#include "llvm/Config/config.h"
|
||||
|
||||
/*
|
||||
* This is a modified version of that suggested by the Autoconf manual.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* include/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */
|
||||
/* include/llvm/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef _CONFIG_DLFCN_H
|
||||
#define _CONFIG_DLFCN_H
|
||||
|
||||
#include "Config/config.h"
|
||||
#include "llvm/Config/config.h"
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user