[llvm-commits] [parallel] CVS: llvm/include/Support/DataTypes.h.in DenseMap.h ELF.h ThreadSupport.h.in hash_map.in hash_set.in iterator.in type_traits.h Annotation.h CommandLine.h FileUtilities.h GraphWriter.h MathExtras.h STLExtras.h Signals.h Statistic.h ilist DataTypes.h ThreadSupport.h hash_map hash_set iterator
Misha Brukman
brukman at cs.uiuc.edu
Mon Mar 1 17:58:32 PST 2004
Changes in directory llvm/include/Support:
DataTypes.h.in added (r1.1.2.1)
DenseMap.h added (r1.3.2.1)
ELF.h added (r1.4.2.1)
ThreadSupport.h.in added (r1.1.2.1)
hash_map.in added (r1.1.2.1)
hash_set.in added (r1.1.2.1)
iterator.in added (r1.1.2.1)
type_traits.h added (r1.1.2.1)
Annotation.h updated: 1.13 -> 1.13.4.1
CommandLine.h updated: 1.29 -> 1.29.4.1
FileUtilities.h updated: 1.14 -> 1.14.2.1
GraphWriter.h updated: 1.18 -> 1.18.4.1
MathExtras.h updated: 1.10 -> 1.10.4.1
STLExtras.h updated: 1.13 -> 1.13.4.1
Signals.h updated: 1.8 -> 1.8.2.1
Statistic.h updated: 1.9 -> 1.9.2.1
ilist updated: 1.16 -> 1.16.4.1
DataTypes.h (r1.18) removed
ThreadSupport.h (r1.2) removed
hash_map (r1.14) removed
hash_set (r1.13) removed
iterator (r1.6) removed
---
Log message:
Merge from trunk
---
Diffs of the changes: (+876 -45)
Index: llvm/include/Support/DataTypes.h.in
diff -c /dev/null llvm/include/Support/DataTypes.h.in:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/DataTypes.h.in Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,45 ----
+ //===-- 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:
+ //
+ // int64_t : is a typedef for the signed 64 bit system type
+ // uint64_t : is a typedef for the unsigned 64 bit system type
+ // INT64_MAX : is a #define specifying the max value for int64_t's
+ //
+ // 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
+
+ // Note that <inttypes.h> includes <stdint.h>, if this is a C99 system.
+ @INCLUDE_INTTYPES_H@
+ @INCLUDE_SYS_TYPES_H@
+
+ #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 */
Index: llvm/include/Support/DenseMap.h
diff -c /dev/null llvm/include/Support/DenseMap.h:1.3.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/DenseMap.h Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,63 ----
+ //===- 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 {
+
+ template <typename T, typename ToIndexT>
+ 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_);
+ }
+ };
+
+ } // End llvm namespace
+
+ #endif
Index: llvm/include/Support/ELF.h
diff -c /dev/null llvm/include/Support/ELF.h:1.4.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/ELF.h Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,295 ----
+ //===-- 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
Index: llvm/include/Support/ThreadSupport.h.in
diff -c /dev/null llvm/include/Support/ThreadSupport.h.in:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/ThreadSupport.h.in Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,40 ----
+ //===-- 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
Index: llvm/include/Support/hash_map.in
diff -c /dev/null llvm/include/Support/hash_map.in:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/hash_map.in Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,66 ----
+ //===-- 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
Index: llvm/include/Support/hash_set.in
diff -c /dev/null llvm/include/Support/hash_set.in:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/hash_set.in Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,67 ----
+ //===-- 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
Index: llvm/include/Support/iterator.in
diff -c /dev/null llvm/include/Support/iterator.in:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/iterator.in Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,66 ----
+ //===-- 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
Index: llvm/include/Support/type_traits.h
diff -c /dev/null llvm/include/Support/type_traits.h:1.1.2.1
*** /dev/null Mon Mar 1 17:57:29 2004
--- llvm/include/Support/type_traits.h Mon Mar 1 17:57:18 2004
***************
*** 0 ****
--- 1,54 ----
+ //===- 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 at 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
Index: llvm/include/Support/Annotation.h
diff -u llvm/include/Support/Annotation.h:1.13 llvm/include/Support/Annotation.h:1.13.4.1
--- llvm/include/Support/Annotation.h:1.13 Tue Nov 11 16:41:29 2003
+++ llvm/include/Support/Annotation.h Mon Mar 1 17:57:18 2004
@@ -68,7 +68,7 @@
Annotation *Next; // The next annotation in the linked list
public:
inline Annotation(AnnotationID id) : ID(id), Next(0) {}
- virtual ~Annotation() {} // Designed to be subclassed
+ virtual ~Annotation(); // Designed to be subclassed
// getID - Return the unique ID# of this annotation
inline AnnotationID getID() const { return ID; }
@@ -95,14 +95,7 @@
void operator=(const Annotable &); // Do not implement
public:
Annotable() : AnnotationList(0) {}
- virtual ~Annotable() { // Virtual because it's designed to be subclassed...
- Annotation *A = AnnotationList;
- while (A) {
- Annotation *Next = A->getNext();
- delete A;
- A = Next;
- }
- }
+ virtual ~Annotable(); // Virtual because it's designed to be subclassed...
// getAnnotation - Search the list for annotations of the specified ID. The
// pointer returned is either null (if no annotations of the specified ID
Index: llvm/include/Support/CommandLine.h
diff -u llvm/include/Support/CommandLine.h:1.29 llvm/include/Support/CommandLine.h:1.29.4.1
--- llvm/include/Support/CommandLine.h:1.29 Sun Nov 16 14:21:13 2003
+++ llvm/include/Support/CommandLine.h Mon Mar 1 17:57:18 2004
@@ -20,14 +20,15 @@
#ifndef SUPPORT_COMMANDLINE_H
#define SUPPORT_COMMANDLINE_H
+#include "Support/type_traits.h"
#include <string>
#include <vector>
#include <utility>
#include <cstdarg>
#include <cassert>
-#include "boost/type_traits/object_traits.hpp"
namespace llvm {
+
/// cl Namespace - This namespace contains all of the command line option
/// processing machinery. It is intentionally a short name to make qualified
/// usage concise.
@@ -719,7 +720,7 @@
class ParserClass = parser<DataType> >
class opt : public Option,
public opt_storage<DataType, ExternalStorage,
- ::boost::is_class<DataType>::value> {
+ is_class<DataType>::value> {
ParserClass Parser;
virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) {
Index: llvm/include/Support/FileUtilities.h
diff -u llvm/include/Support/FileUtilities.h:1.14 llvm/include/Support/FileUtilities.h:1.14.2.1
--- llvm/include/Support/FileUtilities.h:1.14 Wed Dec 31 00:16:02 2003
+++ llvm/include/Support/FileUtilities.h Mon Mar 1 17:57:18 2004
@@ -131,6 +131,26 @@
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
Index: llvm/include/Support/GraphWriter.h
diff -u llvm/include/Support/GraphWriter.h:1.18 llvm/include/Support/GraphWriter.h:1.18.4.1
--- llvm/include/Support/GraphWriter.h:1.18 Sun Nov 16 14:21:13 2003
+++ llvm/include/Support/GraphWriter.h Mon Mar 1 17:57:18 2004
@@ -117,7 +117,7 @@
}
if (EI != EE)
- O << "|truncated...";
+ O << "|<g64>truncated...";
O << "}";
}
O << "}\"];\n"; // Finish printing the "node" line
@@ -126,6 +126,8 @@
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) {
Index: llvm/include/Support/MathExtras.h
diff -u llvm/include/Support/MathExtras.h:1.10 llvm/include/Support/MathExtras.h:1.10.4.1
--- llvm/include/Support/MathExtras.h:1.10 Sun Nov 16 14:21:13 2003
+++ llvm/include/Support/MathExtras.h Mon Mar 1 17:57:18 2004
@@ -18,6 +18,10 @@
namespace llvm {
+#if defined(log2)
+# undef log2
+#endif
+
inline unsigned log2(uint64_t C) {
unsigned getPow;
for (getPow = 0; C > 1; ++getPow)
Index: llvm/include/Support/STLExtras.h
diff -u llvm/include/Support/STLExtras.h:1.13 llvm/include/Support/STLExtras.h:1.13.4.1
--- llvm/include/Support/STLExtras.h:1.13 Sat Nov 22 21:50:31 2003
+++ llvm/include/Support/STLExtras.h Mon Mar 1 17:57:18 2004
@@ -73,9 +73,6 @@
// mapped_iterator - This is a simple iterator adapter that causes a function to
// be dereferenced whenever operator* is invoked on the iterator.
//
-// It turns out that this is disturbingly similar to boost::transform_iterator
-//
-#if 1
template <class RootIt, class UnaryFunc>
class mapped_iterator {
RootIt current;
@@ -131,28 +128,6 @@
return mapped_iterator<_Iterator, Func>(X.getCurrent() - N);
}
-#else
-
-// This fails to work, because some iterators are not classes, for example
-// vector iterators are commonly value_type **'s
-template <class RootIt, class UnaryFunc>
-class mapped_iterator : public RootIt {
- UnaryFunc Fn;
-public:
- typedef typename UnaryFunc::result_type value_type;
- typedef typename UnaryFunc::result_type *pointer;
- typedef void reference; // Can't modify value returned by fn
-
- typedef mapped_iterator<RootIt, UnaryFunc> _Self;
- typedef RootIt super;
- inline explicit mapped_iterator(const RootIt &I) : super(I) {}
- inline mapped_iterator(const super &It) : super(It) {}
-
- inline value_type operator*() const { // All this work to do
- return Fn(super::operator*()); // this little thing
- }
-};
-#endif
// map_iterator - Provide a convenient way to create mapped_iterators, just like
// make_pair is useful for creating pairs...
@@ -160,6 +135,43 @@
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;
}
Index: llvm/include/Support/Signals.h
diff -u llvm/include/Support/Signals.h:1.8 llvm/include/Support/Signals.h:1.8.2.1
--- llvm/include/Support/Signals.h:1.8 Tue Dec 30 22:42:00 2003
+++ llvm/include/Support/Signals.h Mon Mar 1 17:57:18 2004
@@ -24,6 +24,9 @@
///
void RemoveFileOnSignal(const std::string &Filename);
+ /// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
+ /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
+ void PrintStackTraceOnErrorSignal();
} // End llvm namespace
#endif
Index: llvm/include/Support/Statistic.h
diff -u llvm/include/Support/Statistic.h:1.9 llvm/include/Support/Statistic.h:1.9.2.1
--- llvm/include/Support/Statistic.h:1.9 Wed Jan 14 17:37:22 2004
+++ llvm/include/Support/Statistic.h Mon Mar 1 17:57:18 2004
@@ -15,9 +15,9 @@
// This is useful for reporting information like the number of instructions
// simplified, optimized or removed by various transformations, like this:
//
-// static Statistic<> NumInstEliminated("GCSE - Number of instructions killed");
+// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed");
//
-// Later, in the code: ++NumInstEliminated;
+// Later, in the code: ++NumInstsKilled;
//
//===----------------------------------------------------------------------===//
Index: llvm/include/Support/ilist
diff -u llvm/include/Support/ilist:1.16 llvm/include/Support/ilist:1.16.4.1
--- llvm/include/Support/ilist:1.16 Sun Nov 16 19:07:58 2003
+++ llvm/include/Support/ilist Mon Mar 1 17:57:18 2004
@@ -152,15 +152,109 @@
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;
+ }
- // Dummy operators to make errors apparent...
- template<class X> void operator+(X Val) {}
- template<class X> void operator-(X Val) {}
+ // 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...
@@ -213,19 +307,25 @@
}
~iplist() { clear(); delete Tail; }
- // Iterator creation methods...
+ // 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 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());}
- // Miscellaneous inspection routines...
+
+ // "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; }
More information about the llvm-commits
mailing list