llvm.org GIT mirror llvm / ea61c35
Remove trailing whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21409 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 14 years ago
36 changed file(s) with 356 addition(s) and 356 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/Bytecode/Analyzer.h - Analyzer for Bytecode files --*- 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 functionality is implemented by the lib/Bytecode/Reader library.
1010 // It is used to read VM bytecode files from a file or memory buffer
11 // and print out a diagnostic analysis of the contents of the file. It is
12 // intended for three uses: (a) understanding the bytecode format, (b) ensuring
13 // correctness of bytecode format, (c) statistical analysis of generated
11 // and print out a diagnostic analysis of the contents of the file. It is
12 // intended for three uses: (a) understanding the bytecode format, (b) ensuring
13 // correctness of bytecode format, (c) statistical analysis of generated
1414 // bytecode files.
1515 //
1616 //===----------------------------------------------------------------------===//
2929 class Function;
3030 class Module;
3131
32 /// This structure is used to contain the output of the Bytecode Analysis
33 /// library. It simply contains fields to hold each item of the analysis
32 /// This structure is used to contain the output of the Bytecode Analysis
33 /// library. It simply contains fields to hold each item of the analysis
3434 /// results.
3535 /// @brief Bytecode Analysis results structure
3636 struct BytecodeAnalysis {
6767 unsigned vbrCompBytes; ///< Number of vbr bytes (compressed)
6868 unsigned vbrExpdBytes; ///< Number of vbr bytes (expanded)
6969
70 typedef std::map
70 typedef std::map
7171 BlockSizeMap;
7272 BlockSizeMap BlockSizes;
7373
9090 unsigned vbrExpdBytes; ///< Number of vbr bytes (expanded)
9191 };
9292
93 /// A mapping of function slot numbers to the collected information about
93 /// A mapping of function slot numbers to the collected information about
9494 /// the function.
95 std::map FunctionInfo;
95 std::map FunctionInfo;
9696
9797 /// The content of the progressive verification
9898 std::string VerifyInfo;
9999
100100 /// Flags for what should be done
101 bool detailedResults; ///< If true, FunctionInfo has contents
101 bool detailedResults; ///< If true, FunctionInfo has contents
102102 bool progressiveVerify; ///< If true, VerifyInfo has contents
103103 };
104104
105105 /// This function is the main entry point into the bytecode analysis library. It
106 /// allows you to simply provide a \p filename and storage for the \p Results
106 /// allows you to simply provide a \p filename and storage for the \p Results
107107 /// that will be filled in with the analysis results.
108108 /// @brief Analyze contents of a bytecode File
109109 Module* AnalyzeBytecodeFile(
0 //===-- llvm/Bytecode/Archive.h - LLVM Bytecode Archive ---------*- 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 Archive and ArchiveMember classes that provide
1010 // manipulation of LLVM Archive files. The implementation is provided by the
11 // lib/Bytecode/Archive library. This library is used to read and write
12 // archive (*.a) files that contain LLVM bytecode files (or others).
11 // lib/Bytecode/Archive library. This library is used to read and write
12 // archive (*.a) files that contain LLVM bytecode files (or others).
1313 //
1414 //===----------------------------------------------------------------------===//
1515
2525
2626 namespace llvm {
2727
28 // Forward declare classes
28 // Forward declare classes
2929 class ModuleProvider; // From VMCore
3030 class Module; // From VMCore
3131 class Archive; // Declared below
3333
3434 /// This class is the main class manipulated by users of the Archive class. It
3535 /// holds information about one member of the Archive. It is also the element
36 /// stored by the Archive's ilist, the Archive's main abstraction. Because of
37 /// the special requirements of archive files, users are not permitted to
38 /// construct ArchiveMember instances. You should obtain them from the methods
36 /// stored by the Archive's ilist, the Archive's main abstraction. Because of
37 /// the special requirements of archive files, users are not permitted to
38 /// construct ArchiveMember instances. You should obtain them from the methods
3939 /// of the Archive class instead.
4040 /// @brief This class represents a single archive member.
4141 class ArchiveMember {
7676 /// @brief Get the user associated with this archive member.
7777 unsigned getUser() const { return info.user; }
7878
79 /// The "group" is the owning group of the file per Unix security. This
80 /// may not have any applicability on non-Unix systems but is a required
79 /// The "group" is the owning group of the file per Unix security. This
80 /// may not have any applicability on non-Unix systems but is a required
8181 /// component of the "ar" file format.
8282 /// @brief Get the group associated with this archive member.
8383 unsigned getGroup() const { return info.group; }
8484
85 /// The "mode" specifies the access permissions for the file per Unix
85 /// The "mode" specifies the access permissions for the file per Unix
8686 /// security. This may not have any applicabiity on non-Unix systems but is
8787 /// a required component of the "ar" file format.
8888 /// @brief Get the permission mode associated with this archive member.
8989 unsigned getMode() const { return info.mode; }
9090
91 /// This method returns the time at which the archive member was last
91 /// This method returns the time at which the archive member was last
9292 /// modified when it was not in the archive.
9393 /// @brief Get the time of last modification of the archive member.
9494 sys::TimeValue getModTime() const { return info.modTime; }
9797 /// @brief Get the size of the archive member.
9898 unsigned getSize() const { return info.fileSize; }
9999
100 /// This method returns the total size of the archive member as it
100 /// This method returns the total size of the archive member as it
101101 /// appears on disk. This includes the file content, the header, the
102102 /// long file name if any, and the padding.
103103 /// @brief Get total on-disk member size.
105105
106106 /// This method will return a pointer to the in-memory content of the
107107 /// archive member, if it is available. If the data has not been loaded
108 /// into memory, the return value will be null.
108 /// into memory, the return value will be null.
109109 /// @returns a pointer to the member's data.
110110 /// @brief Get the data content of the archive member
111111 const void* getData() const { return data; }
146146 bool hasPath() const { return flags&HasPathFlag; }
147147
148148 /// Long filenames are an artifact of the ar(1) file format which allows
149 /// up to sixteen characters in its header and doesn't allow a path
149 /// up to sixteen characters in its header and doesn't allow a path
150150 /// separator character (/). To avoid this, a "long format" member name is
151151 /// allowed that doesn't have this restriction. This method determines if
152152 /// that "long format" is used for this member.
157157 /// This method returns the status info (like Unix stat(2)) for the archive
158158 /// member. The status info provides the file's size, permissions, and
159159 /// modification time. The contents of the Path::StatusInfo structure, other
160 /// than the size and modification time, may not have utility on non-Unix
160 /// than the size and modification time, may not have utility on non-Unix
161161 /// systems.
162162 /// @returns the status info for the archive member
163163 /// @brief Obtain the status info for the archive member
211211 /// @}
212212 };
213213
214 /// This class defines the interface to LLVM Archive files. The Archive class
215 /// presents the archive file as an ilist of ArchiveMember objects. The members
214 /// This class defines the interface to LLVM Archive files. The Archive class
215 /// presents the archive file as an ilist of ArchiveMember objects. The members
216216 /// can be rearranged in any fashion either by directly editing the ilist or by
217 /// using editing methods on the Archive class (recommended). The Archive
218 /// class also provides several ways of accessing the archive file for various
217 /// using editing methods on the Archive class (recommended). The Archive
218 /// class also provides several ways of accessing the archive file for various
219219 /// purposes such as editing and linking. Full symbol table support is provided
220 /// for loading only those files that resolve symbols. Note that read
221 /// performance of this library is _crucial_ for performance of JIT type
220 /// for loading only those files that resolve symbols. Note that read
221 /// performance of this library is _crucial_ for performance of JIT type
222222 /// applications and the linkers. Consequently, the implementation of the class
223223 /// is optimized for reading.
224224 class Archive {
272272 /// @{
273273 public:
274274 /// This method splices a \p src member from an archive (possibly \p this),
275 /// to a position just before the member given by \p dest in \p this. When
275 /// to a position just before the member given by \p dest in \p this. When
276276 /// the archive is written, \p src will be written in its new location.
277277 /// @brief Move a member to a new location
278278 inline void splice(iterator dest, Archive& arch, iterator src)
279279 { return members.splice(dest,arch.members,src); }
280
280
281281 /// This method erases a \p target member from the archive. When the
282282 /// archive is written, it will no longer contain \p target. The associated
283283 /// ArchiveMember is deleted.
289289 /// @{
290290 public:
291291 /// Create an empty archive file and associate it with the \p Filename. This
292 /// method does not actually create the archive disk file. It creates an
292 /// method does not actually create the archive disk file. It creates an
293293 /// empty Archive object. If the writeToDisk method is called, the archive
294 /// file \p Filename will be created at that point, with whatever content
295 /// the returned Archive object has at that time.
294 /// file \p Filename will be created at that point, with whatever content
295 /// the returned Archive object has at that time.
296296 /// @returns An Archive* that represents the new archive file.
297297 /// @brief Create an empty Archive.
298298 static Archive* CreateEmpty(
313313 /// This method opens an existing archive file from \p Filename and reads in
314314 /// its symbol table without reading in any of the archive's members. This
315315 /// reduces both I/O and cpu time in opening the archive if it is to be used
316 /// solely for symbol lookup (e.g. during linking). The \p Filename must
316 /// solely for symbol lookup (e.g. during linking). The \p Filename must
317317 /// exist and be an archive file or an exception will be thrown. This form
318318 /// of opening the archive is intended for read-only operations that need to
319319 /// locate members via the symbol table for link editing. Since the archve
320320 /// members are not read by this method, the archive will appear empty upon
321 /// return. If editing operations are performed on the archive, they will
321 /// return. If editing operations are performed on the archive, they will
322322 /// completely replace the contents of the archive! It is recommended that
323323 /// if this form of opening the archive is used that only the symbol table
324 /// lookup methods (getSymbolTable, findModuleDefiningSymbol, and
324 /// lookup methods (getSymbolTable, findModuleDefiningSymbol, and
325325 /// findModulesDefiningSymbols) be used.
326326 /// @throws std::string if an error occurs opening the file
327327 /// @returns an Archive* that represents the archive file.
332332 );
333333
334334 /// This destructor cleans up the Archive object, releases all memory, and
335 /// closes files. It does nothing with the archive file on disk. If you
336 /// haven't used the writeToDisk method by the time the destructor is
335 /// closes files. It does nothing with the archive file on disk. If you
336 /// haven't used the writeToDisk method by the time the destructor is
337337 /// called, all changes to the archive will be lost.
338338 /// @throws std::string if an error occurs
339 /// @brief Destruct in-memory archive
339 /// @brief Destruct in-memory archive
340340 ~Archive();
341341
342342 /// @}
354354 /// @brief Get the iplist of the members
355355 MembersList& getMembers() { return members; }
356356
357 /// This method allows direct query of the Archive's symbol table. The
357 /// This method allows direct query of the Archive's symbol table. The
358358 /// symbol table is a std::map of std::string (the symbol) to unsigned (the
359 /// file offset). Note that for efficiency reasons, the offset stored in
359 /// file offset). Note that for efficiency reasons, the offset stored in
360360 /// the symbol table is not the actual offset. It is the offset from the
361361 /// beginning of the first "real" file member (after the symbol table). Use
362362 /// the getFirstFileOffset() to obtain that offset and add this value to the
363 /// offset in the symbol table to obtain the real file offset. Note that
364 /// there is purposefully no interface provided by Archive to look up
365 /// members by their offset. Use the findModulesDefiningSymbols and
363 /// offset in the symbol table to obtain the real file offset. Note that
364 /// there is purposefully no interface provided by Archive to look up
365 /// members by their offset. Use the findModulesDefiningSymbols and
366366 /// findModuleDefiningSymbol methods instead.
367367 /// @returns the Archive's symbol table.
368368 /// @brief Get the archive's symbol table
385385 /// @brief Instantiate all the bytecode modules located in the archive
386386 bool getAllModules(std::vector& Modules, std::string* ErrMessage);
387387
388 /// This accessor looks up the \p symbol in the archive's symbol table and
388 /// This accessor looks up the \p symbol in the archive's symbol table and
389389 /// returns the associated module that defines that symbol. This method can
390 /// be called as many times as necessary. This is handy for linking the
390 /// be called as many times as necessary. This is handy for linking the
391391 /// archive into another module based on unresolved symbols. Note that the
392392 /// ModuleProvider returned by this accessor should not be deleted by the
393 /// caller. It is managed internally by the Archive class. It is possible
393 /// caller. It is managed internally by the Archive class. It is possible
394394 /// that multiple calls to this accessor will return the same ModuleProvider
395 /// instance because the associated module defines multiple symbols.
396 /// @returns The ModuleProvider* found or null if the archive does not
395 /// instance because the associated module defines multiple symbols.
396 /// @returns The ModuleProvider* found or null if the archive does not
397397 /// contain a module that defines the \p symbol.
398398 /// @brief Look up a module by symbol name.
399399 ModuleProvider* findModuleDefiningSymbol(
401401 );
402402
403403 /// This method is similar to findModuleDefiningSymbol but allows lookup of
404 /// more than one symbol at a time. If \p symbols contains a list of
405 /// undefined symbols in some module, then calling this method is like
404 /// more than one symbol at a time. If \p symbols contains a list of
405 /// undefined symbols in some module, then calling this method is like
406406 /// making one complete pass through the archive to resolve symbols but is
407 /// more efficient than looking at the individual members. Note that on
407 /// more efficient than looking at the individual members. Note that on
408408 /// exit, the symbols resolved by this method will be removed from \p
409409 /// symbols to ensure they are not re-searched on a subsequent call. If
410410 /// you need to retain the list of symbols, make a copy.
413413 std::set& symbols, ///< Symbols to be sought
414414 std::set& modules ///< The modules matching \p symbols
415415 );
416
417 /// This method determines whether the archive is a properly formed llvm
418 /// bytecode archive. It first makes sure the symbol table has been loaded
419 /// and has a non-zero size. If it does, then it is an archive. If not,
420 /// then it tries to load all the bytecode modules of the archive. Finally,
416
417 /// This method determines whether the archive is a properly formed llvm
418 /// bytecode archive. It first makes sure the symbol table has been loaded
419 /// and has a non-zero size. If it does, then it is an archive. If not,
420 /// then it tries to load all the bytecode modules of the archive. Finally,
421421 /// it returns whether it was successfull.
422422 /// @returns true if the archive is a proper llvm bytecode archive
423423 /// @brief Determine whether the archive is a proper llvm bytecode archive.
427427 /// @name Mutators
428428 /// @{
429429 public:
430 /// This method is the only way to get the archive written to disk. It
430 /// This method is the only way to get the archive written to disk. It
431431 /// creates or overwrites the file specified when \p this was created
432432 /// or opened. The arguments provide options for writing the archive. If
433433 /// \p CreateSymbolTable is true, the archive is scanned for bytecode files
434 /// and a symbol table of the externally visible function and global
434 /// and a symbol table of the externally visible function and global
435435 /// variable names is created. If \p TruncateNames is true, the names of the
436 /// archive members will have their path component stripped and the file
437 /// name will be truncated at 15 characters. If \p Compress is specified,
438 /// all archive members will be compressed before being written. If
436 /// archive members will have their path component stripped and the file
437 /// name will be truncated at 15 characters. If \p Compress is specified,
438 /// all archive members will be compressed before being written. If
439439 /// \p PrintSymTab is true, the symbol table will be printed to std::cout.
440440 /// @throws std::string if an error occurs
441441 /// @brief Write (possibly modified) archive contents to disk
448448 /// This method adds a new file to the archive. The \p filename is examined
449449 /// to determine just enough information to create an ArchiveMember object
450450 /// which is then inserted into the Archive object's ilist at the location
451 /// given by \p where.
451 /// given by \p where.
452452 /// @throws std::string if an error occurs reading the \p filename.
453453 /// @returns nothing
454454 /// @brief Add a file to the archive.
458458 /// @name Implementation
459459 /// @{
460460 protected:
461 /// @brief Construct an Archive for \p filename and optionally map it
461 /// @brief Construct an Archive for \p filename and optionally map it
462462 /// into memory.
463463 Archive(const sys::Path& filename, bool map = false );
464464
485485 bool CreateSymbolTable, bool TruncateNames, bool ShouldCompress);
486486
487487 /// @brief Fill in an ArchiveMemberHeader from ArchiveMember.
488 bool fillHeader(const ArchiveMember&mbr,
488 bool fillHeader(const ArchiveMember&mbr,
489489 ArchiveMemberHeader& hdr,int sz, bool TruncateNames) const;
490
490
491491 /// This type is used to keep track of bytecode modules loaded from the
492492 /// symbol table. It maps the file offset to a pair that consists of the
493 /// associated ArchiveMember and the ModuleProvider.
493 /// associated ArchiveMember and the ModuleProvider.
494494 /// @brief Module mapping type
495 typedef std::map >
495 typedef std::map >
496496 ModuleMap;
497497
498498 /// @}
0 //===-- BytecodeHandler.h - Handle Bytecode Parsing Events ------*- 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 defines the interface to the Bytecode Handler. The handler
2727 class Module;
2828
2929 /// This class provides the interface for handling bytecode events during
30 /// reading of bytecode. The methods on this interface are invoked by the
31 /// BytecodeReader as it discovers the content of a bytecode stream.
32 /// This class provides a a clear separation of concerns between recognizing
33 /// the semantic units of a bytecode file (the Reader) and deciding what to do
34 /// with them (the Handler).
30 /// reading of bytecode. The methods on this interface are invoked by the
31 /// BytecodeReader as it discovers the content of a bytecode stream.
32 /// This class provides a a clear separation of concerns between recognizing
33 /// the semantic units of a bytecode file (the Reader) and deciding what to do
34 /// with them (the Handler).
3535 ///
3636 /// The BytecodeReader recognizes the content of the bytecode file and
3737 /// calls the BytecodeHandler methods to let it perform additional tasks. This
3939 /// purposes simply by creating a subclass of BytecodeHandler. None of the
4040 /// parsing details need to be understood, only the meaning of the calls
4141 /// made on this interface.
42 ///
42 ///
4343 /// @see BytecodeHandler
4444 /// @brief Handle Bytecode Parsing Events
4545 class BytecodeHandler {
6363
6464 /// This method is called whenever the parser detects an error in the
6565 /// bytecode formatting. It gives the handler a chance to do something
66 /// with the error message before the parser throws an exception to
67 /// terminate the parsing.
66 /// with the error message before the parser throws an exception to
67 /// terminate the parsing.
6868 /// @brief Handle parsing errors.
6969 virtual void handleError(const std::string& str ) {}
7070
9090 const std::string& moduleId ///< An identifier for the module
9191 ) {}
9292
93 /// This method is called once the version information has been parsed. It
94 /// provides the information about the version of the bytecode file being
93 /// This method is called once the version information has been parsed. It
94 /// provides the information about the version of the bytecode file being
9595 /// read.
9696 /// @brief Handle the bytecode prolog
9797 virtual void handleVersionInfo(
104104 /// contains the global variables and the function placeholders
105105 virtual void handleModuleGlobalsBegin() {}
106106
107 /// This method is called when a non-initialized global variable is
107 /// This method is called when a non-initialized global variable is
108108 /// recognized. Its type, constness, and linkage type are provided.
109109 /// @brief Handle a non-initialized global variable
110 virtual void handleGlobalVariable(
110 virtual void handleGlobalVariable(
111111 const Type* ElemType, ///< The type of the global variable
112112 bool isConstant, ///< Whether the GV is constant or not
113113 GlobalValue::LinkageTypes,///< The linkage type of the GV
119119 /// provides the number of types that the list contains. The handler
120120 /// should expect that number of calls to handleType.
121121 /// @brief Handle a type
122 virtual void handleTypeList(
122 virtual void handleTypeList(
123123 unsigned numEntries ///< The number of entries in the type list
124124 ) {}
125125
126 /// This method is called when a new type is recognized. The type is
126 /// This method is called when a new type is recognized. The type is
127127 /// converted from the bytecode and passed to this method.
128128 /// @brief Handle a type
129 virtual void handleType(
129 virtual void handleType(
130130 const Type* Ty ///< The type that was just recognized
131131 ) {}
132132
133133 /// This method is called when the function prototype for a function is
134134 /// encountered in the module globals block.
135 virtual void handleFunctionDeclaration(
135 virtual void handleFunctionDeclaration(
136136 Function* Func ///< The function being declared
137137 ) {}
138138
145145 /// in the module globals block.
146146 virtual void handleDependentLibrary(const std::string& libName) {}
147147
148 /// This method is called if the module globals has a non-empty target
148 /// This method is called if the module globals has a non-empty target
149149 /// triple
150150 virtual void handleTargetTriple(const std::string& triple) {}
151151
158158 virtual void handleCompactionTableBegin() {}
159159
160160 /// @brief Handle start of a compaction table plane
161 virtual void handleCompactionTablePlane(
161 virtual void handleCompactionTablePlane(
162162 unsigned Ty, ///< The type of the plane (slot number)
163163 unsigned NumEntries ///< The number of entries in the plane
164164 ) {}
165165
166166 /// @brief Handle a type entry in the compaction table
167 virtual void handleCompactionTableType(
167 virtual void handleCompactionTableType(
168168 unsigned i, ///< Index in the plane of this type
169169 unsigned TypSlot, ///< Slot number for this type
170170 const Type* ///< The type referenced by this slot
181181 virtual void handleCompactionTableEnd() {}
182182
183183 /// @brief Handle start of a symbol table
184 virtual void handleSymbolTableBegin(
184 virtual void handleSymbolTableBegin(
185185 Function* Func, ///< The function to which the ST belongs
186186 SymbolTable* ST ///< The symbol table being filled
187187 ) {}
188188
189189 /// @brief Handle start of a symbol table plane
190 virtual void handleSymbolTablePlane(
190 virtual void handleSymbolTablePlane(
191191 unsigned TySlot, ///< The slotnum of the type plane
192192 unsigned NumEntries, ///< Number of entries in the plane
193193 const Type* Typ ///< The type of this type plane
194194 ) {}
195195
196196 /// @brief Handle a named type in the symbol table
197 virtual void handleSymbolTableType(
197 virtual void handleSymbolTableType(
198198 unsigned i, ///< The index of the type in this plane
199199 unsigned slot, ///< Slot number of the named type
200200 const std::string& name ///< Name of the type
201201 ) {}
202202
203203 /// @brief Handle a named value in the symbol table
204 virtual void handleSymbolTableValue(
204 virtual void handleSymbolTableValue(
205205 unsigned i, ///< The index of the value in this plane
206206 unsigned slot, ///< Slot number of the named value
207207 const std::string& name ///< Name of the value.
226226 unsigned blocknum ///< The block number of the block
227227 ) {}
228228
229 /// This method is called for each instruction that is parsed.
229 /// This method is called for each instruction that is parsed.
230230 /// @returns true if the instruction is a block terminating instruction
231231 /// @brief Handle an instruction
232232 virtual bool handleInstruction(
245245 virtual void handleGlobalConstantsBegin() {}
246246
247247 /// @brief Handle a constant expression
248 virtual void handleConstantExpression(
248 virtual void handleConstantExpression(
249249 unsigned Opcode, ///< Opcode of primary expression operator
250250 std::vector ArgVec, ///< expression args
251251 Constant* C ///< The constant value
252252 ) {}
253253
254254 /// @brief Handle a constant array
255 virtual void handleConstantArray(
255 virtual void handleConstantArray(
256256 const ArrayType* AT, ///< Type of the array
257257 std::vector& ElementSlots,///< Slot nums for array values
258258 unsigned TypeSlot, ///< Slot # of type
259259 Constant* Val ///< The constant value
260260 ) {}
261261
262 /// @brief Handle a constant structure
263 virtual void handleConstantStruct(
262 /// @brief Handle a constant structure
263 virtual void handleConstantStruct(
264264 const StructType* ST, ///< Type of the struct
265265 std::vector& ElementSlots,///< Slot nums for struct values
266266 Constant* Val ///< The constant value
267267 ) {}
268268
269269 /// @brief Handle a constant packed
270 virtual void handleConstantPacked(
270 virtual void handleConstantPacked(
271271 const PackedType* PT, ///< Type of the array
272272 std::vector& ElementSlots,///< Slot nums for packed values
273273 unsigned TypeSlot, ///< Slot # of type
275275 ) {}
276276
277277 /// @brief Handle a constant pointer
278 virtual void handleConstantPointer(
278 virtual void handleConstantPointer(
279279 const PointerType* PT, ///< Type of the pointer
280280 unsigned Slot, ///< Slot num of initializer value
281281 GlobalValue* GV ///< Referenced global value
287287 ) {}
288288
289289 /// @brief Handle a primitive constant value
290 virtual void handleConstantValue(
290 virtual void handleConstantValue(
291291 Constant * c ///< The constant just defined
292292 ) {}
293293
0 //===-- llvm/Bytecode/Format.h - VM bytecode file format info ---*- 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 //
9 // This header defines intrinsic constants that are useful to libraries that
9 // This header defines intrinsic constants that are useful to libraries that
1010 // need to hack on bytecode files directly, like the reader and writer.
1111 //
1212 //===----------------------------------------------------------------------===//
5050 };
5151
5252 /// In LLVM 1.3 format, the identifier and the size of the block are
53 /// encoded into a single vbr_uint32 with 5 bits for the block identifier
54 /// and 27-bits for block length. This limits blocks to a maximum of
55 /// 128MBytes of data, and block types to 31 which should be sufficient
53 /// encoded into a single vbr_uint32 with 5 bits for the block identifier
54 /// and 27-bits for block length. This limits blocks to a maximum of
55 /// 128MBytes of data, and block types to 31 which should be sufficient
5656 /// for the foreseeable usage. Because the values of block identifiers MUST
5757 /// fit within 5 bits (values 1-31), this enumeration is used to ensure
5858 /// smaller values are used for 1.3 and subsequent bytecode versions.
7979
8080 // InstructionList - The instructions in the body of a function. This
8181 // superceeds the old BasicBlock node used in LLVM 1.0.
82 InstructionListBlockID = 0x07, ///< 1.3 identifier for insruction list
82 InstructionListBlockID = 0x07, ///< 1.3 identifier for insruction list
8383
8484 // CompactionTable - blocks with this id are used to define local remapping
8585 // tables for a function, allowing the indices used within the function to
0 //===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ---*- 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 functionality is implemented by the lib/Bytecode/Reader library.
5959 /// dependent libraries.
6060 /// @returns true on success, false otherwise
6161 /// @brief Get the list of dependent libraries from a bytecode file.
62 bool GetBytecodeDependentLibraries(const std::string &fileName,
62 bool GetBytecodeDependentLibraries(const std::string &fileName,
6363 Module::LibraryListType& deplibs);
6464
6565 /// This function will read only the necessary parts of a bytecode file in order
6666 /// to obtain a list of externally visible global symbols that the bytecode
67 /// module defines. This is used for archiving and linking when only the list
67 /// module defines. This is used for archiving and linking when only the list
6868 /// of symbols the module defines is needed.
6969 /// @returns true on success, false otherwise
7070 /// @brief Get a bytecode file's externally visibile defined global symbols.
71 bool GetBytecodeSymbols(const sys::Path& fileName,
71 bool GetBytecodeSymbols(const sys::Path& fileName,
7272 std::vector& syms);
7373
7474 /// This function will read only the necessary parts of a bytecode buffer in
75 /// order to obtain a list of externally visible global symbols that the
76 /// bytecode module defines. This is used for archiving and linking when only
75 /// order to obtain a list of externally visible global symbols that the
76 /// bytecode module defines. This is used for archiving and linking when only
7777 /// the list of symbols the module defines is needed and the bytecode is
7878 /// already in memory.
7979 /// @returns the ModuleProvider on success, 0 if the bytecode can't be parsed
0 //===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass -*- 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 pass to write the working module to a file after
2525 bool DeleteStream;
2626 bool CompressFile;
2727 public:
28 WriteBytecodePass()
28 WriteBytecodePass()
2929 : Out(&std::cout), DeleteStream(false), CompressFile(true) {}
30 WriteBytecodePass(std::ostream *o, bool DS = false, bool CF = true)
30 WriteBytecodePass(std::ostream *o, bool DS = false, bool CF = true)
3131 : Out(o), DeleteStream(DS), CompressFile(CF) {}
3232
3333 inline ~WriteBytecodePass() {
3434 if (DeleteStream) delete Out;
3535 }
36
36
3737 bool runOnModule(Module &M) {
3838 WriteBytecodeToFile(&M, *Out, CompressFile );
3939 return false;
0 //===-- llvm/Bytecode/Writer.h - Writer for VM bytecode files ---*- 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 functionality is implemented by the lib/BytecodeWriter library.
2727
2828 namespace llvm {
2929 class Module;
30 void WriteBytecodeToFile(const Module *M, std::ostream &Out,
30 void WriteBytecodeToFile(const Module *M, std::ostream &Out,
3131 bool compress = true);
3232 } // End llvm namespace
3333
0 //===-- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework --------*- 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 is intended to be used as a base class for target-specific
7777 /// AsciiDirective - This directive allows emission of an ascii string with
7878 /// the standard C escape characters embedded into it.
7979 const char *AsciiDirective;
80
80
8181 /// DataDirectives - These directives are used to output some unit of
8282 /// integer data to the current section. If a data directive is set to
8383 /// null, smaller data directives will be used to emit the large sizes.
0 //===-- InstrScheduling.h - Interface To Instruction Scheduling -*- 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 minimal, but complete, interface to instruction
2121
2222 //---------------------------------------------------------------------------
2323 // Function: createScheduleInstructionsWithSSAPass(..)
24 //
24 //
2525 // Purpose:
2626 // Entry point for instruction scheduling on SSA form.
2727 // Schedules the machine instructions generated by instruction selection.
0 //===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // This file defines the IntrinsicLowering interface. This interface allows
1010 // addition of domain-specific or front-end specific intrinsics to LLVM without
1111 // having to modify all of the code generators to support the new intrinsic.
3737 namespace llvm {
3838 class CallInst;
3939 class Module;
40
40
4141 class IntrinsicLowering {
4242 public:
4343 virtual ~IntrinsicLowering() {}
6666 /// implementation to allow for future extensibility.
6767 struct DefaultIntrinsicLowering : public IntrinsicLowering {
6868 virtual void AddPrototypes(Module &M);
69 virtual void LowerIntrinsicCall(CallInst *CI);
69 virtual void LowerIntrinsicCall(CallInst *CI);
7070 };
7171 }
7272
0 //===-- llvm/CodeGen/LiveVariables.h - Live Variable Analysis ---*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // This file implements the LiveVariable analysis pass. For each machine
1010 // instruction in the function, this pass calculates the set of registers that
1111 // are immediately dead after the instruction (i.e., the instruction calculates
2222 // to resolve physical register lifetimes in each basic block). If a physical
2323 // register is not register allocatable, it is not tracked. This is useful for
2424 // things like the stack pointer and condition codes.
25 //
25 //
2626 //===----------------------------------------------------------------------===//
2727
2828 #ifndef LLVM_CODEGEN_LIVEVARIABLES_H
110110 /// killed_iterator - Iterate over registers killed by a machine instruction
111111 ///
112112 typedef std::multimap::iterator killed_iterator;
113
113
114114 /// killed_begin/end - Get access to the range of registers killed by a
115115 /// machine instruction.
116116 killed_iterator killed_begin(MachineInstr *MI) {
0 //===-- llvm/CodeGen/MachineBasicBlock.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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // Collect the sequence of machine instructions for a basic block.
1010 //
1111 //===----------------------------------------------------------------------===//
7474 }
7575
7676 ~MachineBasicBlock();
77
77
7878 /// getBasicBlock - Return the LLVM basic block that this instance
7979 /// corresponded to originally.
8080 ///
110110 typedef std::vector::const_iterator const_pred_iterator;
111111 typedef std::vector::iterator succ_iterator;
112112 typedef std::vector::const_iterator const_succ_iterator;
113
113
114114 pred_iterator pred_begin() { return Predecessors.begin (); }
115115 const_pred_iterator pred_begin() const { return Predecessors.begin (); }
116116 pred_iterator pred_end() { return Predecessors.end (); }
161161 iterator erase(iterator I, iterator E) { return Insts.erase(I, E); }
162162 MachineInstr *remove(MachineInstr *I) { return Insts.remove(I); }
163163 void clear() { Insts.clear(); }
164
164
165165 /// splice - Take a block of instructions from MBB 'Other' in the range [From,
166166 /// To), and insert them into this MBB right before 'where'.
167167 void splice(iterator where, MachineBasicBlock *Other, iterator From,
218218 typedef MachineBasicBlock::succ_iterator ChildIteratorType;
219219
220220 static NodeType *getEntryNode(MachineBasicBlock *BB) { return BB; }
221 static inline ChildIteratorType child_begin(NodeType *N) {
221 static inline ChildIteratorType child_begin(NodeType *N) {
222222 return N->succ_begin();
223223 }
224 static inline ChildIteratorType child_end(NodeType *N) {
224 static inline ChildIteratorType child_end(NodeType *N) {
225225 return N->succ_end();
226226 }
227227 };
231231 typedef MachineBasicBlock::const_succ_iterator ChildIteratorType;
232232
233233 static NodeType *getEntryNode(const MachineBasicBlock *BB) { return BB; }
234 static inline ChildIteratorType child_begin(NodeType *N) {
234 static inline ChildIteratorType child_begin(NodeType *N) {
235235 return N->succ_begin();
236236 }
237 static inline ChildIteratorType child_end(NodeType *N) {
237 static inline ChildIteratorType child_end(NodeType *N) {
238238 return N->succ_end();
239239 }
240240 };
251251 static NodeType *getEntryNode(Inverse G) {
252252 return G.Graph;
253253 }
254 static inline ChildIteratorType child_begin(NodeType *N) {
254 static inline ChildIteratorType child_begin(NodeType *N) {
255255 return N->pred_begin();
256256 }
257 static inline ChildIteratorType child_end(NodeType *N) {
257 static inline ChildIteratorType child_end(NodeType *N) {
258258 return N->pred_end();
259259 }
260260 };
263263 typedef const MachineBasicBlock NodeType;
264264 typedef MachineBasicBlock::const_pred_iterator ChildIteratorType;
265265 static NodeType *getEntryNode(Inverse G) {
266 return G.Graph;
267 }
268 static inline ChildIteratorType child_begin(NodeType *N) {
266 return G.Graph;
267 }
268 static inline ChildIteratorType child_begin(NodeType *N) {
269269 return N->pred_begin();
270270 }
271 static inline ChildIteratorType child_end(NodeType *N) {
271 static inline ChildIteratorType child_end(NodeType *N) {
272272 return N->pred_end();
273273 }
274274 };
0 //===-- llvm/CodeGen/MachineCodeEmitter.h - Code emission -------*- 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 an abstract interface that is used by the machine code
3636 /// about to be code generated.
3737 ///
3838 virtual void startFunction(MachineFunction &F) {}
39
39
4040 /// finishFunction - This callback is invoked when the specified function has
4141 /// finished code generation.
4242 ///
8787 /// addRelocation - Whenever a relocatable address is needed, it should be
8888 /// noted with this interface.
8989 virtual void addRelocation(const MachineRelocation &MR) = 0;
90
90
9191 // getConstantPoolEntryAddress - Return the address of the 'Index' entry in
9292 // the constant pool that was last emitted with the 'emitConstantPool' method.
9393 //
0 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // The MachineConstantPool class keeps track of constants referenced by a
1010 // function which must be spilled to memory. This is used for constants which
1111 // are unable to be used directly as operands to instructions, which typically
0 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // The MachineFrameInfo class represents an abstract stack frame until
1010 // prolog/epilog code is inserted. This class is key to allowing stack frame
1111 // representation optimizations, such as frame pointer elimination. It also
167167 ///
168168 bool hasCalls() const { return HasCalls; }
169169 void setHasCalls(bool V) { HasCalls = V; }
170
170
171171 /// getMaxCallFrameSize - Return the maximum size of a call frame that must be
172172 /// allocated for an outgoing function call. This is only available if
173173 /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
185185 Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset));
186186 return -++NumFixedObjects;
187187 }
188
188
189189 /// CreateStackObject - Create a new statically sized stack object, returning
190190 /// a postive identifier to represent it.
191191 ///
0 //===-- llvm/CodeGen/MachineFunction.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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // Collect native machine code for a function. This class contains a list of
1010 // MachineBasicBlock instances that make up the current compiled function.
1111 //
1212 // This class also contains pointers to various classes which hold
1313 // target-specific information about the generated code.
14 //
14 //
1515 //===----------------------------------------------------------------------===//
1616
1717 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
3434 // this is only set by the MachineFunction owning the ilist
3535 friend class MachineFunction;
3636 MachineFunction* Parent;
37
37
3838 public:
3939 ilist_traits() : Parent(0) { }
40
40
4141 static MachineBasicBlock* getPrev(MachineBasicBlock* N) { return N->Prev; }
4242 static MachineBasicBlock* getNext(MachineBasicBlock* N) { return N->Next; }
43
43
4444 static const MachineBasicBlock*
4545 getPrev(const MachineBasicBlock* N) { return N->Prev; }
46
46
4747 static const MachineBasicBlock*
4848 getNext(const MachineBasicBlock* N) { return N->Next; }
49
49
5050 static void setPrev(MachineBasicBlock* N, MachineBasicBlock* prev) {
5151 N->Prev = prev;
5252 }
178178 /// is an error to add the same register to the same set more than once.
179179 void addLiveIn(unsigned Reg) { LiveIns.push_back(Reg); }
180180 void addLiveOut(unsigned Reg) { LiveOuts.push_back(Reg); }
181
181
182182 // Iteration support for live in/out sets. These sets are kept in sorted
183183 // order by their register number.
184184 typedef std::vector::const_iterator liveinout_iterator;
218218 /// in your path.
219219 ///
220220 void viewCFG() const;
221
221
222222 /// viewCFGOnly - This function is meant for use from the debugger. It works
223223 /// just like viewCFG, but it does not include the contents of basic blocks
224224 /// into the nodes, just the label. If you are only interested in the CFG
255255 // Provide accessors for basic blocks...
256256 const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
257257 BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
258
258
259259 //===--------------------------------------------------------------------===//
260260 // BasicBlock iterator forwarding functions
261261 //
330330 };
331331
332332
333 // Provide specializations of GraphTraits to be able to treat a function as a
333 // Provide specializations of GraphTraits to be able to treat a function as a
334334 // graph of basic blocks... and to walk it in inverse order. Inverse order for
335335 // a function is considered to be when traversing the predecessor edges of a BB
336336 // instead of the successor edges.
0 //===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-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 MachineFunctionPass class. MachineFunctionPass's are
0 //===-- llvm/CodeGen/MachineInstr.h - MachineInstr class --------*- 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 declaration of the MachineInstr class, which is the
3434 typedef short MachineOpCode;
3535
3636 //===----------------------------------------------------------------------===//
37 // class MachineOperand
38 //
37 // class MachineOperand
38 //
3939 // Purpose:
4040 // Representation of each machine instruction operand.
4141 // This class is designed so that you can allocate a vector of operands
4444 // E.g, for this VM instruction:
4545 // ptr = alloca type, numElements
4646 // we generate 2 machine instructions on the SPARC:
47 //
47 //
4848 // mul Constant, Numelements -> Reg
4949 // add %sp, Reg -> Ptr
50 //
50 //
5151 // Each instruction has 3 operands, listed above. Of those:
5252 // - Reg, NumElements, and Ptr are of operand type MO_Register.
5353 // - Constant is of operand type MO_SignExtendedImmed on the SPARC.
5656 //
5757 // - Reg will be of virtual register type MO_MInstrVirtualReg. The field
5858 // MachineInstr* minstr will point to the instruction that computes reg.
59 //
59 //
6060 // - %sp will be of virtual register type MO_MachineReg.
6161 // The field regNum identifies the machine register.
62 //
62 //
6363 // - NumElements will be of virtual register type MO_VirtualReg.
6464 // The field Value* value identifies the value.
65 //
65 //
6666 // - Ptr will also be of virtual register type MO_VirtualReg.
6767 // Again, the field Value* value identifies the value.
68 //
68 //
6969 //===----------------------------------------------------------------------===//
7070
7171 struct MachineOperand {
107107 MO_ExternalSymbol, // Name of external global symbol
108108 MO_GlobalAddress, // Address of a global value
109109 };
110
110
111111 private:
112112 union {
113113 Value* value; // BasicBlockVal for a label operand.
114114 // ConstantVal for a non-address immediate.
115115 // Virtual register for an SSA operand,
116116 // including hidden operands required for
117 // the generated machine code.
117 // the generated machine code.
118118 // LLVM global for MO_GlobalAddress.
119119
120120 int64_t immedVal; // Constant value for an explicit constant
133133 // valid for MO_GlobalAddress and MO_ExternalSym
134134 } extra;
135135
136 void zeroContents () {
136 void zeroContents () {
137137 memset (&contents, 0, sizeof (contents));
138138 memset (&extra, 0, sizeof (extra));
139139 }
192192 extra = M.extra;
193193 }
194194
195
195
196196 ~MachineOperand() {}
197
197
198198 const MachineOperand &operator=(const MachineOperand &MO) {
199199 contents = MO.contents;
200200 flags = MO.flags;
204204 }
205205
206206 /// getType - Returns the MachineOperandType for this operand.
207 ///
207 ///
208208 MachineOperandType getType() const { return opType; }
209209
210210 /// getUseType - Returns the MachineOperandUseType of this operand.
244244 /// has one. This is deprecated and only used by the SPARC v9 backend.
245245 ///
246246 Value* getVRegValueOrNull() const {
247 return (opType == MO_VirtualRegister || opType == MO_CCRegister ||
247 return (opType == MO_VirtualRegister || opType == MO_CCRegister ||
248248 isPCRelativeDisp()) ? contents.value : NULL;
249249 }
250250
311311 ///
312312 bool hasAllocatedReg() const {
313313 return (extra.regNum >= 0 &&
314 (opType == MO_VirtualRegister || opType == MO_CCRegister ||
314 (opType == MO_VirtualRegister || opType == MO_CCRegister ||
315315 opType == MO_MachineRegister));
316316 }
317317
330330 // code.' It's not clear where the duplication is.
331331 assert(hasAllocatedReg() && "This operand cannot have a register number!");
332332 extra.regNum = Reg;
333 }
333 }
334334
335335 void setValueReg(Value *val) {
336336 assert(getVRegValueOrNull() != 0 && "Original operand must of type Value*");
337337 contents.value = val;
338338 }
339
339
340340 void setImmedValue(int immVal) {
341341 assert(isImmediate() && "Wrong MachineOperand mutator");
342342 contents.immedVal = immVal;
357357 void markLo32() { flags |= LOFLAG32; }
358358 void markHi64() { flags |= HIFLAG64; }
359359 void markLo64() { flags |= LOFLAG64; }
360
360
361361 private:
362362 /// setRegForValue - Replaces the Value with its corresponding physical
363363 /// register after register allocation is complete. This is deprecated
364364 /// and only used by the SPARC v9 back-end.
365365 ///
366366 void setRegForValue(int reg) {
367 assert(opType == MO_VirtualRegister || opType == MO_CCRegister ||
367 assert(opType == MO_VirtualRegister || opType == MO_CCRegister ||
368368 opType == MO_MachineRegister);
369369 extra.regNum = reg;
370370 }
371
371
372372 friend class MachineInstr;
373373 };
374374
375375
376376 //===----------------------------------------------------------------------===//
377 // class MachineInstr
378 //
377 // class MachineInstr
378 //
379379 // Purpose:
380380 // Representation of each machine instruction.
381 //
381 //
382382 // MachineOpCode must be an enum, defined separately for each target.
383383 // E.g., It is defined in SparcInstructionSelection.h for the SPARC.
384 //
384 //
385385 // There are 2 kinds of operands:
386 //
387 // (1) Explicit operands of the machine instruction in vector operands[]
388 //
386 //
387 // (1) Explicit operands of the machine instruction in vector operands[]
388 //
389389 // (2) "Implicit operands" are values implicitly used or defined by the
390390 // machine instruction, such as arguments to a CALL, return value of
391391 // a CALL (if any), and return value of a RETURN.
425425 /// block.
426426 ///
427427 MachineInstr(MachineBasicBlock *MBB, short Opcode, unsigned numOps);
428
428
429429 ~MachineInstr();
430430
431431 const MachineBasicBlock* getParent() const { return parent; }
438438 /// Access to explicit operands of the instruction.
439439 ///
440440 unsigned getNumOperands() const { return operands.size() - numImplicitRefs; }
441
441
442442 const MachineOperand& getOperand(unsigned i) const {
443443 assert(i < getNumOperands() && "getOperand() out of range!");
444444 return operands[i];
453453 // This returns the i'th entry in the operand vector.
454454 // That represents the i'th explicit operand or the (i-N)'th implicit operand,
455455 // depending on whether i < N or i >= N.
456 //
456 //
457457 const MachineOperand& getExplOrImplOperand(unsigned i) const {
458458 assert(i < operands.size() && "getExplOrImplOperand() out of range!");
459459 return (i < getNumOperands()? getOperand(i)
462462
463463 //
464464 // Access to implicit operands of the instruction
465 //
465 //
466466 unsigned getNumImplicitRefs() const{ return numImplicitRefs; }
467
467
468468 MachineOperand& getImplicitOp(unsigned i) {
469469 assert(i < numImplicitRefs && "implicit ref# out of range!");
470470 return operands[i + operands.size() - numImplicitRefs];
671671 /// replace - Support to rewrite a machine instruction in place: for now,
672672 /// simply replace() and then set new operands with Set.*Operand methods
673673 /// below.
674 ///
674 ///
675675 void replace(short Opcode, unsigned numOperands);
676676
677677 /// setOpcode - Replace the opcode of the current instruction with a new one.
686686 }
687687
688688 // Access to set the operands when building the machine instruction
689 //
689 //
690690 void SetMachineOperandVal(unsigned i,
691691 MachineOperand::MachineOperandType operandType,
692692 Value* V);
701701 unsigned substituteValue(const Value* oldVal, Value* newVal,
702702 bool defsOnly, bool notDefsAndUses,
703703 bool& someArgsWereIgnored);
704
704
705705 // SetRegForOperand -
706706 // SetRegForImplicitRef -
707707 // Mark an explicit or implicit operand with its allocated physical register.
708 //
708 //
709709 void SetRegForOperand(unsigned i, int regNum);
710710 void SetRegForImplicitRef(unsigned i, int regNum);
711711
712712 //
713713 // Iterator to enumerate machine operands.
714 //
714 //
715715 template
716716 class ValOpIterator : public forward_iterator {
717717 unsigned i;
718718 MITy MI;
719
719
720720 void skipToNextVal() {
721721 while (i < MI->getNumOperands() &&
722722 !( (MI->getOperand(i).getType() == MachineOperand::MO_VirtualRegister ||
724724 && MI->getOperand(i).getVRegValue() != 0))
725725 ++i;
726726 }
727
727
728728 inline ValOpIterator(MITy mi, unsigned I) : i(I), MI(mi) {
729729 skipToNextVal();
730730 }
731
731
732732 public:
733733 typedef ValOpIterator _Self;
734
734
735735 inline VTy operator*() const {
736736 return MI->getOperand(i).getVRegValue();
737737 }
741741
742742 inline VTy operator->() const { return operator*(); }
743743
744 inline bool isUse() const { return MI->getOperand(i).isUse(); }
745 inline bool isDef() const { return MI->getOperand(i).isDef(); }
744 inline bool isUse() const { return MI->getOperand(i).isUse(); }
745 inline bool isDef() const { return MI->getOperand(i).isDef(); }
746746
747747 inline _Self& operator++() { i++; skipToNextVal(); return *this; }
748748 inline _Self operator++(int) { _Self tmp = *this; ++*this; return tmp; }
749749
750 inline bool operator==(const _Self &y) const {
750 inline bool operator==(const _Self &y) const {
751751 return i == y.i;
752752 }
753 inline bool operator!=(const _Self &y) const {
753 inline bool operator!=(const _Self &y) const {
754754 return !operator==(y);
755755 }
756756
0 //===-- CodeGen/MachineInstBuilder.h - Simplify creation of MIs -*- 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 a function named BuildMI, which is useful for dramatically
8585 MI->addMachineRegOperand(Reg, Ty);
8686 return *this;
8787 }
88
88
8989 /// addImm - Add a new immediate operand.
9090 ///
9191 const MachineInstrBuilder &addImm(int Val) const {
0 //===-- llvm/CodeGen/MachineRelocation.h - Target Relocation ----*- 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 MachineRelocation class.
0 //===-- Passes.h - Target independent code generation passes ----*- 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 interfaces to access the target independent code generation
3030 /// last LLVM modifying pass to clean up blocks that are not reachable from
3131 /// the entry block.
3232 FunctionPass *createUnreachableBlockEliminationPass();
33
33
3434 /// MachineFunctionPrinter pass - This pass prints out the machine function to
3535 /// standard error, as a debugging tool.
3636 FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
6161 /// LocalRegisterAllocation Pass - This pass register allocates the input code
6262 /// a basic block at a time, yielding code better than the simple register
6363 /// allocator, but not as good as a global allocator.
64 ///
64 ///
6565 FunctionPass *createLocalRegisterAllocator();
66
66
6767 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
6868 /// register allocation algorithm, a global register allocator.
6969 ///
8989 /// the current function, which should happen after the function has been
9090 /// emitted to a .s file or to memory.
9191 FunctionPass *createMachineCodeDeleter();
92
92
9393 /// getRegisterAllocator - This creates an instance of the register allocator
9494 /// for the Sparc.
9595 FunctionPass *getRegisterAllocator(TargetMachine &T);
0 //===-- SchedGraphCommon.h - Scheduling Base Graph --------------*- 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 common graph class that is based on the SSA graph. It includes
4646 typedef std::vector::const_iterator const_iterator;
4747 typedef std::vector::reverse_iterator reverse_iterator;
4848 typedef std::vector::const_reverse_iterator const_reverse_iterator;
49
49
5050 // Accessor methods
5151 unsigned getNodeId() const { return ID; }
5252 int getLatency() const { return latency; }
5959 iterator endInEdges() { return inEdges.end(); }
6060 iterator beginOutEdges() { return outEdges.begin(); }
6161 iterator endOutEdges() { return outEdges.end(); }
62
62
6363 const_iterator beginInEdges() const { return inEdges.begin(); }
6464 const_iterator endInEdges() const { return inEdges.end(); }
6565 const_iterator beginOutEdges() const { return outEdges.begin(); }
6969
7070 // Debugging support
7171 virtual void print(std::ostream &os) const = 0;
72
72
7373 protected:
7474 friend class SchedGraphCommon;
7575 friend class SchedGraphEdge; // give access for adding edges
76
77
76
77
7878 // disable default constructor and provide a ctor for single-block graphs
7979 SchedGraphNodeCommon(); // DO NOT IMPLEMENT
80
80
8181 inline SchedGraphNodeCommon(unsigned Id, int index, int late=0) : ID(Id), latency(late), origIndexInBB(index) {}
82
82
8383 virtual ~SchedGraphNodeCommon();
84
84
8585 //Functions to add and remove edges
8686 inline void addInEdge(SchedGraphEdge* edge) { inEdges.push_back(edge); }
8787 inline void addOutEdge(SchedGraphEdge* edge) { outEdges.push_back(edge); }
8888 void removeInEdge(const SchedGraphEdge* edge);
8989 void removeOutEdge(const SchedGraphEdge* edge);
90
90
9191 };
9292
9393 // ostream << operator for SchedGraphNode class
94 inline std::ostream &operator<<(std::ostream &os,
94 inline std::ostream &operator<<(std::ostream &os,
9595 const SchedGraphNodeCommon &node) {
9696 node.print(os);
9797 return os;
111111 enum DataDepOrderType {
112112 TrueDep = 0x1, AntiDep=0x2, OutputDep=0x4, NonDataDep=0x8
113113 };
114
114
115115 protected:
116116 SchedGraphNodeCommon* src;
117117 SchedGraphNodeCommon* sink;
119119 unsigned int depOrderType;
120120 int minDelay; // cached latency (assumes fixed target arch)
121121 int iteDiff;
122
122
123123 union {
124124 const Value* val;
125125 int machineRegNum;
129129 public:
130130 // For all constructors, if minDelay is unspecified, minDelay is
131131 // set to _src->getLatency().
132
132
133133 // constructor for CtrlDep or MemoryDep edges, selected by 3rd argument
134134 SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
135135 SchedGraphEdgeDepType _depType, unsigned int _depOrderType,
136136 int _minDelay = -1);
137
137
138138 // constructor for explicit value dependence (may be true/anti/output)
139139 SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
140140 const Value* _val, unsigned int _depOrderType,
141141 int _minDelay = -1);
142
142
143143 // constructor for machine register dependence
144144 SchedGraphEdge(SchedGraphNodeCommon* _src,SchedGraphNodeCommon* _sink,
145145 unsigned int _regNum, unsigned int _depOrderType,
146146 int _minDelay = -1);
147
147
148148 // constructor for any other machine resource dependences.
149149 // DataDepOrderType is always NonDataDep. It it not an argument to
150150 // avoid overloading ambiguity with previous constructor.
151151 SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
152152 ResourceId _resourceId, int _minDelay = -1);
153
153
154154 ~SchedGraphEdge() {}
155
155
156156 SchedGraphNodeCommon* getSrc() const { return src; }
157157 SchedGraphNodeCommon* getSink() const { return sink; }
158158 int getMinDelay() const { return minDelay; }
178178 int getIteDiff() {
179179 return iteDiff;
180180 }
181
181
182182 public:
183183 // Debugging support
184184 void print(std::ostream &os) const;
185185 void dump(int indent=0) const;
186
186
187187 private:
188188 // disable default ctor
189189 SchedGraphEdge(); // DO NOT IMPLEMENT
196196 }
197197
198198 class SchedGraphCommon {
199
199
200200 protected:
201201 SchedGraphNodeCommon* graphRoot; // the root and leaf are not inserted
202202 SchedGraphNodeCommon* graphLeaf; // in the hash_map (see getNumNodes())
206206 // Accessor methods
207207 //
208208 SchedGraphNodeCommon* getRoot() const { return graphRoot; }
209 SchedGraphNodeCommon* getLeaf() const { return graphLeaf; }
210
209 SchedGraphNodeCommon* getLeaf() const { return graphLeaf; }
210
211211 //
212212 // Delete nodes or edges from the graph.
213 //
213 //
214214 void eraseNode(SchedGraphNodeCommon* node);
215215 void eraseIncomingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
216216 void eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
217217 void eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
218
218
219219 SchedGraphCommon() {}
220220 ~SchedGraphCommon();
221221 };
226226 // Ok to make it a template because it shd get instantiated at most twice:
227227 // for and
228228 // for .
229 //
229 //
230230 template
231231 class SGPredIterator: public bidirectional_iterator<_NodeType, ptrdiff_t> {
232232 protected:
233233 _EdgeIter oi;
234234 public:
235235 typedef SGPredIterator<_NodeType, _EdgeType, _EdgeIter> _Self;
236
236
237237 inline SGPredIterator(_EdgeIter startEdge) : oi(startEdge) {}
238
238
239239 inline bool operator==(const _Self& x) const { return oi == x.oi; }
240240 inline bool operator!=(const _Self& x) const { return !operator==(x); }
241
241
242242 // operator*() differs for pred or succ iterator
243243 inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSrc(); }
244244 inline _NodeType* operator->() const { return operator*(); }
245
245
246246 inline _EdgeType* getEdge() const { return *(oi); }
247
247
248248 inline _Self &operator++() { ++oi; return *this; } // Preincrement
249249 inline _Self operator++(int) { // Postincrement
250 _Self tmp(*this); ++*this; return tmp;
251 }
252
250 _Self tmp(*this); ++*this; return tmp;
251 }
252
253253 inline _Self &operator--() { --oi; return *this; } // Predecrement
254254 inline _Self operator--(int) { // Postdecrement
255255 _Self tmp = *this; --*this; return tmp;
262262 _EdgeIter oi;
263263 public:
264264 typedef SGSuccIterator<_NodeType, _EdgeType, _EdgeIter> _Self;
265
265
266266 inline SGSuccIterator(_EdgeIter startEdge) : oi(startEdge) {}
267
267
268268 inline bool operator==(const _Self& x) const { return oi == x.oi; }
269269 inline bool operator!=(const _Self& x) const { return !operator==(x); }
270
270
271271 inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSink(); }
272272 inline _NodeType* operator->() const { return operator*(); }
273
273
274274 inline _EdgeType* getEdge() const { return *(oi); }
275
275
276276 inline _Self &operator++() { ++oi; return *this; } // Preincrement
277277 inline _Self operator++(int) { // Postincrement
278 _Self tmp(*this); ++*this; return tmp;
279 }
280
278 _Self tmp(*this); ++*this; return tmp;
279 }
280
281281 inline _Self &operator--() { --oi; return *this; } // Predecrement
282282 inline _Self operator--(int) { // Postdecrement
283283 _Self tmp = *this; --*this; return tmp;
0 //===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // This file declares the SelectionDAG class, and transitively defines the
1010 // SDNode class and subclasses.
11 //
11 //
1212 //===----------------------------------------------------------------------===//
1313
1414 #ifndef LLVM_CODEGEN_SELECTIONDAG_H
6161 typedef std::vector::const_iterator allnodes_iterator;
6262 allnodes_iterator allnodes_begin() const { return AllNodes.begin(); }
6363 allnodes_iterator allnodes_end() const { return AllNodes.end(); }
64
64
6565 /// getRoot - Return the root tag of the SelectionDAG.
6666 ///
6767 const SDOperand &getRoot() const { return Root; }
0 //===-- llvm/CodeGen/SelectionDAGISel.h - Common Base Class------*- 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 the SelectionDAGISel class, which is used as the common
4848 unsigned MakeReg(MVT::ValueType VT);
4949
5050 virtual void InstructionSelectBasicBlock(SelectionDAG &SD) = 0;
51
51
5252 private:
5353 SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
5454 Value *V, unsigned Reg);
5555 void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
5656 FunctionLoweringInfo &FuncInfo);
57
57
5858 void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
5959 std::vector > &PHINodesToUpdate,
6060 FunctionLoweringInfo &FuncInfo);
0 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // This file declares the SDNode class and derived classes, which are used to
1010 // represent the nodes and operations present in a SelectionDAG. These nodes
1111 // and operations are machine code level operations, with some similarities to
5050 // single token result. This is used to represent the fact that the operand
5151 // operators are independent of each other.
5252 TokenFactor,
53
53
5454 // Various leaf nodes.
5555 Constant, ConstantFP, GlobalAddress, FrameIndex, ConstantPool,
5656 BasicBlock, ExternalSymbol,
184184 // integer result type.
185185 // ZEXTLOAD loads the integer operand and zero extends it to a larger
186186 // integer result type.
187 // EXTLOAD is used for two things: floating point extending loads, and
187 // EXTLOAD is used for two things: floating point extending loads, and
188188 // integer extending loads where it doesn't matter what the high
189189 // bits are set to. The code generator is allowed to codegen this
190190 // into whichever operation is more efficient.
204204 DYNAMIC_STACKALLOC,
205205
206206 // Control flow instructions. These all have token chains.
207
207
208208 // BR - Unconditional branch. The first operand is the chain
209209 // operand, the second is the MBB to branch to.
210210 BR,
239239 MEMSET,
240240 MEMMOVE,
241241 MEMCPY,
242
242
243243 // ADJCALLSTACKDOWN/ADJCALLSTACKUP - These operators mark the beginning and
244244 // end of a call sequence and indicate how much the stack pointer needs to
245245 // be adjusted for that particular call. The first operand is a chain, the
283283 SETUGT, // 1 0 1 0 True if unordered or greater than
284284 SETUGE, // 1 0 1 1 True if unordered, greater than, or equal
285285 SETULT, // 1 1 0 0 True if unordered or less than
286 SETULE, // 1 1 0 1 True if unordered, less than, or equal
286 SETULE, // 1 1 0 1 True if unordered, less than, or equal
287287 SETUNE, // 1 1 1 0 True if unordered or not equal
288288 SETTRUE, // 1 1 1 1 Always true (always folded)
289289 // Don't care operations: undefined if the input is a nan.
292292 SETGT, // 1 X 0 1 0 True if greater than
293293 SETGE, // 1 X 0 1 1 True if greater than or equal
294294 SETLT, // 1 X 1 0 0 True if less than
295 SETLE, // 1 X 1 0 1 True if less than or equal
295 SETLE, // 1 X 1 0 1 True if less than or equal
296296 SETNE, // 1 X 1 1 0 True if not equal
297297 SETTRUE2, // 1 X 1 1 1 Always true (always folded)
298298
384384 /// getValueType - Return the ValueType of the referenced return value.
385385 ///
386386 inline MVT::ValueType getValueType() const;
387
387
388388 // Forwarding methods - These forward to the corresponding methods in SDNode.
389389 inline unsigned getOpcode() const;
390390 inline unsigned getNodeDepth() const;
805805
806806 static bool classof(const MVTSDNode *) { return true; }
807807 static bool classof(const SDNode *N) {
808 return
808 return
809809 N->getOpcode() == ISD::SIGN_EXTEND_INREG ||
810810 N->getOpcode() == ISD::FP_ROUND_INREG ||
811811 N->getOpcode() == ISD::EXTLOAD ||
812 N->getOpcode() == ISD::SEXTLOAD ||
812 N->getOpcode() == ISD::SEXTLOAD ||
813813 N->getOpcode() == ISD::ZEXTLOAD ||
814814 N->getOpcode() == ISD::TRUNCSTORE;
815815 }
818818 class SDNodeIterator : public forward_iterator {
819819 SDNode *Node;
820820 unsigned Operand;
821
821
822822 SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
823823 public:
824824 bool operator==(const SDNodeIterator& x) const {
831831 Operand = I.Operand;
832832 return *this;
833833 }
834
834
835835 pointer operator*() const {
836836 return Node->getOperand(Operand).Val;
837837 }
838838 pointer operator->() const { return operator*(); }
839
839
840840 SDNodeIterator& operator++() { // Preincrement
841841 ++Operand;
842842 return *this;
843843 }
844844 SDNodeIterator operator++(int) { // Postincrement
845 SDNodeIterator tmp = *this; ++*this; return tmp;
845 SDNodeIterator tmp = *this; ++*this; return tmp;
846846 }
847847
848848 static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
858858 typedef SDNode NodeType;
859859 typedef SDNodeIterator ChildIteratorType;
860860 static inline NodeType *getEntryNode(SDNode *N) { return N; }
861 static inline ChildIteratorType child_begin(NodeType *N) {
861 static inline ChildIteratorType child_begin(NodeType *N) {
862862 return SDNodeIterator::begin(N);
863863 }
864 static inline ChildIteratorType child_end(NodeType *N) {
864 static inline ChildIteratorType child_end(NodeType *N) {
865865 return SDNodeIterator::end(N);
866866 }
867867 };
0 //===-- llvm/CodeGen/ValueSet.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 header is OBSOLETE, do not use it for new code.
2121
2222 class Value;
2323
24 // RAV - Used to print values in a form used by the register allocator.
24 // RAV - Used to print values in a form used by the register allocator.
2525 //
2626 struct RAV { // Register Allocator Value
2727 const Value &V;
0 //===- CodeGen/ValueTypes.h - Low-Level Target independ. types --*- 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 set of low-level target independent types which various
22 *
33 * This file was developed by the LLVM research group and is distributed under
44 * the University of Illinois Open Source License. See LICENSE.TXT for details.
5 *
5 *
66 ******************************************************************************
77 *
88 * Description:
0 //===- Debugger.h - LLVM debugger library interface -------------*- 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 LLVM source-level debugger library interface.
0 //===- InferiorProcess.h - Represent the program being debugged -*- 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 InferiorProcess class, which is used to represent,
5858 static InferiorProcess *create(Module *M,
5959 const std::vector &Arguments,
6060 const char * const *envp);
61
61
6262 // InferiorProcess destructor - Kill the current process. If something
6363 // terrible happens, we throw an exception from the destructor.
6464 virtual ~InferiorProcess() {}
0 //===- ProgramInfo.h - Information about the loaded program -----*- 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 various pieces of information about the currently loaded
6969 public:
7070 SourceFileInfo(const GlobalVariable *Desc, const SourceLanguage &Lang);
7171 ~SourceFileInfo();
72
72
7373 const std::string &getBaseName() const { return BaseName; }
7474 const std::string &getDirectory() const { return Directory; }
7575 unsigned getDebugVersion() const { return Version; }
148148 /// with the program, through the getSourceFileFromDesc method. If ALL of
149149 /// the source files are needed, the getSourceFiles() method scans the
150150 /// entire program looking for them.
151 ///
151 ///
152152 std::multimap SourceFileIndex;
153153
154154 /// SourceFunctions - This map contains entries functions in the source
162162 /// effectively a small map from the languages that are active in the
163163 /// program to their caches. This can be accessed by the language by the
164164 /// "getLanguageCache" method.
165 std::vector
165 std::vector
166166 SourceLanguageCache*> > LanguageCaches;
167167 public:
168168 ProgramInfo(Module *m);
171171 /// getProgramTimeStamp - Return the time-stamp of the program when it was
172172 /// loaded.
173173 sys::TimeValue getProgramTimeStamp() const { return ProgramTimeStamp; }
174
174
175175 //===------------------------------------------------------------------===//
176176 // Interfaces to the source code files that make up the program.
177177 //
0 //===- RuntimeInfo.h - Information about running program --------*- 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 classes that capture various pieces of information about
4141 const SourceFileInfo *SourceInfo;
4242 public:
4343 StackFrame(RuntimeInfo &RI, void *ParentFrameID);
44
44
4545 StackFrame &operator=(const StackFrame &RHS) {
4646 FrameID = RHS.FrameID;
4747 FunctionDesc = RHS.FunctionDesc;
7979 /// CallStack - This caches information about the current stack trace of the
8080 /// program. This is lazily computed as needed.
8181 std::vector CallStack;
82
82
8383 /// CurrentFrame - The user can traverse the stack frame with the
8484 /// up/down/frame family of commands. This index indicates the current
8585 /// stack frame.
0 //===- SourceFile.h - Class to represent a source code 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 the SourceFile class which is used to represent a single
5959 /// getDescriptor - Return the debugging decriptor for this source file.
6060 ///
6161 const GlobalVariable *getDescriptor() const { return Descriptor; }
62
62
6363 /// getFilename - Return the fully resolved path that this file was loaded
6464 /// from.
6565 const std::string &getFilename() const { return Filename.toString(); }
66
66
6767 /// getSourceLine - Given a line number, return the start and end of the
6868 /// line in the file. If the line number is invalid, or if the file could
6969 /// not be loaded, null pointers are returned for the start and end of the
7171 /// any newlines from the end of the line, to ease formatting of the text.
7272 void getSourceLine(unsigned LineNo, const char *&LineStart,
7373 const char *&LineEnd) const;
74
74
7575 /// getNumLines - Return the number of lines the source file contains.
7676 ///
7777 unsigned getNumLines() const {
8383 /// readFile - Load Filename into memory
8484 ///
8585 void readFile();
86
86
8787 /// calculateLineOffsets - Compute the LineOffset vector for the current
8888 /// file.
8989 void calculateLineOffsets() const;
0 //===- SourceLanguage.h - Interact with source languages --------*- 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 abstract SourceLanguage interface, which is used by the
0 //===- ExecutionEngine.h - Abstract Execution Engine Interface --*- 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 abstract interface that implements execution support
5656 ExecutionEngine(ModuleProvider *P);
5757 ExecutionEngine(Module *M);
5858 virtual ~ExecutionEngine();
59
59
6060 Module &getModule() const { return CurMod; }
6161 const TargetData &getTargetData() const { return *TD; }
6262
0 //===-- GenericValue.h - Represent any type of LLVM value -------*- 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 //===----------------------------------------------------------------------===//
8 //
8 //
99 // The GenericValue class is used to represent an LLVM value of arbitrary type.
1010 //
1111 //===----------------------------------------------------------------------===//