Commit Graph

1413 Commits

Author SHA1 Message Date
Reid Kleckner
95eb3ad353 Parameterize the BumpPtrAllocator over a slab allocator. It defaults to using
malloc, so there should be no functional changes to other code.

These changes are necessary since I have plans to use this allocator in the JIT
memory manager, and it needs a special allocator.

I also added some tests which helped me pinpoint some bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 00:30:41 +00:00
David Greene
3c9509f82a Hide the DOUT static variable behind a function interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76425 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-20 16:16:06 +00:00
Nick Lewycky
7e7dc45eb1 Fix ConstantRange::unionWith. Also make it work a little hard in some cases to
return the smallest union of two ranges instead of just any range that happens
to contain the union.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76360 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-19 03:44:35 +00:00
Nick Lewycky
3a4a884c16 Replace intersectWith with maximalIntersectWith. The latter guarantees that
all values belonging to the intersection will belong to the resulting range.
The former was inconsistent about that point (either way is fine, just pick
one.) This is part of PR4545.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 06:34:42 +00:00
Daniel Dunbar
7df0c07dbc Provide slightly more refined error message when trying to lookup a target, and
none are registered.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 15:50:49 +00:00
Daniel Dunbar
34ccf037fe Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.
- No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76103 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 21:17:53 +00:00
Dan Gohman
ad60f660c6 Use size_t.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76069 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 15:24:40 +00:00
Chris Lattner
90bb3f3706 add a knob to turn off PrettyStackTrace globally. Patch by Zoltan
Varga!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 06:17:45 +00:00
Daniel Dunbar
603bea3274 Add registered target list to --version output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75889 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 02:06:09 +00:00
Dan Gohman
e87b2abe91 Change raw_ostream so that it doesn't call llvm_report_error
immediately on every output error. Instead, add a flag to
raw_ostream, and set the flag whenever an error is detected.

The flag can be queried and cleared from the public API. This
gives applications more flexibility to handling errors in
application-specific ways.

If the flag is not cleared when the raw_ostream is destructed,
llvm_report_error is called from the destructor. This ensures
that errors are not implicitly silenced, and provides
convenient default behavior for tools like llc and opt.
Clients wishing to avoid llvm_report_error calls from
raw_ostream should check for errors and clear the error flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75857 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 23:25:33 +00:00
Daniel Dunbar
51b198af83 Reapply TargetRegistry refactoring commits.
--- Reverse-merging r75799 into '.':
 U   test/Analysis/PointerTracking
U    include/llvm/Target/TargetMachineRegistry.h
U    include/llvm/Target/TargetMachine.h
U    include/llvm/Target/TargetRegistry.h
U    include/llvm/Target/TargetSelect.h
U    tools/lto/LTOCodeGenerator.cpp
U    tools/lto/LTOModule.cpp
U    tools/llc/llc.cpp
U    lib/Target/PowerPC/PPCTargetMachine.h
U    lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
U    lib/Target/PowerPC/PPCTargetMachine.cpp
U    lib/Target/PowerPC/PPC.h
U    lib/Target/ARM/ARMTargetMachine.cpp
U    lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
U    lib/Target/ARM/ARMTargetMachine.h
U    lib/Target/ARM/ARM.h
U    lib/Target/XCore/XCoreTargetMachine.cpp
U    lib/Target/XCore/XCoreTargetMachine.h
U    lib/Target/PIC16/PIC16TargetMachine.cpp
U    lib/Target/PIC16/PIC16TargetMachine.h
U    lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
U    lib/Target/Alpha/AlphaTargetMachine.cpp
U    lib/Target/Alpha/AlphaTargetMachine.h
U    lib/Target/X86/X86TargetMachine.h
U    lib/Target/X86/X86.h
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
U    lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
U    lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
U    lib/Target/X86/X86TargetMachine.cpp
U    lib/Target/MSP430/MSP430TargetMachine.cpp
U    lib/Target/MSP430/MSP430TargetMachine.h
U    lib/Target/CppBackend/CPPTargetMachine.h
U    lib/Target/CppBackend/CPPBackend.cpp
U    lib/Target/CBackend/CTargetMachine.h
U    lib/Target/CBackend/CBackend.cpp
U    lib/Target/TargetMachine.cpp
U    lib/Target/IA64/IA64TargetMachine.cpp
U    lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
U    lib/Target/IA64/IA64TargetMachine.h
U    lib/Target/IA64/IA64.h
U    lib/Target/MSIL/MSILWriter.cpp
U    lib/Target/CellSPU/SPUTargetMachine.h
U    lib/Target/CellSPU/SPU.h
U    lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
U    lib/Target/CellSPU/SPUTargetMachine.cpp
U    lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
U    lib/Target/Mips/MipsTargetMachine.cpp
U    lib/Target/Mips/MipsTargetMachine.h
U    lib/Target/Mips/Mips.h
U    lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
U    lib/Target/Sparc/SparcTargetMachine.cpp
U    lib/Target/Sparc/SparcTargetMachine.h
U    lib/ExecutionEngine/JIT/TargetSelect.cpp
U    lib/Support/TargetRegistry.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 20:24:03 +00:00
Dan Gohman
a1bdcedc38 Add a Force option to raw_fd_ostream to specify whether opening
an existing file is considered an error. Convert several tools
to use raw_fd_ostream instead of std::ostream, and to use this
new option instead of doing a manual check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75801 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 17:29:42 +00:00
Stuart Hastings
2286f8dc4c Revert 75762, 75763, 75766..75769, 75772..75775, 75778, 75780, 75782 to repair broken LLVM-GCC build.
Will revert 75770 in the llvm-gcc trunk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75799 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 17:27:11 +00:00
Dan Gohman
d890de10af Add a raw_ostream version of CheckBitcodeOutputToConsole.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 17:04:50 +00:00
Dan Gohman
d3a974fc20 Check for errors on close(2) too. And lseek(2).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 16:43:01 +00:00
Dan Gohman
9f79d3ea50 Use 0664 instead of 0644 for the default open mode. This is
consistent with common std::ostream implmentations, and it gives
the user the option of using the umask group write bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 16:39:40 +00:00
Daniel Dunbar
3fb7eee9c2 Allow multiple registrations of the same target.
- This doesn't necessarily seem like a good idea, but the JIT unittest
   currently relies on it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75769 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 10:32:44 +00:00
Daniel Dunbar
579fb87ce7 Detect write failures on raw_fd_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 08:11:46 +00:00
Daniel Dunbar
f23d4930bd Fix stupid thinko
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75754 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 07:37:49 +00:00
Daniel Dunbar
73b3ec4134 Address some review comments on TargetRegistry.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75753 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 07:09:29 +00:00
Ted Kremenek
51381d25af Update CMake file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75746 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 05:39:55 +00:00
Daniel Dunbar
bb06129140 Add new TargetRegistry.
Targets implement a single global Target structure which will live in a new
<Target>/TargetInfo library; this will be present in any image which the target
is usable in.
 - Optional target specific classes can then be registered and attached to the
   Target description.

 - Registration for normal Targets will be done via the initialization functions
   instead of using static constructors.

 - This allows clients to use a single interface to obtain target data, without
   requiring the code generator be linked in. It also provides a natural
   extension point for adding new optional target data (assembler parser,
   disassembler, etc.).

 - This also provides a new entry point for obtaining a target for a particular
   triple (without a module).

 - Not yet used, however this should eventually replace the TargetMachineRegistry.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 04:24:58 +00:00
Chris Lattner
1f318e00ba minor syntax cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75707 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 23:14:10 +00:00
Ted Kremenek
d84ba34daa Update CMake file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75677 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 20:44:17 +00:00
David Greene
71847813bc Have asm printers use formatted_raw_ostream directly to avoid a
dynamic_cast<>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 20:18:05 +00:00
Torok Edwin
c23197a26f llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 16:55:14 +00:00
Torok Edwin
93990d775e After converting assert(0) to LLVM_UNREACHABLE we lost file/line location.
Fix by making the LLVM_UNREACHABLE pass __FILE__ and __LINE__ to
llvm_unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75631 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 12:49:22 +00:00
Chris Lattner
b8ac841c9a Add NetBSD to the Triple class, patch by Krister Walfridsson!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75489 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 20:22:23 +00:00
David Greene
191cf2851b Make some more changes suggested by Chris. Manipulators go away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75472 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 16:49:27 +00:00
Daniel Dunbar
a53902b258 Switch to raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 05:27:30 +00:00
Nick Lewycky
780905e9f9 Fix an error in ConstantRange::getSignedMax on wrapped ranges. Thanks once
again to Daniel Dunbar and KLEE!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75449 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 04:50:21 +00:00
Nick Lewycky
ff84de767a 'i8 full-range' sign extended to i16 should equal [-128, 128) not [-128, 127).
Found by Daniel Dunbar and KLEE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75448 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 04:17:23 +00:00
Nick Lewycky
f1db120d04 Multiply was very wrong for wrapped ranges. This supplies a half-fix that will
generally return Full on all wrapped inputs. "Fixes" PR4545.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75444 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 03:27:41 +00:00
Nick Lewycky
cf9e07dea8 Fix a bug summing two full sets. The overflow checking doesn't handle sets as
large as the full set, only those one size smaller. Thanks to Daniel Dunbar
who found this bug using Klee!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75443 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 02:49:08 +00:00
Daniel Dunbar
a00e85c9b1 Improve sys::Path::makeAbsolute on Win32.
- Patch by Viktor Kutuzov!

 - Minor tweak by me to add llvm_unreachable calls on FIXMEd error paths.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 20:23:56 +00:00
Nick Lewycky
956daf0f7f Implement udiv for ConstantRanges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75413 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 05:18:18 +00:00
Nick Lewycky
2ff893f486 Implement ConstantRange::multiply based on the code in LoopVR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75410 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 02:19:05 +00:00
Torok Edwin
c25e7581b9 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 20:10:48 +00:00
Nick Lewycky
646ca92bfc Fix handling of max and full set.
A full set is a constant range that represents any number. If you take the
umax of that and [5, 10) you end up with [5, INT_MAX] because the values less
than 5 would be umax's against a value which is at least 5.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 19:22:21 +00:00
Nick Lewycky
f067a23356 Clarify and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 17:04:01 +00:00
Torok Edwin
7d696d8040 Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75363 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 13:10:19 +00:00
Nick Lewycky
bf8c7f0adf Move a method that creates constant ranges relative to another constant range
per icmp predicate out of predsimplify and into ConstantRange.

Add another utility method that determines whether one range is a subset of
another. Combine with the former to determine whether icmp pred range, range
is known to be true or not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 06:15:39 +00:00
David Greene
62fe47a337 Make changes suggested by Chris and eliminate newly-added raw_ostream
hooks as they're no longer needed.

The major change with this patch is to make formatted_raw_ostream usable
by any client of raw_ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 21:14:44 +00:00
David Greene
53674361ef Add some hooks that a redesigned AsmStream needs to do its job. These
allow derived classes to examine the stream buffer before it's flushed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 23:43:41 +00:00
Dan Gohman
38b0644761 Revert the part of 75177 that split ConstantRange into two classes, and
merge the new functionality and unittests into ConstantRange. Thanks to
Nick Lewycky for pointing out that it isn't necessary to have two separate
classes here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75191 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 23:16:10 +00:00
Dan Gohman
a3755d8d36 Add a ConstantSignedRange class, which does for signed integers
what ConstantRange does for unsigned integers. Factor out a
common base class for common functionality.

Add some new functions for performing arithmetic on constant
ranges. Some of these are currently just stubbed out with
conservative implementations.

Add unittests for ConstantRange and ConstantSignedRange.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 22:07:27 +00:00
David Greene
00ad26ff57 Add support for other GraphViz display tools. This can help
with very large graphs, where dot isn't necessarily the 
most visually pleasing way of looking at the graph.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75144 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 17:06:18 +00:00
David Greene
229509a8bc Allow users of GraphWriter to display graphs asynchronously. This
provides a way to quickly dump a bunch of graph information to dot files
and display them.  It's a timesaver when working on large systems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75056 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 21:53:41 +00:00
Mike Stump
d33007eb5f Fix build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 18:52:14 +00:00
Owen Anderson
a9d1f2c559 Have scoped mutexes take referenes instead of pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74931 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 18:33:04 +00:00
Torok Edwin
f361238a93 Fix braces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 17:39:53 +00:00
Torok Edwin
31e2466f15 Introduce new error handling API.
This will replace exit()/abort() style error handling with an API
that allows clients to register custom error handling hooks.
The default is to call exit(1) when no error handler is provided.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74922 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 17:32:34 +00:00
Chris Lattner
eeb4a84ac8 switch the .ll parser to use SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74735 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 23:08:13 +00:00
Chris Lattner
2f510aed9c add an explicit class for holding llvm::SourceMgr diagnostics and use
it to print them.  This gives us column numbers in the diag line.  Before:

t.s:4: error: unexpected token in argument list
 mov %eax %edx
          ^

now:
t.s:4:11: error: unexpected token in argument list
 mov %eax %edx
          ^



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74732 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 22:24:20 +00:00
Daniel Dunbar
74a81813c2 Tweak FindExecutable so that relative executable paths work as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 21:36:28 +00:00
Daniel Dunbar
93696a38b7 Fix FindExecutable to work if given an absolute executable path name.
- Patch by Viktor Kutuzov, with tweaks by me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74608 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 15:26:13 +00:00
Dan Gohman
38a253ddf7 Reapply 74494, this time removing the conflicting definition of operator<<
in APIntTest.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 20:10:56 +00:00
Bill Wendling
527b6e6292 Temporarily revert r74494. It was causing failures in the unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74515 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 07:05:27 +00:00
Owen Anderson
5ec56cc438 Fix the build on Cygwin. Patch by Aaron Gray.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 05:33:46 +00:00
Dan Gohman
670031666c Define an operator<< for APInt to be used with std::ostream.
This will allow it to be used in unittests that use gtest's
EXPECT_EQ.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74494 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 01:28:08 +00:00
Daniel Dunbar
3fb7683bec Normalize SourceMgr messages.
- Don't print "Parsing" in front of every message.

 - Take additional "type" argument which is prepended to the message (with ": ")
   if given.

 - Update clients to print errors (warnings) as:
<filename>:<line number>: error(warning): ...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74489 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 00:49:23 +00:00
Duncan Sands
cd1267d2d6 Add triple for OpenBSD.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-29 13:36:13 +00:00
Owen Anderson
cb73734247 Use atomic operations for accessing this global counter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74294 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 18:09:03 +00:00
Douglas Gregor
8947881444 Fix linking of llvm-ld and lli with CMake, from Xerxes Rånby
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74285 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 15:37:00 +00:00
Owen Anderson
0b49c32c56 Support thread-local pretty stack traces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74227 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 23:31:33 +00:00
Owen Anderson
92915e31e9 Use atomic operations when accessing statistics, and make the lazy initialization of statistics actually threadsafe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74005 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 21:19:38 +00:00
Owen Anderson
46d9a64944 Make timers threadsafe again. This isn't quite as nice as I'd hoped (it uses locking rather than atomic arithmetic),
but should work on all the platforms we care about.

I might revisit this if a totally awesome way to do it occurs to me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 20:52:29 +00:00
Owen Anderson
6f2c64d70a Revert my last series of commits related to Timer and 64-bit atomics. Not all the targets
we care about are capable of supporting it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73993 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 20:17:22 +00:00
Lang Hames
b2889959c4 Switched size_t to int64_t to prevent type mismatch in call to max.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73988 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 19:49:23 +00:00
Owen Anderson
14112e5169 Actually, these need to be signed integers, not unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73978 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 18:21:13 +00:00
Owen Anderson
cd92c1000e Use 64-bit integer counters for tracking time, rather than doubles. This will be more atomic op friendly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 18:12:30 +00:00
Owen Anderson
3b8d135879 Make the lazy initialization of DefaultTimerGroup threadsafe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73963 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 17:33:37 +00:00
Owen Anderson
200aa6d89b Revert r73923, which broke clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73957 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 16:36:10 +00:00
Owen Anderson
61ffc0c7fd Guard the plugin loader.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73925 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 00:02:39 +00:00
Owen Anderson
af2e2b54b6 Add guards around timer groups, which can be shared.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 23:37:06 +00:00
Owen Anderson
5de83afcdc Guard the statistics table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 23:08:27 +00:00
Owen Anderson
521db56182 Guard the global annotation tables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 22:44:15 +00:00
Chris Lattner
14ee48a5ba rename SourceMgr::PrintError to PrintMessage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73861 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 21:22:11 +00:00
Chris Lattner
7ee5d5f97b move include searching logic from TGLexer to SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 05:06:04 +00:00
Chris Lattner
8070ea3f06 Rename TGSourceMgr -> SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 03:41:50 +00:00
Chris Lattner
1e3a8a4924 rename TGLoc -> SMLoc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73843 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 03:39:35 +00:00
Chris Lattner
099e198ae8 move TGSourceMgr class out of TableGen into libsupport.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73842 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 03:36:54 +00:00
Duncan Sands
852cd112ed Add support for AuroraUX. Patch by evocallaghan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73766 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 14:40:01 +00:00
Ted Kremenek
e53118ea32 Update CMake files to account for new location of Threading.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73708 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 17:47:09 +00:00
Owen Anderson
e3cd5ca7e7 Move Threading.[h|cpp] from Support to System.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73707 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:54:52 +00:00
Owen Anderson
1cca27ebb6 Add newline at end of file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 20:53:09 +00:00
Douglas Gregor
dd0ae752ed Add Threading.cpp to the CMake project files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73516 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 17:45:38 +00:00
Owen Anderson
4c7ac18fc9 Split the thread-related APIs out into their own file, and add a few more
calls for convenience.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73512 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 17:33:51 +00:00
Torok Edwin
e8ebb0fe1b Add support for outputting ANSI colors to raw_fd_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72854 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 07:09:50 +00:00
Mike Stump
c5ca713b80 Add support for letting the client choose different flavors of NaNs. Testcase to be
added in clang.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72606 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 03:49:43 +00:00
Bill Wendling
51b16f4737 Untabification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72604 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 01:09:53 +00:00
Douglas Gregor
0d09b83a48 Minor fix for CMake build system
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 16:52:17 +00:00
Daniel Dunbar
7eaf057e54 Add llvm::triple constructor from arch, vendor, os strings, and recognize
DragonFly OS type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 02:24:11 +00:00
Evan Cheng
cf69a743b7 80 column violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 23:47:47 +00:00
Owen Anderson
6afe2fa288 Have llvm_start_multithreaded return a bool indicating whether multithreaded
initialization succeeded or not, rather than just asserting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72182 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 21:03:06 +00:00
Owen Anderson
b4d97b78df Add llvm_start_multithreaded(), which starts up the LLVM internals in thread-safe mode. Provide double-check locking
initialization of ManagedStatic's when running in thread-safe mode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72151 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 00:39:20 +00:00
Eli Friedman
96cd7af935 Tweak MemoryBuffer::getSTDIN so that it returns after the first EOF.
It doesn't matter for piped input, but it's annoying when typing at the 
console.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 08:44:04 +00:00
Mike Stump
8cf6571ec0 Add dumping support for DW_AT_APPLE_isa and DW_AT_APPLE_block.
Radar 6867696


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 00:03:51 +00:00
Mike Stump
f3dc0c048a Fix whitespacing (space after switch).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71738 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 23:23:20 +00:00
Jay Foad
4e5ea553d0 Move helper functions for optimizing division by constant into the APInt
class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70488 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 10:15:35 +00:00
Bill Wendling
b587f9662a Add support for a character after a command line option. Like '-Os'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70437 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 23:26:16 +00:00
Chris Lattner
38300e91f5 Fix PR4040: APInt's string constructor is too strict
patch by Jeff Yasskin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 18:34:04 +00:00
Douglas Gregor
8f7be4731e Make all raw_ostreams support the tell() function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69583 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-20 07:34:17 +00:00
Chris Lattner
d7fd2126c2 teach EscapeString and UnescapeString to handle ".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 20:12:52 +00:00
Chris Lattner
00a7b52385 Remove AllowInverse: it leaks memory and is not the right
abstraction for CommandLine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68588 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 03:43:51 +00:00
Mikhail Glushenkov
7074875642 Fix build on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68269 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 01:11:37 +00:00
Daniel Dunbar
23e97b05da Add llvm::Triple class for abstracting access to target triples.
- The code is silly, I'm just amusing myself. Rewrite to be efficient
   if you like. :)

Also, if you wish to debate the proper names of the triple components
I'm all ears.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 21:53:23 +00:00
Dan Gohman
de551f91d8 Use CHAR_BIT instead of hard-coding 8 in several places where it
is appropriate. This helps visually differentiate host-oriented
calculations from target-oriented calculations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68227 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 18:45:54 +00:00
Misha Brukman
d485e885f0 * Fixed spelling of `invertible'
* Simplified if statement


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 00:15:46 +00:00
Chris Lattner
e8b64106ec move a large method out of line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-28 02:08:47 +00:00
Dale Johannesen
1b25cb2416 Fix internal representation of fp80 to be the
same as a normal i80 {low64, high16} rather
than its own {high64, low16}.  A depressing number
of places know about this; I think I got them all.
Bitcode readers and writers convert back to the old
form to avoid breaking compatibility.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 21:16:53 +00:00
Dan Gohman
f871ccb853 Now that errs() is properly non-buffered, there's no need to
explicitly flush it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67526 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 15:57:19 +00:00
Duncan Sands
bf5836b075 Fix comment typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67302 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 11:37:15 +00:00
Daniel Dunbar
b372c1114c Add BUILTIN_EXPECT Support/Compiler macro.
- Use for exceptional buffer conditions in raw_ostream:write to shave
   off a cycle or two.

 - Please rename if you have a better one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67103 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 21:15:18 +00:00
Daniel Dunbar
262541b074 raw_ostream: Put all exceptional conditions in raw_ostream::write
under a single branch.

Also, add a FIXME for formatted output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67069 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 01:36:56 +00:00
Daniel Dunbar
d17d74bb80 raw_ostream: Rework implementation of unbuffered streams so outputting
a single character requires only one branch to follow slow path.
 - Never use a buffer when writing on an unbuffered stream.

 - Move default buffer size to header.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 01:13:35 +00:00
Daniel Dunbar
89a66a96fe raw_ostream: Replace flush_impl with write_impl, which takes data to
write as arguments.
 - Add raw_ostream::GetNumBytesInBuffer.
 - Privatize buffer pointers.
 - Get rid of slow and unnecessary code for writing out large strings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 23:29:31 +00:00
Daniel Dunbar
cf2a2c6a26 raw_ostream: Lift out flush_nonempty.
- Flush a known non-empty buffers; enforces the interface to
   flush_impl and kills off HandleFlush (which I saw no reason to be
   an inline method, Chris?).

 - Clarify invariant that flush_impl is only called with OutBufCur >
   OutBufStart.

 - This also cleary collects all places where we have to deal with the
   buffer possibly not existing.

 - A few more comments and fixing the unbuffered behavior remain in
   this commit sequence.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67057 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 22:55:06 +00:00
Daniel Dunbar
b451a0cdec Make raw_ostream::operator<<(const void *) fast; it doesn't matter but
it is easy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67054 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 22:08:44 +00:00
Daniel Dunbar
de75d7ffcd Add slow path for single character write, and use exclusively for
single characters writes outside of the fast path in raw_ostream.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 22:00:17 +00:00
Stuart Hastings
d52ec65b6d Fix a hashing bug in APInt. A certain pathological testcase (too
large for the testsuite) took over six minutes to compile on my Mac.
The patched LLVM-GCC compiles that testcase in three seconds (GCC
takes less than one second).  This hash function is more complex
(about 35 instructions on x86) than what Chris wanted, but I expect it
will be well-behaved with arbitrary inputs.

Thank you to everyone who responded to my previous request for advice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:51:13 +00:00
Chris Lattner
ee167a729e just initialize the first element, we don't need to set the rest to zeros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 00:24:01 +00:00
Chris Lattner
807926a945 Eliminate a 9640 byte static mutable initialized data item by moving it
to the stack.  This shrinks all llvm tools by 9k, and improves reentrancy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 00:03:51 +00:00
Chris Lattner
e213f3f972 static functions don't need an anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 23:59:55 +00:00
Daniel Dunbar
e77e434bc9 PR3478: raw_ostream should not buffer stderr
- Add unbuffered flag to raw_ostream, forwarded by raw_fd_ostream and
   used by raw_stderr_ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66545 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 16:21:55 +00:00
Dan Gohman
c7ffc9efd6 Use c_str() to force the string to be nul-terminated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66279 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 18:13:15 +00:00
Chris Lattner
49155ffaba on apple systems, integrate nicely with crash reporter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 07:19:54 +00:00
Duncan Sands
30a31ebf7f Add missing file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66160 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 09:19:13 +00:00
Chris Lattner
d56786f79a Daniel wanted the stack printed upside down. Perhaps he
feels a kinship to machine stacks that grow down.  Now we get
stuff like this:

Stack dump:
0.	Program arguments: clang clang_crash_Iw2Osj.mi 
1.	/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/xmmintrin.h:624:1: parsing function body '_mm_cvtpi16_ps'
2.	/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/xmmintrin.h:624:1: in compound statement ('{}')
Abort



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66145 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 07:03:49 +00:00
Chris Lattner
fcba7cd630 indicate what the program args line is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66144 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 06:51:42 +00:00
Chris Lattner
e97c733541 add some helper classes for building light-weight symbolic stack traces
that get printed when a program crashes.  This is the first step of many.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66076 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 21:40:23 +00:00
Devang Patel
13319ceffd The debugger sometimes lookup dynamically in the runtime to find ivar info of any Objective-C classes. It would be very helpful to debugger if the compiler encodes runtime version number in DWARF.
Add support for two additional DWARF attributes to encode Objective-C runtime version number.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64834 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 22:43:44 +00:00
Cedric Venet
aff9c270de Unbreak the build on win32.
Cleanup some warning.

Remark: when struct/class are declared differently than they are defined, this make problem for VC++ since it seems to mangle class differently that struct. These error are very hard to understand and find. So please, try to keep your definition/declaration in sync.

Only tested with VS2008. hope it does not break anything. feel free to revert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64554 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 16:06:42 +00:00
Evan Cheng
e2b3fdd649 Switch from new[] + delete[] to malloc + free since llvm does not catch C++ exceptions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64448 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 08:24:55 +00:00
Evan Cheng
726135ad1a If new[] fails, return 0 rather then trying to dereference a null pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64444 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 07:54:34 +00:00
Nick Lewycky
f996831427 Add an API for strings with possible NULLs in the middle. Refactor the other
two AddString methods to use it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64005 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 04:57:08 +00:00
Mike Stump
d64e0eb094 Improve -fno-opt style option processing to not require an extra
option to make the -fno- form on the option.  We also document the new
form in the CommandLine documentation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 22:48:49 +00:00
Mike Stump
d6f175b3ec Add opposite_of and inverse_opt to support -fno- style options. This
is necessary for eventual gcc commmand line compatibility.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63384 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-30 08:19:46 +00:00
Mikhail Glushenkov
6c55b1ca7b Clarify comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63171 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 03:46:22 +00:00
Torok Edwin
2d0f1c57c3 APInt's countLeadingOnes() was broken for negative i128 values,
causing assertion failures in getSExtValue().
Fix it by making highWordBits actually contain what its name says,
and add some more unit-tests for APInt.
This fixes PR3419.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63107 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 18:06:03 +00:00
Ted Kremenek
9c27886dd5 Add method raw_fd_ostream::seek() for random access within a file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 21:42:04 +00:00
Devang Patel
3b64c6bc29 Introduce two DWARF attribute extentions DW_AT_APPLE_optimized, DW_AT_APPLE_flags.
DW_AT_APPLE_optimized flag is set when a compile_unit is optimized. The debugger takes advantage of this information some way.

DW_AT_APPLE_flags encodes command line options when certain env. variable is set. This is used by build engineers to track various gcc command lines used by by  a project, irrespective of whether the project used makefile, Xcode or something else.

llvm-gcc patch is next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62888 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 22:33:47 +00:00
Dale Johannesen
541ed9fd02 Do not use host floating point types when emitting
ASCII IR; loading and storing these can change the
bits of NaNs on some hosts.  Remove or add warnings
at a few other places using host floating point;
this is a bad thing to do in general.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62712 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 20:32:55 +00:00
Chris Lattner
455e9abf36 Remove uses of uint32_t in favor of 'unsigned' for better
compatibility with cygwin.  Patch by Jay Foad!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62695 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 18:09:24 +00:00
Mikhail Glushenkov
1421b7bc23 Mimic gcc behaviour with regard to response files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 13:14:02 +00:00
Dale Johannesen
ed6af24e14 Make special cases (0 inf nan) work for frem.
Besides APFloat, this involved removing code
from two places that thought they knew the
result of frem(0., x) but were wrong.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 00:35:19 +00:00
Dale Johannesen
24b66a83ca Add an IEEE remainder function, which is not
fully implemented yet and not used.  This is
mainly to clarify that APFloat::mod implements
C fmod, not remainder.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62593 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-20 18:35:05 +00:00
Chris Lattner
ccb3ab46f6 improve compatibility with various versions of graphviz, patch by
Patrick Boettcher!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62592 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-20 18:25:03 +00:00
Dale Johannesen
1f54f58e64 compile-time fmod was done incorrectly. PR 3316.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62528 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 21:17:05 +00:00
Nick Lewycky
4bd4787785 Fix typo, sentence fragment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62512 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 17:42:33 +00:00
Mikhail Glushenkov
7059d47a6e Support for multi-valued options in CommandLine
Makes possible to specify options that take multiple arguments (a-la
-sectalign on Darwin). See documentation for details.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 22:54:19 +00:00
Misha Brukman
9b8f542e27 Removed trailing whitespace from Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 16:44:42 +00:00
Steve Naroff
1f33f8e4cc Tweak --version to include the date and time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61378 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 18:41:47 +00:00
Nuno Lopes
34283c8303 remove unused var
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60770 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 17:04:06 +00:00
Nick Lewycky
28ea4f6c07 Fixes for Visual Studio users. Patch by OvermindDL1 on llvm-dev!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60679 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 00:45:02 +00:00
Ted Kremenek
d75ba1c357 Have raw_fd_ostream keep track of the position in the file to make tell() go faster by not requiring a flush().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60560 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 22:51:11 +00:00
Nuno Lopes
440954c64b fix build on some machines. thanks buildbot
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60175 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 16:42:44 +00:00
Nuno Lopes
4ba9aac839 fix my previous commit r60064: compare strings instead of pointers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60174 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 16:37:02 +00:00
Bill Wendling
b7c0d94465 Get rid of bogus "control may reach end of non-void function ‘...’ being
inlined" message.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60165 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 08:00:12 +00:00
Ted Kremenek
5984680c1f Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60085 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 03:33:13 +00:00
Evan Cheng
794a7dbce0 Revert r60042. IndVarSimplify should check if APFloat is PPCDoubleDouble first before trying to convert it to an integer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 01:11:57 +00:00
Nuno Lopes
08d67c7763 change AnnotationManager to use 'const char*' instead of std::string. this fixes the leakage of those strings and avoids the creation of such strings in static cosntructors (should result in a little improvement of startup time)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60064 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 00:00:44 +00:00
Evan Cheng
88f2d6c167 convertToSignExtendedInteger should return opInvalidOp instead of asserting if sematics of float does not allow arithmetics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 19:00:29 +00:00
Daniel Dunbar
0d9eb9b491 Add Binary flag to raw_fd_ostream constructor.
Document raw_fd_ostream's treatment of "-".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59219 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 05:01:07 +00:00
Dan Gohman
20cd13f54f Overload AddInteger on int/long/long long instead of on int/int64_t,
to avoid overload ambiguities. This fixes build errors introduced
by r58623.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03 19:40:18 +00:00
Chris Lattner
f61ca1eeda fix PR2953, an off-by-one error handling formatted i/o.
Thanks to Török Edwin for the awesome reduced testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58199 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 19:20:47 +00:00
Ted Kremenek
43d1f02b54 Added raw_fd_ostream::close().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58052 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-23 23:49:09 +00:00
Julien Lerouge
e7d3af5473 Fix for PR2881: fix a small leak exposed by valgrind, using a ManagedStatic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57984 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 16:30:41 +00:00
Daniel Dunbar
48534b31d8 Clear raw_fd_ostream error string on success and explain behavior in
documentation.

Add C++ header marker.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57923 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21 19:53:10 +00:00
Dan Gohman
b8cab9227a Fix command-line option printing to print two spaces where needed,
instead of requiring all "short description" strings to begin with
two spaces. This makes these strings less mysterious, and it fixes
some cases where short description strings mistakenly did not
begin with two spaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-14 20:25:08 +00:00
Dale Johannesen
51b7f8268b Change TAG_ names to DW_TAG for gcc (testsuite) compatibility.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57425 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 21:23:01 +00:00
Dale Johannesen
ba0fb07156 Change Dwarf comments starting with AT_ to DW_AT_ to
match gcc.  Helps with the testsuite.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57410 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 06:20:47 +00:00
Chris Lattner
119c30b955 rearrange some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57384 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-11 22:07:19 +00:00
Dale Johannesen
23a98551ab Add a "loses information" return value to APFloat::convert
and APFloat::convertToInteger.  Restore return value to
IEEE754.  Adjust all users accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57329 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-09 23:00:39 +00:00
Dale Johannesen
7111b02c73 Rename APFloat::convertToAPInt to bitcastToAPInt to
make it clearer what the function does.  No functional
change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57325 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-09 18:53:47 +00:00
Dale Johannesen
e4a4245906 Mark negative-zero-to-int conversion as Inexact,
since -0.0 can't be represented as an int.
This prevents llvm from reducing -0.0 to a
load-and-convert of int 0.  Fixes
ieee.exp/mzero[2356].c in gcc testsuite.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 00:40:01 +00:00
Dale Johannesen
2df5eec2ff Be more precise about which conversions of NaNs
are Inexact.  (These are not Inexact as defined
by IEEE754, but that seems like a reasonable way
to abstract what happens:  information is lost.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57218 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 22:59:10 +00:00
Dale Johannesen
65609f2efa Temporarily revert functionality change from my previous patch;
it is too aggressive.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57203 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 20:43:48 +00:00
Dale Johannesen
d3d8ce3aba Mark shortening NaN conversions as Inexact. PR 2856.
Improve description of unsupported formats.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57185 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 18:22:29 +00:00
Oscar Fuentes
3d01fc7de8 Initial support for the CMake build system.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56419 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-22 01:08:49 +00:00
Cedric Venet
a3f343f4cd Updating VC++ project.
Adding one include file and correct one declaration from class to struct in order to make llvm compile on VC2005.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-24 11:56:40 +00:00
Chris Lattner
78a2812538 Add raw_stream adaptors that write into an std::string and SmallVector/SmallString.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 22:43:04 +00:00
Chris Lattner
944fac71e0 Switch the asmprinter (.ll) and all the stuff it requires over to
use raw_ostream instead of std::ostream.  Among other goodness,
this speeds up llvm-dis of kc++ with a release build from 0.85s
to 0.49s (88% faster).

Other interesting changes:
 1) This makes Value::print be non-virtual.
 2) AP[S]Int and ConstantRange can no longer print to ostream directly, 
    use raw_ostream instead.
 3) This fixes a bug in raw_os_ostream where it didn't flush itself 
    when destroyed.
 4) This adds a new SDNode::print method, instead of only allowing "dump".


A lot of APIs have both std::ostream and raw_ostream versions, it would
be useful to go through and systematically anihilate the std::ostream 
versions.

This passes dejagnu, but there may be minor fallout, plz let me know if
so and I'll fix it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55263 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 22:23:09 +00:00
Chris Lattner
42f77ab95a add #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55252 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 20:34:06 +00:00
Chris Lattner
097af7fc8f add a simple mechanism for formatted output. This gives raw_ostream's
all the power and risk of fprintf format strings.  Use them like this:

  OS << format("%10.4f", 42.0) << "\n" << format("%x", 42) << '\n';



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55246 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 19:23:10 +00:00
Dan Gohman
535de1a8c1 Add a clear() method to FoldingSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55210 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 00:42:16 +00:00
Chris Lattner
969a46a948 improve support for systems that need unistd.h to get STDOUT_FILENO.
Patch contributed by Bjorn Reese!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55179 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 15:45:00 +00:00
Owen Anderson
fd2a05332a Fix write() when the string being written is larger than the buffer. This broke various ObjC testcases
with very long symbol names.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55148 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-21 22:39:33 +00:00
Owen Anderson
66b17ba0d2 Move non-trivial methods out of line to avoid code-size bloat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-21 20:58:52 +00:00
Owen Anderson
cb37188323 Use raw_ostream throughout the AsmPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-21 00:14:44 +00:00
Chris Lattner
98f8ccfad0 Move the fast-path (<=i64) cases of various APInt methods inline
and the slow-path cases out of line.  This speeds up instcombine
a bit in real world cases.  Patch contributed by m-s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55063 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 17:02:31 +00:00
Dan Gohman
eace52f12d It's not necessary to check if a value is null before delete[].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55053 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 14:55:37 +00:00
Argyrios Kyrtzidis
b68dc369e0 Get raw_ostream.cpp to compile on MSVC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54879 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 09:25:21 +00:00
Chris Lattner
fad86b003a Rework the routines that convert AP[S]Int into a string. Now, instead of
returning an std::string by value, it fills in a SmallString/SmallVector
passed in.  This significantly reduces string thrashing in some cases.

More specifically, this:
 - Adds an operator<< and a print method for APInt that allows you to 
   directly send them to an ostream.
 - Reimplements APInt::toString to be much simpler and more efficient
   algorithmically in addition to not thrashing strings quite as much.

This speeds up llvm-dis on kc++ by 7%, and may also slightly speed up the
asmprinter.  This also fixes a bug I introduced into the asmwriter in a
previous patch w.r.t. alias printing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54873 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 07:19:36 +00:00
Chris Lattner
9f17eb0b79 remove a dead APInt ctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54869 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 04:58:58 +00:00
Chris Lattner
07f51f788e add support for a cout/cerr analog (outs()/errs()) as well as
a simple adaptor class to give raw output capabilities to 
something that wants to write to an ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54865 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 04:13:37 +00:00
Chris Lattner
c52b128e1a opening "-" automatically yields stdout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54863 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 03:53:23 +00:00
Chris Lattner
d497df5cf5 rename OutputData to 'write' to match ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54857 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 01:46:05 +00:00
Chris Lattner
60d3962624 add a new raw_ostream class which is an extremely high performance ostream that
can *only* output data (no seeking, reading, etc).  This is adapted from the
clang "-E outputter", and is roughly 10% faster than stdio on darwin and 30%
(or more) faster than std::ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54855 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 01:35:29 +00:00
Dan Gohman
ee4bd9a5b4 Avoid repeatedly reallocating the FoldingSetNodeID when searching
through multiple nodes in a bucket.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-12 17:40:22 +00:00
Dan Gohman
430b8a22e2 Fix several const-correctness issues, resolving some -Wcast-qual warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 14:45:15 +00:00
Dan Gohman
fed90b6d09 Fold the useful features of alist and alist_node into ilist, and
a new ilist_node class, and remove them. Unlike alist_node,
ilist_node doesn't attempt to manage storage itself, so it avoids
the associated problems, including being opaque in gdb.

Adjust the Recycler class so that it doesn't depend on alist_node.
Also, change it to use explicit Size and Align parameters, allowing
it to work when the largest-sized node doesn't have the greatest
alignment requirement.

Change MachineInstr's MachineMemOperand list from a pool-backed
alist to a std::list for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54146 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-28 21:51:04 +00:00
Wojciech Matyjewicz
de0f2382e4 Fix PR2088. Use modulo linear equation solver to compute loop iteration
count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53810 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-20 15:55:14 +00:00
Dan Gohman
5e84368b26 Reapply 53476 and 53480, with a fix so that it properly updates
the BB member to the current basic block after emitting
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53567 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 18:19:29 +00:00
Evan Cheng
b5eec33dcd Back out 53476 and 53480 for now. Somehow they cause llc to miscompile 179.art.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-12 01:38:51 +00:00
Dan Gohman
dbe2a5a269 Add support for putting NamedRegionTimers in TimerGroups, and
use a timer group for the timers in SelectionDAGISel. Also,
Split scheduling out from emitting, to give each their own
timer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53476 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 21:54:34 +00:00
Dan Gohman
c418bf3dd5 Use find instead of lower_bound.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53474 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 20:58:19 +00:00
Dan Gohman
e14d81deeb Add some basic Pool-allocation infrastructure. This adds a Recycler class,
for handling bookkeeping for deleted objects, as well as the alist class
template, for keeping lists of objects allocated from Recyclers, and some
related utilities.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53210 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 22:58:06 +00:00
Owen Anderson
72e61b8501 Add a version of AddString that takes a const char* so we can avoid extraneous
conversions to std::string.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-01 23:49:59 +00:00
Dan Gohman
153d28a414 Append to the ActiveTimers std::vector before looking at the timer instead
of after, so that any reallocation it does doesn't get counted for the pass
being timed.  This probably doesn't account for a timing discrepancy I was
looking into, but I'm fixing it anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52693 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 22:07:07 +00:00
Wojciech Matyjewicz
300c6c5167 First step to fix PR2088. Implement routine to compute the
multiplicative inverse of a given number. Modify udivrem to allow input and 
output pairs of arguments to overlap. Patch is based on the work by Chandler
Carruth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 19:39:50 +00:00
Dan Gohman
95df6b3603 Avoid creating a redundant zero APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52602 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 22:03:12 +00:00
Ted Kremenek
8d6a58c5d5 Consistently set "Buckets[NumBuckets] = reinterpret_cast<void*>(-1)" throughout FoldingSet.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52425 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 19:12:43 +00:00
Zhou Sheng
bfde7d6b9e As comments said, for negative value, the arithmetic
over-shift-right should return -1. So here it should be signed-extended,
when bitwidth larger than 64.

test case: llvm/test/ExecutionEngine/2008-06-05-APInt-OverAShr.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51999 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 13:27:38 +00:00
Matthijs Kooijman
33540adca5 Give a proper error message when a command line option is defined more than
once (ie, at two different places in the source, not two times on the
commandline).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 13:26:11 +00:00
Bill Wendling
eecfa369eb Remove more iostream header includes. Needed to implement a "FlushStream"
function to flush a specified std::ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51705 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 21:46:33 +00:00
Dan Gohman
7edd009efe Tidy up whitespace in ConstantRange::print output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51606 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 20:29:07 +00:00
Dale Johannesen
386f3e9d50 Don't assume underlying APInt type is limited
to 64 bits.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51135 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 22:53:25 +00:00
Dale Johannesen
6a33cc12eb Remove undefined behavior in hex string->APFloat
conversion.  Try 0x1.0000a4p+0f.  Neil, please review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51132 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 22:05:31 +00:00
Dan Gohman
844731a7f1 Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51017 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 00:00:25 +00:00
Dan Gohman
7c2e4f2fc5 Make firstEightPowers const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50975 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-12 16:38:14 +00:00
Dan Gohman
84b7df43fb Remove uses of llvm/System/IncludeFile.h that are no longer needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06 01:32:53 +00:00
Evan Cheng
34cd4a484e Fix more -Wshorten-64-to-32 warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 18:30:58 +00:00
Evan Cheng
48e8c80e17 Suppress -Wshorten-64-to-32 warnings for 64-bit hosts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50590 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02 21:15:08 +00:00
Gabor Greif
8811080a65 fcntl.h is pretty standard on unix (without the sys/)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50475 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 08:53:22 +00:00
Dan Gohman
3e2dda63d0 Fix a pointer-arithmetic bug that caused 64-bit host pointer values to
be truncated to 32 bits. This fixes the recent Benchmarks/McCat/09-vor
regression on x86-64, among other things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50372 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 20:25:15 +00:00
Ted Kremenek
c9715624fa Bug fix in BumpPtrAllocator: don't assume that all objects have the same alignment. "Bump" of the pointer for the next allocated object to be of the specified alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 17:58:07 +00:00
Mikhail Glushenkov
beb4d8293d Add support for response files to the CommandLine library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50355 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 16:44:25 +00:00
Dan Gohman
3c02aca238 Make these variables static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50196 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 23:15:23 +00:00
Dale Johannesen
79f82f9fd5 Check that APFloat::convert is not trying to target
ppc long double, which doesn't work.

This may break some stuff temporarily, but I want to
avoid the propagation of code that assumes this works.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49983 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-20 01:34:03 +00:00
Dan Gohman
b11af0db2e Use gv's --spartan option, which trades away an extra row of UI buttons
for more space for displaying the graph.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49730 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-15 17:27:05 +00:00
Dan Gohman
3bd659ba20 Make several symbols static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49496 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 21:11:47 +00:00
Bill Wendling
a442006f48 Fix compilation errors on MSVC. Patch by Argiris Kirtzidis!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49055 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 22:09:20 +00:00
Chris Lattner
038112a4e0 Change the MemoryBuffer::getFile* methods to take just a pointer to the
start of a filename, not a filename+length.  All clients can produce a
null terminated name, and the system api's require null terminated 
strings anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49041 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 18:04:03 +00:00
Chris Lattner
11da4cf25c Reimplement MemoryBuffer::getFile with three enhancements:
1) stop using MappedFile.
2) if profitable use the sys::path::MapInFilePages api to
   read the file.
3) otherwise fallback to read.

When sys::path::MapInFilePages is implemented, this provides
several benefits:

#1: this avoids fragmenting memory for small files.
#2: this avoids extraneous stat calls when the file size is known.
#3: this only keeps the file descriptor open while reading the 
    file, not for the duration of the lifetime of the memory 
    buffer.  This fixes a serious clang FD 'leak' problem.

I believe that this will work on a win32 machine, but I don't have
one to test on.  I'd appreciate it if someone could check.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49031 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 06:05:21 +00:00
Chris Lattner
37db5d67f9 Remove the MappedFile::charBase member, rename base -> getBase() and
make getBase() return a const-correct pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49025 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 03:40:53 +00:00
Chris Lattner
a7750c1142 Change DiffFilesWithTolerance to be written in terms of MemoryBuffer,
not an mmapped file.  This more closely matches its requirements and
provides an implicitly null terminated buffer, something this
routine had to emulate itself before.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49024 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 03:39:49 +00:00
Chris Lattner
bdbd2d710c Remove MappedFile support for mapping files for write and exec
and shared.  This complicates the design, is not used, and probably
doesn't even work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49022 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 03:10:22 +00:00
Dan Gohman
950a4c40b8 Add explicit keywords.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48801 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-25 22:06:05 +00:00
Dan Gohman
cfbb2f074d A quick nm audit turned up several fixed tables and objects that were
marked read-write. Use const so that they can be allocated in a
read-only segment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48800 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-25 21:45:14 +00:00
Bill Wendling
f7a91e68a8 Add assert for non-hexadecimal radixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48421 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-16 20:05:52 +00:00
Evan Cheng
a8de38f351 Fix a typo. It's causing consumer-typeset to miscompile. Perhaps more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48035 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-07 22:39:49 +00:00
Dan Gohman
cf609575ef Add support to APInt for shift and rotate operations with APInt
instead of uint32_t for the shift/rotate count operand type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47741 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-29 01:40:47 +00:00
Dan Gohman
93c276e1c9 Add a method to APFloat to convert directly from APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47738 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-29 01:26:11 +00:00
Dan Gohman
61e015fe74 Fix a bug that caused opt and other tools to silently ignore
invalid command-line options.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47523 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-23 01:55:25 +00:00
Dan Gohman
b5660dc822 Add explicit keywords.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47382 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 16:44:09 +00:00
Anton Korobeynikov
d57160d097 Add 'sink' cmdline option. Patch by Mikhail Glushenkov!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47377 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 12:38:07 +00:00
Anton Korobeynikov
ae9f3a3b7c Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47367 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 11:08:44 +00:00
Ted Kremenek
a795aca96a Fixed bug in APInt::Profile() where the BitWidth field was not included in the
profile of the APSInt object. This caused unexpected Profile collisions where
none should have occurred.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47338 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-19 20:50:41 +00:00
Ted Kremenek
e3e09574ae Fixed bug in FoldingSetIteratorImpl where we did not correctly check if
we had reached the "fake bucket" after the last bucket, allowing the iterator
in some cases to run off the end of the hashtable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 21:12:46 +00:00
Dan Gohman
5a0e7b41c1 Fix a warning about comparison between signed and unsigned,
being consistent with the rest of the APInt implementation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-14 22:38:45 +00:00
Dan Gohman
42dd77f207 Add countTrailingOnes member functions to APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47086 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 21:11:05 +00:00
Ted Kremenek
1f801fa5ad Added "Profile" method to APFloat for use with FoldingSet.
Added member template "Add" to FoldingSetNodeID that allows "adding" arbitrary
objects to a profile via dispatch to FoldingSetTrait<T>::Profile().

Removed FoldingSetNodeID::AddAPFloat and FoldingSetNodeID::APInt, as their
functionality is now replaced using the above mentioned member template.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46957 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 17:24:50 +00:00
Dan Gohman
167b8bc24d Add support to FoldingSet for hashing APInt objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46833 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 23:09:15 +00:00
Ted Kremenek
26e3c445fc Added "bucket_iterators" to FoldingSet. Bucket iterators allow iteration
over all the nodes in a particular bucket.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46716 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 21:11:17 +00:00
Ted Kremenek
27a8e0dc2f Fixed 80 col. violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46709 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 17:14:20 +00:00
Dale Johannesen
b63fa050b7 Chris' change to print an approximation to long doubles
exposed a bug in APFloat's long double->double conversion of
NaNs.  Broke several things in the ieee part of gcc testsuite.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 18:34:01 +00:00
Dan Gohman
b10abe1e8c Remove top-level const qualifiers from casts, avoiding associated
compiler warnings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46509 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 12:08:20 +00:00
Lauro Ramos Venancio
42f6e455de Simplify the code and fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46458 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 20:02:51 +00:00
Lauro Ramos Venancio
599ddf9a76 Fix fpcmp infinite loop when comparing "29-266" with "29-268".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46455 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 18:23:23 +00:00
Ted Kremenek
4048a08284 Added FoldingSet style 'profiling' support for APSInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46189 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:31:12 +00:00
Ted Kremenek
e420debd26 Added FoldingSet style 'profiling' support for APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:23:33 +00:00
Ted Kremenek
0a3fecad0a Made 'FoldingSetNodeID' a proper class instead of a nested class in
'FoldingSetNodeImpl' (previously 'FoldingSetNodeID' was a typedef of
'FoldingSetNodeImpl::NodeID').

Why?  Clients can now easily forward declare 'FoldingSetNodeID' without having
to include FoldingSet.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46187 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:22:50 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Chris Lattner
fc643c5e88 remove attribution from lib Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45415 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:09:26 +00:00
Anton Korobeynikov
97d37260df Cygwin defines uint32_t as unsigned long. Unbreak call to std::min in this case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45342 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-24 11:16:47 +00:00
Reid Spencer
9af1887537 Don't have APInt.cpp depend upon DerivedTypes.h. This helps with splitting the
Support libraries separately into their own module.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44852 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-11 06:53:58 +00:00
Chris Lattner
36d26c201f proper #include order.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44707 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-08 19:00:03 +00:00
Gordon Henriksen
985cb62234 Adding a StringPool data structure, which GC will use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44705 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-08 17:07:47 +00:00
Neil Booth
cc2335968f Prior commit updated wrong if, apologies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44614 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-05 13:06:04 +00:00
Neil Booth
a89e45f754 Handle zero correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44613 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-05 13:01:24 +00:00
Dale Johannesen
db1e30272c Handle 0 correctly in string->APFloat conversion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44594 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-05 01:10:19 +00:00
Chris Lattner
9e513acd31 Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44296 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 22:42:31 +00:00
Chris Lattner
5e557123ad Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44294 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 22:36:25 +00:00
Chris Lattner
2b1f1066ac Fix the Linker testcase regressions, by making MemoryBuffer::getFileOrSTDIN return
a valid but empty buffer if stdin is empty.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44219 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-18 18:52:28 +00:00
Dale Johannesen
d0763b9159 Fix denormal check in float->APInt conversion.
PR 1804.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44201 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-17 01:02:27 +00:00
Chris Lattner
373a733be0 make smallptrset more const and type correct, which caught a few
minor bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-06 22:12:43 +00:00
Neil Booth
e3d936ac9c Remove some unnecessary C-style statics.
Restore an assertion that arithmetic can be performed on this format.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43638 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 15:10:05 +00:00
Neil Booth
43a4b28e94 Add back line whose removal somehow crept into prior patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43627 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 22:51:07 +00:00
Neil Booth
ee7ae384f5 When converting to integer, do bit manipulations in the destination
memory rather than in a copy of the APFloat.  This avoids problems
when the destination is wider than our significand and is cleaner.

Also provide deterministic values in all cases where conversion
fails, namely zero for NaNs and the minimal or maximal value
respectively for underflow or overflow.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43626 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 22:43:37 +00:00
Hartmut Kaiser
8df77a9e0f Clarified operator precedence.
Silenced VC++ warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43372 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 23:15:31 +00:00
Chris Lattner
8dc2e288ac This requires rtti info because tblgen uses commandline,
and tblgen requires rtti.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43127 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 15:57:29 +00:00
Neil Booth
686700e325 Fast-track obviously over-large and over-small exponents during decimal->
integer conversion.  In some such cases this makes us one or two orders
of magnitude faster than NetBSD's libc.  Glibc seems to have a similar
fast path.

Also, tighten up some upper bounds to save a bit of memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42984 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 15:00:55 +00:00
Neil Booth
e5e0194583 Consolidate logic for creating NaNs. Silence compiler warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42966 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 10:39:51 +00:00
Neil Booth
caf19d79e5 Whether arithmetic is supported is a property of the semantics. Make it
so, and clean up the checks by putting them in an inline function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42965 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 10:29:28 +00:00
Neil Booth
1870f29c6c Separate out parsing of decimal number. Use this to only allocate
memory for the significand once up-front.  Also ignore insignificant
trailing zeroes; this saves unnecessary multiplications later.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42964 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 10:16:12 +00:00
Neil Booth
d1a23d573d If the power of 5 is exact, and the reciprocal exact, the error is zero not one half-ulps. This prevents an infinite loop in rare cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42950 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 03:34:08 +00:00
Neil Booth
6ac7016eb1 Remove duplicate comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42913 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 16:05:57 +00:00
Neil Booth
96c7471b39 Implement correctly-rounded decimal->binary conversion, i.e. conversion
from user input strings.

Such conversions are more intricate and subtle than they may appear;
it is unlikely I have got it completely right first time.  I would
appreciate being informed of any bugs and incorrect roundings you
might discover.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42912 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 16:02:31 +00:00
Neil Booth
5b8e0c5fd3 Remove a field that was never used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42911 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 15:35:10 +00:00
Neil Booth
7a951ca548 If we're trying to be arbitrary precision, unsigned char clearly won't cut it. Needed for dec->bin conversions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42910 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 15:33:27 +00:00
Neil Booth
1e8390d8d6 Don't attempt to mask no bits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42909 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 15:31:31 +00:00
Dale Johannesen
a471c2ecda Next PPC long double bits. First cut at constants.
No compile-time support for constant operations yet,
just format transformations.  Make readers and
writers work.  Split constants into 2 doubles in
Legalize.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42865 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 18:07:22 +00:00
Chris Lattner
3daae2701b Add new MemoryBuffer::getMemBufferCopy method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42815 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 21:46:38 +00:00
Dan Gohman
9a5263241d Pass argc by value, not by reference, since it isn't modified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42788 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 16:04:57 +00:00
Chris Lattner
be2c4596cb Change a #include into a forward declaration
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42781 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 03:40:30 +00:00
Dan Gohman
82a13c9c48 Move the space in overview output for commands out of each of the
commands and into the common code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42752 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-08 15:45:12 +00:00
Neil Booth
5477f8593d Use APInt::tcExtract. It's cleaner, and works :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42746 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-08 14:39:42 +00:00
Neil Booth
68e53ad6cb Add a new function tcExtract for extracting a bignum from an
arbitrary range of bits embedded in the middle of another bignum.
This kind of operation is desirable in many cases of software
floating point, e.g. converting bignum integers to floating point
numbers of fixed precision (you want to extract the precision most
significant bits).

Elsewhere, add an assertion, and exit the shift functions early if
the shift count is zero.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42745 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-08 13:47:12 +00:00
Neil Booth
f16c595252 Add back convertFromSignExtendedInteger.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42735 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 12:15:41 +00:00
Neil Booth
7a7bc0f724 Now that convertFromUnsignedParts has a sane, constant interface,
convertFromZeroExtendedInteger can be simplified as it doesn't need
to make a copy of the source bignum.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42734 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 12:10:57 +00:00
Neil Booth
643ce59495 Reimplement convertFromUnsignedInteger so it is passed a const bignum.
It used to modify its argument in-place.

This interface is saner and the implementation more efficient.  It will
be needed for decimal->binary conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42733 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 12:07:53 +00:00
Neil Booth
ccf596a53e convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42732 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 11:45:55 +00:00
Neil Booth
33d4c92e78 combineLostFractions does not need to be a member function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42729 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 08:51:21 +00:00
Neil Booth
92f7e8d925 Cleaner, more general exponent output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42690 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-06 07:29:25 +00:00
Chris Lattner
a11ef82207 silence warnings in no-assert build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42687 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-06 06:13:42 +00:00
Neil Booth
055c0b3a8f Fix and clarify some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42670 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-06 00:43:45 +00:00
Neil Booth
978661d053 Generalize tcFullMultiply so that the operands can be of differing
part widths.  Also, return the number of parts actually required to
hold the result's value.
Remove an over-cautious condition from rounding of float->hex conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42669 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-06 00:24:48 +00:00
Neil Booth
a30b0ee959 Add APFloat -> hexadecimal string conversion, as per %a and %A in C99.
Useful for diagnostics and debugging.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42598 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-03 22:26:02 +00:00
Chris Lattner
116c3219df Add initial iterator support for folding set.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42589 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-03 21:12:09 +00:00
Chris Lattner
9a7288b0c6 Simplify implementation of the FoldingSet circular list, a necessary step
to giving it iterators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42586 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-03 20:45:43 +00:00
Neil Booth
b7dea4cb36 Tweak RoundAwayFromZero the bit number below which is truncated, and make
it const.

Preparation for APFloat -> hexadecimal string conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42576 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-03 15:16:41 +00:00
Dale Johannesen
cce23a4c35 Simplify and fix signed int -> FP conversions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42483 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-30 18:17:01 +00:00
Neil Booth
4f88170be0 Whitespace and compiler warning cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42373 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-26 21:33:42 +00:00
Dale Johannesen
0edc47ad7b Make APFloat->int conversions deterministic even in
cases with undefined behavior.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42328 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 23:07:07 +00:00
Dale Johannesen
902ff94aff Fix long double<->shorter FP type conversions
of zero, infinity, and NaNs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42298 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 17:25:00 +00:00
Neil Booth
c8db43ddaf Handle storage complications of float->float conversions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42220 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-22 02:56:19 +00:00
Dale Johannesen
910993e8dc Change APFloat::convertFromInteger to take the incoming
bit width instead of number of words allocated, which
makes it actually work for int->APF conversions.
Adjust callers.  Add const to one of the APInt constructors
to prevent surprising match when called with const
argument.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42210 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-21 22:09:37 +00:00
Dale Johannesen
a72a5a095d Fix PR 1688. See comments there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42181 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-20 23:47:58 +00:00
Devang Patel
8feb1f4467 Do not hide APInt::dump() inside #ifndef NDEBUG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42068 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-17 22:24:00 +00:00
Chris Lattner
2204906892 fix a gcc warning: comparison between signed and unsigned integer expressions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41972 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 22:57:00 +00:00
Dale Johannesen
9e3d3abd93 Remove the assumption that FP's are either float or
double from some of the many places in the optimizers
it appears, and do something reasonable with x86
long double.
Make APInt::dump() public, remove newline, use it to
dump ConstantSDNode's.
Allow APFloats in FoldingSet.
Expand X86 backend handling of long doubles (conversions
to/from int, mostly).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41967 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 22:26:36 +00:00
Dan Gohman
f82e1e66ce And an FoldingSetImpl::NodeID::AddInteger overload for int64_t, to avoid
ambiguity.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41960 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 20:48:42 +00:00
Dan Gohman
cb648f90a2 Remove spurious consts. This fixes warnings with compilers that
are strict about such things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41956 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 20:08:19 +00:00
Dale Johannesen
257500db04 Compensate for partCount change in Bogus definition
(could break hash table in ConstantFP)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41874 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-12 01:22:05 +00:00
Dale Johannesen
3f6eb7419d Add APInt interfaces to APFloat (allows directly
access to bits).  Use them in place of float and
double interfaces where appropriate.
First bits of x86 long double constants handling 
(untested, probably does not work).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41858 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-11 18:32:33 +00:00
Evan Cheng
7dfda9e674 Smarter Reset(). Instead of deallocating all memory regions and reallocate the
first region, just deallocate all but the last region in the list.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-08 00:02:17 +00:00
Evan Cheng
188b5224fd Added Reset() to free all allocated memory regions and reset state to be the same as right after ctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41728 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-05 21:41:34 +00:00
Dale Johannesen
58c2e4c5fd Fix mod so it actually works. Fix conversions to
native types to handle denormals correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41726 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-05 20:39:49 +00:00
Dale Johannesen
e15c2db993 Oops, should be part of 41664; won't work very well without this piece.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41665 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-31 23:35:31 +00:00
Dale Johannesen
eaf089430e Enhance APFloat to retain bits of NaNs (fixes oggenc).
Use APFloat interfaces for more references, mostly
of ConstantFPSDNode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-31 04:03:46 +00:00
Dale Johannesen
f04afdbb48 Change LegalFPImmediates to use APFloat.
Add APFloat interfaces to ConstantFP, SelectionDAG.
Fix integer bit in double->APFloat conversion.
Convert LegalizeDAG to use APFloat interface in
ConstantFPSDNode uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41587 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 00:23:21 +00:00
Dale Johannesen
12595d7b16 Poison APFloat::operator==. Replace existing uses with bitwiseIsEqual.
This means backing out the preceding change to Constants.cpp, alas.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41378 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 22:09:56 +00:00
Dale Johannesen
d3b51fd170 Revised per review feedback from previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41353 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 05:08:11 +00:00
Chris Lattner
ada530b4f5 silence some warnings in an optimized build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41352 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 03:02:34 +00:00
Dale Johannesen
343e770983 Change internal representation of ConstantFP to use APFloat.
Interface to rest of the compiler unchanged, as yet.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41348 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 00:56:33 +00:00
Chris Lattner
9132a2b818 rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()
Add an APSInt::toString() method.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41309 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 05:15:32 +00:00
Chris Lattner
b39cdde41d initial checkin of Neil's APFloat work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41203 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-20 22:49:32 +00:00
Chris Lattner
fe8e14a6c9 This adds a bunch of static functions that implement unsigned
two's complement bignum arithmetic.  They could be used to
implement much of APInt, but the idea is they are enough to
implement APFloat as well, which the current APInt interface
is not suited for.

Patch by Neil Booth!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41124 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-16 15:56:55 +00:00
Anton Korobeynikov
ebf0303810 Properly use const qualifiers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41111 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-15 21:12:30 +00:00
Reid Spencer
2372ccc111 Make getSTDIN return null if the standard input is empty, as the header file
documentation implies and as its uses depend.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40939 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 20:01:58 +00:00
Reid Spencer
c69b0dd19d Escape some escapes that confuse doxygen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40850 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-05 19:33:11 +00:00
Chris Lattner
42e4bdf257 When clearing a SmallPtrSet, if the set had a huge capacity, but the
contents of the set were small, deallocate and shrink the set.  This
avoids having us to memset as much data, significantly speeding up
some pathological cases.  For example, this speeds up the verifier
from 0.3899s to 0.0763 (5.1x) on the testcase from PR1432 in a 
release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40837 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-05 07:32:14 +00:00
Owen Anderson
e992a56ae9 Allow SmallPtrSet to hold pointers to const data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40556 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-27 18:07:02 +00:00
Owen Anderson
bf31b85ea2 Make the copy constructor of SmallPtrSet much faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40474 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24 21:31:23 +00:00
Owen Anderson
71a1e57d18 Remember to free the heap allocated array if we're not going to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40043 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 06:45:33 +00:00
Owen Anderson
b54b315251 Fix an issue where assignments that caused a SmallPtrSet to become non-small
would result in calling realloc() on a null pointer.  Instead, if we encounter
this situation, make a normal call to malloc().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40014 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 19:54:15 +00:00
Reid Spencer
845b31de0c Unbreak the build by putting calls to free into the implementation file and
having that implementation file #include <cstdlib>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39952 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 02:16:12 +00:00
Owen Anderson
1629a1fa87 Use realloc() to (potentially) resize the contents of SmallPtrSet in place.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39926 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:27:44 +00:00
Nick Lewycky
28753f8df2 Clarify the language. Pointed out by Duncan Sands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39857 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 17:41:03 +00:00
Nick Lewycky
377b1190cb Add alternate ConstantRange intersection algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39851 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 02:51:34 +00:00
Owen Anderson
69b5d12676 Make the assignment operator for SmallPtrSet much faster for normal cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38474 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-09 22:27:20 +00:00
Owen Anderson
4d6f96d699 Make the assignment operator for SmallPtrSet return a reference, and fix a long-standing bug in the copy
ctor while I'm at it.

Thanks to Chris Lattner for help with this patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38470 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-09 20:59:01 +00:00
Owen Anderson
da8ebc6b43 Fix an error in the assignment operator that was causing an infinite loop in GVNPRE.cpp.
Patch by Chis Lattner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38467 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-09 18:51:15 +00:00
Chris Lattner
91f0158d4d implement operator= for smallptrset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38460 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-09 16:54:03 +00:00
Gabor Greif
a99be51bf5 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
2007-07-05 17:07:56 +00:00
Nick Lewycky
ea332946d3 Fix undefined behaviour reported by the new --enable-expensive-checks option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37829 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-01 03:06:30 +00:00
Owen Anderson
6394e5e4fd Fix a bug in SmallPtrSet that was causing GVNPRE to enter an infinite loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37697 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-22 00:11:18 +00:00
Chris Lattner
61766cae0b Two changes:
1. Make SmallPtrSet::erase faster in the small case by replacing a memmove
    with a pointer copy.
 2. Fix a bug where the null terminator at the end of the array in the small
    case was not copied


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37696 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-21 23:23:32 +00:00
Nick Lewycky
ae5eb7accf Fix edge case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37532 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-09 04:20:33 +00:00
Dale Johannesen
81da02b553 Make tail merging the default, except on powerPC. There was no prior art
for a target-dependent default with a command-line override; this way
should be generally usable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37285 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-22 17:14:46 +00:00
Reid Spencer
20a4c23bcc Fix an assertion introduced by my last change to the toString method. We
can't use getZExtValue() to extract the low order bits for each digit.
Instead, we need to access the low order word directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37242 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-19 00:29:55 +00:00
Reid Spencer
fb0709a180 Get rid of leading zeros in the output of toString.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37175 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-17 19:23:02 +00:00
Reid Spencer
02ae8b78ff For lshr by 0 bits, just return *this as a short cut. This also prevents
undefined behavior when the width > 64 bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37153 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-17 06:26:29 +00:00
Reid Spencer
6551dcdd8a Fix a bug in the "fromString" method where radix 2,8 and 16 values were
not being generated correctly because the shl operator does not mutate its
object but returns a new value. Also, make the distinction between radix
16 and the others more clear.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37111 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-16 19:18:22 +00:00
Reid Spencer
69944e85aa Make the results for the rotate functions correct when rotateAmt == 0.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37026 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-14 00:15:28 +00:00
Reid Spencer
19dc32a2d4 Add some things needed by the llvm-gcc version supporting bit accurate integer
types:
1. Functions to compute div/rem at the same time.
2. Further assurance that an APInt with 0 bitwidth cannot be constructed.
3. Left and right rotate operations.
4. An exactLogBase2 function which requires an exact power of two or it
   returns -1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37025 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-13 23:44:59 +00:00
Reid Spencer
92c7283500 Fix shl to produce the correct result when the bitwidth is > 64 and the
shift amount is 0. Previously this code would do a lshr by the bit width
which can lead to incorrect results.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37010 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-12 18:01:57 +00:00
Chris Lattner
a24b04e9e5 fix a memory leak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 00:43:26 +00:00
Jeff Cohen
0fea8ebb4a Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36901 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-07 15:21:46 +00:00
Chris Lattner
5499da8833 Enhance MemoryBuffer to return error messages in strings if they occur.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36899 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 23:32:36 +00:00
Chris Lattner
9e66233361 remove this file for now, we can bring it back from cvs if we need it in
the future (and integrate it with membuffer, etc)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36876 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 19:10:47 +00:00
Chris Lattner
d6f595946d remove libbzip2, it is dead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36875 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 19:05:34 +00:00
Chris Lattner
73a978a753 don't build bzip2 for now
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36871 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 09:31:32 +00:00
Chris Lattner
dfa8d8c6ee disable this for now
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36870 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 09:31:06 +00:00
Chris Lattner
82e791dc42 Fix MemoryBuffer::getFile to return null if it has an error opening the
file instead of aborting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36858 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 07:24:46 +00:00
Chris Lattner
82493289e0 This is a patch to fix a compile error in STLExtras.h, and
a bug in GraphWriter.cpp.

Patch by Florian Brandner


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36684 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-03 18:32:10 +00:00
Chris Lattner
a5ae15ecb7 silence some annoying gcc 4.3 warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36680 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-03 18:15:36 +00:00
Jeff Cohen
930c0fead9 Fix MemoryBuffer breakage correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36561 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-29 14:43:31 +00:00
Jeff Cohen
9bc406019e Unbreak build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36559 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-29 14:21:44 +00:00
Chris Lattner
333ffd4abf Add a new memorybuffer class, to unify all the file reading code in the system
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36553 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-29 06:58:52 +00:00
Zhou Sheng
c125c00e68 Using APInt more efficiently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 16:42:07 +00:00
Jeff Cohen
ac58a16f85 Fix PR1329.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36016 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 21:50:21 +00:00
Reid Spencer
0468ab3025 We want the number of bits needed, not the power of 2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35977 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 00:00:10 +00:00
Reid Spencer
57ae4f5f01 Implement a getBitsNeeded method to determine how many bits are needed to
represent a string in binary form by an APInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35968 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 19:19:07 +00:00
Zhou Sheng
daacf22537 Make the apint construction more effective.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35960 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 05:57:32 +00:00
Chris Lattner
69d6f1358c improve the patch for PR1318 to also support grouped options with custom
handlers (like the pass list).  My previous fix only supported *new* command
line options, not additions to old ones.

This fixes test/Feature/load_module.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35935 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-12 00:36:29 +00:00
Chris Lattner
159b0a4340 Fix PR1318 by reacting appropriately to a mutating option list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35905 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 15:35:18 +00:00
Reid Spencer
2cd43e402a Fix an approximate calculation in an assertion not to give false negatives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35901 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 13:00:04 +00:00
Reid Spencer
c74b461507 For PR1291:
Change uses of sys::Path class to sys::PathWithStatus in those places where
the file status information is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 18:53:16 +00:00
Nick Lewycky
e32157c609 Add signExtend to ConstantRange, to complement zeroExtend and truncate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35733 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 15:41:33 +00:00
Chris Lattner
ee2b32082e Fix a bug in my earlier commit which exposed positional options backwards.
This fixes llvm-ar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35727 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 05:38:53 +00:00
Chris Lattner
9878d6ae3a rearchitect the registration mechanism used by the command line option stuff.
This dramatically reduce the amount of memory allocated by the commandline stuff
at static init time, changing it to build local data structures when ParseCommandLineOptions
is called.  In a dummy empty program that links some llvm libraries, this reduces
the number of malloc'd bytes from 4864 to 3360 on entry to main.  Most of that
memory is now allocated by non-commandline related stuff.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35701 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 21:06:55 +00:00
Chris Lattner
af035f3460 remove the dead removeArgument method, rename Options to OptionsMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35690 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-05 21:58:17 +00:00
Chris Lattner
12ba806c5d stringmap memory managed with malloc now
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35666 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 17:24:28 +00:00
Chris Lattner
d2f197da59 use calloc instead of new/memset, it is more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35644 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 00:44:31 +00:00
Chris Lattner
794a014809 Extend StringMap to support being initialized as completely empty. When
initialized this way, they do not do a malloc to allocate their buckets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35642 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 00:29:37 +00:00
Chris Lattner
ef4c916193 greatly reduce hte default size of stringmap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 22:15:38 +00:00
Nick Lewycky
9babd0e0f2 Implement union of wrapped sets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35534 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 03:47:44 +00:00
Reid Spencer
8475ec068c For PR789:
Make the sys::Path::getFileStatus function more efficient by having it
return a pointer to the FileStatus structure rather than copy it. Adjust
uses of the function accordingly. Also, fix some memory issues in sys::Path.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35476 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 19:05:44 +00:00
Reid Spencer
5ba2b702c2 For PR789:
Updates for change in interface of getFileStatus method of sys::Path class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35458 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 16:48:16 +00:00
Zhou Sheng
6dbe233959 Fix a bug in getAllOnesValue() which broke
some test cases for bitwidth > 64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35232 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-21 04:34:37 +00:00
Jeff Cohen
09dfd8e19d Fix (and simplify) 48-bit byte swap.
Get pos/neg infinity the correct way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35223 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 20:42:36 +00:00
Reid Spencer
adf2a206ec Fix coding standards violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35189 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 21:19:02 +00:00
Reid Spencer
3a34137548 Implement extension of sign bits for negative values in the uint64_t
constructor. This helps to fix test/Assembler/2007-03-19-NegValue.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35180 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 20:37:47 +00:00
Reid Spencer
4fd8606791 Revert the last patch as it violates the conditions of sext/zext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35068 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 18:37:25 +00:00
Zhou Sheng
7d820f57e2 For APInt::z/sext(width), if width == BitWidth, just return *this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35065 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 17:47:45 +00:00
Nick Lewycky
3400e6af6b Add getter methods for the extremes of a ConstantRange.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35056 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-10 15:54:12 +00:00
Jeff Cohen
ca5183d445 Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34917 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:00:42 +00:00
Reid Spencer
46f9c94bdd Fix ashr for bitwidths > 64. This is now validated up to 1024 bits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34852 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 22:39:11 +00:00
Reid Spencer
f09aef7698 Use a better algorithm for rounding sqrt results. Change the FIXME about
this to a NOTE: because pari/gp results start to get rounded incorrectly
after 192 bits of precision. APInt and pari/gp never differ by more than
1, but APInt is more accurate because it does not lose precision after 192
bits as does pari/gp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34834 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 04:21:55 +00:00
Nick Lewycky
c6a28fcf5d Implement unionWith.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34833 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 03:33:05 +00:00
Reid Spencer
9bf94a4a9f Add a FIXME
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34828 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 02:01:34 +00:00
Reid Spencer
36184ed4cd Fix a problem where shifting by 64-bits leads to incorrect results on PPC
but not on X86 becuase shift by word size is "undefined".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34825 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 01:19:42 +00:00
Reid Spencer
295e40aa5c Combine two lines that can be.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34818 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 23:30:25 +00:00
Reid Spencer
4e1e87f09c Make the static table of results in sqrt const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34791 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 17:47:31 +00:00
Reid Spencer
68e2300ad9 Add methods for bit width modification: sextOrTrunc, zextOrTrunc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34789 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 17:15:32 +00:00
Reid Spencer
a6e8a955d6 Remove the "isSigned" parameters from ConstantRange. It turns out they
are not needed as the results are the same with or without it.

Patch by Nicholas Lewycky.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 07:54:15 +00:00
Reid Spencer
b5ca2cd509 Use a real table in sqrt to shorten and quicken the code.
Thanks for the idea Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34779 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 06:23:32 +00:00
Reid Spencer
af8fb19846 Add a square root function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34775 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-01 05:39:56 +00:00
Reid Spencer
bb626a6751 Move ConstantRange class to lib/Support from lib/Analysis and make its
interface not depend on Type or ICmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34761 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 22:02:48 +00:00
Reid Spencer
581b0d453a For PR1205:
Remove ConstantInt from ConstantRange interface and adjust its users to
compensate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34758 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 19:57:34 +00:00
Reid Spencer
dc5c159701 For PR1205:
First round of ConstantRange changes. This makes all CR constructors use
only APInt and not use ConstantInt. Clients are adjusted accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34756 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 18:57:32 +00:00
Reid Spencer
663e711dc2 For PR1205:
Convert ConstantRange class to use APInt internally as its value type for
the constant range, instead of ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34745 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 17:36:23 +00:00
Reid Spencer
94900774ad Make the trunc/sext/zext methods return APInt& so that these operations
can be chained together with other operations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 17:34:32 +00:00
Reid Spencer
ff60576646 Fix a bug in RoundDoubleToAPInt where it would force the size to 64 bits
instead of honoring the client's requested bit width.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34712 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-28 01:30:08 +00:00
Reid Spencer
f5c0fd9e16 Join two lines that can be joined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34705 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 23:49:07 +00:00
Reid Spencer
681dcd14e9 Implement countLeadingOnes() and getMinSignedBits(). This helps to minimize
the bit width of negative numbers by computing the minimum bit width for a
negative value. E.g. 0x1800000000000000 could be just 0x8000000000000000


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34695 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 21:59:26 +00:00
Reid Spencer
66ed1099ff Improve APInt interface:
1. Add unsigned and signed versions of methods so a "bool" argument doesn't
   need to be passed in.
2. Make the various getMin/getMax functions all be inline since they are
   so simple.
3. Simplify sdiv and srem code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34680 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 20:24:31 +00:00
Reid Spencer
96d91372fd Conform to single person attribution in file comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34678 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 19:31:09 +00:00
Reid Spencer
1fa111e8d4 1. Fix three serious bugs in the comparison code.
2. Change RoundDoubleToAPInt to take a bit width parameter. Use that
   parameter to limit the bit width of the result.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34673 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 18:23:40 +00:00
Reid Spencer
b4d8ae5dfb Get rid of extraneous // in file comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34662 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 07:35:18 +00:00
Reid Spencer
30f44f3287 Simplify and document RoundDoubleToAPInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34648 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-27 01:28:10 +00:00
Reid Spencer
9ac44113a8 1. Make sure all delete operators of arrays use the array form of delete.
2. Rewrite operator=(const APInt& RHS) to allow the RHS to be a different
   bit width than the LHS. This makes it possible to use APInt as the key
   of a DenseMap, as needed for the IntConstants map in Constants.cpp
3. Fix operator=(uint64_t) to clear unused bits in case the client assigns
   a value that has more bits than the APInt allows.
4. Assert that bit widths are equal in operator==
5. Revise getHashValue() to put the bit width in the low order six bits.
   This should help to make i1 0, i2 0, ... i64 0 all distinct in the
   IntConstants DenseMap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34646 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 23:38:21 +00:00
Reid Spencer
794f4725b8 Implement the getHashValue method.
Fix toString use of getValue to use getZExtValue()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34642 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 21:02:27 +00:00
Reid Spencer
9d1ae8fabe Re-enable this. The header was committed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34634 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 08:10:54 +00:00
Chris Lattner
ab143beb93 another missing header :( :( :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 07:51:00 +00:00
Reid Spencer
47fbe9e00c 1. Remove redundant calls to clearUsedBits().
2. Fix countTrailingZeros to use a faster algorithm.
3. Simplify sext() slightly by using isNegative().
4. Implement ashr using word-at-a-time logic instead of bit-at-a-time
5. Rename locals named isNegative so they don't clash with method name.
6. Fix fromString to compute negated value correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34629 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 07:44:38 +00:00
Reid Spencer
ba81c2b871 Rewrite lshr to not do bit by bit copy but to copy and shift whole words.
This makes it much more efficient.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34618 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-26 01:19:48 +00:00
Reid Spencer
f30b1885ae Fix sext operation. Shifting by zero would leave an incorrect mask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34617 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 23:54:00 +00:00
Reid Spencer
9eec241347 1. Fix the flip() method to correctly flip all words of the APInt.
2. Implement the trunc, sext, and zext operations.
3. Improve fromString to accept negative values as input.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34616 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 23:44:53 +00:00
Reid Spencer
5d0d05c9b8 1. Provide more detail in file comment.
2. Move comments for methods to .h file, delete them in .cpp file.
3. All places that were doing manual clear of high order bits now call the
   clearUnusedBits() method in order to not depend on undefined behavior
   of the >> operator when the number of bits shifted equals the word size.
4. Reduced # of loc by using the new result of clearUnusedBits() method.
5. Simplified logic (decreased indentation) in a few places.
6. Added code comments to larger functions that needed them.
7. Added FIXME notes about weak implementations of things (e.g. bit-by-bit
   shift right is sub-optimal).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34603 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 19:32:03 +00:00
Reid Spencer
31d16b039a Allow this to compile now that the header file is checked in.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34581 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 07:30:14 +00:00
Chris Lattner
0f07e55312 this doesn't compile, disable it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34571 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 02:32:44 +00:00
Reid Spencer
24c4a8f548 Clean up lshr and ashr to coding standards.
Handle the single word cases for shiftAmt == BitWidth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34569 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 01:56:07 +00:00
Reid Spencer
438d71eea4 Whoops, last word with bits in large shift left wasn't correct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34565 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 01:08:58 +00:00
Reid Spencer
8755380fff Fix the > 64 bits case for left shift.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34564 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-25 00:56:44 +00:00
Reid Spencer
1050ec5cc4 Fix the remainder shifting in KnuthDiv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34562 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-24 20:38:01 +00:00
Reid Spencer
5bce8547f3 1. Fix a bug in fromString for the <= 64bits case
2. Fix shl when shiftAmount == BitWidth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34560 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-24 20:19:37 +00:00
Reid Spencer
610fad85d2 1. Fix last bug in KnuthDiv. All divide tests pass up to 1024 bits now.
2. Clean up comments, style, coding standards, etc.
3. Simplify a constructor.

Extended testing revealed some additional bugs in shifting. I'll fix these
tomorrow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34559 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-24 10:01:42 +00:00
Reid Spencer
9d6c919efe 1. Make internal functions take const arguments where they should, just
to be safe.
2. Make internal functions that return a carry/borrow return bool instead
   of uint64_t because the carry/borrow can only be in range [0,1].
3. Assert that the pointers to KnuthDiv are all different so that the
   result and operands can't overlap.
4. Add debug output to KnuthDiv function.
5. Fix a problem with KnuthDiv by separating the b's complement operation
   from the subtraction borrow operation. This fixes a wide range of
   division problems, but alas, not all of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34554 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-24 03:58:46 +00:00
Chris Lattner
34aae111ff remove folding set debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34549 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-24 01:41:48 +00:00
Chris Lattner
d675b8347d Avoid TBAA issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34539 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-23 22:31:24 +00:00
Reid Spencer
9290463760 1. Fix a carry out problem in add if destination and x point to the same
memory (as done in fromString).
2. Implement Knuth divide more closely to what is recommended in his book.
3. Fix computation of the remainder for Knuth Divide (bad shifting).
4. Remove some cruft from the file


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34518 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-23 01:57:13 +00:00
Reid Spencer
15aab8a723 When converting from 64 to 32-bits, use the actual number of words to
extract the value, not the number of words implied by the active bits.
This fixes numerous, but not all divide bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34484 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-22 00:58:45 +00:00
Reid Spencer
ab2b2c827c Fix countLeadingZeros in the case that the bitwidth evenly divides the
word size. This fixes all reads of uninitialized data (buffer over read)
and makes APInt.cpp memory clean, per valgrind. The only remaining
problem is division in a few cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34483 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-22 00:22:00 +00:00
Reid Spencer
e0cdd3349d Reorganize some code to make it clearer, avoid a few uninitialized memory
reads, and reduce the number of temporary APInt instances we construct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34467 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-21 08:21:52 +00:00
Reid Spencer
60c0a6a74b Fix the carry in addition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34465 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-21 05:44:56 +00:00
Reid Spencer
385f7547b9 1. Add a dump() method for faster debugging.
2. Change 0 initialization of union to larger component so all is zeroed.
3. Fix the borrow logic in subtraction so it works for > 128 bits.
4. Rewrite fromString to use a simpler but correct algorithm and also to
   not set the bit width contrary to the user's request.
5. Optimize toString a bit by making it only do one Knuth divide per
   iteration instead of two.

With these changes, all arithmetic passes (verified by pari/GP) up to
1024 bits except for certain division cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34463 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-21 03:55:44 +00:00
Reid Spencer
e549c4940c Fix countLeadingZeros to actually return the correct number.
Fix toString to correctly return "0" for zero valued APInts over 128 bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34459 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-21 00:29:48 +00:00
Reid Spencer
54362ca095 Make long addition and subtraction work. Speed things up by using internal
functions more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34458 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20 23:40:25 +00:00
Reid Spencer
61eb180a53 Clean up variable names in operator*.
Attempt #3 for getting a portable INFINITY value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34454 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20 20:42:10 +00:00
Reid Spencer
580546a82b Use INFINITY macro from math.h instead of constructing hex floating point
constants (avoids warnings).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34452 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20 18:29:12 +00:00
Reid Spencer
9c0696f153 First version that can process arith.cpp test case up to 1024 bits:
1. Ensure pVal is set to 0 in each constructor.
2. Fix roundToDouble to make correct calculations and not read beyond the
   end of allocated memory.
3. Implement Knuth's "classical algorithm" for division from scratch and
   eliminate buffer overflows and uninitialized mememory reads. Document
   it properly too.
4. Implement a wrapper function for KnuthDiv which handles the 64-bit to
   32-bit conversion and back. It also implement short division for the
   n == 1 case that Knuth's algorithm can't handle.
5. Simplify the logic of udiv and urem a little, make them exit early, and
   have them use the "divide" wrapper function to perform the division
   or remainder operation.
6. Move the toString function to the end of the file, closer to where
   the division functions are located.

Note: division is still broken for some > 64 bit values, but at least it
      doesn't crash any more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34449 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20 08:51:03 +00:00
Chris Lattner
d283566319 Not all managedstatics need object pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34444 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20 06:18:57 +00:00
Reid Spencer
f99a0ac0dc 1. Fix some indentation and variable names in the get{Min,Max}Value methods.
2. Implement toString for power-of-2 radix without using divide and always
   printing full words. This allows hex/binary to look at the bit
   respresentation of the APInt as well as avoid bugs in divide.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34396 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18 22:29:05 +00:00
Reid Spencer
a58f05847c 1. Use APINT_WORD_SIZE instead of sizeof(uint64_t)
2. Teach slt about signedness.
3. Teach roundToDouble to properly sign extend.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34391 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18 20:09:41 +00:00
Reid Spencer
af0e956cef 1. Remove dead code (lshift function).
2. Consolidate memory allocation into just two inline functions.
3. Convert "unsigned" to uint32_t to gaurantee its size.
4. Eliminate magic constants and replace with symbolic equivalent.
5. Improve code documentation slightly.
6. Simplify the logical operator code because bitwidths must be the same.
7. Fix indentation per coding standards.
8. Use exit-early style to reduce indentation in several functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34389 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18 18:38:44 +00:00
Reid Spencer
f2c521c58d Make add_1 exit early if carry is 0.
Fix line breaks and 80 cols violation.
Simplify operator^= since bitwidths must be the same.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34388 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18 06:39:42 +00:00
Reid Spencer
443b570149 Implement signed output for toString.
Fix bugs in countLeadingZeros and countTrailingZeros.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34386 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18 00:44:22 +00:00
Reid Spencer
c72f28042b Fix some bugs in division logic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34384 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17 22:38:07 +00:00
Reid Spencer
5e0a851ed3 Move static functions closer to their usage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34363 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17 03:16:00 +00:00
Reid Spencer
71bd08f9be Clean up the divide and remainder logic a bit (exit early). Use more
meaningful variable names. Add comments to document the flow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34362 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17 02:07:07 +00:00
Reid Spencer
cd6f2bfc26 Fix bugs introduced by constructor parameter order change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34357 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17 00:18:01 +00:00
Reid Spencer
e81d2dad2c Review changes:
1. Function style changes.
2. 80-col violations.
3. Better names for things.
4. Arrange constructors so they all take bit width first.
5. Add named signed and unsigned comparison functions and remove the
   corresponding operators.
6. Remove operator&& and operator|| but provide a getBoolValue function which
   converts to bool as comparison against 0. This allows the normal && and
   || operators to be used as if (X.getBoolValue() && Y.getBoolValue())

Note: this still doesn't function 100% yet. I'm working on the bugs now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34353 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-16 22:36:51 +00:00
Anton Korobeynikov
9ba8a76f8b Add possibility to set memory limit for binaries run via libSystem. This
is especially needed for bugpoint. This partly implements PR688


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34349 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-16 19:11:07 +00:00
Zhou Sheng
b04973edfa Fix some buges:
1. Make getMinValue() returns the right value.
2. Fix the ByteSwap() crash problem.
3. Make Postfix increment work correctly.
4. Fix some bugs in LogBase2, Hi/LoBits and UDiv.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34304 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 06:36:31 +00:00
Reid Spencer
879dfe1c9c Use brute-force algorithm for to_string. It doesn't have to be efficient
at this point, it just needs to work so we can test things reliably.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34262 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-14 02:52:25 +00:00
Reid Spencer
db3faa64ee Make some minor improvements to APInt:
1. Make all the operators use uppercase
2. Rename APIntRoundToDouble method just RoundToDouble, the APInt is
   redundant.
3. Turn the class on for compilation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34253 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-13 22:41:58 +00:00
Zhou Sheng
d93f00c35d 1. Make APInt::shl work correctly and more efficiently.
2. Add functions to support the numberical conversion between APInt and
   double/float.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34201 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-12 20:02:55 +00:00
Chris Lattner
44dcd01cb3 Add support for removing elements out of StringMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 20:58:00 +00:00
Chris Lattner
b5bb9f5b5c Replace the ugly FindValue method with STL-like find methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34183 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 19:49:41 +00:00
Chris Lattner
360cac8fef remove support for stringmap visitors now that iterators exist.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34180 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 08:22:15 +00:00
Chris Lattner
a86559ec42 add support for iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34179 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 08:20:35 +00:00
Nick Lewycky
3e051647c0 Fix comments to match names of functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34173 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 00:58:49 +00:00
Zhou Sheng
ff4304f824 Eliminates friend function declaration inside APInt, instead, adds public
methods as those global function's internal implementation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34083 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-09 07:48:24 +00:00
Chris Lattner
bb28a81ba3 Rename CStringMap -> StringMap, since it now supports nul characters in the
strings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34064 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 19:20:57 +00:00
Chris Lattner
ee182422ff Allow cstringmap to contain strings with nul characters in them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 19:08:37 +00:00
Zhou Sheng
a05eaa658e Switched this file on accidently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34054 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 16:45:48 +00:00
Zhou Sheng
0b706b18bd As Chris and Reid suggested, remove "isSigned" field from APInt, instead,
add some signed/unsigned arithmetic operation functions into APInt.h to
handle the signed/unsigned issue. These functions will be defined inside a
namespace "APIntOps" which is inside llvm namespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34053 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 14:35:19 +00:00
Zhou Sheng
a3832fd46a As Chris suggested, fixed some problems. (This is the first part)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33989 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 06:14:53 +00:00
Chris Lattner
e237cf934f do not let the table fill up with tombstones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33973 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 01:11:25 +00:00
Zhou Sheng
353815dc19 As Reid suggested, fixed some problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33955 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06 06:04:53 +00:00
Chris Lattner
6ad4c148cf Disable this for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33953 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06 05:38:37 +00:00
Zhou Sheng
fd43dcfc57 Add a class APInt to represent arbitrary precision constant integral values.
It is a functional replacement for common case integer type like "unsigned",
"uint64_t", but also allows non-byte-width integer type and large integer
value types such as 3-bits, 15-bits, or more than 64-bits of precision. For
more details, see pr1043.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33951 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06 03:00:16 +00:00
Chris Lattner
7ef856dfad Fix a bug in smallptrset::erase: in the small case, return true if the
element was in the set.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33931 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 23:10:31 +00:00
Chris Lattner
e4116f8553 Encode small integers more densely in foldingset, avoiding overflowing the SmallVector as often.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33864 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 01:48:10 +00:00
Chris Lattner
0de4439ad1 improve comments, add an assertion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33750 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-01 05:33:21 +00:00
Devang Patel
aed293dfba Add PrintVersionMessage() that tools can use to print version number
without exiting program.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33737 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-01 01:43:37 +00:00
Reid Spencer
9e693eb499 Add some debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33718 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 21:27:38 +00:00