llvm.org GIT mirror llvm / a99be51
Here is the bulk of the sanitizing. Almost all occurrences of "bytecode" in the sources have been eliminated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37913 91177308-0d34-0410-b5e6-96231b3b80d8 Gabor Greif 12 years ago
49 changed file(s) with 199 addition(s) and 199 deletion(s). Raw diff Collapse all Expand all
77 //===----------------------------------------------------------------------===//
88 //
99 // This programs is a simple example that creates an LLVM module "from scratch",
10 // emitting it as a bytecode file to standard out. This is just to show how
10 // emitting it as a bitcode file to standard out. This is just to show how
1111 // LLVM projects work and to demonstrate some of the LLVM APIs.
1212 //
1313 //===----------------------------------------------------------------------===//
5151 // Create the return instruction and add it to the basic block
5252 BB->getInstList().push_back(new ReturnInst(Add));
5353
54 // Output the bytecode file to stdout
54 // Output the bitcode file to stdout
5555 WriteBitcodeToFile(M, std::cout);
5656
5757 // Delete the module and all of its contents.
4040 ///
4141 /// Classes must implement this interface so that they may be notified when an
4242 /// abstract type is resolved. Abstract types may be resolved into more
43 /// concrete types through: linking, parsing, and bytecode reading. When this
43 /// concrete types through: linking, parsing, and bitcode reading. When this
4444 /// happens, all of the users of the type must be updated to reference the new,
4545 /// more concrete type. They are notified through the AbstractTypeUser
4646 /// interface.
77 //===----------------------------------------------------------------------===//
88 //
99 // This class implements an iterator to walk through the constants referenced by
10 // a method. This is used by the Bytecode & Assembly writers to build constant
10 // a method. This is used by the Bitcode & Assembly writers to build constant
1111 // pools.
1212 //
1313 //===----------------------------------------------------------------------===//
1313 //
1414 //===----------------------------------------------------------------------===//
1515
16 #ifndef LLVM_BITECODE_ARCHIVE_H
17 #define LLVM_BITECODE_ARCHIVE_H
16 #ifndef LLVM_BITCODE_ARCHIVE_H
17 #define LLVM_BITCODE_ARCHIVE_H
1818
1919 #include "llvm/ADT/ilist"
2020 #include "llvm/System/Path.h"
376376 /// @brief Get the offset to the first "real" file member in the archive.
377377 unsigned getFirstFileOffset() { return firstFileOffset; }
378378
379 /// This method will scan the archive for bytecode modules, interpret them
379 /// This method will scan the archive for bitcode modules, interpret them
380380 /// and return a vector of the instantiated modules in \p Modules. If an
381381 /// error occurs, this method will return true. If \p ErrMessage is not null
382382 /// and an error occurs, \p *ErrMessage will be set to a string explaining
383383 /// the error that occurred.
384384 /// @returns true if an error occurred
385 /// @brief Instantiate all the bytecode modules located in the archive
385 /// @brief Instantiate all the bitcode modules located in the archive
386386 bool getAllModules(std::vector& Modules, std::string* ErrMessage);
387387
388388 /// This accessor looks up the \p symbol in the archive's symbol table and
417417 );
418418
419419 /// This method determines whether the archive is a properly formed llvm
420 /// bytecode archive. It first makes sure the symbol table has been loaded
420 /// bitcode archive. It first makes sure the symbol table has been loaded
421421 /// and has a non-zero size. If it does, then it is an archive. If not,
422 /// then it tries to load all the bytecode modules of the archive. Finally,
422 /// then it tries to load all the bitcode modules of the archive. Finally,
423423 /// it returns whether it was successfull.
424 /// @returns true if the archive is a proper llvm bytecode archive
425 /// @brief Determine whether the archive is a proper llvm bytecode archive.
426 bool isBytecodeArchive();
424 /// @returns true if the archive is a proper llvm bitcode archive
425 /// @brief Determine whether the archive is a proper llvm bitcode archive.
426 bool isBitcodeArchive();
427427
428428 /// @}
429429 /// @name Mutators
432432 /// This method is the only way to get the archive written to disk. It
433433 /// creates or overwrites the file specified when \p this was created
434434 /// or opened. The arguments provide options for writing the archive. If
435 /// \p CreateSymbolTable is true, the archive is scanned for bytecode files
435 /// \p CreateSymbolTable is true, the archive is scanned for bitcode files
436436 /// and a symbol table of the externally visible function and global
437437 /// variable names is created. If \p TruncateNames is true, the names of the
438438 /// archive members will have their path component stripped and the file
524524 /// @brief Frees all the members and unmaps the archive file.
525525 void cleanUpMemory();
526526
527 /// This type is used to keep track of bytecode modules loaded from the
527 /// This type is used to keep track of bitcode modules loaded from the
528528 /// symbol table. It maps the file offset to a pair that consists of the
529529 /// associated ArchiveMember and the ModuleProvider.
530530 /// @brief Module mapping type
107107 void setLinkage(LinkageTypes LT) { Linkage = LT; }
108108 LinkageTypes getLinkage() const { return Linkage; }
109109
110 /// hasNotBeenReadFromBytecode - If a module provider is being used to lazily
110 /// hasNotBeenReadFromBitcode - If a module provider is being used to lazily
111111 /// stream in functions from disk, this method can be used to check to see if
112112 /// the function has been read in yet or not. Unless you are working on the
113113 /// JIT or something else that streams stuff in lazily, you don't need to
114114 /// worry about this.
115 bool hasNotBeenReadFromBytecode() const { return Linkage == GhostLinkage; }
115 bool hasNotBeenReadFromBitcode() const { return Linkage == GhostLinkage; }
116116
117117 /// Override from Constant class. No GlobalValue's are null values so this
118118 /// always returns false.
2727 /// In this case the Linker still retains ownership of the Module. If the
2828 /// releaseModule() method is used, the ownership of the Module is transferred
2929 /// to the caller and the Linker object is only suitable for destruction.
30 /// The Linker can link Modules from memory, bytecode files, or bytecode
30 /// The Linker can link Modules from memory, bitcode files, or bitcode
3131 /// archives. It retains a set of search paths in which to find any libraries
3232 /// presented to it. By default, the linker will generate error and warning
3333 /// messages to std::cerr but this capability can be turned off with the
161161 ItemList& NativeItems ///< Output list of native files/libs
162162 );
163163
164 /// This function links the bytecode \p Files into the composite module.
164 /// This function links the bitcode \p Files into the composite module.
165165 /// Note that this does not do any linking of unresolved symbols. The \p
166166 /// Files are all completely linked into \p HeadModule regardless of
167 /// unresolved symbols. This function just loads each bytecode file and
167 /// unresolved symbols. This function just loads each bitcode file and
168168 /// calls LinkInModule on them.
169169 /// @returns true if an error occurs, false otherwise
170170 /// @see getLastError
173173 const std::vector & Files ///< Files to link in
174174 );
175175
176 /// This function links a single bytecode file, \p File, into the composite
176 /// This function links a single bitcode file, \p File, into the composite
177177 /// module. Note that this does not attempt to resolve symbols. This method
178 /// just loads the bytecode file and calls LinkInModule on it. If an error
178 /// just loads the bitcode file and calls LinkInModule on it. If an error
179179 /// occurs, the Linker's error string is set.
180180 /// @returns true if an error occurs, false otherwise
181181 /// @see getLastError
215215 bool& is_native ///< Indicates if lib a native library
216216 );
217217
218 /// This function links one bytecode archive, \p Filename, into the module.
218 /// This function links one bitcode archive, \p Filename, into the module.
219219 /// The archive is searched to resolve outstanding symbols. Any modules in
220220 /// the archive that resolve outstanding symbols will be linked in. The
221221 /// library is searched repeatedly until no more modules that resolve
270270 /// @name Implementation
271271 /// @{
272272 private:
273 /// Read in and parse the bytecode file named by FN and return the
273 /// Read in and parse the bitcode file named by FN and return the
274274 /// Module it contains (wrapped in an auto_ptr), or 0 if an error occurs.
275275 std::auto_ptr LoadObject(const sys::Path& FN);
276276
2020
2121 /// Determine if the ostream provided is connected to the std::cout and
2222 /// displayed or not (to a console window). If so, generate a warning message
23 /// advising against display of bytecode and return true. Otherwise just return
23 /// advising against display of bitcode and return true. Otherwise just return
2424 /// false
2525 /// @brief Check for output written to a console
26 bool CheckBytecodeOutputToConsole(
26 bool CheckBitcodeOutputToConsole(
2727 std::ostream* stream_to_check, ///< The stream to be checked
2828 bool print_warning = true ///< Control whether warnings are printed
2929 );
111111 /// @brief Construct a path to the system library directory
112112 static void GetSystemLibraryPaths(std::vector& Paths);
113113
114 /// Construct a vector of sys::Path that contains the "standard" bytecode
114 /// Construct a vector of sys::Path that contains the "standard" bitcode
115115 /// library paths suitable for linking into an llvm program. This function
116116 /// *must* return the value of LLVM_LIB_SEARCH_PATH as well as the value
117117 /// of LLVM_LIBDIR. It also must provide the System library paths as
118118 /// returned by GetSystemLibraryPaths.
119119 /// @see GetSystemLibraryPaths
120 /// @brief Construct a list of directories in which bytecode could be
120 /// @brief Construct a list of directories in which bitcode could be
121121 /// found.
122 static void GetBytecodeLibraryPaths(std::vector& Paths);
122 static void GetBitcodeLibraryPaths(std::vector& Paths);
123123
124124 /// Find the path to a library using its short name. Use the system
125125 /// dependent library paths to locate the library.
5151 ///
5252 /// Opaque types are also kinda weird and scary and different because they have
5353 /// to keep a list of uses of the type. When, through linking, parsing, or
54 /// bytecode reading, they become resolved, they need to find and update all
54 /// bitcode reading, they become resolved, they need to find and update all
5555 /// users of the unknown type, causing them to reference a new, more concrete
5656 /// type. Opaque types are deleted when their use list dwindles to zero users.
5757 ///
7676 IntegerTyID, ///< 4: Arbitrary bit width integers
7777 FunctionTyID, ///< 5: Functions
7878 StructTyID, ///< 6: Structures
79 PackedStructTyID,///< 7: Packed Structure. This is for bytecode only
79 PackedStructTyID,///< 7: Packed Structure. This is for bitcode only
8080 ArrayTyID, ///< 8: Arrays
8181 PointerTyID, ///< 9: Pointers
8282 OpaqueTyID, ///< 10: Opaque: type with unknown structure
209209 symbols.push_back(FI->getName());
210210 }
211211
212 // Get just the externally visible defined symbols from the bytecode
213 bool llvm::GetBytecodeSymbols(const sys::Path& fName,
214 std::vector& symbols,
215 std::string* ErrMsg) {
212 // Get just the externally visible defined symbols from the bitcode
213 bool llvm::GetBitcodeSymbols(const sys::Path& fName,
214 std::vector& symbols,
215 std::string* ErrMsg) {
216216 std::auto_ptr Buffer(
217217 MemoryBuffer::getFileOrSTDIN(&fName.toString()[0],
218218 fName.toString().size()));
241241 }
242242
243243 ModuleProvider*
244 llvm::GetBytecodeSymbols(const unsigned char *BufPtr, unsigned Length,
245 const std::string& ModuleID,
246 std::vector& symbols,
247 std::string* ErrMsg) {
244 llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
245 const std::string& ModuleID,
246 std::vector& symbols,
247 std::string* ErrMsg) {
248248 // Get the module provider
249249 MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(Length, ModuleID.c_str());
250250 memcpy((char*)Buffer->getBufferStart(), BufPtr, Length);
None //===-- lib/Bytecode/ArchiveInternals.h -------------------------*- C++ -*-===//
0 //===-- lib/Archive/ArchiveInternals.h -------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #ifndef LIB_BYTECODE_ARCHIVEINTERNALS_H
14 #define LIB_BYTECODE_ARCHIVEINTERNALS_H
13 #ifndef LIB_ARCHIVE_ARCHIVEINTERNALS_H
14 #define LIB_ARCHIVE_ARCHIVEINTERNALS_H
1515
1616 #include "llvm/Bitcode/Archive.h"
1717 #include "llvm/System/TimeValue.h"
2828
2929 namespace llvm {
3030
31 /// The ArchiveMemberHeader structure is used internally for bytecode
31 /// The ArchiveMemberHeader structure is used internally for bitcode
3232 /// archives.
3333 /// The header precedes each file member in the archive. This structure is
3434 /// defined using character arrays for direct and correct interpretation
6666 }
6767 };
6868
69 // Get just the externally visible defined symbols from the bytecode
70 bool GetBytecodeSymbols(const sys::Path& fName,
69 // Get just the externally visible defined symbols from the bitcode
70 bool GetBitcodeSymbols(const sys::Path& fName,
7171 std::vector& symbols,
7272 std::string* ErrMsg);
7373
74 ModuleProvider* GetBytecodeSymbols(const unsigned char*Buffer,unsigned Length,
75 const std::string& ModuleID,
76 std::vector& symbols,
77 std::string* ErrMsg);
74 ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
75 const std::string& ModuleID,
76 std::vector& symbols,
77 std::string* ErrMsg);
7878 }
7979
8080 #endif
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // Builds up standard unix archive files (.a) containing LLVM bytecode.
9 // Builds up standard unix archive files (.a) containing LLVM bitcode.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
108108 // it will accept them. If the name starts with #1/ and the remainder is
109109 // digits, then those digits specify the length of the name that is
110110 // stored immediately following the header. The special name
111 // __LLVM_SYM_TAB__ identifies the symbol table for LLVM bytecode.
111 // __LLVM_SYM_TAB__ identifies the symbol table for LLVM bitcode.
112112 // Anything else is a regular, short filename that is terminated with
113113 // a '/' and blanks.
114114
343343 return result.release();
344344 }
345345
346 // Get all the bytecode modules from the archive
346 // Get all the bitcode modules from the archive
347347 bool
348348 Archive::getAllModules(std::vector& Modules, std::string* ErrMessage) {
349349
486486 if (!mbr)
487487 return 0;
488488
489 // Now, load the bytecode module to get the ModuleProvider
489 // Now, load the bitcode module to get the ModuleProvider
490490 std::string FullMemberName = archPath.toString() + "(" +
491491 mbr->getPath().toString() + ")";
492492 MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(),
540540 std::string FullMemberName = archPath.toString() + "(" +
541541 mbr->getPath().toString() + ")";
542542 ModuleProvider* MP =
543 GetBytecodeSymbols((const unsigned char*)At, mbr->getSize(),
544 FullMemberName, symbols, error);
543 GetBitcodeSymbols((const unsigned char*)At, mbr->getSize(),
544 FullMemberName, symbols, error);
545545
546546 if (MP) {
547547 // Insert the module's symbols into the symbol table
554554 modules.insert(std::make_pair(offset, std::make_pair(MP, mbr)));
555555 } else {
556556 if (error)
557 *error = "Can't parse bytecode member: " +
557 *error = "Can't parse bitcode member: " +
558558 mbr->getPath().toString() + ": " + *error;
559559 delete mbr;
560560 return false;
590590 return true;
591591 }
592592
593 bool Archive::isBytecodeArchive() {
593 bool Archive::isBitcodeArchive() {
594594 // Make sure the symTab has been loaded. In most cases this should have been
595595 // done when the archive was constructed, but still, this is just in case.
596596 if (!symTab.size())
601601 // if it has a size
602602 if (symTab.size()) return true;
603603
604 //We still can't be sure it isn't a bytecode archive
604 // We still can't be sure it isn't a bitcode archive
605605 if (!loadArchive(0))
606606 return false;
607607
608608 std::vector Modules;
609609 std::string ErrorMessage;
610610
611 // Scan the archive, trying to load a bytecode member. We only load one to
611 // Scan the archive, trying to load a bitcode member. We only load one to
612612 // see if this works.
613613 for (iterator I = begin(), E = end(); I != E; ++I) {
614614 if (!I->isBytecode() && !I->isCompressedBytecode())
623623 Module *M = ParseBitcodeFile(Buffer);
624624 delete Buffer;
625625 if (!M)
626 return false; // Couldn't parse bytecode, not a bytecode archive.
626 return false; // Couldn't parse bitcode, not a bitcode archive.
627627 delete M;
628628 return true;
629629 }
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // Builds up an LLVM archive file (.a) containing LLVM bytecode.
9 // Builds up an LLVM archive file (.a) containing LLVM bitcode.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
221221 }
222222
223223 // Now that we have the data in memory, update the
224 // symbol table if its a bytecode file.
224 // symbol table if its a bitcode file.
225225 if (CreateSymbolTable &&
226226 (member.isBytecode() || member.isCompressedBytecode())) {
227227 std::vector symbols;
229229 member.getPath().toString()
230230 + ")";
231231 ModuleProvider* MP =
232 GetBytecodeSymbols((const unsigned char*)data,fSize,
233 FullMemberName, symbols, ErrMsg);
234
235 // If the bytecode parsed successfully
232 GetBitcodeSymbols((const unsigned char*)data,fSize,
233 FullMemberName, symbols, ErrMsg);
234
235 // If the bitcode parsed successfully
236236 if ( MP ) {
237237 for (std::vector::iterator SI = symbols.begin(),
238238 SE = symbols.end(); SI != SE; ++SI) {
254254 delete mFile;
255255 }
256256 if (ErrMsg)
257 *ErrMsg = "Can't parse bytecode member: " + member.getPath().toString()
257 *ErrMsg = "Can't parse bitcode member: " + member.getPath().toString()
258258 + ": " + *ErrMsg;
259259 return true;
260260 }
15631563
15641564 bool BitcodeReader::materializeFunction(Function *F, std::string *ErrInfo) {
15651565 // If it already is material, ignore the request.
1566 if (!F->hasNotBeenReadFromBytecode()) return false;
1566 if (!F->hasNotBeenReadFromBitcode()) return false;
15671567
15681568 DenseMap >::iterator DFII =
15691569 DeferredFunctionInfo.find(F);
15841584
15851585 void BitcodeReader::dematerializeFunction(Function *F) {
15861586 // If this function isn't materialized, or if it is a proto, this is a noop.
1587 if (F->hasNotBeenReadFromBytecode() || F->isDeclaration())
1587 if (F->hasNotBeenReadFromBitcode() || F->isDeclaration())
15881588 return;
15891589
15901590 assert(DeferredFunctionInfo.count(F) && "No info to read function later?");
16001600 DeferredFunctionInfo.begin(), E = DeferredFunctionInfo.end(); I != E;
16011601 ++I) {
16021602 Function *F = I->first;
1603 if (F->hasNotBeenReadFromBytecode() &&
1603 if (F->hasNotBeenReadFromBitcode() &&
16041604 materializeFunction(F, ErrInfo))
16051605 return 0;
16061606 }
8989
9090 private:
9191 // The buffer we accumulate the file header into. Note that this should be
92 // changed into something much more efficient later (and the bytecode writer
92 // changed into something much more efficient later (and the bitcode writer
9393 // as well!).
9494 DataBuffer FileHeader;
9595
77 //===----------------------------------------------------------------------===//
88 //
99 // This tool implements a just-in-time compiler for LLVM, allowing direct
10 // execution of LLVM bytecode in an efficient manner.
10 // execution of LLVM bitcode in an efficient manner.
1111 //
1212 //===----------------------------------------------------------------------===//
1313
257257 return Addr; // Check if function already code gen'd
258258
259259 // Make sure we read in the function if it exists in this Module.
260 if (F->hasNotBeenReadFromBytecode()) {
260 if (F->hasNotBeenReadFromBitcode()) {
261261 // Determine the module provider this function is provided by.
262262 Module *M = F->getParent();
263263 ModuleProvider *MP = 0;
272272 std::string ErrorMsg;
273273 if (MP->materializeFunction(F, &ErrorMsg)) {
274274 cerr << "Error reading function '" << F->getName()
275 << "' from bytecode file: " << ErrorMsg << "\n";
275 << "' from bitcode file: " << ErrorMsg << "\n";
276276 abort();
277277 }
278278 }
542542 // Call the lazy resolver function unless we already KNOW it is an external
543543 // function, in which case we just skip the lazy resolution step.
544544 void *Actual = (void*)(intptr_t)LazyResolverFn;
545 if (F->isDeclaration() && !F->hasNotBeenReadFromBytecode())
545 if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode())
546546 Actual = TheJIT->getPointerToFunction(F);
547547
548548 // Otherwise, codegen a new stub. For now, the stub will call the lazy
761761 void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);
762762 if (ResultPtr) return ResultPtr;
763763
764 if (F->isDeclaration() && !F->hasNotBeenReadFromBytecode()) {
764 if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) {
765765 // If this is an external function pointer, we can force the JIT to
766766 // 'compile' it, which really just adds it to the map.
767767 if (DoesntNeedStub)
116116 if (!arch)
117117 return error("Cannot read archive '" + Filename.toString() +
118118 "': " + ErrMsg);
119 if (!arch->isBytecodeArchive()) {
119 if (!arch->isBitcodeArchive()) {
120120 is_native = true;
121121 return false;
122122 }
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file contains routines to handle linking together LLVM bytecode files,
9 // This file contains routines to handle linking together LLVM bitcode files,
1010 // and to handle annoying things like static libraries.
1111 //
1212 //===----------------------------------------------------------------------===//
1919 // LinkItems - This function is the main entry point into linking. It takes a
2020 // list of LinkItem which indicates the order the files should be linked and
2121 // how each file should be treated (plain file or with library search). The
22 // function only links bytecode and produces a result list of items that are
22 // function only links bitcode and produces a result list of items that are
2323 // native objects.
2424 bool
2525 Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) {
108108 }
109109
110110 /// LinkLibraries - takes the specified library files and links them into the
111 /// main bytecode object file.
111 /// main bitcode object file.
112112 ///
113113 /// Inputs:
114114 /// Libraries - The list of libraries to link into the module.
139139 return false;
140140 }
141141
142 /// LinkInFile - opens a bytecode file and links in all objects which
142 /// LinkInFile - opens a bitcode file and links in all objects which
143143 /// provide symbols that are currently undefined.
144144 ///
145145 /// Inputs:
146 /// File - The pathname of the bytecode file.
146 /// File - The pathname of the bitcode file.
147147 ///
148148 /// Outputs:
149149 /// ErrorMessage - A C++ string detailing what error occurred, if any.
178178 case sys::Bitcode_FileType:
179179 case sys::Bytecode_FileType:
180180 case sys::CompressedBytecode_FileType: {
181 verbose("Linking bytecode file '" + File.toString() + "'");
181 verbose("Linking bitcode file '" + File.toString() + "'");
182182 std::auto_ptr M(LoadObject(File));
183183 if (M.get() == 0)
184184 return error("Cannot load file '" + File.toString() + "'" + Error);
207207 /// or relative pathname, or as a file somewhere in LLVM_LIB_SEARCH_PATH.
208208 ///
209209 /// Inputs:
210 /// Files - A vector of sys::Path indicating the LLVM bytecode filenames
210 /// Files - A vector of sys::Path indicating the LLVM bitcode filenames
211211 /// to be linked. The names can refer to a mixture of pure LLVM
212 /// bytecode files and archive (ar) formatted files.
212 /// bitcode files and archive (ar) formatted files.
213213 ///
214214 /// Return value:
215215 /// FALSE - No errors.
7979
8080 void
8181 Linker::addSystemPaths() {
82 sys::Path::GetBytecodeLibraryPaths(LibPaths);
82 sys::Path::GetBitcodeLibraryPaths(LibPaths);
8383 LibPaths.insert(LibPaths.begin(),sys::Path("./"));
8484 }
8585
9393 return result;
9494 }
9595
96 // LoadObject - Read in and parse the bytecode file named by FN and return the
96 // LoadObject - Read in and parse the bitcode file named by FN and return the
9797 // module it contains (wrapped in an auto_ptr), or auto_ptr() and set
9898 // Error if an error occurs.
9999 std::auto_ptr
111111
112112 if (Result)
113113 return std::auto_ptr(Result);
114 Error = "Bytecode file '" + FN.toString() + "' could not be loaded";
114 Error = "Bitcode file '" + FN.toString() + "' could not be loaded";
115115 if (ParseErrorMessage.size())
116116 Error += ": " + ParseErrorMessage;
117117 return std::auto_ptr();
1818 #include
1919 using namespace llvm;
2020
21 bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check,
22 bool print_warning) {
21 bool llvm::CheckBitcodeOutputToConsole(std::ostream* stream_to_check,
22 bool print_warning) {
2323 if (stream_to_check == cout.stream() &&
2424 sys::Process::StandardOutIsDisplayed()) {
2525 if (print_warning) {
26 cerr << "WARNING: You're attempting to print out a bytecode file.\n"
26 cerr << "WARNING: You're attempting to print out a bitcode file.\n"
2727 << "This is inadvisable as it may cause display problems. If\n"
28 << "you REALLY want to taste LLVM bytecode first-hand, you\n"
28 << "you REALLY want to taste LLVM bitcode first-hand, you\n"
2929 << "can force output with the `-f' option.\n\n";
3030 }
3131 return true;
217217 }
218218
219219 void
220 Path::GetBytecodeLibraryPaths(std::vector& Paths) {
220 Path::GetBitcodeLibraryPaths(std::vector& Paths) {
221221 char * env_var = getenv("LLVM_LIB_SEARCH_PATH");
222222 if (env_var != 0) {
223223 getPathList(env_var,Paths);
823823 static bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) {
824824 return RelocM != Reloc::Static &&
825825 (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
826 (GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode()));
826 (GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode()));
827827 }
828828
829829 SDOperand ARMTargetLowering::LowerGlobalAddressDarwin(SDOperand Op,
77 //===----------------------------------------------------------------------===//
88 //
99 // This file defines the PowerPC 32-bit CodeEmitter and associated machinery to
10 // JIT-compile bytecode to native PowerPC.
10 // JIT-compile bitcode to native PowerPC.
1111 //
1212 //===----------------------------------------------------------------------===//
1313
136136 return false;
137137
138138 return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
139 (GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode());
139 (GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode());
140140 }
3939 if (isTargetDarwin()) {
4040 return (!isDirectCall &&
4141 (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
42 (GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode())));
42 (GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode())));
4343 } else if (TM.getRelocationModel() == Reloc::PIC_ && isPICStyleGOT()) {
4444 // Extra load is needed for all non-statics.
4545 return (!isDirectCall &&
10361036 bool FunctionPassManager::run(Function &F) {
10371037 std::string errstr;
10381038 if (MP->materializeFunction(&F, &errstr)) {
1039 cerr << "Error reading bytecode file: " << errstr << "\n";
1039 cerr << "Error reading bitcode file: " << errstr << "\n";
10401040 abort();
10411041 }
10421042 return FPM->run(F);
88 //
99 // This is the llc code generator driver. It provides a convenient
1010 // command-line interface for generating native assembly-language code
11 // or C code, given LLVM bytecode.
11 // or C code, given LLVM bitcode.
1212 //
1313 //===----------------------------------------------------------------------===//
1414
4343 // and back-end code generation options are specified with the target machine.
4444 //
4545 static cl::opt
46 InputFilename(cl::Positional, cl::desc("ytecode>"), cl::init("-"));
46 InputFilename(cl::Positional, cl::desc("itcode>"), cl::init("-"));
4747
4848 static cl::opt
4949 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
183183 if (Buffer.get())
184184 M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
185185 if (M.get() == 0) {
186 std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
186 std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
187187 std::cerr << "Reason: " << ErrorMessage << "\n";
188188 return 1;
189189 }
3232
3333 namespace {
3434 cl::opt
35 InputFile(cl::desc("ytecode>"), cl::Positional, cl::init("-"));
35 InputFile(cl::desc("itcode>"), cl::Positional, cl::init("-"));
3636
3737 cl::list
3838 InputArgv(cl::ConsumeAfter, cl::desc("..."));
7373 if (DisableCoreFiles)
7474 sys::Process::PreventCoreFiles();
7575
76 // Load the bytecode...
76 // Load the bitcode...
7777 std::string ErrorMsg;
7878 ModuleProvider *MP = 0;
7979 if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
77 //===----------------------------------------------------------------------===//
88 //
99 // Builds up (relatively) standard unix archive files (.a) containing LLVM
10 // bytecode or other files.
10 // bitcode or other files.
1111 //
1212 //===----------------------------------------------------------------------===//
1313
5353 " [b] - put file(s) before [relpos] (same as [i])\n"
5454 " [f] - truncate inserted file names\n"
5555 " [i] - put file(s) before [relpos] (same as [b])\n"
56 " [k] - always print bytecode files (default is to skip them)\n"
56 " [k] - always print bitcode files (default is to skip them)\n"
5757 " [N] - use instance [count] of name\n"
5858 " [o] - preserve original dates\n"
5959 " [P] - use full path names when matching\n"
8787 bool Create = false; ///< 'c' modifier
8888 bool TruncateNames = false; ///< 'f' modifier
8989 bool InsertBefore = false; ///< 'i' modifier
90 bool DontSkipBytecode = false; ///< 'k' modifier
90 bool DontSkipBitcode = false; ///< 'k' modifier
9191 bool UseCount = false; ///< 'N' modifier
9292 bool OriginalDates = false; ///< 'o' modifier
9393 bool FullPath = false; ///< 'P' modifier
192192 case 'x': ++NumOperations; Operation = Extract; break;
193193 case 'c': Create = true; break;
194194 case 'f': TruncateNames = true; break;
195 case 'k': DontSkipBytecode = true; break;
195 case 'k': DontSkipBitcode = true; break;
196196 case 'l': /* accepted but unused */ break;
197197 case 'o': OriginalDates = true; break;
198198 case 'P': FullPath = true; break;
340340
341341 // doPrint - Implements the 'p' operation. This function traverses the archive
342342 // looking for members that match the path list. It is careful to uncompress
343 // things that should be and to skip bytecode files unless the 'k' modifier was
343 // things that should be and to skip bitcode files unless the 'k' modifier was
344344 // given.
345345 bool doPrint(std::string* ErrMsg) {
346346 if (buildPaths(false, ErrMsg))
355355
356356 // Skip things that don't make sense to print
357357 if (I->isLLVMSymbolTable() || I->isSVR4SymbolTable() ||
358 I->isBSD4SymbolTable() || (!DontSkipBytecode &&
358 I->isBSD4SymbolTable() || (!DontSkipBitcode &&
359359 (I->isBytecode() || I->isCompressedBytecode())))
360360 continue;
361361
693693 // like --help and --version.
694694 cl::ParseCommandLineOptions(argc, argv,
695695 " LLVM Archiver (llvm-ar)\n\n"
696 " This program archives bytecode files into single libraries\n"
696 " This program archives bitcode files into single libraries\n"
697697 );
698698
699699 // Print a stack trace if we signal out.
124124 return 1;
125125 }
126126
127 if (Force || !CheckBytecodeOutputToConsole(Out,true))
127 if (Force || !CheckBitcodeOutputToConsole(Out,true))
128128 WriteBitcodeToFile(M.get(), *Out);
129129 } catch (const std::string& msg) {
130130 cerr << argv[0] << ": " << msg << "\n";
218218
219219
220220 /// file command - If the user specifies an option, search the PATH for the
221 /// specified program/bytecode file and load it. If the user does not specify
221 /// specified program/bitcode file and load it. If the user does not specify
222222 /// an option, unload the current program.
223223 void CLIDebugger::fileCommand(std::string &Options) {
224224 std::string Prog = getToken(Options);
77 //===----------------------------------------------------------------------===//
88 //
99 // This utility may be invoked in the following manner:
10 // llvm-dis [options] - Read LLVM bytecode from stdin, write asm to stdout
11 // llvm-dis [options] x.bc - Read LLVM bytecode from the x.bc file, write asm
10 // llvm-dis [options] - Read LLVM bitcode from stdin, write asm to stdout
11 // llvm-dis [options] x.bc - Read LLVM bitcode from the x.bc file, write asm
1212 // to the x.ll file.
1313 // Options:
1414 // --help - Output information about command line switches
3030 using namespace llvm;
3131
3232 static cl::opt
33 InputFilename(cl::Positional, cl::desc("ytecode>"), cl::init("-"));
33 InputFilename(cl::Positional, cl::desc("itcode>"), cl::init("-"));
3434
3535 static cl::opt
3636 OutputFilename("o", cl::desc("Override output filename"),
6464 if (ErrorMessage.size())
6565 cerr << ErrorMessage << "\n";
6666 else
67 cerr << "bytecode didn't read correctly.\n";
67 cerr << "bitcode didn't read correctly.\n";
6868 return 1;
6969 }
7070
2727
2828 // InputFilename - The filename to read from.
2929 static cl::opt
30 InputFilename(cl::Positional, cl::desc("ytecode file>"),
30 InputFilename(cl::Positional, cl::desc("itcode file>"),
3131 cl::init("-"), cl::value_desc("filename"));
3232
3333 static cl::opt
6666 delete Buffer;
6767
6868 if (M.get() == 0) {
69 cerr << argv[0] << ": bytecode didn't read correctly.\n";
69 cerr << argv[0] << ": bitcode didn't read correctly.\n";
7070 return 1;
7171 }
7272
1010 // system 'ld' conventions. As such, the default output file is ./a.out.
1111 // Additionally, this program outputs a shell script that is used to invoke LLI
1212 // to execute the program. In this manner, the generated executable (a.out for
13 // example), is directly executable, whereas the bytecode file actually lives in
13 // example), is directly executable, whereas the bitcode file actually lives in
1414 // the a.out.bc file generated by this program. Also, Force is on by default.
1515 //
1616 // Note that if someone (or a script) deletes the executable program generated,
4141
4242 // Input/Output Options
4343 static cl::list InputFilenames(cl::Positional, cl::OneOrMore,
44 cl::desc("ytecode files>"));
44 cl::desc("itcode files>"));
4545
4646 static cl::opt OutputFilename("o", cl::init("a.out"),
4747 cl::desc("Override output filename"),
202202 return;
203203 }
204204
205 /// GenerateBytecode - generates a bytecode file from the module provided
206 void GenerateBytecode(Module* M, const std::string& FileName) {
205 /// GenerateBitcode - generates a bitcode file from the module provided
206 void GenerateBitcode(Module* M, const std::string& FileName) {
207207
208208 if (Verbose)
209 cout << "Generating Bytecode To " << FileName << '\n';
209 cout << "Generating Bitcode To " << FileName << '\n';
210210
211211 // Create the output file.
212212 std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
215215 if (!Out.good())
216216 PrintAndExit("error opening '" + FileName + "' for writing!");
217217
218 // Ensure that the bytecode file gets removed from the disk if we get a
218 // Ensure that the bitcode file gets removed from the disk if we get a
219219 // terminating signal.
220220 sys::RemoveFileOnSignal(sys::Path(FileName));
221221
222222 // Write it out
223223 WriteBitcodeToFile(M, Out);
224224
225 // Close the bytecode file.
225 // Close the bitcode file.
226226 Out.close();
227227 }
228228
229229 /// GenerateAssembly - generates a native assembly language source file from the
230 /// specified bytecode file.
230 /// specified bitcode file.
231231 ///
232232 /// Inputs:
233 /// InputFilename - The name of the input bytecode file.
233 /// InputFilename - The name of the input bitcode file.
234234 /// OutputFilename - The name of the file to generate.
235235 /// llc - The pathname to use for LLC.
236236 /// envp - The environment to use when running LLC.
241241 const std::string &InputFilename,
242242 const sys::Path &llc,
243243 std::string &ErrMsg ) {
244 // Run LLC to convert the bytecode file into assembly code.
244 // Run LLC to convert the bitcode file into assembly code.
245245 std::vector args;
246246 args.push_back(llc.c_str());
247247 args.push_back("-f");
258258 return sys::Program::ExecuteAndWait(llc, &args[0], 0, 0, 0, 0, &ErrMsg);
259259 }
260260
261 /// GenerateCFile - generates a C source file from the specified bytecode file.
261 /// GenerateCFile - generates a C source file from the specified bitcode file.
262262 static int GenerateCFile(const std::string &OutputFile,
263263 const std::string &InputFile,
264264 const sys::Path &llc,
265265 std::string& ErrMsg) {
266 // Run LLC to convert the bytecode file into C.
266 // Run LLC to convert the bitcode file into C.
267267 std::vector args;
268268 args.push_back(llc.c_str());
269269 args.push_back("-march=c");
282282 }
283283
284284 /// GenerateNative - generates a native object file from the
285 /// specified bytecode file.
285 /// specified bitcode file.
286286 ///
287287 /// Inputs:
288 /// InputFilename - The name of the input bytecode file.
288 /// InputFilename - The name of the input bitcode file.
289289 /// OutputFilename - The name of the file to generate.
290290 /// NativeLinkItems - The native libraries, files, code with which to link
291291 /// LibPaths - The list of directories in which to find libraries.
376376 }
377377
378378 /// EmitShellScript - Output the wrapper file that invokes the JIT on the LLVM
379 /// bytecode file for the program.
379 /// bitcode file for the program.
380380 static void EmitShellScript(char **argv) {
381381 if (Verbose)
382382 cout << "Emitting Shell Script\n";
477477 // Construct a Linker (now that Verbose is set)
478478 Linker TheLinker(progname, OutputFilename, Verbose);
479479
480 // Keep track of the native link items (versus the bytecode items)
480 // Keep track of the native link items (versus the bitcode items)
481481 Linker::ItemList NativeLinkItems;
482482
483483 // Add library paths to the linker
516516 // Optimize the module
517517 Optimize(Composite.get());
518518
519 // Generate the bytecode for the optimized module.
520 std::string RealBytecodeOutput = OutputFilename;
521 if (!LinkAsLibrary) RealBytecodeOutput += ".bc";
522 GenerateBytecode(Composite.get(), RealBytecodeOutput);
519 // Generate the bitcode for the optimized module.
520 std::string RealBitcodeOutput = OutputFilename;
521 if (!LinkAsLibrary) RealBitcodeOutput += ".bc";
522 GenerateBitcode(Composite.get(), RealBitcodeOutput);
523523
524524 // If we are not linking a library, generate either a native executable
525525 // or a JIT shell script, depending upon what the user wants.
544544
545545 const char* args[4];
546546 args[0] = I->c_str();
547 args[1] = RealBytecodeOutput.c_str();
547 args[1] = RealBitcodeOutput.c_str();
548548 args[2] = tmp_output.c_str();
549549 args[3] = 0;
550550 if (0 == sys::Program::ExecuteAndWait(prog, args, 0,0,0,0, &ErrMsg)) {
551 if (tmp_output.isBytecodeFile() || tmp_output.isBitcodeFile()) {
552 sys::Path target(RealBytecodeOutput);
551 if (tmp_output.isBitcodeFile() || tmp_output.isBitcodeFile()) {
552 sys::Path target(RealBitcodeOutput);
553553 target.eraseFromDisk();
554554 if (tmp_output.renamePathOnDisk(target, &ErrMsg))
555555 PrintAndExit(ErrMsg, 2);
556556 } else
557 PrintAndExit("Post-link optimization output is not bytecode");
557 PrintAndExit("Post-link optimization output is not bitcode");
558558 } else {
559559 PrintAndExit(ErrMsg);
560560 }
562562 }
563563
564564 // If the user wants to generate a native executable, compile it from the
565 // bytecode file.
565 // bitcode file.
566566 //
567 // Otherwise, create a script that will run the bytecode through the JIT.
567 // Otherwise, create a script that will run the bitcode through the JIT.
568568 if (Native) {
569569 // Name of the Assembly Language output file
570570 sys::Path AssemblyFile ( OutputFilename);
583583 if (gcc.isEmpty())
584584 PrintAndExit("Failed to find gcc");
585585
586 // Generate an assembly language file for the bytecode.
586 // Generate an assembly language file for the bitcode.
587587 std::string ErrMsg;
588 if (0 != GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput,
588 if (0 != GenerateAssembly(AssemblyFile.toString(), RealBitcodeOutput,
589589 llc, ErrMsg))
590590 PrintAndExit(ErrMsg);
591591
612612 if (gcc.isEmpty())
613613 PrintAndExit("Failed to find gcc");
614614
615 // Generate an assembly language file for the bytecode.
615 // Generate an assembly language file for the bitcode.
616616 std::string ErrMsg;
617617 if (0 != GenerateCFile(
618 CFile.toString(), RealBytecodeOutput, llc, ErrMsg))
618 CFile.toString(), RealBitcodeOutput, llc, ErrMsg))
619619 PrintAndExit(ErrMsg);
620620
621621 if (0 != GenerateNative(OutputFilename, CFile.toString(),
634634 if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg))
635635 PrintAndExit(ErrMsg);
636636
637 // Make the bytecode file readable and directly executable in LLEE as well
638 if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg))
637 // Make the bitcode file readable and directly executable in LLEE as well
638 if (sys::Path(RealBitcodeOutput).makeExecutableOnDisk(&ErrMsg))
639639 PrintAndExit(ErrMsg);
640640
641 if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg))
641 if (sys::Path(RealBitcodeOutput).makeReadableOnDisk(&ErrMsg))
642642 PrintAndExit(ErrMsg);
643643 }
644644 } catch (const std::string& msg) {
2727
2828 static cl::list
2929 InputFilenames(cl::Positional, cl::OneOrMore,
30 cl::desc("ytecode files>"));
30 cl::desc("itcode files>"));
3131
3232 static cl::opt
3333 OutputFilename("o", cl::desc("Override output filename"), cl::init("-"),
4141 static cl::opt
4242 DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);
4343
44 // LoadFile - Read the specified bytecode file in and return it. This routine
44 // LoadFile - Read the specified bitcode file in and return it. This routine
4545 // searches the link path for the specified file to try to find it...
4646 //
4747 static inline std::auto_ptr LoadFile(const std::string &FN) {
6565 if (Result) return std::auto_ptr(Result); // Load successful!
6666
6767 if (Verbose) {
68 cerr << "Error opening bytecode file: '" << Filename.c_str() << "'";
68 cerr << "Error opening bitcode file: '" << Filename.c_str() << "'";
6969 if (ErrorMessage.size()) cerr << ": " << ErrorMessage;
7070 cerr << "\n";
7171 }
7272 } else {
73 cerr << "Bytecode file: '" << Filename.c_str() << "' does not exist.\n";
73 cerr << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
7474 }
7575
7676 return std::auto_ptr();
141141 return 1;
142142 }
143143
144 if (Verbose) cerr << "Writing bytecode...\n";
144 if (Verbose) cerr << "Writing bitcode...\n";
145145 WriteBitcodeToFile(Composite.get(), *Out);
146146
147147 if (Out != &std::cout) delete Out;
77 //===----------------------------------------------------------------------===//
88 //
99 // This program is a utility that works like traditional Unix "nm",
10 // that is, it prints out the names of symbols in a bytecode file,
10 // that is, it prints out the names of symbols in a bitcode file,
1111 // along with some information about each symbol.
1212 //
1313 // This "nm" does not print symbols' addresses. It supports many of
4242 cl::aliasopt(OutputFormat));
4343
4444 cl::list
45 InputFilenames(cl::Positional, cl::desc("ytecode files>"),
45 InputFilenames(cl::Positional, cl::desc("itcode files>"),
4646 cl::ZeroOrMore);
4747
4848 cl::opt UndefinedOnly("undefined-only",
3131
3232 namespace {
3333 cl::opt
34 BytecodeFile(cl::Positional, cl::desc(""),
35 cl::Required);
34 BitcodeFile(cl::Positional, cl::desc(""),
35 cl::Required);
3636
3737 cl::opt
3838 ProfileDataFile(cl::Positional, cl::desc(""),
114114 cl::ParseCommandLineOptions(argc, argv, " llvm profile dump decoder\n");
115115 sys::PrintStackTraceOnErrorSignal();
116116
117 // Read in the bytecode file...
117 // Read in the bitcode file...
118118 std::string ErrorMessage;
119119 Module *M = 0;
120 if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BytecodeFile,
120 if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile,
121121 &ErrorMessage)) {
122122 M = ParseBitcodeFile(Buffer, &ErrorMessage);
123123 delete Buffer;
124124 }
125125 if (M == 0) {
126 std::cerr << argv[0] << ": " << BytecodeFile << ": "
126 std::cerr << argv[0] << ": " << BitcodeFile << ": "
127127 << ErrorMessage << "\n";
128128 return 1;
129129 }
4747 // like --help and --version.
4848 cl::ParseCommandLineOptions(argc, argv,
4949 " LLVM Archive Index Generator (llvm-ranlib)\n\n"
50 " This program adds or updates an index of bytecode symbols\n"
50 " This program adds or updates an index of bitcode symbols\n"
5151 " to an LLVM archive file."
5252 );
5353
3030 using namespace llvm;
3131
3232 static cl::opt
33 InputFilename(cl::Positional, cl::desc("ytecode file>"),
33 InputFilename(cl::Positional, cl::desc("itcode file>"),
3434 cl::init("-"));
3535
3636 static cl::opt
5959 if (ErrorMessage.size())
6060 std::cerr << ErrorMessage << "\n";
6161 else
62 std::cerr << "bytecode didn't read correctly.\n";
62 std::cerr << "bitcode didn't read correctly.\n";
6363 return 1;
6464 }
6565
6464 DumpAction(&cd->Linker);
6565 }
6666
67 static bool GetBytecodeDependentLibraries(const std::string &fname,
68 Module::LibraryListType& deplibs,
69 std::string* ErrMsg) {
67 static bool GetBitcodeDependentLibraries(const std::string &fname,
68 Module::LibraryListType& deplibs,
69 std::string* ErrMsg) {
7070 ModuleProvider *MP = 0;
7171 if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(fname)) {
7272 MP = getBitcodeModuleProvider(Buffer);
557557 }
558558
559559 /// This method processes a linkage item. The item could be a
560 /// Bytecode file needing translation to native code and that is
561 /// dependent on other bytecode libraries, or a native code
560 /// Bitcode file needing translation to native code and that is
561 /// dependent on other bitcode libraries, or a native code
562562 /// library that should just be linked into the program.
563563 bool ProcessLinkageItem(const llvm::sys::Path& link_item,
564564 SetVector& set,
585585 // If we got here fullpath is the path to the file, and its readable.
586586 set.insert(fullpath);
587587
588 // If its an LLVM bytecode file ...
589 if (fullpath.isBytecodeFile()) {
588 // If its an LLVM bitcode file ...
589 if (fullpath.isBitcodeFile()) {
590590 // Process the dependent libraries recursively
591591 Module::LibraryListType modlibs;
592 if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs, &err)) {
592 if (GetBitcodeDependentLibraries(fullpath.toString(),modlibs, &err)) {
593593 // Traverse the dependent libraries list
594594 Module::lib_iterator LI = modlibs.begin();
595595 Module::lib_iterator LE = modlibs.end();
674674 // Get the suffix of the file name
675675 const std::string& ftype = I->second;
676676
677 // If its a library, bytecode file, or object file, save
677 // If its a library, bitcode file, or object file, save
678678 // it for linking below and short circuit the
679679 // pre-processing/translation/assembly phases
680680 if (ftype.empty() || ftype == "o" || ftype == "bc" || ftype=="a") {
770770 // ll -> bc Helper
771771 if (action.isSet(OUTPUT_IS_ASM_FLAG)) {
772772 /// The output of the translator is an LLVM Assembly program
773 /// We need to translate it to bytecode
773 /// We need to translate it to bitcode
774774 Action* action = new Action();
775775 action->program.set("llvm-as");
776776 action->args.push_back(InFile.toString());
815815 // ll -> bc Helper
816816 if (action.isSet(OUTPUT_IS_ASM_FLAG)) {
817817 /// The output of the optimizer is an LLVM Assembly program
818 /// We need to translate it to bytecode with llvm-as
818 /// We need to translate it to bitcode with llvm-as
819819 Action* action = new Action();
820820 action->program.set("llvm-as");
821821 action->args.push_back(InFile.toString());
4242 /// @brief The phases of processing that llvmc understands
4343 enum Phases {
4444 PREPROCESSING, ///< Source language combining, filtering, substitution
45 TRANSLATION, ///< Translate source -> LLVM bytecode/assembly
45 TRANSLATION, ///< Translate source -> LLVM bitcode/assembly
4646 OPTIMIZATION, ///< Optimize translation result
4747 ASSEMBLY, ///< Convert program to executable
48 LINKING, ///< Link bytecode and native code
48 LINKING, ///< Link bitcode and native code
4949 NUM_PHASES ///< Always last!
5050 };
5151
128128 TIME_ACTIONS_FLAG = 0x0010, ///< Time the actions as they execute
129129 SHOW_STATS_FLAG = 0x0020, ///< Show pass statistics
130130 EMIT_NATIVE_FLAG = 0x0040, ///< Emit native code instead of bc
131 EMIT_RAW_FLAG = 0x0080, ///< Emit raw, unoptimized bytecode
131 EMIT_RAW_FLAG = 0x0080, ///< Emit raw, unoptimized bitcode
132132 KEEP_TEMPS_FLAG = 0x0100, ///< Don't delete temporary files
133133 STRIP_OUTPUT_FLAG = 0x0200, ///< Strip symbols from linked output
134134 DRIVER_FLAGS_MASK = 0x03FF ///< Union of the above flags
5555 BINDIR_SUBST, ///< The substitution item %bindir%
5656 ASSEMBLY, ///< The value "assembly" (and variants)
5757 ASSEMBLER, ///< The name "assembler" (and variants)
58 BYTECODE, ///< The value "bytecode" (and variants)
58 BITCODE, ///< The value "bitcode" (and variants)
5959 COMMAND, ///< The name "command" (and variants)
6060 DEFS_SUBST, ///< The substitution item %defs%
6161 EQUALS, ///< The equals sign, =
7878 COMMAND command|Command|COMMAND
7979 LANG lang|Lang|LANG
8080 LIBS libs|Libs|LIBS
81 LINKER linker|Linker|LINKER
81 LINKER linker|Linker|LINKER
8282 NAME name|Name|NAME
8383 OPT1 opt1|Opt1|OPT1
8484 OPT2 opt2|Opt2|OPT2
9696
9797 True true|True|TRUE|on|On|ON|yes|Yes|YES
9898 False false|False|FALSE|off|Off|OFF|no|No|NO
99 Bytecode bc|BC|bytecode|Bytecode|BYTECODE
99 Bitcode bc|BC|bitcode|Bitcode|BITCODE
100100 Assembly asm|ASM|assembly|Assembly|ASSEMBLY
101101
102102 BadSubst \%[a-zA-Z]*\%
185185 %WOpts% { return handleSubstitution(WOPTS_SUBST); }
186186
187187 {Assembly} { return handleValueContext(ASSEMBLY); }
188 {Bytecode} { return handleValueContext(BYTECODE); }
188 {Bitcode} { return handleValueContext(BITCODE); }
189189 {True} { return handleValueContext(TRUETOK); }
190190 {False} { return handleValueContext(FALSETOK); }
191191
290290 case ASSEMBLY:
291291 str += "assembly";
292292 break;
293 case BYTECODE:
294 str += "bytecode";
293 case BITCODE:
294 str += "bitcode";
295295 break;
296296 case TRUETOK:
297297 str += "true";
339339 case ASSEMBLY:
340340 anOption += "assembly";
341341 break;
342 case BYTECODE:
343 anOption += "bytecode";
342 case BITCODE:
343 anOption += "bitcode";
344344 break;
345345 case TRUETOK:
346346 anOption += "true";
391391 next();
392392 if (token == ASSEMBLY) {
393393 return true;
394 } else if (token == BYTECODE) {
394 } else if (token == BITCODE) {
395395 return false;
396396 } else {
397397 error("Expecting output type value");
142142 cl::desc("Specify a target machine"), cl::value_desc("machine"));
143143
144144 static cl::opt Native("native", cl::init(false),
145 cl::desc("Generative native code instead of bytecode"));
145 cl::desc("Generative native code instead of bitcode"));
146146
147147 static cl::opt DebugOutput("g", cl::init(false),
148148 cl::desc("Generate objects that include debug symbols"));
2929 delete (llvm::LTO*)lto;
3030 }
3131
32 /// Read an LLVM bytecode file using LTO::readLLVMObjectFile.
32 /// Read an LLVM bitcode file using LTO::readLLVMObjectFile.
3333 extern "C"
3434 llvm_lto_status
3535 llvm_read_object_file(llvm_lto_t lto, const char *input_filename) {
106106 delete m;
107107 }
108108
109 /// InputFilename is a LLVM bytecode file. If Module with InputFilename is
109 /// InputFilename is a LLVM bitcode file. If Module with InputFilename is
110110 /// available then return it. Otherwise parseInputFilename.
111111 Module *
112112 LTO::getModule(const std::string &InputFilename)
127127 return m;
128128 }
129129
130 /// InputFilename is a LLVM bytecode file. Reade this bytecode file and
130 /// InputFilename is a LLVM bitcode file. Reade this bitcode file and
131131 /// set corresponding target triplet string.
132132 void
133133 LTO::getTargetTriple(const std::string &InputFilename,
138138 targetTriple = m->getTargetTriple();
139139 }
140140
141 /// InputFilename is a LLVM bytecode file. Read it using bytecode reader.
141 /// InputFilename is a LLVM bitcode file. Read it using bitcode reader.
142142 /// Collect global functions and symbol names in symbols vector.
143143 /// Collect external references in references vector.
144144 /// Return LTO_READ_SUCCESS if there is no error.
4545 // Other command line options...
4646 //
4747 static cl::opt
48 InputFilename(cl::Positional, cl::desc("ytecode file>"),
48 InputFilename(cl::Positional, cl::desc("itcode file>"),
4949 cl::init("-"), cl::value_desc("filename"));
5050
5151 static cl::opt
6060
6161 static cl::opt
6262 NoOutput("disable-output",
63 cl::desc("Do not write result bytecode file"), cl::Hidden);
63 cl::desc("Do not write result bitcode file"), cl::Hidden);
6464
6565 static cl::opt
6666 NoVerify("disable-verify", cl::desc("Do not verify result module"), cl::Hidden);
329329 if (ErrorMessage.size())
330330 cerr << ErrorMessage << "\n";
331331 else
332 cerr << "bytecode didn't read correctly.\n";
332 cerr << "bitcode didn't read correctly.\n";
333333 return 1;
334334 }
335335
361361 // If the output is set to be emitted to standard out, and standard out is a
362362 // console, print out a warning message and refuse to do it. We don't
363363 // impress anyone by spewing tons of binary goo to a terminal.
364 if (!Force && !NoOutput && CheckBytecodeOutputToConsole(Out,!Quiet)) {
364 if (!Force && !NoOutput && CheckBitcodeOutputToConsole(Out,!Quiet)) {
365365 NoOutput = true;
366366 }
367367
417417 if (!NoVerify && !VerifyEach)
418418 Passes.add(createVerifierPass());
419419
420 // Write bytecode out to disk or cout as the last step...
420 // Write bitcode out to disk or cout as the last step...
421421 if (!NoOutput && !AnalyzeOnly)
422422 Passes.add(CreateBitcodeWriterPass(*Out));
423423