llvm.org GIT mirror llvm / 63b3afa
Remove trailing whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21411 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 15 years ago
41 changed file(s) with 385 addition(s) and 385 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/Support/AIXDataTypesFix.h - Fix datatype defs ------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file overrides default system-defined types and limits which cannot be
0 //===-- llvm/Support/Annotation.h - Annotation classes ----------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file contains the declarations for two classes: Annotation & Annotable.
8080 //===----------------------------------------------------------------------===//
8181 //
8282 // Annotable - This class is used as a base class for all objects that would
83 // like to have annotation capability. One notable subclass is Value, which
83 // like to have annotation capability. One notable subclass is Value, which
8484 // means annotations can be attached to almost everything in LLVM.
8585 //
8686 // Annotable objects keep their annotation list sorted as annotations are
156156 // one-to-one mapping between string Annotation names and Annotation ID numbers.
157157 //
158158 // Compared to the rest of the Annotation system, these mapping methods are
159 // relatively slow, so they should be avoided by locally caching Annotation
159 // relatively slow, so they should be avoided by locally caching Annotation
160160 // ID #'s. These methods are safe to call at any time, even by static ctors, so
161161 // they should be used by static ctors most of the time.
162162 //
163163 // This class also provides support for annotations that are created on demand
164164 // by the Annotable::getOrCreateAnnotation method. To get this to work, simply
165 // register an annotation handler
165 // register an annotation handler
166166 //
167167 struct AnnotationManager {
168168 typedef Annotation *(*Factory)(AnnotationID, const Annotable *, void*);
182182 // Annotation creation on demand support...
183183
184184 // registerAnnotationFactory - This method is used to register a callback
185 // function used to create an annotation on demand if it is needed by the
185 // function used to create an annotation on demand if it is needed by the
186186 // Annotable::getOrCreateAnnotation method.
187187 //
188188 static void registerAnnotationFactory(AnnotationID ID, Factory Func,
0 //===-- llvm/Support/CFG.h - Process LLVM structures as graphs --*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines specializations of GraphTraits that allow Function and
3333 public:
3434 typedef PredIterator<_Ptr,_USE_iterator> _Self;
3535 typedef typename super::pointer pointer;
36
36
3737 inline void advancePastNonTerminators() {
3838 // Loop to ignore non terminator uses (for example PHI nodes)...
3939 while (It != BB->use_end() && !isa(*It))
4040 ++It;
4141 }
42
42
4343 inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) {
4444 advancePastNonTerminators();
4545 }
4646 inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {}
47
47
4848 inline bool operator==(const _Self& x) const { return It == x.It; }
4949 inline bool operator!=(const _Self& x) const { return !operator==(x); }
50
51 inline pointer operator*() const {
50
51 inline pointer operator*() const {
5252 assert(It != BB->use_end() && "pred_iterator out of range!");
53 return cast(*It)->getParent();
53 return cast(*It)->getParent();
5454 }
5555 inline pointer *operator->() const { return &(operator*()); }
56
56
5757 inline _Self& operator++() { // Preincrement
5858 assert(It != BB->use_end() && "pred_iterator out of range!");
5959 ++It; advancePastNonTerminators();
60 return *this;
61 }
62
60 return *this;
61 }
62
6363 inline _Self operator++(int) { // Postincrement
64 _Self tmp = *this; ++*this; return tmp;
64 _Self tmp = *this; ++*this; return tmp;
6565 }
6666 };
6767
6868 typedef PredIterator pred_iterator;
69 typedef PredIterator
69 typedef PredIterator
7070 Value::use_const_iterator> pred_const_iterator;
7171
7272 inline pred_iterator pred_begin(BasicBlock *BB) { return pred_iterator(BB); }
9393 typedef SuccIterator _Self;
9494 typedef typename super::pointer pointer;
9595 // TODO: This can be random access iterator, need operator+ and stuff tho
96
96
9797 inline SuccIterator(Term_ T) : Term(T), idx(0) { // begin iterator
9898 assert(T && "getTerminator returned null!");
9999 }
111111 /// getSuccessorIndex - This is used to interface between code that wants to
112112 /// operate on terminator instructions directly.
113113 unsigned getSuccessorIndex() const { return idx; }
114
114
115115 inline bool operator==(const _Self& x) const { return idx == x.idx; }
116116 inline bool operator!=(const _Self& x) const { return !operator==(x); }
117
117
118118 inline pointer operator*() const { return Term->getSuccessor(idx); }
119119 inline pointer operator->() const { return operator*(); }
120
120
121121 inline _Self& operator++() { ++idx; return *this; } // Preincrement
122122 inline _Self operator++(int) { // Postincrement
123 _Self tmp = *this; ++*this; return tmp;
124 }
125
123 _Self tmp = *this; ++*this; return tmp;
124 }
125
126126 inline _Self& operator--() { --idx; return *this; } // Predecrement
127127 inline _Self operator--(int) { // Postdecrement
128128 _Self tmp = *this; --*this; return tmp;
152152 // GraphTraits specializations for basic block graphs (CFGs)
153153 //===--------------------------------------------------------------------===//
154154
155 // Provide specializations of GraphTraits to be able to treat a function as a
155 // Provide specializations of GraphTraits to be able to treat a function as a
156156 // graph of basic blocks...
157157
158158 template <> struct GraphTraits {
160160 typedef succ_iterator ChildIteratorType;
161161
162162 static NodeType *getEntryNode(BasicBlock *BB) { return BB; }
163 static inline ChildIteratorType child_begin(NodeType *N) {
163 static inline ChildIteratorType child_begin(NodeType *N) {
164164 return succ_begin(N);
165165 }
166 static inline ChildIteratorType child_end(NodeType *N) {
166 static inline ChildIteratorType child_end(NodeType *N) {
167167 return succ_end(N);
168168 }
169169 };
174174
175175 static NodeType *getEntryNode(const BasicBlock *BB) { return BB; }
176176
177 static inline ChildIteratorType child_begin(NodeType *N) {
177 static inline ChildIteratorType child_begin(NodeType *N) {
178178 return succ_begin(N);
179179 }
180 static inline ChildIteratorType child_end(NodeType *N) {
180 static inline ChildIteratorType child_end(NodeType *N) {
181181 return succ_end(N);
182182 }
183183 };
184184
185 // Provide specializations of GraphTraits to be able to treat a function as a
185 // Provide specializations of GraphTraits to be able to treat a function as a
186186 // graph of basic blocks... and to walk it in inverse order. Inverse order for
187187 // a function is considered to be when traversing the predecessor edges of a BB
188188 // instead of the successor edges.
191191 typedef BasicBlock NodeType;
192192 typedef pred_iterator ChildIteratorType;
193193 static NodeType *getEntryNode(Inverse G) { return G.Graph; }
194 static inline ChildIteratorType child_begin(NodeType *N) {
194 static inline ChildIteratorType child_begin(NodeType *N) {
195195 return pred_begin(N);
196196 }
197 static inline ChildIteratorType child_end(NodeType *N) {
197 static inline ChildIteratorType child_end(NodeType *N) {
198198 return pred_end(N);
199199 }
200200 };
203203 typedef const BasicBlock NodeType;
204204 typedef pred_const_iterator ChildIteratorType;
205205 static NodeType *getEntryNode(Inverse G) {
206 return G.Graph;
207 }
208 static inline ChildIteratorType child_begin(NodeType *N) {
206 return G.Graph;
207 }
208 static inline ChildIteratorType child_begin(NodeType *N) {
209209 return pred_begin(N);
210210 }
211 static inline ChildIteratorType child_end(NodeType *N) {
211 static inline ChildIteratorType child_end(NodeType *N) {
212212 return pred_end(N);
213213 }
214214 };
219219 // GraphTraits specializations for function basic block graphs (CFGs)
220220 //===--------------------------------------------------------------------===//
221221
222 // Provide specializations of GraphTraits to be able to treat a function as a
222 // Provide specializations of GraphTraits to be able to treat a function as a
223223 // graph of basic blocks... these are the same as the basic block iterators,
224224 // except that the root node is implicitly the first node of the function.
225225 //
242242 };
243243
244244
245 // Provide specializations of GraphTraits to be able to treat a function as a
245 // Provide specializations of GraphTraits to be able to treat a function as a
246246 // graph of basic blocks... and to walk it in inverse order. Inverse order for
247247 // a function is considered to be when traversing the predecessor edges of a BB
248248 // instead of the successor edges.
0 //===-- llvm/Support/CallSite.h - Abstract Call & Invoke instrs -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines the CallSite class, which is a handy wrapper for code that
0 //===-- llvm/Support/Casting.h - Allow flexible, checked, casts -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines the isa(), cast(), dyn_cast(), cast_or_null(),
4747 // if (isa(myVal)) { ... }
4848 //
4949 template
50 inline bool isa_impl(const From &Val) {
50 inline bool isa_impl(const From &Val) {
5151 return To::classof(&Val);
5252 }
5353
5656 // When From != SimplifiedType, we can simplify the type some more by using
5757 // the simplify_type template.
5858 static bool doit(const From &Val) {
59 return isa_impl_cl::template
59 return isa_impl_cl::template
6060 isa(simplify_type::getSimplifiedValue(Val));
6161 }
6262 };
158158
159159 template
160160 struct cast_retty {
161 typedef typename cast_retty_wrap
161 typedef typename cast_retty_wrap
162162 typename simplify_type::SimpleType>::ret_type ret_type;
163163 };
164164
247247 }*/
248248 };
249249
250 template <> inline bool isa_impl(const bar &Val) {
250 template <> inline bool isa_impl(const bar &Val) {
251251 cerr << "Classof: " << &Val << "\n";
252252 return true;
253253 }
278278 const foo *F12 = cast_or_null(B2);
279279 const foo *F13 = cast_or_null(B4);
280280 const foo *F14 = cast_or_null(fub()); // Shouldn't print.
281
281
282282 // These lines are errors...
283283 //foo *F20 = cast(B2); // Yields const foo*
284284 //foo &F21 = cast(B3); // Yields const foo&
0 //===- llvm/Support/CommandLine.h - Command line handler --------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This class implements a command line argument processor that is useful when
125125 // an argument. Should return true if there was an error processing the
126126 // argument and the program should exit.
127127 //
128 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
128 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
129129 const std::string &Arg) = 0;
130130
131 virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
131 virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
132132 return Optional;
133133 }
134134 virtual enum ValueExpected getValueExpectedFlagDefault() const {
135 return ValueOptional;
135 return ValueOptional;
136136 }
137137 virtual enum OptionHidden getOptionHiddenFlagDefault() const {
138138 return NotHidden;
215215 // Return the width of the option tag for printing...
216216 virtual unsigned getOptionWidth() const = 0;
217217
218 // printOptionInfo - Print out information about this option. The
218 // printOptionInfo - Print out information about this option. The
219219 // to-be-maintained width is specified.
220220 //
221221 virtual void printOptionInfo(unsigned GlobalWidth) const = 0;
222222
223223 // addOccurrence - Wrapper around handleOccurrence that enforces Flags
224224 //
225 bool addOccurrence(unsigned pos, const char *ArgName,
225 bool addOccurrence(unsigned pos, const char *ArgName,
226226 const std::string &Value);
227227
228228 // Prints option name followed by message. Always returns true.
310310 std::vector > > Values;
311311 void processValues(va_list Vals);
312312 public:
313 ValuesClass(const char *EnumName, DataType Val, const char *Desc,
313 ValuesClass(const char *EnumName, DataType Val, const char *Desc,
314314 va_list ValueArgs) {
315315 // Insert the first value, which is required.
316316 Values.push_back(std::make_pair(EnumName, std::make_pair(Val, Desc)));
365365
366366 // getOption - Return option name N.
367367 virtual const char *getOption(unsigned N) const = 0;
368
368
369369 // getDescription - Return description N
370370 virtual const char *getDescription(unsigned N) const = 0;
371371
372372 // Return the width of the option tag for printing...
373373 virtual unsigned getOptionWidth(const Option &O) const;
374374
375 // printOptionInfo - Print out information about this option. The
375 // printOptionInfo - Print out information about this option. The
376376 // to-be-maintained width is specified.
377377 //
378378 virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const;
441441 }
442442
443443 // parse - Return true on error.
444 bool parse(Option &O, const char *ArgName, const std::string &Arg,
444 bool parse(Option &O, const char *ArgName, const std::string &Arg,
445445 DataType &V) {
446446 std::string ArgVal;
447447 if (hasArgStr)
484484 enum ValueExpected getValueExpectedFlagDefault() const {
485485 return ValueRequired;
486486 }
487
487
488488 void initialize(Option &O) {}
489
489
490490 // Return the width of the option tag for printing...
491491 unsigned getOptionWidth(const Option &O) const;
492
492
493493 // printOptionInfo - Print out information about this option. The
494494 // to-be-maintained width is specified.
495495 //
518518 bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val);
519519
520520 enum ValueExpected getValueExpectedFlagDefault() const {
521 return ValueOptional;
521 return ValueOptional;
522522 }
523523
524524 // getValueName - Do not print = at all
589589 class parser : public basic_parser {
590590 public:
591591 // parse - Return true on error.
592 bool parse(Option &O, const char *AN, const std::string &Arg,
592 bool parse(Option &O, const char *AN, const std::string &Arg,
593593 std::string &Value) {
594594 Value = Arg;
595595 return false;
726726 //
727727 template
728728 class ParserClass = parser >
729 class opt : public Option,
729 class opt : public Option,
730730 public opt_storage
731731 is_class::value> {
732732 ParserClass Parser;
733733
734 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
734 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
735735 const std::string &Arg) {
736736 typename ParserClass::parser_data_type Val;
737737 if (Parser.parse(*this, ArgName, Arg, Val))
883883 std::vector Positions;
884884 ParserClass Parser;
885885
886 virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
886 virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
887887 return ZeroOrMore;
888888 }
889889 virtual enum ValueExpected getValueExpectedFlagDefault() const {
890890 return Parser.getValueExpectedFlagDefault();
891891 }
892892
893 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
893 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
894894 const std::string &Arg) {
895895 typename ParserClass::parser_data_type Val;
896896 if (Parser.parse(*this, ArgName, Arg, Val))
914914 public:
915915 ParserClass &getParser() { return Parser; }
916916
917 unsigned getPosition(unsigned optnum) const {
917 unsigned getPosition(unsigned optnum) const {
918918 assert(optnum < this->size() && "Invalid option index");
919 return Positions[optnum];
919 return Positions[optnum];
920920 }
921921
922922 // One option...
986986
987987 class alias : public Option {
988988 Option *AliasFor;
989 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
989 virtual bool handleOccurrence(unsigned pos, const char *ArgName,
990990 const std::string &Arg) {
991991 return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
992992 }
0 //===- llvm/Support/Compressor.h --------------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::Compressor class.
2222 /// a block of memory. The algorithm used here is currently bzip2 but that
2323 /// may change without notice. Should newer algorithms prove to compress
2424 /// bytecode better than bzip2, that newer algorithm will be added, but won't
25 /// replace bzip2. This interface allows us to abstract the notion of
26 /// compression and deal with alternate compression schemes over time.
27 /// The type of compression used can be determined by inspecting the
28 /// first byte of the compressed output. Currently value '0' means no
25 /// replace bzip2. This interface allows us to abstract the notion of
26 /// compression and deal with alternate compression schemes over time.
27 /// The type of compression used can be determined by inspecting the
28 /// first byte of the compressed output. Currently value '0' means no
2929 /// compression was used (for very small files) and value '2' means bzip2
30 /// compression was used. The Compressor is intended for use with memory
30 /// compression was used. The Compressor is intended for use with memory
3131 /// mapped files where the entire data block to be compressed or decompressed
3232 /// is available in memory. However, output can be gathered in repeated calls
33 /// to a callback. Utilities for sending compressed or decompressed output
33 /// to a callback. Utilities for sending compressed or decompressed output
3434 /// to a stream or directly to a memory block are also provided.
3535 /// @since 1.4
3636 /// @brief An abstraction for memory to memory data (de)compression
3838 /// @name High Level Interface
3939 /// @{
4040 public:
41 /// This method compresses a block of memory pointed to by \p in with
42 /// size \p size to a block of memory, \p out, that is allocated with
41 /// This method compresses a block of memory pointed to by \p in with
42 /// size \p size to a block of memory, \p out, that is allocated with
4343 /// malloc. It is the caller's responsibility to free \p out. The \p hint
4444 /// indicates which type of compression the caller would *prefer*.
4545 /// @throws std::string explaining error if a compression error occurs
5151 char*&out ///< The returned output buffer
5252 );
5353
54 /// This method compresses a block of memory pointed to by \p in with
54 /// This method compresses a block of memory pointed to by \p in with
5555 /// size \p size to a stream. The stream \p out must be open and ready for
5656 /// writing when this method is called. The stream will not be closed by
57 /// this method. The \p hint argument indicates which type of
57 /// this method. The \p hint argument indicates which type of
5858 /// compression the caller would *prefer*.
5959 /// @returns The amount of data written to \p out.
6060 /// @brief Compress memory to a file.
6464 std::ostream& out ///< The output stream to write data on
6565 );
6666
67 /// This method decompresses a block of memory pointed to by \p in with
67 /// This method decompresses a block of memory pointed to by \p in with
6868 /// size \p size to a new block of memory, \p out, \p that was allocated
69 /// by malloc. It is the caller's responsibility to free \p out.
69 /// by malloc. It is the caller's responsibility to free \p out.
7070 /// @returns The size of the output buffer \p out.
7171 /// @brief Decompress memory to a new memory buffer.
7272 static size_t decompressToNewBuffer(
7575 char*&out ///< The returned output buffer
7676 );
7777
78 /// This method decompresses a block of memory pointed to by \p in with
78 /// This method decompresses a block of memory pointed to by \p in with
7979 /// size \p size to a stream. The stream \p out must be open and ready for
8080 /// writing when this method is called. The stream will not be closed by
81 /// this method.
81 /// this method.
8282 /// @returns The amount of data written to \p out.
8383 /// @brief Decompress memory to a stream.
8484 static size_t decompressToStream(
9292 /// @{
9393 public:
9494 /// A callback function type used by the Compressor's low level interface
95 /// to get the next chunk of data to which (de)compressed output will be
96 /// written. This callback completely abstracts the notion of how to
95 /// to get the next chunk of data to which (de)compressed output will be
96 /// written. This callback completely abstracts the notion of how to
9797 /// handle the output data of compression or decompression. The callback
98 /// is responsible for determining both the storage location and the size
98 /// is responsible for determining both the storage location and the size
9999 /// of the output. The callback may also do other things with the data
100100 /// such as write it, transmit it, etc. Note that providing very small
101101 /// values for \p size will make the compression run very inefficiently.
137137 /// Note that the callback function will be called as many times as
138138 /// necessary to complete the compression of the \p in block but that the
139139 /// total size will generally be greater than \p size. It is a good idea
140 /// to provide as large a value to the callback's \p size parameter as
140 /// to provide as large a value to the callback's \p size parameter as
141141 /// possible so that fewer calls to the callback are made.
142142 /// @throws std::string if an error occurs
143143 /// @returns the total size of the decompressed data
0 //===-- llvm/Support/ConstantRange.h - Represent a range --------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // Represent a range of possible values that may occur when the program is run
3838 /// Initialize a full (the default) or empty set for the specified type.
3939 ///
4040 ConstantRange(const Type *Ty, bool isFullSet = true);
41
41
4242 /// Initialize a range to hold the single specified value.
4343 ///
4444 ConstantRange(Constant *Value);
4848 /// have different types, or if the constant are not integral values.
4949 ///
5050 ConstantRange(Constant *Lower, Constant *Upper);
51
51
5252 /// Initialize a set of values that all satisfy the condition with C.
5353 ///
5454 ConstantRange(unsigned SetCCOpcode, ConstantIntegral *C);
6464 /// getType - Return the LLVM data type of this range.
6565 ///
6666 const Type *getType() const;
67
67
6868 /// isFullSet - Return true if this set contains all of the elements possible
6969 /// for this data-type
7070 ///
7171 bool isFullSet() const;
72
72
7373 /// isEmptySet - Return true if this set contains no members.
7474 ///
7575 bool isEmptySet() const;
8282 /// contains - Return true if the specified value is in the set.
8383 ///
8484 bool contains(ConstantInt *Val) const;
85
85
8686 /// getSingleElement - If this set contains a single element, return it,
8787 /// otherwise return null.
8888 ///
8989 ConstantIntegral *getSingleElement() const;
90
90
9191 /// isSingleElement - Return true if this set contains exactly one member.
9292 ///
9393 bool isSingleElement() const { return getSingleElement() != 0; }
0 //===-- llvm/Support/DotGraphTraits.h - Customize .dot output ---*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a template class that can be used to customize dot output
0 //===- llvm/Support/Debug.h - Easy way to add debug output ------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file implements a handle way of adding debugging information to your
0 //===-- llvm/Support/DynamicLinker.h - Portable Dynamic Linker --*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // Lightweight interface to dynamic library linking and loading, and dynamic
3030 /// the currently running process, as reported by the dynamic linker,
3131 /// or NULL if the symbol does not exist or some other error has
3232 /// occurred.
33 ///
33 ///
3434 void *GetAddressOfSymbol (const char *symbolName);
3535 void *GetAddressOfSymbol (const std::string &symbolName);
3636
0 //===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This header contains common, non-processor-specific data structures and
1010 // constants for the ELF file format.
11 //
11 //
1212 // The details of the ELF32 bits in this file are largely based on
1313 // the Tool Interface Standard (TIS) Executable and Linking Format
1414 // (ELF) Specification Version 1.2, May 1995. The ELF64 stuff is not
136136 Elf32_Addr sh_addr; // Address where section is to be loaded
137137 Elf32_Off sh_offset; // File offset of section data, in bytes
138138 Elf32_Word sh_size; // Size of section, in bytes
139 Elf32_Word sh_link; // Section type-specific header table index link
139 Elf32_Word sh_link; // Section type-specific header table index link
140140 Elf32_Word sh_info; // Section type-specific extra information
141141 Elf32_Word sh_addralign; // Section address alignment
142142 Elf32_Word sh_entsize; // Size of records contained within the section
203203 unsigned char st_info; // Symbol's type and binding attributes
204204 unsigned char st_other; // Must be zero; reserved
205205 Elf32_Half st_shndx; // Which section (header table index) it's defined in
206
206
207207 // These accessors and mutators correspond to the ELF32_ST_BIND,
208208 // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
209209 unsigned char getBinding () const { return st_info >> 4; }
237237
238238 // Relocation entry, without explicit addend.
239239 struct Elf32_Rel {
240 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
240 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
241241 Elf32_Word r_info; // Symbol table index and type of relocation to apply
242
242
243243 // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
244244 // and ELF32_R_INFO macros defined in the ELF specification:
245245 Elf32_Word getSymbol () const { return (r_info >> 8); }
253253
254254 // Relocation entry with explicit addend.
255255 struct Elf32_Rela {
256 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
256 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
257257 Elf32_Word r_info; // Symbol table index and type of relocation to apply
258258 Elf32_Sword r_addend; // Compute value for relocatable field by adding this
259
259
260260 // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
261261 // and ELF32_R_INFO macros defined in the ELF specification:
262262 Elf32_Word getSymbol () const { return (r_info >> 8); }
0 //===- llvm/Support/FileUtilities.h - File System Utilities -----*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a family of utility functions which are useful for doing
4040 public:
4141 FileRemover(const sys::Path &filename, bool deleteIt = true)
4242 : Filename(filename), DeleteIt(deleteIt) {}
43
43
4444 ~FileRemover() {
4545 if (DeleteIt)
4646 try {
0 //===- llvm/Support/GetElementPtrTypeIterator.h -----------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file implements an iterator for walking through the types indexed by
4141 return I;
4242 }
4343
44 bool operator==(const generic_gep_type_iterator& x) const {
44 bool operator==(const generic_gep_type_iterator& x) const {
4545 return OpIt == x.OpIt;
4646 }
4747 bool operator!=(const generic_gep_type_iterator& x) const {
4848 return !operator==(x);
4949 }
5050
51 const Type *operator*() const {
51 const Type *operator*() const {
5252 return CurTy;
5353 }
5454
6060 // This is a non-standard operator->. It allows you to call methods on the
6161 // current type directly.
6262 const Type *operator->() const { return operator*(); }
63
63
6464 Value *getOperand() const { return *OpIt; }
6565
6666 generic_gep_type_iterator& operator++() { // Preincrement
7070 CurTy = 0;
7171 }
7272 ++OpIt;
73 return *this;
73 return *this;
7474 }
7575
7676 generic_gep_type_iterator operator++(int) { // Postincrement
77 generic_gep_type_iterator tmp = *this; ++*this; return tmp;
77 generic_gep_type_iterator tmp = *this; ++*this; return tmp;
7878 }
7979 };
8080
0 //===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a simple interface that can be used to print out generic
9898 I != E; ++I)
9999 writeNode(&*I);
100100 }
101
101
102102 void writeNode(NodeType *const *Node) {
103103 writeNode(*Node);
104104 }
105
105
106106 void writeNode(NodeType *Node) {
107107 std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
108
108
109109 O << "\tNode" << reinterpret_cast(Node) << " [shape=record,";
110110 if (!NodeAttributes.empty()) O << NodeAttributes << ",";
111111 O << "label=\"{";
112112
113113 if (!DOTTraits::renderGraphFromBottomUp())
114114 O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
115
115
116116 // Print out the fields of the current node...
117117 child_iterator EI = GTraits::child_begin(Node);
118118 child_iterator EE = GTraits::child_end(Node);
119119 if (EI != EE) {
120120 if (!DOTTraits::renderGraphFromBottomUp()) O << "|";
121121 O << "{";
122
122
123123 for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) {
124124 if (i) O << "|";
125125 O << "" << DOTTraits::getEdgeSourceLabel(Node, EI);
126126 }
127
127
128128 if (EI != EE)
129129 O << "|truncated...";
130130 O << "}";
132132 }
133133 if (DOTTraits::renderGraphFromBottomUp())
134134 O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
135
135
136136 O << "}\"];\n"; // Finish printing the "node" line
137
137
138138 // Output all of the edges now
139139 EI = GTraits::child_begin(Node);
140140 for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i)
173173 O << DOT::EscapeString(Label);
174174 if (NumEdgeSources) {
175175 O << "|{";
176
176
177177 for (unsigned i = 0; i != NumEdgeSources; ++i) {
178178 if (i) O << "|";
179179 O << "";
196196 O << ":g" << SrcNodePort;
197197 O << " -> Node" << reinterpret_cast(DestNodeID);
198198 if (DestNodePort >= 0)
199 O << ":g" << DestNodePort;
199 O << ":g" << DestNodePort;
200200
201201 if (!Attrs.empty())
202202 O << "[" << Attrs << "]";
0 //===- llvm/Support/InstIterator.h - Classes for inst iteration -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file contains definitions of two iterators for iterating over the
5353 template
5454 InstIterator(InstIterator &II)
5555 : BBs(II.BBs), BB(II.BB), BI(II.BI) {}
56
57 template InstIterator(M &m)
56
57 template InstIterator(M &m)
5858 : BBs(&m.getBasicBlockList()), BB(BBs->begin()) { // begin ctor
5959 if (BB != BBs->end()) {
6060 BI = BB->begin();
6262 }
6363 }
6464
65 template InstIterator(M &m, bool)
65 template InstIterator(M &m, bool)
6666 : BBs(&m.getBasicBlockList()), BB(BBs->end()) { // end ctor
6767 }
6868
6969 // Accessors to get at the underlying iterators...
7070 inline BBIty &getBasicBlockIterator() { return BB; }
7171 inline BIty &getInstructionIterator() { return BI; }
72
72
7373 inline reference operator*() const { return *BI; }
7474 inline pointer operator->() const { return &operator*(); }
75
76 inline bool operator==(const InstIterator &y) const {
75
76 inline bool operator==(const InstIterator &y) const {
7777 return BB == y.BB && (BB == BBs->end() || BI == y.BI);
7878 }
79 inline bool operator!=(const InstIterator& y) const {
79 inline bool operator!=(const InstIterator& y) const {
8080 return !operator==(y);
8181 }
8282
83 InstIterator& operator++() {
83 InstIterator& operator++() {
8484 ++BI;
8585 advanceToNextBB();
86 return *this;
86 return *this;
8787 }
88 inline InstIterator operator++(int) {
89 InstIterator tmp = *this; ++*this; return tmp;
88 inline InstIterator operator++(int) {
89 InstIterator tmp = *this; ++*this; return tmp;
9090 }
91
92 InstIterator& operator--() {
91
92 InstIterator& operator--() {
9393 while (BB == BBs->end() || BI == BB->begin()) {
9494 --BB;
9595 BI = BB->end();
9696 }
9797 --BI;
98 return *this;
98 return *this;
9999 }
100 inline InstIterator operator--(int) {
101 InstIterator tmp = *this; --*this; return tmp;
100 inline InstIterator operator--(int) {
101 InstIterator tmp = *this; --*this; return tmp;
102102 }
103103
104104 inline bool atEnd() const { return BB == BBs->end(); }
120120 Function::iterator, BasicBlock::iterator,
121121 Instruction> inst_iterator;
122122 typedef InstIterator,
123 Function::const_iterator,
123 Function::const_iterator,
124124 BasicBlock::const_iterator,
125125 const Instruction> const_inst_iterator;
126126
0 //===- llvm/Support/InstVisitor.h - Define instruction visitors -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This template class is used to define instruction visitors in a typesafe
0 //===-- llvm/Support/LeakDetector.h - Provide leak detection ----*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a class that can be used to provide very simple memory leak
4747 removeGarbageObjectImpl(Object);
4848 #endif
4949 }
50
50
5151 /// checkForGarbage - Traverse the internal representation of garbage
5252 /// pointers. If there are any pointers that have been add'ed, but not
5353 /// remove'd, big obnoxious warnings about memory leaks are issued.
0 //===-- llvm/Support/Mangler.h - Self-contained name mangler ----*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // Unified name mangler for various backends.
6262 /// doesn't guarantee unique names for values. getValueName already
6363 /// does this for you, so there's no point calling it on the result
6464 /// from getValueName.
65 ///
65 ///
6666 static std::string makeNameProper(const std::string &x);
6767 };
6868
0 //===-- llvm/Support/MathExtras.h - Useful math functions -------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file contains some functions that are useful for math stuff.
0 //===- llvm/Support/PassNameParser.h ----------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file the PassNameParser and FilteredPassNameParser<> classes, which are
3333 // PassNameParser class - Make use of the pass registration mechanism to
3434 // automatically add a command line argument to opt for each pass.
3535 //
36 class PassNameParser : public PassRegistrationListener,
36 class PassNameParser : public PassRegistrationListener,
3737 public cl::parser {
3838 cl::Option *Opt;
3939 public:
4040 PassNameParser() : Opt(0) {}
41
41
4242 void initialize(cl::Option &O) {
4343 Opt = &O;
4444 cl::parser::initialize(O);
0 //===-- llvm/Support/PatternMatch.h - Match on the LLVM IR ------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file provides a simple and efficient mechanism for performing general
3232 #include "llvm/Instructions.h"
3333
3434 namespace llvm {
35 namespace PatternMatch {
35 namespace PatternMatch {
3636
3737 template
3838 bool match(Val *V, const Pattern &P) {
8787 R.match(CE->getOperand(1));
8888 return false;
8989 }
90 };
90 };
9191
9292 template
9393 inline BinaryOp_match m_Add(const LHS &L,
177177 #endif
178178 return false;
179179 }
180 };
180 };
181181
182182 template
183183 inline BinaryOpClass_match
215215 else
216216 return LHS == ConstantFP::get(LHS->getType(), -0.0) && L.match(RHS);
217217 }
218 };
218 };
219219
220220 template
221221 inline neg_match m_Neg(const LHS &L) { return L; }
0 //===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // A tool can #include this file to get a -load option that allows the user to
0 //===- llvm/Support/SlowOperationInformer.h - Keep user informed *- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a simple object which can be used to let the user know what
3737 class SlowOperationInformer {
3838 std::string OperationName;
3939 unsigned LastPrintAmount;
40
40
4141 SlowOperationInformer(const SlowOperationInformer&); // DO NOT IMPLEMENT
4242 void operator=(const SlowOperationInformer&); // DO NOT IMPLEMENT
4343 public:
4444 SlowOperationInformer(const std::string &Name);
4545 ~SlowOperationInformer();
46
46
4747 /// progress - Clients should periodically call this method when they are in
4848 /// an exception-safe state. The Amount variable should indicate how far
4949 /// along the operation is, given in 1/10ths of a percent (in other words,
0 //===- StableBasicBlockNumbering.h - Provide BB identifiers -----*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This class provides a *stable* numbering of basic blocks that does not depend
0 //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file contains functions used to do a variety of low-level, often
1818
1919 namespace llvm {
2020
21 /// Determine if the ostream provided is connected to the std::cout and
22 /// displayed or not (to a console window). If so, generate a warning message
21 /// Determine if the ostream provided is connected to the std::cout and
22 /// displayed or not (to a console window). If so, generate a warning message
2323 /// advising against display of bytecode and return true. Otherwise just return
2424 /// false
2525 /// @brief Check for output written to a console
0 //===-- llvm/Support/ThreadSupport-NoSupport.h - Generic Impl ---*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines a generic ThreadSupport implementation used when there is
0 //===-- llvm/Support/ThreadSupport-PThreads.h - PThreads support *- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines pthreads implementations of the generic threading
3838
3939 errorcode = pthread_mutexattr_settype(&Attr, PTHREAD_MUTEX_RECURSIVE);
4040 assert(errorcode == 0);
41
41
4242 errorcode = pthread_mutex_init(&mutex, &Attr);
4343 assert(errorcode == 0);
4444
0 //===-- llvm/Support/Timer.h - Interval Timing Support ----------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines three classes: Timer, TimeRegion, and TimerGroup,
7373 return Elapsed < T.Elapsed;
7474 }
7575 bool operator>(const Timer &T) const { return T.operator<(*this); }
76
76
7777 /// startTimer - Start the timer running. Time between calls to
7878 /// startTimer/stopTimer is counted by the Timer class. Note that these calls
7979 /// must be correctly paired.
0 //===-- llvm/Support/ToolRunner.h -------------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file exposes an abstraction around a platform C compiler, used to
6262 FileType fileType,
6363 const std::string &InputFile,
6464 const std::string &OutputFile,
65 const std::vector &SharedLibs =
65 const std::vector &SharedLibs =
6666 std::vector(), unsigned Timeout = 0);
6767
6868 /// MakeSharedObject - This compiles the specified file (which is either a .c
109109 const std::vector &Args,
110110 const std::string &InputFile,
111111 const std::string &OutputFile,
112 const std::vector &SharedLibs =
112 const std::vector &SharedLibs =
113113 std::vector(),
114114 unsigned Timeout = 0) = 0;
115115 };
139139 const std::vector &Args,
140140 const std::string &InputFile,
141141 const std::string &OutputFile,
142 const std::vector &SharedLibs =
142 const std::vector &SharedLibs =
143143 std::vector(),
144144 unsigned Timeout = 0);
145145
176176 const std::vector &Args,
177177 const std::string &InputFile,
178178 const std::string &OutputFile,
179 const std::vector &SharedLibs =
179 const std::vector &SharedLibs =
180180 std::vector(),
181181 unsigned Timeout = 0);
182182
0 //===- llvm/Support/TypeInfo.h - Support for type_info objects -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This class makes std::type_info objects behave like first class objects that
4444 private:
4545 const std::type_info *Info;
4646 };
47
47
4848 // Comparison operators
4949 inline bool operator==(const TypeInfo &lhs, const TypeInfo &rhs) {
5050 return lhs.get() == rhs.get();
6161 inline bool operator>(const TypeInfo &lhs, const TypeInfo &rhs) {
6262 return rhs < lhs;
6363 }
64
64
6565 inline bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs) {
6666 return !(lhs > rhs);
6767 }
68
68
6969 inline bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs) {
7070 return !(lhs < rhs);
7171 }
0 //===- llvm/Support/type_traits.h - Simplfied type traits -------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file provides a template class that determines if a type is a class or
1010 // not. The basic mechanism, based on using the pointer to member function of
11 // a zero argument to a function was "boosted" from the boost type_traits
12 // library. See http://www.boost.org/ for all the gory details.
11 // a zero argument to a function was "boosted" from the boost type_traits
12 // library. See http://www.boost.org/ for all the gory details.
1313 //
1414 //===----------------------------------------------------------------------===//
1515
2626 namespace dont_use
2727 {
2828 // These two functions should never be used. They are helpers to
29 // the is_class template below. They cannot be located inside
29 // the is_class template below. They cannot be located inside
3030 // is_class because doing so causes at least GCC to think that
3131 // the value of the "value" enumerator is not constant. Placing
32 // them out here (for some strange reason) allows the sizeof
32 // them out here (for some strange reason) allows the sizeof
3333 // operator against them to magically be constant. This is
3434 // important to make the is_class::value idiom zero cost. it
35 // evaluates to a constant 1 or 0 depending on whether the
35 // evaluates to a constant 1 or 0 depending on whether the
3636 // parameter T is a class or not (respectively).
3737 template char is_class_helper(void(T::*)(void));
3838 template double is_class_helper(...);
0 //===-- llvm/System/DynamicLibrary.h - Portable Dynamic Library -*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the sys::DynamicLibrary class.
2020 namespace sys {
2121
2222 /// This class provides a portable interface to dynamic libraries which also
23 /// might be known as shared libraries, shared objects, dynamic shared
23 /// might be known as shared libraries, shared objects, dynamic shared
2424 /// objects, or dynamic link libraries. Regardless of the terminology or the
2525 /// operating system interface, this class provides a portable interface that
26 /// allows dynamic libraries to be loaded and and searched for externally
26 /// allows dynamic libraries to be loaded and and searched for externally
2727 /// defined symbols. This is typically used to provide "plug-in" support.
2828 /// @since 1.4
2929 /// @brief Portable dynamic library abstraction.
3333 public:
3434 /// Construct a DynamicLibrary that represents the currently executing
3535 /// program. The program must have been linked with -export-dynamic or
36 /// -dlopen self for this to work. Any symbols retrieved with the
36 /// -dlopen self for this to work. Any symbols retrieved with the
3737 /// GetAddressOfSymbol function will refer to the program not to any
3838 /// library.
3939 /// @throws std::string indicating why the program couldn't be opened.
4848
4949 /// After destruction, the symbols of the library will no longer be
5050 /// available to the program. It is important to make sure the lifespan
51 /// of a DynamicLibrary exceeds the lifetime of the pointers returned
52 /// by the GetAddressOfSymbol otherwise the program may walk off into
51 /// of a DynamicLibrary exceeds the lifetime of the pointers returned
52 /// by the GetAddressOfSymbol otherwise the program may walk off into
5353 /// uncharted territory.
5454 /// @see GetAddressOfSymbol.
5555 /// @brief Closes the DynamicLibrary
0 //===- llvm/System/MappedFile.h - MappedFile OS Concept ---------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::sys::MappedFile class.
1919 namespace sys {
2020
2121 /// Forward declare a class used for holding platform specific information
22 /// that needs to be
22 /// that needs to be
2323 struct MappedFileInfo;
2424
25 /// This class provides an abstraction for a memory mapped file in the
25 /// This class provides an abstraction for a memory mapped file in the
2626 /// operating system's filesystem. It provides platform independent operations
2727 /// for mapping a file into memory for both read and write access. This class
2828 /// does not provide facilities for finding the file or operating on paths to
29 /// files. The sys::Path class is used for that.
29 /// files. The sys::Path class is used for that.
3030 /// @since 1.4
3131 /// @brief An abstraction for memory mapped files.
3232 class MappedFile {
8484 char* charBase() const { return reinterpret_cast(base_); }
8585
8686 /// This function returns a reference to the sys::Path object kept by the
87 /// MappedFile object. This contains the path to the file that is or
87 /// MappedFile object. This contains the path to the file that is or
8888 /// will be mapped.
8989 /// @returns sys::Path containing the path name.
9090 /// @brief Returns the mapped file's path as a sys::Path
9191 /// @throws nothing
9292 const sys::Path& path() const { return path_; }
9393
94 /// This function returns the number of bytes in the file.
94 /// This function returns the number of bytes in the file.
9595 /// @throws std::string if an error occurs
9696 size_t size() const;
9797
105105 /// @brief Remove the file mapping from memory.
106106 void unmap();
107107
108 /// The mapped file is put into memory.
108 /// The mapped file is put into memory.
109109 /// @returns The base memory address of the mapped file.
110110 /// @brief Map the file into memory.
111111 void* map();
112112
113113 /// This method causes the size of the file, and consequently the size
114 /// of the mapping to be set. This is logically the same as unmap(),
115 /// adjust size of the file, map(). Consequently, when calling this
116 /// function, the caller should not rely on previous results of the
114 /// of the mapping to be set. This is logically the same as unmap(),
115 /// adjust size of the file, map(). Consequently, when calling this
116 /// function, the caller should not rely on previous results of the
117117 /// map(), base(), or baseChar() members as they may point to invalid
118118 /// areas of memory after this call.
119119 /// @throws std::string if an error occurs
0 //===- llvm/System/Memory.h - Memory Support --------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::sys::Memory class.
4141 public:
4242 /// This method allocates a block of Read/Write/Execute memory that is
4343 /// suitable for executing dynamically generated code (e.g. JIT). An
44 /// attempt to allocate \p NumBytes bytes of virtual memory is made.
44 /// attempt to allocate \p NumBytes bytes of virtual memory is made.
4545 /// @throws std::string if an error occurred.
4646 /// @brief Allocate Read/Write/Execute memory.
4747 static MemoryBlock AllocateRWX(unsigned NumBytes);
4848
4949 /// This method releases a block of Read/Write/Execute memory that was
50 /// allocated with the AllocateRWX method. It should not be used to
50 /// allocated with the AllocateRWX method. It should not be used to
5151 /// release any memory block allocated any other way.
5252 /// @throws std::string if an error occurred.
5353 /// @brief Release Read/Write/Execute memory.
0 //===- llvm/System/Path.h - Path Operating System Concept -------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::sys::Path class.
2222 namespace llvm {
2323 namespace sys {
2424
25 /// This class provides an abstraction for the path to a file or directory
25 /// This class provides an abstraction for the path to a file or directory
2626 /// in the operating system's filesystem and provides various basic operations
2727 /// on it. Note that this class only represents the name of a path to a file
28 /// or directory which may or may not be valid for a given machine's file
28 /// or directory which may or may not be valid for a given machine's file
2929 /// system. A Path ensures that the name it encapsulates is syntactical valid
3030 /// for the operating system it is running on but does not ensure correctness
31 /// for any particular file system. A Path either references a file or a
31 /// for any particular file system. A Path either references a file or a
3232 /// directory and the distinction is consistently maintained. Most operations
3333 /// on the class have invariants that require the Path object to be either a
34 /// file path or a directory path, but not both. Those operations will also
35 /// leave the object as either a file path or object path. There is exactly
34 /// file path or a directory path, but not both. Those operations will also
35 /// leave the object as either a file path or object path. There is exactly
3636 /// one invalid Path which is the empty path. The class should never allow any
3737 /// other syntactically invalid non-empty path name to be assigned. Empty
3838 /// paths are required in order to indicate an error result. If the path is
3939 /// empty, the isValid operation will return false. All operations will fail
40 /// if isValid is false. Operations that change the path will either return
41 /// false if it would cause a syntactically invalid path name (in which case
42 /// the Path object is left unchanged) or throw an std::string exception
40 /// if isValid is false. Operations that change the path will either return
41 /// false if it would cause a syntactically invalid path name (in which case
42 /// the Path object is left unchanged) or throw an std::string exception
4343 /// indicating the error.
4444 /// @since 1.4
4545 /// @brief An abstraction for operating system paths.
5353 /// However, to support llvm-ar, the mode, user, and group fields are
5454 /// retained. These pertain to unix security and may not have a meaningful
5555 /// value on non-Unix platforms. However, the fileSize and modTime fields
56 /// should always be applicabe on all platforms. The structure is
56 /// should always be applicabe on all platforms. The structure is
5757 /// filled in by the getStatusInfo method.
5858 /// @brief File status structure
5959 struct StatusInfo {
60 StatusInfo() : fileSize(0), modTime(0,0), mode(0777), user(999),
60 StatusInfo() : fileSize(0), modTime(0,0), mode(0777), user(999),
6161 group(999), isDir(false) { }
6262 size_t fileSize; ///< Size of the file in bytes
6363 TimeValue modTime; ///< Time of file's modification
7272 /// @{
7373 public:
7474 /// Construct a path to the root directory of the file system. The root
75 /// directory is a top level directory above which there are no more
75 /// directory is a top level directory above which there are no more
7676 /// directories. For example, on UNIX, the root directory is /. On Windows
7777 /// it is C:\. Other operating systems may have different notions of
7878 /// what the root directory is.
8080 static Path GetRootDirectory();
8181
8282 /// Construct a path to a unique temporary directory that is created in
83 /// a "standard" place for the operating system. The directory is
84 /// guaranteed to be created on exit from this function. If the directory
83 /// a "standard" place for the operating system. The directory is
84 /// guaranteed to be created on exit from this function. If the directory
8585 /// cannot be created, the function will throw an exception.
8686 /// @throws std::string indicating why the directory could not be created.
8787 /// @brief Constrct a path to an new, unique, existing temporary
9999 /// Construct a vector of sys::Path that contains the "standard" bytecode
100100 /// library paths suitable for linking into an llvm program. This function
101101 /// *must* return the value of LLVM_LIB_SEARCH_PATH as well as the value
102 /// of LLVM_LIBDIR. It also must provide the System library paths as
102 /// of LLVM_LIBDIR. It also must provide the System library paths as
103103 /// returned by GetSystemLibraryPaths.
104104 /// @see GetSystemLibraryPaths
105105 /// @brief Construct a list of directories in which bytecode could be
111111 /// @brief Find a library.
112112 static Path FindLibrary(std::string& short_name);
113113
114 /// Construct a path to the default LLVM configuration directory. The
114 /// Construct a path to the default LLVM configuration directory. The
115115 /// implementation must ensure that this is a well-known (same on many
116 /// systems) directory in which llvm configuration files exist. For
116 /// systems) directory in which llvm configuration files exist. For
117117 /// example, on Unix, the /etc/llvm directory has been selected.
118118 /// @throws nothing
119119 /// @brief Construct a path to the default LLVM configuration directory
129129
130130 /// Construct a path to the current user's home directory. The
131131 /// implementation must use an operating system specific mechanism for
132 /// determining the user's home directory. For example, the environment
133 /// variable "HOME" could be used on Unix. If a given operating system
132 /// determining the user's home directory. For example, the environment
133 /// variable "HOME" could be used on Unix. If a given operating system
134134 /// does not have the concept of a user's home directory, this static
135135 /// constructor must provide the same result as GetRootDirectory.
136136 /// @throws nothing
138138 static Path GetUserHomeDirectory();
139139
140140 /// Return the suffix commonly used on file names that contain a shared
141 /// object, shared archive, or dynamic link library. Such files are
142 /// linked at runtime into a process and their code images are shared
143 /// between processes.
141 /// object, shared archive, or dynamic link library. Such files are
142 /// linked at runtime into a process and their code images are shared
143 /// between processes.
144144 /// @returns The dynamic link library suffix for the current platform.
145145 /// @brief Return the dynamic link library suffix.
146146 static std::string GetDLLSuffix();
200200 /// @returns true if \p this path is lexicographically less than \p that.
201201 /// @throws nothing
202202 /// @brief Less Than Operator
203 bool operator< (const Path& that) const {
204 return 0 > path.compare( that.path );
203 bool operator< (const Path& that) const {
204 return 0 > path.compare( that.path );
205205 }
206206
207207 /// @}
212212 /// determine if the current value of \p this is a syntactically valid
213213 /// path name for the operating system. The path name does not need to
214214 /// exist, validity is simply syntactical. Empty paths are always invalid.
215 /// @returns true iff the path name is syntactically legal for the
216 /// host operating system.
215 /// @returns true iff the path name is syntactically legal for the
216 /// host operating system.
217217 /// @brief Determine if a path is syntactically valid or not.
218218 bool isValid() const;
219219
243243 /// This function determines if the path name in this object references
244244 /// the root (top level directory) of the file system. The details of what
245245 /// is considered the "root" may vary from system to system so this method
246 /// will do the necessary checking.
246 /// will do the necessary checking.
247247 /// @returns true iff the path name references the root directory.
248248 /// @brief Determines if the path references the root directory.
249249 bool isRootDirectory() const;
250250
251 /// This function opens the file associated with the path name provided by
251 /// This function opens the file associated with the path name provided by
252252 /// the Path object and reads its magic number. If the magic number at the
253253 /// start of the file matches \p magic, true is returned. In all other
254254 /// cases (file not found, file not accessible, etc.) it returns false.
273273
274274 /// This function determines if the path name in the object references an
275275 /// LLVM Bytecode file by looking at its magic number.
276 /// @returns true if the file starts with the magic number for LLVM
276 /// @returns true if the file starts with the magic number for LLVM
277277 /// bytecode files.
278278 /// @brief Determine if the path references a bytecode file.
279279 bool isBytecodeFile() const;
281281 /// This function determines if the path name in the object references a
282282 /// native Dynamic Library (shared library, shared object) by looking at
283283 /// the file's magic number. The Path object must reference a file, not a
284 /// directory.
284 /// directory.
285285 /// @return strue if the file starts with the magid number for a native
286286 /// shared library.
287287 /// @brief Determine if the path reference a dynamic library.
296296 bool exists() const;
297297
298298 /// This function determines if the path name references a readable file
299 /// or directory in the file system. Unlike isFile and isDirectory, this
299 /// or directory in the file system. Unlike isFile and isDirectory, this
300300 /// function actually checks for the existence and readability (by the
301301 /// current program) of the file or directory.
302302 /// @returns true if the pathname references a readable file.
305305 bool readable() const;
306306
307307 /// This function determines if the path name references a writable file
308 /// or directory in the file system. Unlike isFile and isDirectory, this
308 /// or directory in the file system. Unlike isFile and isDirectory, this
309309 /// function actually checks for the existence and writability (by the
310310 /// current program) of the file or directory.
311311 /// @returns true if the pathname references a writable file.
313313 /// in the file system.
314314 bool writable() const;
315315
316 /// This function determines if the path name references an executable
317 /// file in the file system. Unlike isFile and isDirectory, this
318 /// function actually checks for the existence and executability (by
316 /// This function determines if the path name references an executable
317 /// file in the file system. Unlike isFile and isDirectory, this
318 /// function actually checks for the existence and executability (by
319319 /// the current program) of the file.
320320 /// @returns true if the pathname references an executable file.
321 /// @brief Determines if the path is an executable file in the file
321 /// @brief Determines if the path is an executable file in the file
322322 /// system.
323323 bool executable() const;
324324
352352 /// @brief Build a list of directory's contents.
353353 bool getDirectoryContents(std::set& paths) const;
354354
355 /// This method attempts to destroy the directory named by the last in
356 /// the Path name. If \p remove_contents is false, an attempt will be
357 /// made to remove just the directory that this Path object refers to
355 /// This method attempts to destroy the directory named by the last in
356 /// the Path name. If \p remove_contents is false, an attempt will be
357 /// made to remove just the directory that this Path object refers to
358358 /// (the final Path component). If \p remove_contents is true, an attempt
359 /// will be made to remove the entire contents of the directory,
360 /// recursively.
359 /// will be made to remove the entire contents of the directory,
360 /// recursively.
361361 /// @param destroy_contents Indicates whether the contents of a destroyed
362 /// directory should also be destroyed (recursively).
363 /// @returns false if the Path does not refer to a directory, true
362 /// directory should also be destroyed (recursively).
363 /// @returns false if the Path does not refer to a directory, true
364364 /// otherwise.
365365 /// @throws std::string if there is an error.
366366 /// @brief Removes the file or directory from the filesystem.
367367 bool destroyDirectory( bool destroy_contents = false ) const;
368368
369369 /// This method attempts to destroy the file named by the last item in the
370 /// Path name.
370 /// Path name.
371371 /// @returns false if the Path does not refer to a file, true otherwise.
372372 /// @throws std::string if there is an error.
373373 /// @brief Destroy the file this Path refers to.
374 bool destroyFile() const;
374 bool destroyFile() const;
375375
376376 /// Obtain a 'C' string for the path name.
377377 /// @returns a 'C' string containing the path name.
384384 public:
385385 /// The path name is cleared and becomes empty. This is an invalid
386386 /// path name but is the *only* invalid path name. This is provided
387 /// so that path objects can be used to indicate the lack of a
387 /// so that path objects can be used to indicate the lack of a
388388 /// valid path being found.
389389 void clear() { path.clear(); }
390390
391391 /// This function returns status information about the file. The type of
392 /// path (file or directory) is updated to reflect the actual contents
393 /// of the file system. If the file does not exist, false is returned.
392 /// path (file or directory) is updated to reflect the actual contents
393 /// of the file system. If the file does not exist, false is returned.
394394 /// For other (hard I/O) errors, a std::string is throwing indicating the
395395 /// problem.
396396 /// @throws std::string if an error occurs.
397397 /// @brief Get file status.
398398 void getStatusInfo(StatusInfo& info) const;
399399
400 /// This function returns the last modified time stamp for the file
400 /// This function returns the last modified time stamp for the file
401401 /// referenced by this path. The Path may reference a file or a directory.
402402 /// If the file does not exist, a ZeroTime timestamp is returned.
403403 /// @returns last modified timestamp of the file/directory or ZeroTime
406406 StatusInfo info; getStatusInfo(info); return info.modTime;
407407 }
408408
409 /// This function returns the size of the file referenced by this path.
409 /// This function returns the size of the file referenced by this path.
410410 /// @brief Get file size.
411411 inline size_t getSize() const {
412412 StatusInfo info; getStatusInfo(info); return info.fileSize;
423423 void makeWriteable();
424424
425425 /// This method attempts to make the file referenced by the Path object
426 /// available for execution so that the executable() method will return
426 /// available for execution so that the executable() method will return
427427 /// true.
428428 /// @brief Make the file readable;
429429 void makeExecutable();
430430
431431 /// This method attempts to set the Path object to \p unverified_path
432 /// and interpret the name as a directory name. The \p unverified_path
433 /// is verified. If verification succeeds then \p unverified_path
432 /// and interpret the name as a directory name. The \p unverified_path
433 /// is verified. If verification succeeds then \p unverified_path
434434 /// is accepted as a directory and true is returned. Otherwise,
435435 /// the Path object remains unchanged and false is returned.
436436 /// @returns true if the path was set, false otherwise.
440440 bool setDirectory(const std::string& unverified_path);
441441
442442 /// This method attempts to set the Path object to \p unverified_path
443 /// and interpret the name as a file name. The \p unverified_path
444 /// is verified. If verification succeeds then \p unverified_path
443 /// and interpret the name as a file name. The \p unverified_path
444 /// is verified. If verification succeeds then \p unverified_path
445445 /// is accepted as a file name and true is returned. Otherwise,
446446 /// the Path object remains unchanged and false is returned.
447447 /// @returns true if the path was set, false otherwise.
451451 bool setFile(const std::string& unverified_path);
452452
453453 /// The \p dirname is added to the end of the Path if it is a legal
454 /// directory name for the operating system. The precondition for this
454 /// directory name for the operating system. The precondition for this
455455 /// function is that the Path must reference a directory name (i.e.
456456 /// isDirectory() returns true).
457457 /// @param dirname A string providing the directory name to
463463
464464 /// One directory component is removed from the Path name. The Path must
465465 /// refer to a non-root directory name (i.e. isDirectory() returns true
466 /// but isRootDirectory() returns false). Upon exit, the Path will
466 /// but isRootDirectory() returns false). Upon exit, the Path will
467467 /// refer to the directory above it.
468468 /// @throws nothing
469469 /// @returns false if the directory name could not be removed.
472472
473473 /// The \p filename is added to the end of the Path if it is a legal
474474 /// directory name for the operating system. The precondition for this
475 /// function is that the Path reference a directory name (i.e.
475 /// function is that the Path reference a directory name (i.e.
476476 /// isDirectory() returns true).
477477 /// @throws nothing
478478 /// @returns false if the file name could not be added.
480480 bool appendFile( const std::string& filename );
481481
482482 /// One file component is removed from the Path name. The Path must
483 /// refer to a file (i.e. isFile() returns true). Upon exit,
483 /// refer to a file (i.e. isFile() returns true). Upon exit,
484484 /// the Path will refer to the directory above it.
485485 /// @throws nothing
486486 /// @returns false if the file name could not be removed
489489
490490 /// A period and the \p suffix are appended to the end of the pathname.
491491 /// The precondition for this function is that the Path reference a file
492 /// name (i.e. isFile() returns true). If the Path is not a file, no
492 /// name (i.e. isFile() returns true). If the Path is not a file, no
493493 /// action is taken and the function returns false. If the path would
494494 /// become invalid for the host operating system, false is returned.
495495 /// @returns false if the suffix could not be added, true if it was.
496496 /// @throws nothing
497 /// @brief Adds a period and the \p suffix to the end of the pathname.
497 /// @brief Adds a period and the \p suffix to the end of the pathname.
498498 bool appendSuffix(const std::string& suffix);
499499
500500 /// The suffix of the filename is removed. The suffix begins with and
501501 /// includes the last . character in the filename after the last directory
502502 /// separator and extends until the end of the name. If no . character is
503503 /// after the last directory separator, then the file name is left
504 /// unchanged (i.e. it was already without a suffix) but the function
504 /// unchanged (i.e. it was already without a suffix) but the function
505505 /// returns false.
506506 /// @returns false if there was no suffix to remove, true otherwise.
507507 /// @throws nothing
509509 bool elideSuffix();
510510
511511 /// The current Path name is made unique in the file system. Upon return,
512 /// the Path will have been changed to make a unique file in the file
512 /// the Path will have been changed to make a unique file in the file
513513 /// system or it will not have been changed if the current path name is
514 /// already unique.
514 /// already unique.
515515 /// @throws std::string if an unrecoverable error occurs.
516516 /// @brief Make the current path name unique in the file system.
517517 void makeUnique( bool reuse_current = true );
521521 /// whether intermediate directories are created or not. if \p
522522 /// create_parents is true, then an attempt will be made to create all
523523 /// intermediate directories. If \p create_parents is false, then only the
524 /// final directory component of the Path name will be created. The
525 /// created directory will have no entries.
526 /// @returns false if the Path does not reference a directory, true
524 /// final directory component of the Path name will be created. The
525 /// created directory will have no entries.
526 /// @returns false if the Path does not reference a directory, true
527527 /// otherwise.
528528 /// @param create_parents Determines whether non-existent directory
529529 /// components other than the last one (the "parents") are created or not.
533533
534534 /// This method attempts to create a file in the file system with the same
535535 /// name as the Path object. The intermediate directories must all exist
536 /// at the time this method is called. Use createDirectories to
536 /// at the time this method is called. Use createDirectories to
537537 /// accomplish that. The created file will be empty upon return from this
538538 /// function.
539539 /// @returns false if the Path does not reference a file, true otherwise.
541541 /// @brief Create the file this Path refers to.
542542 bool createFile();
543543
544 /// This is like createFile except that it creates a temporary file. A
545 /// unique temporary file name is generated based on the contents of
544 /// This is like createFile except that it creates a temporary file. A
545 /// unique temporary file name is generated based on the contents of
546546 /// \p this before the call. The new name is assigned to \p this and the
547547 /// file is created. Note that this will both change the Path object
548548 /// *and* create the corresponding file. This function will ensure that
560560 bool renameFile(const Path& newName);
561561
562562 /// This method sets the access time, modification time, and permission
563 /// mode of the file associated with \p this as given by \p si.
563 /// mode of the file associated with \p this as given by \p si.
564564 /// @returns false if the Path does not refer to a file, true otherwise.
565565 /// @throws std::string if the file could not be modified
566566 /// @brief Set file times and mode.
0 //===- llvm/System/Process.h ------------------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::sys::Process class.
1919 namespace sys {
2020
2121 /// This class provides an abstraction for getting information about the
22 /// currently executing process.
22 /// currently executing process.
2323 /// @since 1.4
2424 /// @brief An abstraction for operating system processes.
2525 class Process {
3535
3636 /// This static function will return the total amount of memory allocated
3737 /// by the process. This only counts the memory allocated via the malloc,
38 /// calloc and realloc functions and includes any "free" holes in the
39 /// allocated space.
38 /// calloc and realloc functions and includes any "free" holes in the
39 /// allocated space.
4040 /// @throws nothing
4141 /// @brief Return process memory usage.
4242 static size_t GetMallocUsage();
4343
44 /// This static function will return the total memory usage of the
44 /// This static function will return the total memory usage of the
4545 /// process. This includes code, data, stack and mapped pages usage. Notei
4646 /// that the value returned here is not necessarily the Running Set Size,
4747 /// it is the total virtual memory usage, regardless of mapped state of
4848 /// that memory.
4949 static size_t GetTotalMemoryUsage();
5050
51 /// This static function will set \p user_time to the amount of CPU time
51 /// This static function will set \p user_time to the amount of CPU time
5252 /// spent in user (non-kernel) mode and \p sys_time to the amount of CPU
5353 /// time spent in system (kernel) mode. If the operating system does not
5454 /// support collection of these metrics, a zero TimeValue will be for both
5656 static void GetTimeUsage(
5757 TimeValue& elapsed,
5858 ///< Returns the TimeValue::now() giving current time
59 TimeValue& user_time,
59 TimeValue& user_time,
6060 ///< Returns the current amount of user time for the process
6161 TimeValue& sys_time
6262 ///< Returns the current amount of system time for the process
6363 );
6464
6565 /// This static function will return the process' current user id number.
66 /// Not all operating systems support this feature. Where it is not
67 /// supported, the function should return 65536 as the value.
66 /// Not all operating systems support this feature. Where it is not
67 /// supported, the function should return 65536 as the value.
6868 static int GetCurrentUserId();
6969
7070 /// This static function will return the process' current group id number.
71 /// Not all operating systems support this feature. Where it is not
72 /// supported, the function should return 65536 as the value.
71 /// Not all operating systems support this feature. Where it is not
72 /// supported, the function should return 65536 as the value.
7373 static int GetCurrentGroupId();
7474
75 /// This function makes the necessary calls to the operating system to
76 /// prevent core files or any other kind of large memory dumps that can
75 /// This function makes the necessary calls to the operating system to
76 /// prevent core files or any other kind of large memory dumps that can
7777 /// occur when a program fails.
7878 /// @brief Prevent core file generation.
7979 static void PreventCoreFiles();
8383 /// or pipe.
8484 static bool StandardInIsUserInput();
8585
86 /// This function determines if the standard output is connected to a
86 /// This function determines if the standard output is connected to a
8787 /// "tty" or "console" window. That is, the output would be displayed to
8888 /// the user rather than being put on a pipe or stored in a file.
8989 static bool StandardOutIsDisplayed();
9090
91 /// This function determines if the standard error is connected to a
91 /// This function determines if the standard error is connected to a
9292 /// "tty" or "console" window. That is, the output would be displayed to
9393 /// the user rather than being put on a pipe or stored in a file.
9494 static bool StandardErrIsDisplayed();
0 //===- llvm/System/Program.h ------------------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the llvm::sys::Program class.
3030 /// @{
3131 public:
3232 /// This static constructor (factory) will attempt to locate a program in
33 /// the operating system's file system using some pre-determined set of
34 /// locations to search (e.g. the PATH on Unix).
33 /// the operating system's file system using some pre-determined set of
34 /// locations to search (e.g. the PATH on Unix).
3535 /// @returns A Path object initialized to the path of the program or a
3636 /// Path object that is empty (invalid) if the program could not be found.
3737 /// @throws nothing
4040
4141 /// This function executes the program using the \p arguments provided and
4242 /// waits for the program to exit. This function will block the current
43 /// program until the invoked program exits. The invoked program will
43 /// program until the invoked program exits. The invoked program will
4444 /// inherit the stdin, stdout, and stderr file descriptors, the
4545 /// environment and other configuration settings of the invoking program.
4646 /// If Path::executable() does not return true when this function is
47 /// called then a std::string is thrown.
47 /// called then a std::string is thrown.
4848 /// @param path A sys::Path object providing the path of the program to be
4949 /// executed. It is presumed this is the result of the FindProgramByName
5050 /// method.
5555 /// @brief Executes the program with the given set of \p args.
5656 static int ExecuteAndWait(
5757 const Path& path, ///< The path to the program to execute
58 const char** args, ///< A vector of strings that are passed to the
59 ///< program. The first element should be the name of the program.
58 const char** args, ///< A vector of strings that are passed to the
59 ///< program. The first element should be the name of the program.
6060 ///< The list *must* be terminated by a null char* entry.
61 const char ** env = 0, ///< An optional vector of strings to use for
61 const char ** env = 0, ///< An optional vector of strings to use for
6262 ///< the program's environment. If not provided, the current program's
6363 ///< environment will be used.
64 const sys::Path** redirects = 0, ///< An optional array of pointers to
65 ///< Paths. If the array is null, no redirection is done. The array
64 const sys::Path** redirects = 0, ///< An optional array of pointers to
65 ///< Paths. If the array is null, no redirection is done. The array
6666 ///< should have a size of at least three. If the pointer in the array
67 ///< are not null, then the inferior process's stdin(0), stdout(1),
68 ///< and stderr(2) will be redirected to the corresponding Paths.
69 unsigned secondsToWait = 0 ///< If non-zero, this specifies the amount
70 ///< of time to wait for the child process to exit. If the time
71 ///< expires, the child is killed and this call returns. If zero,
72 ///< this function will wait until the child finishes or forever if
67 ///< are not null, then the inferior process's stdin(0), stdout(1),
68 ///< and stderr(2) will be redirected to the corresponding Paths.
69 unsigned secondsToWait = 0 ///< If non-zero, this specifies the amount
70 ///< of time to wait for the child process to exit. If the time
71 ///< expires, the child is killed and this call returns. If zero,
72 ///< this function will wait until the child finishes or forever if
7373 ///< it doesn't.
7474 );
7575 };
0 //===- llvm/System/Signals.h - Signal Handling support ----------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines some helpful functions for dealing with the possibility of
1919 namespace llvm {
2020 namespace sys {
2121
22 /// This function registers signal handlers to ensure that if a signal gets
22 /// This function registers signal handlers to ensure that if a signal gets
2323 /// delivered that the named file is removed.
2424 /// @brief Remove a file if a fatal signal occurs.
2525 void RemoveFileOnSignal(const Path &Filename);
3030 /// @brief Remove a directory if a fatal signal occurs.
3131 void RemoveDirectoryOnSignal(const Path& path);
3232
33 /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
33 /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
3434 /// process, print a stack trace and then exit.
3535 /// @brief Print a stack trace if a fatal signal occurs.
3636 void PrintStackTraceOnErrorSignal();
0 //===-- TimeValue.h - Declare OS TimeValue Concept --------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Reid Spencer and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This header file declares the operating system TimeValue concept.
1818
1919 namespace llvm {
2020 namespace sys {
21 /// This class is used where a precise fixed point in time is required. The
22 /// range of TimeValue spans many hundreds of billions of years both past and
23 /// present. The precision of TimeValue is to the nanosecond. However, the
24 /// actual precision of its values will be determined by the resolution of
25 /// the system clock. The TimeValue class is used in conjunction with several
26 /// other lib/System interfaces to specify the time at which a call should
21 /// This class is used where a precise fixed point in time is required. The
22 /// range of TimeValue spans many hundreds of billions of years both past and
23 /// present. The precision of TimeValue is to the nanosecond. However, the
24 /// actual precision of its values will be determined by the resolution of
25 /// the system clock. The TimeValue class is used in conjunction with several
26 /// other lib/System interfaces to specify the time at which a call should
2727 /// timeout, etc.
2828 /// @since 1.4
2929 /// @brief Provides an abstraction for a fixed point in time.
8181 /// @name Constructors
8282 /// @{
8383 public:
84 /// Caller provides the exact value in seconds and nanoseconds. The
84 /// Caller provides the exact value in seconds and nanoseconds. The
8585 /// \p nanos argument defaults to zero for convenience.
86 /// @brief Explicit constructor
86 /// @brief Explicit constructor
8787 explicit TimeValue (SecondsType seconds, NanoSecondsType nanos = 0)
8888 : seconds_( seconds ), nanos_( nanos ) { this->normalize(); }
8989
9191 /// fractional part representing nanoseconds.
9292 /// @brief Double Constructor.
9393 explicit TimeValue( double new_time )
94 : seconds_( 0 ) , nanos_ ( 0 ) {
94 : seconds_( 0 ) , nanos_ ( 0 ) {
9595 SecondsType integer_part = static_cast( new_time );
9696 seconds_ = integer_part;
97 nanos_ = static_cast( (new_time -
97 nanos_ = static_cast( (new_time -
9898 static_cast(integer_part)) * NANOSECONDS_PER_SECOND );
9999 this->normalize();
100100 }
166166 /// @brief True iff *this == that.
167167 /// @brief True if this == that.
168168 int operator == (const TimeValue &that) const {
169 return (this->seconds_ == that.seconds_) &&
169 return (this->seconds_ == that.seconds_) &&
170170 (this->nanos_ == that.nanos_);
171171 }
172172
197197 SecondsType seconds() const { return seconds_; }
198198
199199 /// Returns only the nanoseconds component of the TimeValue. The seconds
200 /// portion is ignored.
200 /// portion is ignored.
201201 /// @brief Retrieve the nanoseconds component.
202202 NanoSecondsType nanoseconds() const { return nanos_; }
203203
204204 /// Returns only the fractional portion of the TimeValue rounded down to the
205205 /// nearest microsecond (divide by one thousand).
206206 /// @brief Retrieve the fractional part as microseconds;
207 uint32_t microseconds() const {
207 uint32_t microseconds() const {
208208 return nanos_ / NANOSECONDS_PER_MICROSECOND;
209209 }
210210
221221 /// systems and is therefore provided.
222222 /// @brief Convert to a number of microseconds (can overflow)
223223 uint64_t usec() const {
224 return seconds_ * MICROSECONDS_PER_SECOND +
224 return seconds_ * MICROSECONDS_PER_SECOND +
225225 ( nanos_ / NANOSECONDS_PER_MICROSECOND );
226226 }
227227
228228 /// Returns the TimeValue as a number of milliseconds. Note that the value
229 /// returned can overflow because the range of a uint64_t is smaller than
229 /// returned can overflow because the range of a uint64_t is smaller than
230230 /// the range of a TimeValue. Nevertheless, this is useful on some operating
231231 /// systems and is therefore provided.
232232 /// @brief Convert to a number of milliseconds (can overflow)
233233 uint64_t msec() const {
234 return seconds_ * MILLISECONDS_PER_SECOND +
234 return seconds_ * MILLISECONDS_PER_SECOND +
235235 ( nanos_ / NANOSECONDS_PER_MILLISECOND );
236236 }
237237
244244 return result;
245245 }
246246
247 /// Converts the TimeValue into the corresponding number of seconds
248 /// since the epoch (00:00:00 Jan 1,1970).
247 /// Converts the TimeValue into the corresponding number of seconds
248 /// since the epoch (00:00:00 Jan 1,1970).
249249 uint64_t toEpochTime() const {
250250 return seconds_ - PosixZeroTime.seconds_;
251251 }
313313 /// @brief Converts from microsecond format to TimeValue format
314314 void usec( int64_t microseconds ) {
315315 this->seconds_ = microseconds / MICROSECONDS_PER_SECOND;
316 this->nanos_ = NanoSecondsType(microseconds % MICROSECONDS_PER_SECOND) *
316 this->nanos_ = NanoSecondsType(microseconds % MICROSECONDS_PER_SECOND) *
317317 NANOSECONDS_PER_MICROSECOND;
318318 this->normalize();
319319 }
321321 /// @brief Converts from millisecond format to TimeValue format
322322 void msec( int64_t milliseconds ) {
323323 this->seconds_ = milliseconds / MILLISECONDS_PER_SECOND;
324 this->nanos_ = NanoSecondsType(milliseconds % MILLISECONDS_PER_SECOND) *
324 this->nanos_ = NanoSecondsType(milliseconds % MILLISECONDS_PER_SECOND) *
325325 NANOSECONDS_PER_MILLISECOND;
326326 this->normalize();
327327 }
0 //===-- llvm/Support/ToolRunner.h -------------------------------*- C++ -*-===//
1 //
1 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file was developed by the LLVM research group and is distributed under
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
99 // This file exposes an abstraction around a platform C compiler, used to
6262 FileType fileType,
6363 const std::string &InputFile,
6464 const std::string &OutputFile,
65 const std::vector &SharedLibs =
65 const std::vector &SharedLibs =
6666 std::vector(), unsigned Timeout = 0);
6767
6868 /// MakeSharedObject - This compiles the specified file (which is either a .c
109109 const std::vector &Args,
110110 const std::string &InputFile,
111111 const std::string &OutputFile,
112 const std::vector &SharedLibs =
112 const std::vector &SharedLibs =
113113 std::vector(),
114114 unsigned Timeout = 0) = 0;
115115 };
139139 const std::vector &Args,
140140 const std::string &InputFile,
141141 const std::string &OutputFile,
142 const std::vector &SharedLibs =
142 const std::vector &SharedLibs =
143143 std::vector(),
144144 unsigned Timeout = 0);
145145
176176 const std::vector &Args,
177177 const std::string &InputFile,
178178 const std::string &OutputFile,
179 const std::vector &SharedLibs =
179 const std::vector &SharedLibs =
180180 std::vector(),
181181 unsigned Timeout = 0);
182182