Commit Graph

485 Commits

Author SHA1 Message Date
Reid Spencer 88f3e0731e For bug 122:
Separate Types from Values because Type no longer inherits from Value. The
changes for this are too numerous to list. In essence, any data structure
that contained a Value was doubled so that Types could be contained
similarly. New members include Types, TypeMap, CompactionTypes, and
CompactionTypeMap. Functions taking a Value* were overloaded with a variant
that takes a Type* that acts on the new data structures.

llvm-svn: 14608
2004-07-04 11:42:49 +00:00
Reid Spencer 25319569fb - Type::TypeTyID doesn't exist any more (bug 122)
- Types don't have names any more, just write them on ostream directly

llvm-svn: 14606
2004-07-04 11:37:54 +00:00
Reid Spencer 5ef4237089 Move SlotCalculator.h to lib/Bytecode/Writer since that is the only place
that needs it after the Type != Value changes (bug 122).

llvm-svn: 14605
2004-07-04 11:36:31 +00:00
Reid Spencer bc70f74825 - Don't use macros to call the BytecodeHandler
- Don't use PARSE_ERROR macro unnecessarily (for simple strings)
- Add comments before each function
- Convert for bug 122 (Type != Value)
- Handle new value range on Type::PrimitiveTypeId enumeration by augmenting
  the reader with a new read_typeid method and sanitizeTypeId method.
- Remove BytecodeHandler's default method implementations to header file.

llvm-svn: 14604
2004-07-04 11:33:49 +00:00
Reid Spencer e6c95490a0 - Make ValueList an "OtherVal" user of Values to ensure it doesn't get
mistaken for anything else.
- Move function descriptions to Reader.cpp file per Chris.
- Remove tabs.

llvm-svn: 14602
2004-07-04 11:04:56 +00:00
Reid Spencer 0421e6c843 Remove tabs. Move function declaration to Reader.h where it belongs.
llvm-svn: 14601
2004-07-04 11:03:03 +00:00
Reid Spencer 646f829e33 Add #include <iostream> which is needed now that Value.h doesn't include it
llvm-svn: 14600
2004-07-04 11:01:27 +00:00
Reid Spencer 6eecc40b2d Excise tabs.
llvm-svn: 14599
2004-07-04 11:00:39 +00:00
Reid Spencer fddebf7ff2 Remove files no longer needed. ConstantReader and InstructionReader were
integrated into Reader. Parser.* was just a bad idea. AnalyzerInternals.h
is no longer needed. ReaderPrimitives.h was integrated into Reader.h and
Reader.cpp. Dumper.cpp was integrated into Analyzer.cpp. ReaderInternals.h
became Reader.h. AnalyzerWrappers.cpp was integerated into
ReaderWrappers.cpp

llvm-svn: 14496
2004-06-29 23:32:41 +00:00
Reid Spencer f4ec6383c0 This is a slimming down of the previous ReaderInternals.h that just
declares the BytecodeReader class.

llvm-svn: 14495
2004-06-29 23:31:01 +00:00
Reid Spencer 284b7c7174 MAJOR REWRITE.
- stop passing Buf/BufEnd to every function (now member vars)
- internalize things that used to be in a header file that no one else
  included/needed.
- Remove defunct BCR_TRACE lines
- Standardize error handling with the PARSE_ERROR macro.
- Integrate ConstantReader.cpp and InstructionReader.cpp and reorgnize
  the definition order so that gcc has a chance at optimizing this module
- Standardize case and style of method names.
- Eliminate unneeded header files
- Prepare for Type != Value (bug122) change by splitting Types into their
  own data structures.
- Implement the BytecodeHandler interface calls.
- Provide default implementation of BytecodeHandler interface.

llvm-svn: 14494
2004-06-29 23:29:38 +00:00
Reid Spencer 891cb9d925 Adjustments to allow Bytecode Reading to support the BytecodeHandler
interface which is called by the reader if a BytecodeHandler is provided.

llvm-svn: 14493
2004-06-29 23:24:14 +00:00
Reid Spencer 351f6bf714 Merge Dumper.cpp and AnalyzerWrappers.cpp into this file. Also, adjust the
dumping facility to produce useful output.

llvm-svn: 14492
2004-06-29 23:23:12 +00:00
Reid Spencer c7b9419add Analyzer moved to ../Reader directory.
llvm-svn: 14491
2004-06-29 23:21:53 +00:00
Reid Spencer 75923a4f93 Remove newly defunct Analyzer directory.
llvm-svn: 14490
2004-06-29 23:21:16 +00:00
Chris Lattner 4ba8a8d1ef No functionality changes here:
* Some warning fixes for MSVC
  * Minor simplification to the deque scanning code

llvm-svn: 14417
2004-06-25 20:52:10 +00:00
Chris Lattner ccd8ed145a Fix more warnings building with VC++
llvm-svn: 14391
2004-06-25 00:35:55 +00:00
Chris Lattner 521eb8752b fix warnings
llvm-svn: 14388
2004-06-25 00:11:25 +00:00
Chris Lattner 6b7275996c Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
llvm-svn: 14201
2004-06-17 18:19:28 +00:00
Reid Spencer c0999e134e Implement tracking of bytecode instruction size and the number of long
instructions generated.

llvm-svn: 14154
2004-06-11 15:10:38 +00:00
Reid Spencer c22be9f9d5 Revert an unneeded interface change to Instruction.h
llvm-svn: 14137
2004-06-11 03:06:43 +00:00
Reid Spencer 8395e67fb1 Remove tabs.
llvm-svn: 14123
2004-06-10 22:03:00 +00:00
Reid Spencer 7670bbdfb9 Implement detailed function level data collection and reporting.
llvm-svn: 14122
2004-06-10 22:00:54 +00:00
Reid Spencer 90f0032664 Adjust prototypes to new Handler interface.
llvm-svn: 14121
2004-06-10 22:00:29 +00:00
Reid Spencer 2491b0959e Make the parser deal with functions instead of just function types.
llvm-svn: 14120
2004-06-10 21:59:20 +00:00
Reid Spencer ff35cf92c5 Doxygenize a comment.
llvm-svn: 14115
2004-06-10 08:27:00 +00:00
Reid Spencer 8e5de9cd75 Implemented the bulk of the functionality. Cleaned up the code.
llvm-svn: 14113
2004-06-10 08:09:13 +00:00
Reid Spencer 2acee7e4d6 Cleanup alignment of output.
llvm-svn: 14093
2004-06-09 06:22:00 +00:00
Reid Spencer cc4e35a404 Implement analysis output. Don't dump function details unless requested.
llvm-svn: 14091
2004-06-09 06:17:58 +00:00
Reid Spencer 839fa681f6 Implement some rudimentary analysis.
llvm-svn: 14090
2004-06-09 06:16:43 +00:00
Reid Spencer f1598b0efa Clean up indentation of file body output.
Don't dump functions unless "detailedResults" is requested.

llvm-svn: 14089
2004-06-09 06:16:19 +00:00
Reid Spencer fc6f5508aa Move parsing details to Parser.cpp.
llvm-svn: 14088
2004-06-09 06:15:21 +00:00
Reid Spencer 670c26d3af Bring some things out of header files that belong only in this file.
llvm-svn: 14087
2004-06-09 06:14:52 +00:00
Reid Spencer e73febc64a Cleaned up a dead header file to prevent duplicate definition warnings
in doxygen.

llvm-svn: 14084
2004-06-09 04:38:34 +00:00
Reid Spencer 42427f0ccb Fix the bug that was preventing the parser from working on all bytecode
files. It was reading non-initialized global vars when the flag said it was
initialized and vice versa. Causes mis-alignment since initialized and
non-initialized constants have different bytecode lengths.

llvm-svn: 14057
2004-06-08 05:54:47 +00:00
Reid Spencer 2c5613d1c3 Make it #include Parser.h instead of AnalyzerInternals.h since it only
needs the BytecodeHandler interface which is now in Parser.h

llvm-svn: 14056
2004-06-08 05:53:14 +00:00
Reid Spencer 621a4ad111 Adjust what's included to compensate for changes in Parser.h
llvm-svn: 14055
2004-06-08 05:52:29 +00:00
Reid Spencer fbe659d435 Merged BytecodeHandler.h into Parser.h since the parser and the handler
must always coexist. Cleaned up the documentation on these interfaces
significantly. This is in preparation for moving Parser.h to the include
directories to make it a public interface.

llvm-svn: 14054
2004-06-08 05:51:18 +00:00
Reid Spencer db5c86d0b1 Commit For New Tool: llvm-abcd (Analysis of ByteCode Dumper). This tool
will (eventually) provide statistical analysis of bytecode files as well
as the ability to dump them in a low level format (slot numbers not
resolved). The purpose of this is to aid in the Type!=Value change of
bug 122. With this initial release, llvm-abcd merely dumps out the
bytecode. However, the infrastructure for separating bytecode parsing from
handling the parsing events is in place. The style chosen is similar to
SAX XML parsing where a handler object is called to handlign the parsing
events. This probably isn't useful to anyone but me right now as there is
no analysis yet, and the dumper doesn't work on every bytecode file. It
will probably be useful by the end of this week. Note that there is some
duplication of code from the bytecode reader.  This was done to eliminate
errors from being introduced in the reader and to minimize the impact to
other LLVM developers. At some point, the Analyzer and the Reader will be
integrated to use the same infrastructure. Also, sorry for the minor change
to Instruction.h but I just couldn't bring myself to write code that
depends on Instruction internals.

llvm-svn: 14048
2004-06-07 17:53:43 +00:00
Reid Spencer 9163bcdf0f Moved this file to lib/Bytecode/Writer because its used there only.
llvm-svn: 13900
2004-05-30 00:09:32 +00:00
Chris Lattner 9063461603 Use the new FileUtilities.h API for mapping a file into an address
space

llvm-svn: 13864
2004-05-28 00:24:41 +00:00
Reid Spencer f2f34b3052 Use the SymbolTable::isEmpty() method instead of checking for no value
planes. A SymbolTable could still have types in it! This fixes problems
with two regression tests that failed because a symbol table that only
contained types was being omitted from bytecode files. Thanks to Chris
for the reduced test case that helped find this immediately.

llvm-svn: 13842
2004-05-27 20:18:51 +00:00
Reid Spencer 0aff01a239 Part of bug 122:
This change removes the BuildBytecodeInfo flag from the SlotCalculator
class. This flag was needed to distinguish between the Bytecode/Writer
and the AsmWriter. Now that AsmWriter doesn't use SlotCalculator, we can
remove this flag and simplify some code. Also, some minor name changes
to CachedWriter.h needed to be committed (missed in previous commit).

llvm-svn: 13785
2004-05-26 07:37:11 +00:00
Reid Spencer abac0ef0b7 Put SlotTable.h inclusion back at front of list to be coding standards
compliant. Thanks, Chris.

llvm-svn: 13771
2004-05-25 20:09:05 +00:00
Reid Spencer 6244bc7831 Make the constructor explicit so we can't implicitly convert bool to
SlotTable.

llvm-svn: 13766
2004-05-25 19:09:25 +00:00
Reid Spencer 37dd30c00a Make some improvements suggested by Chris.
llvm-svn: 13765
2004-05-25 19:03:21 +00:00
Reid Spencer 4feb245a31 Adding the initial implementation of the SlotTable class. This class is
the Abstract Data Type that holds slot number values and associates them
with Type* and Value*. The SlotTable is simply the holder of the slot
numbers and provides a controlled interface for building the table. It does
not enforce any particular idiom or functionality for manipulating the slot
numbers.

This is part of bug_122. The SlotCalculator and SlotMachine classes will
follow.

llvm-svn: 13764
2004-05-25 18:44:51 +00:00
Reid Spencer 660ea5fadb Changed to use SymbolTable's new iteration interfaces.
llvm-svn: 13759
2004-05-25 17:29:59 +00:00
Misha Brukman 1846321345 Squelch compile-time warning (profile build).
llvm-svn: 13228
2004-04-28 15:32:09 +00:00
Chris Lattner f011b7dfe6 Fix warning building in optimized mode
llvm-svn: 13190
2004-04-27 18:24:38 +00:00
Chris Lattner 15701e84d1 Implement support for a new LLVM 1.3 bytecode format, which uses uint's
to index into structure types and allows arbitrary 32- and 64-bit integer
types to index into sequential types.

llvm-svn: 12651
2004-04-05 01:27:26 +00:00
Chris Lattner bc8ba73cf1 Remove a bunch of cruft that was used to be backwards compatible with the last
prerelease format for LLVM bytecode files.  Now we only are compatible with
LLVM 1.0+.

llvm-svn: 12643
2004-04-03 23:43:42 +00:00
Brian Gaeke 77e78a4531 Use the true, decoded name of the archive member in getObjectType.
In ReadArchiveBuffer, make sure that MemberName is set in the case where
getObjectType would want to return SVR4LongFilename.

llvm-svn: 12567
2004-03-31 19:51:00 +00:00
Chris Lattner 974efc72be Add support for reading constantexpr select instructions
llvm-svn: 12563
2004-03-31 02:53:59 +00:00
Chris Lattner dd7ce6c31a Make error message a bit nicer.
Contributed by Reid Spencer

llvm-svn: 12523
2004-03-29 00:16:01 +00:00
Chris Lattner e7c9f6f7ae Write select instructions to bytecode
llvm-svn: 12315
2004-03-12 05:52:01 +00:00
Chris Lattner 92412466b6 Read select instrs from bytecode
llvm-svn: 12314
2004-03-12 05:51:49 +00:00
Chris Lattner e33ddf57f6 This debugging hook is no longer needed.
llvm-svn: 11233
2004-02-09 17:20:52 +00:00
Chris Lattner ac6db755c3 Adjust to the changed StructType interface. In particular, getElementTypes() is gone.
llvm-svn: 11228
2004-02-09 04:37:31 +00:00
Chris Lattner fa829be4d3 Start using the new and improve interface to FunctionType arguments
llvm-svn: 11224
2004-02-09 04:14:01 +00:00
Chris Lattner 8c285b20b7 Remove all of the annoying statistics now that I'm finished (for the near
term) working on bytecode size stuff.

llvm-svn: 11046
2004-02-01 01:50:31 +00:00
Misha Brukman ba3c670292 Implement ModuleProvider::materializeModule() by only materializing functions
that are still left in the lazy reader map.

llvm-svn: 10944
2004-01-21 22:55:34 +00:00
Chris Lattner c70b3f63cc SlotCalculator.h moved
llvm-svn: 10931
2004-01-20 19:50:34 +00:00
Chris Lattner 467d977868 Fix PR212 - Bytecode reader misreads 'long -9223372036854775808'!
Fix testcase test/Regression/Assembler/2004-01-20-MaxLongLong.llx

llvm-svn: 10928
2004-01-20 19:13:07 +00:00
Chris Lattner 6cc66d93f1 Fix bogus warning and simplify code
llvm-svn: 10924
2004-01-20 17:06:29 +00:00
Chris Lattner a395324383 Bugfixes for dealing with partially compactified functions
llvm-svn: 10920
2004-01-20 00:54:06 +00:00
Chris Lattner 5a66bb7507 Save another 30K from 176.gcc by encoding the compaction table a bit more
intelligently.

llvm-svn: 10918
2004-01-18 22:35:34 +00:00
Chris Lattner 979ca2fccd Remove -debug output
llvm-svn: 10917
2004-01-18 22:26:53 +00:00
Chris Lattner bc02f4ce97 Add support for writing bytecode files with compactiontables for bytecode files.
This shrinks the bytecode file for 176.gcc by about 200K (10%), and 254.gap by
about 167K, a 25% reduction.  There is still a lot of room for improvement in
the encoding of the compaction table.

llvm-svn: 10915
2004-01-18 21:08:52 +00:00
Chris Lattner e104d88f83 Add support for reading bytecode files with compactiontables for bytecode files.
This shrinks the bytecode file for 176.gcc by about 200K (10%), and 254.gap by
about 167K, a 25% reduction.  There is still a lot of room for improvement in
the encoding of the compaction table.

llvm-svn: 10914
2004-01-18 21:08:15 +00:00
Chris Lattner 677af4a1cb Bytecode format for LLVM 1.2 no longer explicitly encodes zeros in primitive
type planes.  This saves about 5k on 176.gcc, and is needed for a subsequent
patch of mine I'm working on.

llvm-svn: 10908
2004-01-17 23:25:43 +00:00
Chris Lattner 4c57267ece If these blocks are empty, there is no reason to even emit the bytecode blocks.
This saves about 15K in 176.gcc, coupled with another patch that I'm working on.

llvm-svn: 10889
2004-01-15 21:06:57 +00:00
Chris Lattner f4572852dc ConstantPointerRef's are no longer emitted. This saves 20028 bytes in the
bytecode files when compiling 176.gcc, but more importantly will make it
easier to eliminate CPR's in the future (no new .bc revision will be
required to support them)

llvm-svn: 10884
2004-01-15 18:46:56 +00:00
Chris Lattner e2f6317436 Allow bytecode files to refer directly to global values as constants, instead
of forcing them to go through ConstantPointerRef's.  This allows bytecode
files to mirror .ll files, allows more efficient encoding, and makes it easier
to eventually eliminate CPR's.

llvm-svn: 10883
2004-01-15 18:45:25 +00:00
Chris Lattner 980ff78e3c Fix more breakage with string change.
llvm-svn: 10882
2004-01-15 18:39:06 +00:00
Chris Lattner 394fc96f39 Fix PR73: bytecode format inconsistent
llvm-svn: 10876
2004-01-15 17:55:09 +00:00
Chris Lattner 7c73b19bb8 Fix PR73
llvm-svn: 10875
2004-01-15 17:55:01 +00:00
Chris Lattner f63a4ecc0b Fix brokenness in my last checking
llvm-svn: 10874
2004-01-15 16:56:15 +00:00
Chris Lattner faaf32db19 Change all of the bytecode reader primitives to throw exceptions instead of
returning error codes.  Because they don't return an error code, they can
return the value read, which simplifies the code and makes the reader more
efficient (yaay!).

Also eliminate the special case code for little endian machines.

llvm-svn: 10871
2004-01-15 06:13:09 +00:00
Chris Lattner 1af644d9d6 Remove the optimization that depends on ENDIAN_LITTLE: it's not worth it.
llvm-svn: 10870
2004-01-15 06:11:30 +00:00
Chris Lattner 6229fbf328 The new bytecode format supports emitting strings a special case. This is
intended to save size (and does on small programs), but on big programs it
actually increases the size of the program slightly.  The deal is that many
functions end up using the characters that the string contained, and the
characters are no longer in the global constant table, so they have to be
emitted in function specific constant pools.

This pessimization will be fixed in subsequent patches.

llvm-svn: 10864
2004-01-14 23:36:54 +00:00
Chris Lattner 394afe0f90 Version 1.2 now supports encoding strings as a special case, to avoid having
to emit all of those sbyte constants.

llvm-svn: 10863
2004-01-14 23:35:21 +00:00
Chris Lattner c6098c06d5 Like output_data, it's obvious that input_data was only used with 1 character
data.

llvm-svn: 10861
2004-01-14 23:03:22 +00:00
Chris Lattner eeb4ffd8ea It is obvious that this has never been used for outputing more than a single
byte, it's totally endian incorrect!

llvm-svn: 10857
2004-01-14 18:50:28 +00:00
Chris Lattner 29f9590e82 Be const correct
llvm-svn: 10856
2004-01-14 18:41:38 +00:00
Chris Lattner 9a38c78fe6 Ok, I can't handle it. This is a temporary checkin of a ton of statistics that
i'm using in my work to reduce the bytecode file sizes.  These will eventually
be removed.

llvm-svn: 10849
2004-01-14 16:54:21 +00:00
Chris Lattner 893b184db0 Remove support for the pre-1.0 bytecode version #1. This will become
the bytecode revision generated by LLVM 1.2.

llvm-svn: 10848
2004-01-14 16:44:44 +00:00
Chris Lattner 1f018c2d01 Toggle sense of flag
llvm-svn: 10838
2004-01-14 02:50:16 +00:00
Chris Lattner 1b7d4d7b63 Don't use ConstantExpr::getShift anymore
llvm-svn: 10791
2004-01-12 19:08:43 +00:00
Chris Lattner a2bfab849f Do not bother to emit a BytecodeBlock for an empty symbol table. This commonly
occurs when the symbol table for a module has been stripped, making all of the
function local symbols go away.

This saves 6728 bytes in the stripped bytecode file of 254.gap (which obviously
has 841 functions), which isn't a ton, but helps and was easy.

llvm-svn: 10750
2004-01-10 19:56:59 +00:00
Chris Lattner 0c53031c5e Err, we don't need Config/*.h files for things that are standard C++
llvm-svn: 10742
2004-01-10 19:10:01 +00:00
Chris Lattner b0a5964356 minor comment tweaks
llvm-svn: 10741
2004-01-10 19:07:06 +00:00
Chris Lattner 4282cbb93a * finegrainify namespacification of ArchiveReader.cpp
* Refactor reader stuff out of include/llvm/Bytecode/Primitives.h.  This is
  internal implementation details for the reader, not public interfaces!

llvm-svn: 10739
2004-01-10 19:00:15 +00:00
Chris Lattner 82167909a8 Refactor writer stuff out of include/llvm/Bytecode/Primitives.h. This is
internal implementation details for the writer, not public interfaces!

llvm-svn: 10738
2004-01-10 18:56:59 +00:00
Chris Lattner dfe0346e96 Finegrainify namespacification
llvm-svn: 10737
2004-01-10 18:49:43 +00:00
Chris Lattner bc39a1a8c4 Inching our way towards fixing PR82
llvm-svn: 10721
2004-01-09 05:42:34 +00:00
Chris Lattner 328e067246 remove some useless #includes
llvm-svn: 10654
2003-12-30 07:55:21 +00:00
Chris Lattner 9b75157c04 Use new getFileSize function instead of sys/stat.h directly.
llvm-svn: 10650
2003-12-30 07:40:35 +00:00
Chris Lattner a462161f9c Factor FDHandle out of the bytecode reader into the FileUtilities.h support
routines.

llvm-svn: 10642
2003-12-29 21:35:05 +00:00
Chris Lattner 4a2a8f5821 minor cleanups
llvm-svn: 10612
2003-12-26 06:16:00 +00:00
John Criswell bd10d09b07 Reverted back to revision 1.11. The previous fix doesn't really fix
anything; it just causes the bug to go dormant.

llvm-svn: 10585
2003-12-22 16:22:49 +00:00
John Criswell d8c7a7fbaa Fix PR#193.
Modified ReadArchiveBuffer() so that it dynamically allocates the
std::string object used to hold the bytecode object file's name.  This is
necessary because it is passed by reference to the new Module that is
allocated to represent the bytecode object, and previously we were
using a std::string that disappeared on function exit.

llvm-svn: 10565
2003-12-20 22:37:29 +00:00
Brian Gaeke 0a9980582d Make getObjectType() smarter about ranlibbed Mac OS X archives.
llvm-svn: 10493
2003-12-17 00:18:18 +00:00
Brian Gaeke d24cfed317 Throw better error messages, by calling strerror(errno) when we
get an error inside the bytecode reader.

llvm-svn: 10415
2003-12-12 00:47:44 +00:00
Brian Gaeke 36fb4f19cd In getObjectType(), doxygenify comment, and take a pointer to the
beginning of the archive member data as an argument.

Get rid of ParseLongFilenameSection(), which is dead.

In ReadArchiveBuffer(), implement support for 4.4BSD/MacOSX long filenames.
This is kind of invasive, because they prepend the long filename to the archive
member data, and then lie about the size. So we have to keep track of the real
size.

llvm-svn: 10392
2003-12-11 00:38:04 +00:00
Chris Lattner d9cf9b30eb Emit & read more compressed bytecode by not emitting a bytecodeblock for
each basic block in function.  Instead, just emit a stream of instructions,
chopping up basic blocks based on when we find terminator instructions.  This
saves a fairly substantial chunk of bytecode space.  In stripped, sample
cases, for example, we get this reduction in size:

197.parser: 163036 -> 137180:  18.8% reduction
254.gap   : 844936 -> 689392:  22.6%
255.vortex: 621724 -> 528444:  17.7%

...

Not bad for something this simple.  :)  Note that this doesn't require a new
bytecode version number at all, though version 1.1 should not need to support
the old format.

llvm-svn: 10280
2003-12-01 07:05:31 +00:00
Chris Lattner 9c68fa3ab1 * Finegrainify namespacification
* Strength reduce several data structures which were left over from the
  "bad old days"
* Minor efficiency improvements
* Major efficiency improvement: In BytecodeParser::insertValue, do not allocate
  a new ValueTab entry just because some value exists with a large type.  This
  dramatically reduces the number of allocations/deallocations performed by the
  bytecode reader, and speeds up parsing of Kimwitu++ from 34s to 17s.  This is
  to help address PR127

llvm-svn: 10085
2003-11-19 17:27:18 +00:00
Chris Lattner 8700c28ac9 Minor efficiency improvements, finegrainify namespacification
llvm-svn: 10084
2003-11-19 17:21:11 +00:00
Chris Lattner bf346b526f In the future, these slabs can be null...
llvm-svn: 10083
2003-11-19 17:20:42 +00:00
Chris Lattner 11e8f1b595 Minor efficiency improvements all over. Finegrainify Namespacification
llvm-svn: 10082
2003-11-19 17:17:36 +00:00
Chris Lattner e8de15976a Fine grainify namespacification, #include file that defines the interface!
llvm-svn: 10081
2003-11-19 16:06:55 +00:00
Chris Lattner ffa9d511f9 Minor speedup to do less linear time searches of information we already have.
speeds up disassembly of kc++ by .6s

llvm-svn: 10079
2003-11-19 06:01:12 +00:00
Chris Lattner ea25538936 Remove usage of ConstantPointer
llvm-svn: 10051
2003-11-17 17:28:29 +00:00
Brian Gaeke 900cc96e08 Implement skeletal support for __.SYMDEF (ranlib) sections in archives.
Correctly parse the Long Filename section of the archive.
When reading in archive members, set their ModuleIDs to
 "ARCHIVENAME(MEMBERNAME)", as is traditional.

llvm-svn: 10043
2003-11-16 23:08:48 +00:00
Chris Lattner 93dea78f85 I can't believe the incompetence of the people I have to deal with around here.
These fools don't even wrap code at 80 columns.

Oh wait, _I_ wrote that.  That explains a lot!!

llvm-svn: 9999
2003-11-14 16:34:25 +00:00
Chris Lattner cd45bc4086 Fix PR 110: the constant folding code assumes that if something is not a
constant expression, but is of (for example) ubyte type, then it is a
ConstantUInt.  This was not true for placeholders.

llvm-svn: 9994
2003-11-14 06:38:46 +00:00
Brian Gaeke 960707c335 Put all LLVM code into the llvm namespace, as per bug 109.
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
Chris Lattner c3d6f21bbe no need for endl
llvm-svn: 9736
2003-11-05 19:53:32 +00:00
Chris Lattner b36e8a1a2e Add support for constant expr shifts
llvm-svn: 9735
2003-11-05 19:53:03 +00:00
Alkis Evlogimenos 404beb98ef Put DEBUG_OUTPUT at the top along with TRACE_LEVEL. Also fix the code
inside DEBUG_OUTPUT so that it compiles.

llvm-svn: 9614
2003-10-30 18:33:58 +00:00
Brian Gaeke 45eb2eeb74 Explicitly cast type, so we aren't passing output_vbr a size_t.
llvm-svn: 9590
2003-10-29 20:09:01 +00:00
John Criswell 29265fe981 Added LLVM copyright header.
llvm-svn: 9321
2003-10-21 15:17:13 +00:00
John Criswell 4436c49787 Added LLVM copyright notice to Makefiles.
llvm-svn: 9312
2003-10-20 22:26:57 +00:00
John Criswell 482202a601 Added LLVM project notice to the top of every C++ source file.
Header files will be on the way.

llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Chris Lattner b94550e537 Change the Opcode enum for PHI nodes from "Instruction::PHINode" to "Instruction::PHI" to be more consistent with the other instructions.
llvm-svn: 9269
2003-10-19 21:34:28 +00:00
Chris Lattner eb6cfaef4b Fix warning
llvm-svn: 9236
2003-10-18 19:48:10 +00:00
Chris Lattner dc83293a38 add support for new linkage types
llvm-svn: 9228
2003-10-18 06:30:21 +00:00
Chris Lattner 9d57347490 Updated to emit the final 1.0 bytecode format. This supports weak linkage,
more efficient encoding of varargs calls, and the new varargs intrinsics.

llvm-svn: 9221
2003-10-18 05:54:48 +00:00
Chris Lattner 7c6c539296 * New revised variable argument handling support
* More dense bytecode encoding for varargs calls (like printf)
* Eliminated the extremely old bytecode format.  rev #0 is now 1.0

llvm-svn: 9220
2003-10-18 05:54:18 +00:00
Alkis Evlogimenos 8faf8d93d5 Eliminate some extraneous code in SlotCalculator::insertVal().
Rename SlotCalculator::getValSlot() to SlotCalculator::getSlot(),
       SlotCalculator::insertValue() to SlotCalculator::getOrCreateSlot(),
       SlotCalculator::insertVal() to SlotCalculator::insertValue(), and
       SlotCalculator::doInsertVal() to SlotCalculator::doInsertValue().

llvm-svn: 9190
2003-10-17 02:02:40 +00:00
Misha Brukman 0659ddc455 Add separator between different types of readers.
llvm-svn: 9183
2003-10-16 21:19:54 +00:00
Chris Lattner 2d05c60bac Add support for 'weak' linkage.
For now, we translate linkonce into weak linkage in the bytecode format because
we don't have enough bits to represent it.  We will rev the bytecode version
soon anyways, so this will be fixed in the near future.

llvm-svn: 9170
2003-10-16 18:28:50 +00:00
Chris Lattner aa78cc9e5d Minor cleanups
llvm-svn: 9079
2003-10-13 14:57:53 +00:00
Chris Lattner a785563692 Avoid calling getTypeSlot more
llvm-svn: 9077
2003-10-13 14:34:59 +00:00
Chris Lattner f0bf7cb739 This is a header file, thus it needs a -*-C++-*-
llvm-svn: 9072
2003-10-13 04:22:07 +00:00
Chris Lattner 44d2c3514a Regularize header file comments
llvm-svn: 9071
2003-10-13 03:32:08 +00:00
Chris Lattner fdf472a83a Ok, the "fix" for this is to do a real associative container. Symbol tables
are ordered by name, not by slot, so the previous solution wasn't any good.
On a large testcase, this reduces time to parse from 2.17s to 1.58s.

llvm-svn: 9002
2003-10-10 05:43:47 +00:00
Chris Lattner 1434d68164 Another 10% performance improvement by not using replaceAllUsesWith
llvm-svn: 8994
2003-10-09 23:10:14 +00:00
Chris Lattner 2ec9de30cd Reserve space for PHI nodes when we read them in. This provides a VERY
tasty 15% speedup on the testcase from Bill.

llvm-svn: 8993
2003-10-09 22:46:58 +00:00
Chris Lattner 5255bed8bc Use the version of getValue that takes the type plane instead of the type
if possible.  This provides a consistent 8.5% speedup.

llvm-svn: 8991
2003-10-09 22:39:30 +00:00
Chris Lattner 819ce2dca1 Pass a vector around to reduce dynamic allocation
Throw the RawInst class in an anon namespace

llvm-svn: 8990
2003-10-09 20:45:42 +00:00
Chris Lattner 1ae8a48a62 Change getConstantValue to throw an exception on error, not return null
llvm-svn: 8988
2003-10-09 20:41:16 +00:00
Chris Lattner a89c91020c Remove potentially N^2 algorithm from symbol table reader. No speedup
in practice though

llvm-svn: 8985
2003-10-09 20:30:04 +00:00
Chris Lattner e7691a4520 Major refactoring of the bytecode reader. This includes the following
changes:
  * BytecodeReader::getType(...) used to return a null pointer
    on error.  This was only checked about half the time.  Now we convert
    it to throw an exception, and delete the half that checked for error.
    This was checked in before, but psmith crashed and lost the change :(
  * insertValue no longer returns -1 on error, so callers don't need to
    check for it.
  * Substantial rewrite of InstructionReader.cpp, to use more efficient,
    simpler, data structures.  This provides another 5% speedup.  This also
    makes the code much easier to read and understand.

llvm-svn: 8984
2003-10-09 20:22:47 +00:00
Chris Lattner bd26abdc95 Significantly clean up parsing of instructions. This exceptionizes and
simplifies the control flow a bit.  This provides a small (~3%) speedup,
but it's primarily a cleanup exercise.

llvm-svn: 8983
2003-10-09 18:25:19 +00:00
Chris Lattner 1e8addf890 Eliminate the instruction placeholder. Simplify a bunch of code.
This results in no significant speedup, but does provide simpler code

llvm-svn: 8980
2003-10-09 06:14:26 +00:00
Chris Lattner 42dce1e365 Eliminate the old LateResolveValues data structure, replacing it with a
new, simpler, ForwardReferences data structure.  This is just the first
simple replacement, subsequent changes will improve the code more.

This simple change improves the performance of loading a file from HDF5
(contributed by Bill) from 2.36s to 1.93s, a 22% improvement.  This
presumably has to do with the fact that we only create ONE placeholder for
a particular forward referenced values, and also may be because the data
structure is much simpler.

llvm-svn: 8979
2003-10-09 06:05:40 +00:00
Chris Lattner a9c297c8ea Remove a dead method
llvm-svn: 8978
2003-10-09 05:25:34 +00:00
Chris Lattner abf6412c09 This patch substantially simplifies and cleans up handling of basic blocks
in the bytecode parser.  Before we tried to shoehorn basic blocks into the
"getValue" code path with other types of values.  For a variety of reasons
this was a bad idea, so this patch separates it out into its own data structure.

This simplifies the code, makes it fit in 80 columns, and is also much faster.
In a testcase provided by Bill, which has lots of PHI nodes, this patch speeds
up bytecode parsing from taking 6.9s to taking 2.32s.  More speedups to
follow later.

llvm-svn: 8977
2003-10-08 22:52:54 +00:00
Chris Lattner f29c7b1a3f Inline the postResolveValues method. It was poorly named anyway
llvm-svn: 8976
2003-10-08 21:51:46 +00:00
Chris Lattner 85555779de Various cleanups and simplifications. This speeds up reading a bytecode file
Bill gave me from 8.69s to 6.90s.

llvm-svn: 8971
2003-10-08 21:18:57 +00:00
Misha Brukman b5c59fa16d Destroy allocated resources on exception.
llvm-svn: 8969
2003-10-08 19:55:47 +00:00
Brian Gaeke 82f64531f6 All of our supported operating systems (so far) and FreeBSD technically
want you to include <sys/stat.h> for fstat(), struct stat, and friends.

llvm-svn: 8887
2003-10-06 03:30:28 +00:00
Chris Lattner cc593fb6c6 Rename AbstractModuleProvider -> ModuleProvider, to match the header file name,
and because, while the class used by the interface is abstract, the actual
concept is not.

llvm-svn: 8850
2003-10-04 20:14:59 +00:00
Chris Lattner 069d6493c9 Transform two methods to return pointers directly instead of returning them
as 'by reference' arguments.

llvm-svn: 8849
2003-10-04 20:00:03 +00:00
Chris Lattner 4318c4b549 Use V for values, not D.
llvm-svn: 8848
2003-10-04 19:29:21 +00:00
Chris Lattner a0d15e4d9e Do not leak the ModuleProvider if releaseModule() throws.
llvm-svn: 8847
2003-10-04 19:19:37 +00:00
Chris Lattner c7caffab32 There is no need for BytecodeParser to be an AbstractTypeUser. Instead, it
can just use PATypeHolders

llvm-svn: 8832
2003-10-02 20:26:18 +00:00
Chris Lattner 4437995826 Just rethrow previous exception instead of making a new one
llvm-svn: 8718
2003-09-26 14:44:52 +00:00
Chris Lattner 1e9402d93d Define the instance variable Buffer, not the automatic variable Buffer.
This was causing us to munmap random stuff, which is obviously bad.

llvm-svn: 8709
2003-09-25 04:13:53 +00:00
Chris Lattner ce6feda799 Fix alignment problem
llvm-svn: 8707
2003-09-24 22:34:17 +00:00
Misha Brukman 86c8a485d0 Actually assign the string correctly through the std::string pointer.
llvm-svn: 8704
2003-09-24 22:10:47 +00:00
Misha Brukman c3634809e6 * Eliminate BytecodeBufferReader::Length member variable
* Kill unused ALIN_PTRS #define
* Set the error string if user passed it in to be compatible with former API

llvm-svn: 8701
2003-09-24 22:04:02 +00:00
John Criswell 89f4dcf5bc Added code that ensures that we pass the beginning of the data buffer to
the parsing routines regardless of whether the buffer is re-aligned or not.

llvm-svn: 8693
2003-09-23 21:19:11 +00:00
Misha Brukman 1a74cffdec Stop returning bool and pass Instruction by reference;
return std::auto_ptr and use exceptions

llvm-svn: 8684
2003-09-23 16:17:50 +00:00
Misha Brukman 0c0a882bc3 Suggestions made by Chris:
* Instead of a #define, use inline function
* Fix the name on the #define, errr... now inline function to be more logical:
  it doesn't CHECK the alignment, it PERFORMS the alignment
* To get string name of a Type*, use getDescription(), not getName()

llvm-svn: 8683
2003-09-23 16:15:29 +00:00
Misha Brukman 301f7dfa19 * Group class definitions & implementations together
* Make sure we align the buffer we're given
* Do not let exceptions propagate when the caller asks for a Module*
* Add doxygenified comments to wrapper functions

llvm-svn: 8682
2003-09-23 16:13:28 +00:00
Misha Brukman 715fe875bb * Constantify arguments to copy function
* Stop using a #define, make it an inline if statement

llvm-svn: 8678
2003-09-23 15:09:26 +00:00
Misha Brukman 3e18bc1518 Removed no longer used member variable.
llvm-svn: 8677
2003-09-22 23:58:08 +00:00
Misha Brukman bafce80ba4 Added file header comment.
llvm-svn: 8675
2003-09-22 23:44:46 +00:00
Chris Lattner df60fe04ab Update file header for renamed file
llvm-svn: 8673
2003-09-22 23:42:00 +00:00
Misha Brukman 6e9a3517f2 * Cleaned up code:
- no more passing around a string pointer to set errors
  - no more returning booleans and checking for errors, we use C++ exceptions
* Broke functionality into 2 new classes, one reads from file, one from a stream
* Implemented lazy function streaming - the parser can read in a function at-a-time

llvm-svn: 8671
2003-09-22 23:38:23 +00:00
Chris Lattner af4c95a051 Fix a spello Misha made while fixing one of my appostrifications
llvm-svn: 8510
2003-09-15 00:33:20 +00:00
Misha Brukman acda7df68b Fixed spelling and grammar.
llvm-svn: 8489
2003-09-11 22:34:13 +00:00
Chris Lattner 0b792b4ed3 Fix bug
llvm-svn: 8410
2003-09-08 19:43:46 +00:00
Chris Lattner 9c58cf6d03 Add support for the unwind instruction
llvm-svn: 8408
2003-09-08 18:54:55 +00:00
Chris Lattner a9083c961e Read volatile loads/stores
llvm-svn: 8401
2003-09-08 18:20:14 +00:00
Chris Lattner 53bd0b24f2 Remove a gross hack that was there to support bytecode files that are over a year old.
If you still have these suckers laying around, you have GOT to rebuild them.  geeze.

llvm-svn: 8395
2003-09-08 18:04:16 +00:00
Chris Lattner 8e8593a2c4 Add support for writing volatile load/stores
llvm-svn: 8394
2003-09-08 17:58:37 +00:00
Chris Lattner 15ad3f07db Fix reading of invoke instrs
llvm-svn: 8365
2003-09-05 18:25:29 +00:00
Chris Lattner 7f8d98776f Whoa, we were misreading invoke instructions "normal" destinations quite badly.
llvm-svn: 8363
2003-09-05 05:27:58 +00:00
Chris Lattner b4520603a4 Non-functional change
llvm-svn: 8352
2003-09-04 23:47:07 +00:00
Chris Lattner 54d85e389f Avoid printing meaningless numbers
llvm-svn: 8342
2003-09-03 20:25:27 +00:00
Chris Lattner 53db94da05 Follow the pattern of all other atu's
llvm-svn: 8340
2003-09-03 16:01:54 +00:00
Chris Lattner 55a07adc36 Allow modules to have 'any' pointer size and endianness. Luckily, we had
some space for extra flags, so we don't need to bump the revision number.

llvm-svn: 8118
2003-08-24 13:47:36 +00:00
Chris Lattner 6a2b859191 Rename SwitchInst::dest_push_back -> addCase
llvm-svn: 8089
2003-08-23 23:14:52 +00:00
Misha Brukman 7eb05a170a Spell `necessary' correctly.
llvm-svn: 7944
2003-08-18 14:43:39 +00:00
Chris Lattner f26a8ee580 Remove redundant const qualifiers from cast<> expressions
llvm-svn: 7253
2003-07-23 15:30:06 +00:00
Chris Lattner c5372125b9 Remove explicit const qualifiers
llvm-svn: 7245
2003-07-23 14:54:33 +00:00
Misha Brukman 7fdaab4f68 The word `separate' only has one `e'.
llvm-svn: 7173
2003-07-14 17:20:40 +00:00
John Criswell 3ef61afb76 Merged in autoconf branch. This provides configuration via the autoconf
system.

llvm-svn: 7014
2003-06-30 21:59:07 +00:00
Chris Lattner 8826647168 Detemplatize the PATypeHandle class, which was only really instantiated on 'Type'.
llvm-svn: 6774
2003-06-18 19:22:36 +00:00
Chris Lattner bbd00c12e0 Fix bug: Assembler/2003-06-17-InvokeDisassemble.llx
"yes, invoke instructions can have just three arguments"

llvm-svn: 6736
2003-06-17 13:31:10 +00:00
Chris Lattner 4a20791049 Fix bug: Assembler/2003-05-03-BytecodeReaderProblem.llx
by emitting the type planes before any constants (which could be constant
expressions involving undefined types!)

llvm-svn: 6285
2003-05-22 18:35:38 +00:00
Chris Lattner c56bdc5520 Do not assert fail or crash when a bytecode parse fails!
llvm-svn: 6284
2003-05-22 18:26:48 +00:00
Chris Lattner e69a1b9866 Eliminate the uchar typedef, use unsigned char explicitly
llvm-svn: 6283
2003-05-22 18:08:30 +00:00
Chris Lattner 09eb76ddfd Fix Bug: Assembler/2003-05-12-MinIntProblem.llx
llvm-svn: 6123
2003-05-12 15:13:52 +00:00
Chris Lattner f70da10697 Add support for the new va_arg instruction
llvm-svn: 6029
2003-05-08 02:44:12 +00:00
Misha Brukman 1d6f220a87 Fixed 'prevalent'.
llvm-svn: 5860
2003-04-23 02:59:05 +00:00
Chris Lattner 35834a503b Add support for reading and writing pointersize/endianness to and from bytecode
llvm-svn: 5839
2003-04-22 18:15:10 +00:00