Commit Graph

6755 Commits

Author SHA1 Message Date
Chris Lattner
c89fe6da17 Add a new function for the JIT. libsupport is now the only library that
includes mman.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13870 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:59:40 +00:00
Chris Lattner
0cb162b3bb Use the SystemUtils.h file to do our dirty work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13868 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:57:27 +00:00
Chris Lattner
e53477e56c Add support for zero length files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13866 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:34:42 +00:00
Chris Lattner
fb777c270b Use the new FileUtilities.h API for mapping a file into an address
space


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13864 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:24:41 +00:00
Chris Lattner
eb08299518 Add a pair of functions to hide system specific details of mapping a file in for reading.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13863 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:23:48 +00:00
Reid Spencer
4e6620c9e0 Remove some more dead code resulting from adding setTypeName().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13862 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-28 00:21:06 +00:00
Reid Spencer
9ed0f17a62 Remove an assertion that uses Type::TypeTy that is never hit and will
break when Type::TypeTy goes away. Also remove a dead block of code and
dead comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13861 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 22:05:50 +00:00
Reid Spencer
73b7495a96 Clean up a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13860 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 22:04:46 +00:00
Reid Spencer
5dff158858 Fix for bug 348.
The SymbolTable changes caused this one too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13859 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:58:13 +00:00
Brian Gaeke
aeb3c80e8d Make comment lines stick out less.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13858 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:41:48 +00:00
Chris Lattner
6f05f35a84 Remove long unused #includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13857 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:25:44 +00:00
Chris Lattner
63e8dfa8a3 These #includes are long dead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13856 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:24:38 +00:00
John Criswell
e7b9a1a5f2 Fix a bug in the -deadtypeelim pass. The SymbolTable re-write changed it
to eliminate the wrong type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13855 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 21:16:46 +00:00
Chris Lattner
1fc3739560 Fix warnings about reaching end of non-void function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13852 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 20:57:01 +00:00
Chris Lattner
0a576b00b6 Add DynamicLinker support for systems that provide windows.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13851 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 20:53:10 +00:00
Reid Spencer
6ed81e253c Use the SymbolTable::isEmpty() method instead of checking for no value
planes. A SymbolTable could still have types in it! This fixes problems
with two regression tests that failed because a symbol table that only
contained types was being omitted from bytecode files. Thanks to Chris
for the reduced test case that helped find this immediately.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13842 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 20:18:51 +00:00
Chris Lattner
c52663c4ed This code is a real mess, but at least get the JIT *building* on platforms
(such as plan 9) without mmap.  Of course it won't RUN... but that's another
step.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13839 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 18:03:56 +00:00
Chris Lattner
a0846a3fa7 Add support for dos-style files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13837 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 17:49:14 +00:00
Chris Lattner
e1368aef23 Fix InstCombine/load.ll & PR347.
This code hadn't been updated after the "structs with more than 256 elements"
related changes to the GEP instruction.  Also it was not handling the
ConstantAggregateZero class.

Now it does!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13834 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 17:30:27 +00:00
Chris Lattner
8dfe5705b1 Implement constant folding of fmod, which is used a lot in povray
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13823 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 07:25:00 +00:00
Chris Lattner
b18b9d7374 Restructure call constant folding code a bit to make it simpler
Add support for acos/asin/atan.  188.ammp contains three calls to acos with
constant arguments.  Constant folding it allows elimination of those 3 calls
and three FP divisions of the results.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13821 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 06:26:28 +00:00
Chris Lattner
bed85ff010 Header file moved
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13813 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 05:41:36 +00:00
Chris Lattner
a5648f2ea2 Signals.h header moved. Eventually this should move into a lib/System library,
but not right now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13811 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 05:31:24 +00:00
Chris Lattner
d895ffe122 Changes to make libSupport build on systems that don't have the wait syscall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13806 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 01:20:55 +00:00
Alkis Evlogimenos
75dbe8eafa Add constructors that take a BasicBlock to append to, to the rest of
the llvm::Instruction hierarchy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13800 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 00:15:23 +00:00
Alkis Evlogimenos
fe3a093bc6 Do not pass a null pointer if this instruction is not prepended or
appended anywhere.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13798 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 22:50:28 +00:00
Alkis Evlogimenos
f6e8cb4954 Inline trivial constructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13797 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 22:07:18 +00:00
Reid Spencer
b03de0c780 Several clean ups suggested by Chris: remove tabs, make SlotMachine do lazy
initialization so we don't scan large Modules/Functions needlessly, tighten
up restrictions on what can be put in SlotMachine (no Constants that aren't
GlobalValues).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13796 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 21:56:09 +00:00
Reid Spencer
75719bf239 Provide the correct patch for bug 345. The solution is to add a setTypeName
function to llvmAsmParser.y and then use it in the one place in the grammar
that needs it. Also had to make Type::setName public because setTypeName
needs it in order to retain compatibility with setValueName.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13795 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 21:48:31 +00:00
Alkis Evlogimenos
e5828f1fa7 Refactor common initialization code in private init() functions.
This is a first step in supplying append to basic block constructors
for all instruction types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 21:41:09 +00:00
Alkis Evlogimenos
99c58f4910 Use one destination constructor for the unconditional branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13792 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 21:38:14 +00:00
Chris Lattner
85acba6d58 Fix PR344: the incorrect remove was being used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13790 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 17:20:52 +00:00
Chris Lattner
42fbc7e809 A quick and ugly hack to fix PR345. I used TypeTy specifically to make
Reid cringe :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13788 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 17:08:25 +00:00
Reid Spencer
798ff64328 Part of bug 122:
This change removes the BuildBytecodeInfo flag from the SlotCalculator
class. This flag was needed to distinguish between the Bytecode/Writer
and the AsmWriter. Now that AsmWriter doesn't use SlotCalculator, we can
remove this flag and simplify some code. Also, some minor name changes
to CachedWriter.h needed to be committed (missed in previous commit).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13785 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 07:37:11 +00:00
Reid Spencer
0d1b77e282 Part of bug 122. Removed dependency of AsmWriter on SlotCalculator by
incorporating a significantly simpler "SlotMachine" into this file. The
SlotMachine is tailored for use by only the AsmWriter whose requirements
for slot numbers are vastly different than from the Bytecode/Writer. Code
change passes all Feature and Regression tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13784 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 07:18:52 +00:00
Tanya Lattner
ebac64534c Adding scheduling class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13783 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 06:27:36 +00:00
Tanya Lattner
4cffb588f5 Updating my cvs versions. THis is still in progress and much will be changed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13782 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-26 06:27:18 +00:00
Brian Gaeke
1812268126 Add a (not very meaningful) default constructor for AllocInfo objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13773 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 20:43:47 +00:00
Reid Spencer
6b1f58b6a4 Put SlotTable.h inclusion back at front of list to be coding standards
compliant. Thanks, Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13771 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 20:09:05 +00:00
Reid Spencer
a85b8cf110 Make the constructor explicit so we can't implicitly convert bool to
SlotTable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13766 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 19:09:25 +00:00
Reid Spencer
3751bd607b Make some improvements suggested by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13765 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 19:03:21 +00:00
Reid Spencer
293a55f9f0 Adding the initial implementation of the SlotTable class. This class is
the Abstract Data Type that holds slot number values and associates them
with Type* and Value*. The SlotTable is simply the holder of the slot
numbers and provides a controlled interface for building the table. It does
not enforce any particular idiom or functionality for manipulating the slot
numbers.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13764 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 18:44:51 +00:00
Alkis Evlogimenos
2662aa0f00 Remove this file as well as it is no longer needed nor it compiles
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13762 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 18:24:27 +00:00
Reid Spencer
fa452c0550 Document a couple functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13761 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 18:14:38 +00:00
Reid Spencer
94f2df295d Changed to use SymbolTable's new iteration interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13759 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 17:29:59 +00:00
Reid Spencer
b152f9ff78 Changed to use SymbolTable's new lookup interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13758 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 17:29:21 +00:00
Reid Spencer
875510805f Made it illegal to pass a Type* through one of the Value* interfaces. The
SymbolTable will now assert if this is done. This didn't find any incorrect
usage of SymbolTable but will prevent future mistakes until Type != Value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13755 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 15:20:47 +00:00
Reid Spencer
9231ac8b6f Convert to SymbolTable's new iteration interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13754 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:53:40 +00:00
Reid Spencer
af90b0d8b8 Convert to SymbolTable's new iteration interface. Remove tabs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13753 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:53:29 +00:00
Reid Spencer
b870c5f7c5 Completely rewrote the class. SymbolTable now separates Type* from Value* in preparation\
for making Type not derive from Value. There are now separate interfaces \
for looking up, finding, and inserting Types and Values. There are also \
three separate iterator interfaces, one for type planes, one for the types \
(type type plane), and one for values within a type plane. See the \
documentation in the Header file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13752 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:52:42 +00:00
Reid Spencer
567bc2cc1e Convert to SymbolTable's new lookup and iteration interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13751 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:52:20 +00:00
Reid Spencer
c8a1fcdb48 Remove unused header file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13750 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:36 +00:00
Reid Spencer
3f0635e012 Make this pass simply invoke SymbolTable::strip().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13749 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:25 +00:00
Reid Spencer
119b342b20 Remove use of Type::TypeTy from an assert. It will go away soon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13748 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:50:52 +00:00
Reid Spencer
0098bdfb97 Get rid of a wart: useless getFILE function is now a cast macro.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13747 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:46:15 +00:00
Vikram S. Adve
e4e97ef64d Recognize memalign and friends, and handle them specially.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13741 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:14:52 +00:00
Chris Lattner
3c6a0d4ae2 Implement InstCombine:shift.ll:test16, which turns (X >> C1) & C2 != C3
into (X & (C2 << C1)) != (C3 << C1), where the shift may be either left or
right and the compare may be any one.

This triggers 1546 times in 176.gcc alone, as it is a common pattern that
occurs for bitfield accesses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 06:32:08 +00:00
Chris Lattner
c971025b01 Implement some helpers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13738 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 05:32:43 +00:00
Chris Lattner
a710ddc9c4 Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13736 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 04:29:21 +00:00
Tanya Lattner
17fb34bf8c Moved MachineBasicBlock deconstructor to cpp file and removed it from LeakDetector to fix memory leak bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13718 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 07:14:35 +00:00
Chris Lattner
b11a99bd39 Fix a bug in my previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13717 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 06:24:46 +00:00
Tanya Lattner
792699c46e Added MachineFunction parent* to MachineBasicBlock. Customized ilist template
to set the parent when a MachineBasicBlock is added to a MachineFunction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13716 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 06:11:51 +00:00
Chris Lattner
5bf3ce2b7c Eliminate an explicit use of the LLVM basic block, using getParent instead,
which simplifies the code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13707 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 03:44:52 +00:00
Tanya Lattner
0c63e03e04 Changed clone to be const.
Changed copy constructor to set parent, prev, and next pointers to null.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13706 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-24 03:14:18 +00:00
Chris Lattner
f52988a92d Spelling people's names right is kinda important
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:27:29 +00:00
Chris Lattner
99c59e8e21 Add support for accurate garbage collection to the LLVM code generators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13696 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:23:35 +00:00
Chris Lattner
df04097f87 Add some notes to myself, no functional changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13695 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:23:12 +00:00
Chris Lattner
bbdbf30238 minor wording change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13694 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:22:55 +00:00
Chris Lattner
befa499d45 Fix cases where we missed inlining some more obvious candidates because the
caller was in an SCC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13693 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:22:17 +00:00
Chris Lattner
74c68ffd5f Simplify the interface and remove an unneeded #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13692 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:21:35 +00:00
Chris Lattner
9e7cc2f0d4 Fairly substantial changes to update the alias analysis we are querying as
we make the transformation.  This allows us to use interprocedural alias
analyses successfully.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13691 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:21:17 +00:00
Chris Lattner
2741c97104 Adjust to the changes in the AliasSetTracker interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13690 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:20:19 +00:00
Chris Lattner
057f78ab4e Add support for replacement of formal arguments with simpler expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13689 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:55 +00:00
Chris Lattner
08005dfdc9 Implement the -lowergc pass which is used by code generators (like the CBE)
that do not have builtin support for garbage collection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13688 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:22 +00:00
Chris Lattner
e899705c27 Recognize and verify the new GC intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13687 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:16:51 +00:00
Chris Lattner
5a24d70d99 Changes to work with the changes to the AliasAnalysis interface. The -no-aa
class is now in the BasicAliasAnalysis.cpp file


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13684 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:15:48 +00:00
Chris Lattner
b52f440860 Move the -no-aa AA implementation into this file since both of these
alias analysis implementations are special: they do not autoforward to a
chained implementation of alias analysis


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13683 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:15:12 +00:00
Chris Lattner
484e3027b2 Updates to work with the new auto-forwarding AA interface changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13682 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:14:27 +00:00
Chris Lattner
2412a05b80 Fix a really nasty bug with the -disable-ds-field-sensitivity option
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13681 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:14:09 +00:00
Chris Lattner
1bf3408f96 Update to match the autochaining interface that the AA interface uses
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13680 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:13:51 +00:00
Chris Lattner
0f312d6998 Implement the interfaces to update value numbering information. Add an
assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13679 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:13:24 +00:00
Chris Lattner
c43e0ae350 Rename a method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13676 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:10:58 +00:00
Chris Lattner
e995a2abb3 Add a simple implementation of Andersen's interprocedural pointer analysis
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13666 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:00:47 +00:00
Tanya Lattner
b5159ed0cb Fixed up my changes to add support for cloning Machine Instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13665 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 20:58:02 +00:00
Tanya Lattner
466b534a57 Adding support to clone MachineInstr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13661 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 19:35:12 +00:00
Vikram S. Adve
052682f1c3 Inline both direct and indirect callees in the CBU phase because
a direct callee may have indirect callees and so may have changed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13649 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 08:00:34 +00:00
Vikram S. Adve
c5204fb6f8 Complete rewrite of the code that merges DS graphs for equivalence classes
of functions called at a common call site.  The rewrite inlines the
resulting graphs bottom-up on the SCCs of the CBU call graph.  It also
simplifies the merging of equivalence classes by exploiting the fact that
functions in non-trivial SCCs are already merged.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13645 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 07:54:02 +00:00
Brian Gaeke
79333da2bb Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13643 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 05:10:06 +00:00
Chris Lattner
0f9e9d0ad2 Fix for PR340: Verifier misses malformed switch instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13618 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-21 16:47:21 +00:00
Chris Lattner
433e25a920 Fix to make the CBE always emit comparisons inline. Hopefully this will
fix the really bad code we're getting on PPC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13609 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-20 20:25:50 +00:00
Brian Gaeke
ceabd97423 Fix a bug in outputting branches to constant PCs. Since the PC is supplied as
a full 64-bit address, it must be adjusted to fit in the branch instruction's
immediate field. (This is only used in the reoptimizer, for now.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13608 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-20 07:43:40 +00:00
Brian Gaeke
a900452d37 Minor simplification: eliminate a dyn_cast.
Fix a typo in a debug message.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13607 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-19 21:30:01 +00:00
Brian Gaeke
c58a7f4b3c Add CloneTraceInto(), which is based on (and has mostly the same
effects as) CloneFunctionInto().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13601 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-19 09:08:14 +00:00
Brian Gaeke
6129af3fb1 Move RemapInstruction() to ValueMapper, so that it can be shared with
CloneTrace, and because it is primarily an operation on ValueMaps.  It
is now a global (non-static) function which can be pulled in using
ValueMapper.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13600 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-19 09:08:12 +00:00
Brian Gaeke
2fea9ade55 Fold two assertions with backwards error messages into one with a
correct error message.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13590 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-17 21:15:18 +00:00
Brian Gaeke
cc9620ca29 Clean up this pass somewhat:
Add better comments, including a better head-of-file comment.
Prune #includes.
Fix a FIXME that Chris put here by using doInitialization().
Use DEBUG() to print out debug msgs.
Give names to basic blocks inserted by this pass.
Expand tabs.
Use InsertProfilingInitCall() from ProfilingUtils to insert the initialize call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13581 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-14 21:21:52 +00:00
Brian Gaeke
09015d9468 Don't keep track of references to LLVM BasicBlocks while emitting; use
MachineBasicBlocks instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13568 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-14 06:54:58 +00:00
Brian Gaeke
3fb5d1a6cc Support MachineBasicBlock operands on RawFrm instructions.
Get rid of separate numbering for LLVM BasicBlocks; use the automatically
generated MachineBasicBlock numbering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13567 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-14 06:54:57 +00:00
Brian Gaeke
9f088e481c Generate branch machine instructions with MachineBasicBlock operands instead of
LLVM BasicBlock operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13566 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-14 06:54:56 +00:00
Chris Lattner
fa28bb4601 This was not meant to be committed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13565 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:56:34 +00:00
Chris Lattner
82fec4e31d Fix a nasty bug that caused us to unroll EXTREMELY large loops due to overflow
in the size calculation.

This is not something you want to see:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - UNROLLING!

The problem was that 2*2147483648 == 0.

Now we get:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - TOO LARGE: 4294967296>100

Thanks to some anonymous person playing with the demo page that repeatedly
caused zion to go into swapping land.  That's one way to ensure you'll get
a quick bugfix.  :)

Testcase here: Transforms/LoopUnroll/2004-05-13-DontUnrollTooMuch.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13564 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:43:31 +00:00
Chris Lattner
b7cb9ffd34 Two more improvements for null pointer handling: storing a null pointer
and passing a null pointer into a function.

For this testcase:

void %test(int** %X) {
  store int* null, int** %X
  call void %test(int** null)
  ret void
}

we now generate this:

test:
        sub %ESP, 12
        mov %EAX, DWORD PTR [%ESP + 16]
        mov DWORD PTR [%EAX], 0
        mov DWORD PTR [%ESP], 0
        call test
        add %ESP, 12
        ret

instead of this:

test:
        sub %ESP, 12
        mov %EAX, DWORD PTR [%ESP + 16]
        mov %ECX, 0
        mov DWORD PTR [%EAX], %ECX
        mov %EAX, 0
        mov DWORD PTR [%ESP], %EAX
        call test
        add %ESP, 12
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13558 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 15:26:48 +00:00
Chris Lattner
9f1b531090 Second half of my fixed-sized-alloca patch. This folds the LEA to compute
the alloca address into common operations like loads/stores.

In a simple testcase like this (which is just designed to excersize the
alloca A, nothing more):

int %test(int %X, bool %C) {
        %A = alloca int
        store int %X, int* %A
        store int* %A, int** %G
        br bool %C, label %T, label %F
T:
        call int %test(int 1, bool false)
        %V = load int* %A
        ret int %V
F:
        call int %test(int 123, bool true)
        %V2 = load int* %A
        ret int %V2
}

We now generate:

test:
        sub %ESP, 12
        mov %EAX, DWORD PTR [%ESP + 16]
        mov %CL, BYTE PTR [%ESP + 20]
***     mov DWORD PTR [%ESP + 8], %EAX
        mov %EAX, OFFSET G
        lea %EDX, DWORD PTR [%ESP + 8]
        mov DWORD PTR [%EAX], %EDX
        test %CL, %CL
        je .LBB2 # PC rel: F
.LBB1:  # T
        mov DWORD PTR [%ESP], 1
        mov DWORD PTR [%ESP + 4], 0
        call test
***     mov %EAX, DWORD PTR [%ESP + 8]
        add %ESP, 12
        ret
.LBB2:  # F
        mov DWORD PTR [%ESP], 123
        mov DWORD PTR [%ESP + 4], 1
        call test
***     mov %EAX, DWORD PTR [%ESP + 8]
        add %ESP, 12
        ret

Instead of:

test:
        sub %ESP, 20
        mov %EAX, DWORD PTR [%ESP + 24]
        mov %CL, BYTE PTR [%ESP + 28]
***     lea %EDX, DWORD PTR [%ESP + 16]
***     mov DWORD PTR [%EDX], %EAX
        mov %EAX, OFFSET G
        mov DWORD PTR [%EAX], %EDX
        test %CL, %CL
***     mov DWORD PTR [%ESP + 12], %EDX
        je .LBB2 # PC rel: F
.LBB1:  # T
        mov DWORD PTR [%ESP], 1
        mov %EAX, 0
        mov DWORD PTR [%ESP + 4], %EAX
        call test
***     mov %EAX, DWORD PTR [%ESP + 12]
***     mov %EAX, DWORD PTR [%EAX]
        add %ESP, 20
        ret
.LBB2:  # F
        mov DWORD PTR [%ESP], 123
        mov %EAX, 1
        mov DWORD PTR [%ESP + 4], %EAX
        call test
***     mov %EAX, DWORD PTR [%ESP + 12]
***     mov %EAX, DWORD PTR [%EAX]
        add %ESP, 20
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13557 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 15:12:43 +00:00
Chris Lattner
cb2fd557ee Substantially improve code generation for address exposed locals (aka fixed
sized allocas in the entry block).  Instead of generating code like this:

entry:
  reg1024 = ESP+1234
... (much later)
  *reg1024 = 17


Generate code that looks like this:
entry:
  (no code generated)
... (much later)
  t = ESP+1234
  *t = 17

The advantage being that we DRAMATICALLY reduce the register pressure for these
silly temporaries (they were all being spilled to the stack, resulting in very
silly code).  This is actually a manual implementation of rematerialization :)

I have a patch to fold the alloca address computation into loads & stores, which
will make this much better still, but just getting this right took way too much time
and I'm sleepy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13554 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 07:40:27 +00:00
Chris Lattner
bee887211b Fix a really nasty bug from my changes on Monday to PHIElim. These changes
broke obsequi and a lot of other things.  It all boiled down to MBB being
overloaded in an inner scope and me confusing it with the one in the outer
scope.  Ugh!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13517 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 21:47:57 +00:00
Brian Gaeke
d657c42dce Start NextMBBNumber out at zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13515 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 21:35:23 +00:00
Brian Gaeke
0bcb1ad7be Add non-const MachineBasicBlock::getParent() accessor method.
MBBs start out as #-1. When a MBB is added to a MachineFunction, it
gets the next available unique MBB number. If it is removed from a
MachineFunction, it goes back to being #-1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13514 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 21:35:22 +00:00
Chris Lattner
2b10b08ad6 Pass boolean constants into function calls more efficiently, generating:
mov DWORD PTR [%ESP + 4], 1

instead of:

        mov %EAX, 1
        mov DWORD PTR [%ESP + 4], %EAX


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13494 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 16:35:04 +00:00
Chris Lattner
587992721c Do not pass in the same argument to the extracted function more than once, and
give the extracted function a more useful name than just foo_code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13493 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 16:26:18 +00:00
Chris Lattner
d99e1d3afb Implement support for code extracting basic blocks that have a return
instruction in them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 16:07:41 +00:00
Chris Lattner
e746ad512e Implement splitting of PHI nodes, allowing block extraction of BB's that have
PHI node entries from multiple outside-the-region blocks.  This also fixes
extraction of the entry block in a function.  Yaay.

This has successfully block extracted all (but one) block from the score_move
function in obsequi (out of 33).  Hrm, I wonder which block the bug is in.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13489 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 15:29:13 +00:00
Chris Lattner
bf749367cb * Pull some code out into the definedInRegion/definedInCaller methods
* Add a stub for the severSplitPHINodes which will allow us to bbextract
  bb's with PHI nodes in them soon.
* Remove unused arguments from findInputsOutputs
* Dramatically simplify the code in findInputsOutputs.  In particular,
  nothing really cares whether or not a PHI node is using something.
* Move moveCodeToFunction to after emitCallAndSwitchStatement as that's the
  order they get called.
* Fix a bug where we would code extract a region that included a call to
  vastart.  Like 'alloca', calls to vastart must stay in the function that
  they are defined in.
* Add some comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13482 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 06:01:40 +00:00
Chris Lattner
346be7f5bc Generate substantially better code when there are a limited number of exits
from the extracted region.  If the return has 0 or 1 exit blocks, the new
function returns void.  If it has 2 exits, it returns bool, otherwise it
returns a ushort as before.

This allows us to use a conditional branch instruction when there are two
exit blocks, as often happens during block extraction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13481 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 04:14:24 +00:00
Chris Lattner
5b01e298ed Two minor improvements:
1. Get rid of the silly abort block.  When doing bb extraction, we get one
     abort block for every block extracted, which is kinda annoying.
  2. If the switch ends up having a single destination, turn it into an
     unconditional branch.

I would like to add support for conditional branches, but to do this we will
want to have the function return a bool instead of a ushort.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13478 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 03:22:33 +00:00
Chris Lattner
8abf69374e Switch this from using an std::map to using a DenseMap. This speeds up
phi-elimination from 0.6 to 0.54s on kc++.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13454 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-10 19:17:36 +00:00
Chris Lattner
80e20eb487 Use a new VRegPHIUseCount to compute uses of PHI values by other phi values
in the basic block being processed.  This fixes PhiElimination on kimwitu++
from taking 105s to taking a much more reasonable 0.6s (in a debug build).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13453 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-10 19:06:37 +00:00
Chris Lattner
791f896d9f Now that we use an ilist of machine instructions, iterators are more robust
than before.  Because this is the case, we can compute the first non-phi
instruction once when de-phi'ing a block.  This shaves ~4s off of
phielimination of _Z7yyparsev in kimwitu++ from 109s -> 105s.  There are
still much more important gains to come.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13452 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-10 18:47:18 +00:00
Chris Lattner
c81e6bae88 Fix a fairly serious pessimizaion that was preventing us from efficiently
compiling things like 'add long %X, 1'.  The problem is that we were switching
the order of the operands for longs even though we can't fold them yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13451 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-10 15:15:55 +00:00
Chris Lattner
6d3848df7e Patch to fix PR337. Make sure to mark all aliased physical registers as used
when we see a read of a register.  This is important in cases like:

AL = ...
AH = ...

   = AX

The read of AX must make both the AL and AH defs live until the use.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13444 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-10 05:12:43 +00:00
Chris Lattner
9984fd0df9 Fix some comments, avoid sign extending booleans when zero extend works fine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13440 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 23:16:33 +00:00
Chris Lattner
96e3b426d5 Generate more efficient code for casting booleans to integers (no sign extension required)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13439 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 22:28:45 +00:00
Chris Lattner
cb3ad01833 syntactically loopify natural loops so that the GCC loop optimizer can find them. This should *dramatically* improve the performance of CBE compiled code on targets that depend on GCC's loop optimizations (like PPC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13438 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 20:41:32 +00:00
Chris Lattner
4589ed9510 Do not emit prototypes for setjmp/longjmp, as they are handled specially
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13437 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 16:03:29 +00:00
Chris Lattner
0555ed8bff Fine grainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13436 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 06:22:29 +00:00
Chris Lattner
6875807572 Make the floating point constant pools local to each function, split the
FindUsedTypes manipulation stuff out to be a seperate pass, and make the
main CWriter be a function pass now!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13435 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 06:20:51 +00:00
Chris Lattner
c2421439b5 Get this looking more like a function pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13433 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 04:30:20 +00:00
Chris Lattner
0979ca7e3e Implement the AddPrototypes method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13432 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 04:29:57 +00:00
Chris Lattner
a05e0ec419 Print all PHI copies for successor blocks before the terminator, whether it be a conditional branch or switch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13430 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-09 03:42:48 +00:00
Chris Lattner
be97b4e9ab Fix stupid bug in my checkin yesterday
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13429 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 22:41:42 +00:00
Tanya Lattner
6b160503b5 Changed CPUResource to allow access to maxnum users.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13425 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 16:12:50 +00:00
Tanya Lattner
73e3e2e10f Updating my versions of ModuloScheduling in cvs. Still not complete.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13424 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 16:12:10 +00:00
Brian Gaeke
429022bf83 Add support for widening integral casts.
Flesh out the SetCC support... which currently ends in a little bit
of unfinished code (which is probably completely hilarious) for
generating the condition value splitting the basic block up into 4
blocks, like this (clearly a better API is needed for this!):

       BB
   cond. branch
     /         /          R1=1    R2=0
     \      /
      \    /
    R=phi(R1,R2)

Other minor edits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13423 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 06:36:14 +00:00
Brian Gaeke
59dbff714c Add a bunch more branches
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13422 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 06:08:29 +00:00
Brian Gaeke
9f56482a43 Flesh out GEP support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13421 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 05:27:20 +00:00
Brian Gaeke
6b1d2fa1d1 Add ADD with immediate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13420 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 05:26:55 +00:00
Brian Gaeke
c3e970122a Add forms of CMP, SUBCC, and a few branches, and some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13419 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 04:21:32 +00:00
Brian Gaeke
532e60c403 Add stub support for GEPs.
Add support for branches (based loosely on X86/InstSelectSimple).
Add support for not visiting phi nodes in the first pass.
Add support for loading bools.
Flesh out support for stores.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13418 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 04:21:17 +00:00
Alkis Evlogimenos
880e8e4b4c Add required header
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13417 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 03:50:03 +00:00
Alkis Evlogimenos
feab248c93 Remove unneeded header
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13416 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 03:49:35 +00:00
Chris Lattner
620ce14666 Implement folding of GEP's like:
%tmp.0 = getelementptr [50 x sbyte]* %ar, uint 0, int 5         ; <sbyte*> [#uses=2]
        %tmp.7 = getelementptr sbyte* %tmp.0, int 8             ; <sbyte*> [#uses=1]

together.  This patch actually allows us to simplify and generalize the code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 22:09:22 +00:00
Brian Gaeke
e302a7eb43 Add support for copying bool constants to registers.
Disable the code that copies long constants to registers - it looks fishy.
Implement some simple casts: integral, smaller than longs, and equal-width
 or narrowing only.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13413 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 21:39:30 +00:00
Chris Lattner
e7a31c98db Codegen floating point stores of constants into integer instructions. This
allows us to compile:

store float 10.0, float* %P

into:
        mov DWORD PTR [%EAX], 1092616192

instead of:

.CPItest_0:                                     # float 0x4024000000000000
.long   1092616192      # float 10
...
        fld DWORD PTR [.CPItest_0]
        fstp DWORD PTR [%EAX]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13409 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 21:18:15 +00:00
Chris Lattner
260195d2b1 Make comparisons against the null pointer as efficient as integer comparisons
against zero.  In particular, don't emit:

        mov %ESI, 0
        cmp %ECX, %ESI

instead, emit:

       test %ECX, %ECX


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13407 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 19:55:55 +00:00
Chris Lattner
546516c3c0 Fix PR336: The instcombine pass asserts when visiting load instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 15:35:56 +00:00
John Criswell
8cb23dad20 Don't call getForwardedType() twice, as recommended by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13391 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-06 22:15:47 +00:00
Chris Lattner
bf455c2360 Implement the new cl::PositionalEatsArgs flag, refactor code a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13388 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-06 22:04:31 +00:00
John Criswell
7775c1f136 Fix for PR#330.
When looking at getelementptr instructions, make sure to use a forwarded
type.  We want to do this because a DerivedType may drop its uses and then
refine its users, who may then use another user who hasn't been refined yet.
By getting the forwarded type, we always ensure that we're looking at a
Type that isn't in a halfway refined state.

Now, I should be able to put this stuff in PATypeHandle, but it doesn't work
for some reason.  This should do for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13386 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-06 21:18:08 +00:00
Chris Lattner
a19eedeb7a numeric_limits::infinity() apparently does not work on all systems. As a
workaround, use the C HUGE_VAL macro instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13377 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-06 16:25:59 +00:00
Brian Gaeke
6178085cfd Move the stuff that fixes the size, orientation & fonts of graphs to
the debugging functions that call "dot". These fixed settings have
various problems: for example, the fixed size that is set in the graph
traits classes is not appropriate for turning the dot file into a PNG,
and if TrueType font rendering is being used, the 'Courier' TrueType font
may not be installed. It seems easy enough to specify these things on the
command line, anyhow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13366 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-05 06:10:06 +00:00
Brian Gaeke
48b008db57 Apply simplification suggested by Chris: why assign() when operator = will do?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13364 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 22:02:41 +00:00
John Criswell
4a9c90446d Fixed inconsistent indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13363 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 21:46:05 +00:00
Brian Gaeke
7ca6712f81 Missing piece of fix for Bug 333
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13362 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 21:41:45 +00:00
Brian Gaeke
7e4375365e Correctly mangle function names when they are used as part of a
constant pool member's name.
This is intended to address Bug 333.

Also, fix an anachronistic usage of "M" as a parameter of type Function *.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13357 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 21:09:02 +00:00
Brian Gaeke
d11577b68b Add "Args" optional argument to AbstractInterpreter factory methods, which
fills in a ToolArgs vector in the AbstractInterpreter if it is set. This
ToolArgs vector is used to pass additional arguments to LLI and/or LLC.
This is intended to address Bug 40.

Also, make -debug-only=toolrunner work for the LLC and CBE
AbstractInterpreters.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13356 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 21:09:01 +00:00
Chris Lattner
bbc130d110 Remove unneeded check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13355 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 19:35:11 +00:00
Chris Lattner
c8af02c403 Improve signed division by power of 2 *dramatically* from this:
div:
        mov %EDX, DWORD PTR [%ESP + 4]
        mov %ECX, 64
        mov %EAX, %EDX
        sar %EDX, 31
        idiv %ECX
        ret

to this:

div:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, %EAX
        sar %ECX, 5
        shr %ECX, 26
        mov %EDX, %EAX
        add %EDX, %ECX
        sar %EAX, 6
        ret

Note that the intel compiler is currently making this:

div:
        movl      4(%esp), %edx                                 #3.5
        movl      %edx, %eax                                    #4.14
        sarl      $5, %eax                                      #4.14
        shrl      $26, %eax                                     #4.14
        addl      %edx, %eax                                    #4.14
        sarl      $6, %eax                                      #4.14
        ret                                                     #4.14

Which has one less register->register copy.  (hint hint alkis :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13354 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 19:33:58 +00:00
Brian Gaeke
b171d7949d Add stub support for reading BBTraces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13352 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 17:11:14 +00:00
Chris Lattner
b9110c61fb Do not mark instructions in unreachable sections of the function as live.
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13349 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 17:00:46 +00:00
Brian Gaeke
660ef70b62 Share ProfilingType enum with the C profiling runtime libraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13346 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 16:53:07 +00:00
Chris Lattner
9eb9b8ecb9 Improve code generated for integer multiplications by 2,3,5,9
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13342 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 15:47:14 +00:00
Chris Lattner
32ed46b36e Minor efficiency tweak, suggested by Patrick Meredith
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13341 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 15:19:33 +00:00
Brian Gaeke
96e68f9ab1 Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13340 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-03 23:52:07 +00:00
Brian Gaeke
ebbc0e9bbf In InsertProfilingInitCall(), make it legal to pass in a null array, in
which case you'll get a null array and zero passed to the profiling function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13336 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-03 22:06:33 +00:00
Brian Gaeke
c03eb7b923 Add initial implementation of basic-block tracing instrumentation pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13335 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-03 22:06:32 +00:00
Chris Lattner
7b11e339d2 Fix a problem with double freeing memory. For some reason, CallGraph is not
acting like a normal pass.  :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13318 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 16:06:18 +00:00
Chris Lattner
224f7e65e0 Plug a minor memory leak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13317 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 07:31:34 +00:00
Chris Lattner
bdcc0b8c55 Do not clone arbitrary condition instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13316 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 05:19:36 +00:00
Chris Lattner
12fe2b1b82 Do not infinitely "unroll" single BB loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13315 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 05:02:03 +00:00
Chris Lattner
a1f79fb08b Dont' merge terminators that are needed to select PHI node values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13312 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 01:00:44 +00:00
Chris Lattner
e67fa05036 Implement SimplifyCFG/branch-cond-merge.ll
Turning "if (A < B && B < C)" into "if (A < B & B < C)"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13311 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:35:43 +00:00
Chris Lattner
00d513182d Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13309 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:27:23 +00:00
Chris Lattner
216d4d85fd Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13308 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:19:52 +00:00
Chris Lattner
951fdb9764 Fix my missing parens
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13307 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 22:41:51 +00:00
Chris Lattner
92da2c2053 Implement SimplifyCFG/branch-cond-prop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13306 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 22:36:37 +00:00
Chris Lattner
77993632a1 Remove unused #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13304 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 21:29:16 +00:00
Chris Lattner
2268684f6f Iterate over the Machine CFG that Brian added instead of the LLVM CFG.
Look at all of the pretty minuses. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13303 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 21:27:53 +00:00
Chris Lattner
015959ee38 Operate on the Machine CFG instead of on the LLVM CFG
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13302 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 21:24:39 +00:00
Chris Lattner
f25fb4bc64 Stop LiveVariables from using BasicBlocks as part of the mapping, instead
use MachineBasicBlocks.  To do this, we traverse the Machine CFG instead of
the LLVM CFG, which is also *MUCH* more efficient by having fewer levels of
indirections and mappings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13301 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 21:24:24 +00:00
Chris Lattner
55a4700857 Add a constructor that got lost
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13297 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 11:17:13 +00:00
Brian Gaeke
3c66c355b6 Generalize the strlen size_t hack, for the benefit of the other external
functions with wrappers that either take or return size_ts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13296 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 06:42:15 +00:00
Tanya Lattner
0e1c48b209 Removing MachineResource class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13291 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-30 20:40:38 +00:00
Chris Lattner
c1526a9da1 Fix a major pessimization in the instcombiner. If an allocation instruction
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.

Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function.  This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.

This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13289 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-30 04:37:52 +00:00
Misha Brukman
96a8bd7f54 Wrapped code and comments at 80 cols; doxygenified some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13264 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-29 04:05:30 +00:00
Misha Brukman
bf94a1e22a Reorder #includes as per style guide.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13263 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-29 04:04:47 +00:00
Misha Brukman
e5242def97 class AssemblyWriter:
* Make contained ostream pointer, not reference
* Allow setting of that ostream via setStream()

class CachedWriter:
* setStream() in turn calls setStream() on the AssemblyWriter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13247 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 19:24:28 +00:00
Misha Brukman
8618e52be5 Send text and numbers directly to CachedWriter's contained ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13243 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 18:52:43 +00:00
Misha Brukman
500acf72cc Squelch compile-time warning (profile build).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13228 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 15:32:09 +00:00
Misha Brukman
5cf1acff3c * Add ability to print out type as symbolic
* Add Module accessor to AssemblyWriter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13227 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 15:31:21 +00:00
Brian Gaeke
1afe7736ff Make RequiresFPRegKill() take a MachineBasicBlock arg.
In InsertFPRegKills(), just check the MachineBasicBlock for successors
instead of its corresponding BasicBlock.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13213 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 04:45:55 +00:00
Brian Gaeke
235aa5eba7 In InsertFPRegKills(), use the machine-CFG itself rather than the
LLVM CFG when trying to find the successors of BB.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13212 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 04:34:16 +00:00
Brian Gaeke
ea9ca67304 Update the machine-CFG edges whenever we see a branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13211 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-28 04:19:37 +00:00
Brian Gaeke
235d3b7b52 Integrate the rest of my random sparcv9 scribblings into this file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13204 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-27 22:04:03 +00:00
Chris Lattner
003d5173ca Fix warning building in optimized mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13190 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-27 18:24:38 +00:00
Chris Lattner
6ffe551f65 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13185 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-27 15:13:33 +00:00
Brian Gaeke
c6e2d8a2ff Add functions that return instances of these printer passes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13175 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-26 16:27:08 +00:00
Chris Lattner
bac7da8461 If an object is not in the scalar map then it must be a global from another
graph.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13173 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-26 14:44:08 +00:00
Chris Lattner
83a2e6e4a1 Instcombine X/-1 --> 0-X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13172 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-26 14:01:59 +00:00
Brian Gaeke
3ca4fccac5 Fix file header comments and include guards -- many files have been moved or
renamed since they were last spiffed up, or they just never had proper comments
in the first place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13148 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-25 07:04:49 +00:00
Brian Gaeke
27beae85a0 Add a getRegisterInfo() accessor just like on the X86 target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13147 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-25 06:32:28 +00:00
Brian Gaeke
c991586b92 Regularize file header comment and include guard.
Include SparcV9RegisterInfo.h.
Add a getRegisterInfo() accessor and SparcV9RegisterInfo instance, just like
on the X86 target.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13146 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-25 06:32:16 +00:00
Brian Gaeke
2363b4ef5b Add MRegisterInfo subclass for the SparcV9 target (containing only stub
functions for now). This automatically turns on the printing of machine
registers using their own real names, instead of goofy things like %mreg(42),
and allows us to migrate code incrementally to the new interface as we see fit.

The register file description it uses is hand-written, so that the register
numbers will match the ones that the SparcV9 target already uses.
Perhaps someday we'll tablegen it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13145 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-25 06:32:05 +00:00
Misha Brukman
22108fac63 * Allow aggregating extracted function arguments (controlled by flag)
* Commandline option (for now) controls that flag that is passed in


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13141 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 23:54:17 +00:00
Brian Gaeke
dd6d822fa6 Fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13136 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 21:45:02 +00:00
Chris Lattner
4a7553e2da Move the scev expansion code into this pass, where it belongs. There is
still room for cleanup, but at least the code modification is out of the
analysis now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13135 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 21:29:48 +00:00
Chris Lattner
b06432c276 Eliminate all of the SCEV Expansion code which is really part of the
IndVars pass, not part of SCEV *analysis*.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13134 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 21:29:03 +00:00
Brian Gaeke
18f9f66369 Merge TargetRegInfo.h into SparcV9RegInfo.h, which is its only subclass.
This prepares us to be able to de-virtualize and de-abstract it, and
take the register allocator bits out and move them into the register allocator
proper...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13127 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 18:15:48 +00:00
Brian Gaeke
3b2e5e619e Include SparcV9RegInfo.h instead of TargetRegInfo.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13126 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 18:15:47 +00:00
Brian Gaeke
35450d2aaa Include SparcV9RegInfo.h instead of TargetRegInfo.h. This serves as a bit of
documentation that this module needs to be made independent of the
register file description of the current target.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13125 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 18:15:46 +00:00
Brian Gaeke
4d529bc07b Get rid of the old byte-at-a-time emission code used when the Sparc JIT was
being tested on X86, as per Chris's request.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13124 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 18:10:38 +00:00
Brian Gaeke
b440dea57b Go back to the interpreter main loop after performing intrinsic lowering,
because 1) the first instruction might not be a call site, and
2) CS and SF.Caller were not getting set to point to the new call site
anyway (resulting in a crash on e.g. call %llvm.memset).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13122 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 18:05:28 +00:00
Brian Gaeke
b61fc83ecb Use emitWordAt() to emit forward-branch fixups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13120 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 17:11:16 +00:00
Brian Gaeke
62c6f879ae Emit SPARC machine code a word at a time instead of a byte at a time.
Use emitWordAt() to emit forward-branch fixups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13119 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 17:11:15 +00:00
Brian Gaeke
aea1b58f1e Implement emitWordAt() for the JIT emitter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13118 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 17:11:14 +00:00
Brian Gaeke
da8246bb71 Implement emitWordAt() for the debug emitter and the file printer emitter. (I
am not so sure about the file printer emitter, but the debug emitter change
should be harmless.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13117 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 17:11:13 +00:00
Misha Brukman
7d248397a7 Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
the function instead of isolating it. This also means the condition is reversed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13112 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 23:00:51 +00:00
Misha Brukman
79906c9825 Add a flag to choose between isolating a function or deleting the function from
the Module. The default behavior keeps functionality as before: the chosen
function is the one that remains.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13111 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 22:52:22 +00:00
Chris Lattner
b4782d13d1 Disable a previous patch that was causing indvars to loop infinitely :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13108 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 15:12:36 +00:00
Chris Lattner
fcb81f5f4c Fix an extremely serious thinko I made in revision 1.60 of this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13106 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 14:59:40 +00:00
Chris Lattner
1363e85df7 Implement a todo, rewriting all possible scev expressions inside of the
loop.  This eliminates the extra add from the previous case, but it's
not clear that this will be a performance win overall.  Tommorows test
results will tell. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13103 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 23:36:08 +00:00
Chris Lattner
4e5f03602c This code really wants to iterate over the OPERANDS of an instruction, not
over its USES.  If it's dead it doesn't have any uses!  :)

Thanks to the fabulous and mysterious Bill Wendling for pointing this out.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13102 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 22:29:37 +00:00
Chris Lattner
5d461d20ae Implement a fixme. The helps loops that have induction variables of different
types in them.  Instead of creating an induction variable for all types, it
creates a single induction variable and casts to the other sizes.  This generates
this code:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=4]
***     %j.0.0 = cast uint %indvar to short             ; <short> [#uses=1]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %j.0.0, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %no_exit, label %loopexit

instead of:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ]          ; <ushort> [#uses=2]
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %indvar = cast ushort %indvar to short          ; <short> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %indvar, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1
***     %indvar.next = add ushort %indvar, 1
        br bool %tmp.2, label %no_exit, label %loopexit

This is an improvement in register pressure, but probably doesn't happen that
often.

The more important fix will be to get rid of the redundant add.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13101 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 22:22:01 +00:00
Chris Lattner
3e1358a9fa Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :)
Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead
of a vector of pointers to them, but today is not that day.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13100 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 20:44:33 +00:00
Misha Brukman
af76cfb0fb I'm allergic to the word `stuff'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13096 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 18:27:56 +00:00
Brian Gaeke
6896a7dd43 Make SparcV9RegInfo::getRegType() return the right answer for registers
of IntCC, FloatCC, and Special types.

Make SparcV9RegInfo::getRegClassIDOfRegType() return the right answer
if you ask for the class corresponding to SpecialRegType.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13095 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 17:53:58 +00:00
Alkis Evlogimenos
09233fb86e Include cerrno (gcc-3.4 fix)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13091 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 16:11:40 +00:00
Chris Lattner
107fb18d89 Fix typeo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13089 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 14:23:18 +00:00
Chris Lattner
68d57e7ae8 REALLY fix PR324: don't delete linkonce functions until after the SCC traversal
is done, which avoids invalidating iterators in the SCC traversal routines


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13088 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 22:06:53 +00:00
Chris Lattner
72035995d5 Pass the callgraph not the module
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13087 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 21:52:26 +00:00
Chris Lattner
a10df50282 Add the ability for SCC passes to initialize and finalize themselves
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13084 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 21:30:06 +00:00
Chris Lattner
c99acc3709 Fix PR325
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13081 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 20:26:03 +00:00
Chris Lattner
5ad2b1d544 Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13080 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 20:20:59 +00:00
Brian Gaeke
3f083d5de6 Make it legal to ask for the type of a specialreg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13078 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 20:12:57 +00:00
Chris Lattner
759d34ffb7 Add support for the select instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13076 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 16:43:21 +00:00
Brian Gaeke
0eb61037f7 Make it legal to request a load or store of %fsr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13073 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 19:12:12 +00:00
Brian Gaeke
94178e9fca Regularize include guards and remove some excess whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13071 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:53:44 +00:00
Brian Gaeke
03b562aecb Tighten up SparcV9FloatCCRegClass::getRegName()'s assertion - if you ask it for
the name of %fsr (as the comment in SparcV9RegClassInfo.h used to suggest)
you would walk off the end of the FloatCCRegName array.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13070 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:53:43 +00:00
Brian Gaeke
854db8a29a Regularize include guards, remove some excess whitespace and fix some comments.
Remove the extra %fsr register from SparcV9FloatCCRegClass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13069 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:53:42 +00:00
Chris Lattner
18f16094c2 Initial checkin of a simple loop unswitching pass. It still needs work,
but it's a start, and seems to do it's basic job.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13068 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:07:02 +00:00
Chris Lattner
45a1cf87d4 It's not just a printer, it's actually an analysis too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13064 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:42:32 +00:00
Chris Lattner
446b86d381 Remove code to update loop depths
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13058 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:02:09 +00:00
Chris Lattner
5864aebe92 Add #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13057 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:01:23 +00:00
Chris Lattner
3280f7bd55 Move isLoopInvariant to the Loop class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13051 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:46:08 +00:00
Chris Lattner
85661d0978 Add new method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13050 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:45:27 +00:00
Chris Lattner
59fb87d469 Correct rewriting of exit blocks after my last patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13048 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:27:10 +00:00
Chris Lattner
343c0cfa19 Fix computation of exit blocks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13047 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:21:41 +00:00
Chris Lattner
5fa802fe27 Loop exit sets are no longer explicitly held, they are dynamically computed on demand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13046 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:15:13 +00:00
Chris Lattner
f1ab4b4eac Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand.  This makes updating
loop information MUCH easier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13045 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:14:10 +00:00
Chris Lattner
e3a55865bb Reduce the unrolling limit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13040 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 18:06:14 +00:00
Chris Lattner
cc43909bb6 If the preheader of the loop was the entry block of the function, make sure
that the exit block of the loop becomes the new entry block of the function.

This was causing a verifier assertion on 252.eon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13039 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 17:38:42 +00:00
Chris Lattner
998f44f859 Be much more careful about how we update instructions outside of the loop
using instructions inside of the loop.  This should fix the MishaTest failure
from last night.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13038 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 17:32:39 +00:00
Chris Lattner
3048bd1d3e Implement method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13036 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:54:48 +00:00
Chris Lattner
50ca0a195a After unrolling our single basic block loop, fold it into the preheader and exit
block.  The primary motivation for doing this is that we can now unroll nested loops.

This makes a pretty big difference in some cases.  For example, in 183.equake,
we are now beating the native compiler with the CBE, and we are a lot closer
with LLC.

I'm now going to play around a bit with the unroll factor and see what effect
it really has.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13034 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:27:43 +00:00
Chris Lattner
9c2cc4626b Fix a bug: this does not preserve the CFG!
While we're at it, add support for updating loop information correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13033 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:38:37 +00:00
Chris Lattner
24199db80e Add a new method, add a check missing that caused a segfault if a loop didn't
have a canonical indvar


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13032 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:38:05 +00:00
Chris Lattner
83bf2880c3 Initial checkin of a simple loop unroller. This pass is extremely basic and
limited.  Even in it's extremely simple state (it can only *fully* unroll single
basic block loops that execute a constant number of times), it already helps improve
performance a LOT on some benchmarks, particularly with the native code generators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13028 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:20:17 +00:00
Chris Lattner
3c85eef81a Make the tail duplication threshold accessible from the command line instead of hardcoded
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13025 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 00:52:43 +00:00
Chris Lattner
f57a43da9c Fix a memory leak. We leaked the vector holding the entries in switch tables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13023 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 23:49:15 +00:00
Chris Lattner
3221ad0db7 Add the ability to compute exit values for complex loop using unanalyzable
operations.  This allows us to compile this testcase:

int main() {
        int h = 1;
         do h = 3 * h + 1; while (h <= 256);
        printf("%d\n", h);
        return 0;
}

into this:

int %main() {
entry:
        call void %__main( )
        %tmp.6 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]*  %.str_1, long 0, long 0), int 364 )        ; <int> [#uses=0]
        ret int 0
}

This testcase was taken directly from 256.bzip2, believe it or not.

This code is not as general as I would like.  Next up is to refactor it
a bit to handle more cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13019 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 22:58:41 +00:00
Chris Lattner
20aa098ba6 If the loop executes a constant number of times, try a bit harder to replace
exit values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13018 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:44:09 +00:00
Chris Lattner
7980fb9007 Add the ability to compute trip counts that are only controlled by constants
even if the loop is using expressions that we can't compute as a closed-form.
This allows us to calculate that this function always returns 55:

int test() {
  double X;
  int Count = 0;
  for (X = 100; X > 1; X = sqrt(X), ++Count)
    /*empty*/;
  return Count;
}

And allows us to compute trip counts for loops like:

        int h = 1;
         do h = 3 * h + 1; while (h <= 256);

(which occurs in bzip2), and for this function, which occurs after inlining
and other optimizations:

int popcount()
{
   int x = 666;
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}

We still cannot compute the exit values of result or h in the two loops above,
which means we cannot delete the loop, but we are getting closer.  Being able to
compute a constant trip count for these two loops will allow us to unroll them
completely though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13017 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:36:24 +00:00
Chris Lattner
4f1134e51a Fix a HUGE pessimization on X86. The indvars pass was taking this
(familiar) function:

int _strlen(const char *str) {
    int len = 0;
    while (*str++) len++;
    return len;
}

And transforming it to use a ulong induction variable, because the type of
the pointer index was left as a constant long.  This is obviously very bad.

The fix is to shrink long constants in getelementptr instructions to intptr_t,
making the indvars pass insert a uint induction variable, which is much more
efficient.

Here's the before code for this function:

int %_strlen(sbyte* %str) {
entry:
        %tmp.13 = load sbyte* %str              ; <sbyte> [#uses=1]
        %tmp.24 = seteq sbyte %tmp.13, 0                ; <bool> [#uses=1]
        br bool %tmp.24, label %loopexit, label %no_exit

no_exit:                ; preds = %entry, %no_exit
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=2]
***     %indvar = phi ulong [ %indvar.next, %no_exit ], [ 0, %entry ]           ; <ulong> [#uses=2]
        %indvar1 = cast ulong %indvar to uint           ; <uint> [#uses=1]
        %inc.02.sum = add uint %indvar1, 1              ; <uint> [#uses=1]
        %inc.0.0 = getelementptr sbyte* %str, uint %inc.02.sum          ; <sbyte*> [#uses=1]
        %tmp.1 = load sbyte* %inc.0.0           ; <sbyte> [#uses=1]
        %tmp.2 = seteq sbyte %tmp.1, 0          ; <bool> [#uses=1]
        %indvar.next = add ulong %indvar, 1             ; <ulong> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %loopexit.loopexit, label %no_exit

loopexit.loopexit:              ; preds = %no_exit
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %inc.1 = add int %indvar, 1             ; <int> [#uses=1]
        ret int %inc.1

loopexit:               ; preds = %entry
        ret int 0
}


Here's the after code:

int %_strlen(sbyte* %str) {
entry:
        %inc.02 = getelementptr sbyte* %str, uint 1             ; <sbyte*> [#uses=1]
        %tmp.13 = load sbyte* %str              ; <sbyte> [#uses=1]
        %tmp.24 = seteq sbyte %tmp.13, 0                ; <bool> [#uses=1]
        br bool %tmp.24, label %loopexit, label %no_exit

no_exit:                ; preds = %entry, %no_exit
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %inc.0.0 = getelementptr sbyte* %inc.02, uint %indvar           ; <sbyte*> [#uses=1]
        %inc.1 = add int %indvar, 1             ; <int> [#uses=1]
        %tmp.1 = load sbyte* %inc.0.0           ; <sbyte> [#uses=1]
        %tmp.2 = seteq sbyte %tmp.1, 0          ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %loopexit, label %no_exit

loopexit:               ; preds = %entry, %no_exit
        %len.0.1 = phi int [ 0, %entry ], [ %inc.1, %no_exit ]          ; <int> [#uses=1]
        ret int %len.0.1
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13016 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:16:10 +00:00
Chris Lattner
f50af088f1 Even if there are not any induction variables in the loop, if we can compute
the trip count for the loop, insert one so that we can canonicalize the exit
condition.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13015 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:08:33 +00:00
Chris Lattner
f5b9eb37a9 Add support for evaluation of exp/log/log10/pow
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13011 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 22:35:33 +00:00
Chris Lattner
657253119e Fix some really nasty dominance bugs that were exposed by my patch to
make the verifier more strict.  This fixes building zlib


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13002 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 18:08:07 +00:00
Misha Brukman
ea51deb18a Fix retriving parent Function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13001 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 17:37:12 +00:00
Brian Gaeke
c598517c24 Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
Debian.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12986 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 15:57:32 +00:00
Misha Brukman
98eb6264d4 Assert if deleting BasicBlock before removing it from Function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12983 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 15:47:21 +00:00
Chris Lattner
006118fe8c Fix some of the strange CBE-only failures that happened last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12980 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 06:03:17 +00:00
Chris Lattner
e1f0cf179f Make sure to check for a very bad class of errors: an instruction
that does not dominate all of its users, but is in the same basic block as
its users.  This class of error is what caused the mysterious CBE only
failures last night.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12979 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 05:51:47 +00:00
Chris Lattner
bf3d2e2683 Bugpoint was not correctly capturing stderr! This caused it to "find" bugs
that didn't exist, missing the ones that do :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12978 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 05:35:58 +00:00
Chris Lattner
cd01ae5c70 Fix Inline/2004-04-15-InlineDeletesCall.ll
Basically we were using SimplifyCFG as a huge sledgehammer for a simple
optimization.  Because simplifycfg does so many things, we can't use it
for this purpose.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12977 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 05:17:59 +00:00
Chris Lattner
d244057a48 Fix a bug in the previous checkin: if the exit block is not the same as
the back-edge block, we must check the preincremented value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12968 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 20:26:22 +00:00
Brian Gaeke
b75a316758 Give SparcV9CodeEmitter a head-of-file comment and a PassName.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12967 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 20:23:13 +00:00
Misha Brukman
7a46e4c62b Don't use invalid HTML in a doxygen comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12962 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 15:23:45 +00:00
Chris Lattner
59fdaeeae8 Change the canonical induction variable that we insert.
Instead of producing code like this:

Loop:
  X = phi 0, X2
  ...

  X2 = X + 1
  if (X != N-1) goto Loop

We now generate code that looks like this:

Loop:
  X = phi 0, X2
  ...

  X2 = X + 1
  if (X2 != N) goto Loop

This has two big advantages:
  1. The trip count of the loop is now explicit in the code, allowing
     the direct implementation of Loop::getTripCount()
  2. This reduces register pressure in the loop, and allows X and X2 to be
     put into the same register.

As a consequence of the second point, the code we generate for loops went
from:

.LBB2:  # no_exit.1
	...
        mov %EDI, %ESI
        inc %EDI
        cmp %ESI, 2
        mov %ESI, %EDI
        jne .LBB2 # PC rel: no_exit.1

To:

.LBB2:  # no_exit.1
	...
        inc %ESI
        cmp %ESI, 3
        jne .LBB2 # PC rel: no_exit.1

... which has two fewer moves, and uses one less register.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12961 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 15:21:43 +00:00
Chris Lattner
92020faa2c add some helpful methods. Rearrange #includes to proper order
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12960 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 15:16:02 +00:00
Chris Lattner
0a7f98c80d Factor a bunch of classes out into a public header
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12958 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 15:07:24 +00:00
Chris Lattner
0aa84fdd04 Unbreak the build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12956 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 14:17:43 +00:00
Chris Lattner
e9fc96e7cc Implement a FIXME: if we're going to insert a cast, we might as well only
insert it once!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12955 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 22:01:22 +00:00
John Criswell
53b54be5fc Remove code to adjust the iterator for llvm.readio and llvm.writeio.
The iterator is pointing at the next instruction which should not disappear
when doing the load/store replacement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12954 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 21:27:56 +00:00
Brian Gaeke
8121fcd260 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12953 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 21:21:56 +00:00
Chris Lattner
16011e6201 This is a trivial tweak to the addrec insertion code: insert the increment
at the bottom of the loop instead of the top.  This reduces the number of
overlapping live ranges a lot, for example, eliminating a spill in an important
loop in 183.equake with linear scan.

I still need to make the exit comparison of the loop use the post-incremented
version of this variable, but this is an easy first step.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12952 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 21:11:25 +00:00
Brian Gaeke
50872d5385 Add a TargetData to the PassManager regardless of the TargetMachine.
This should unbreak the Sparc JIT again.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12949 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 17:45:52 +00:00
John Criswell
71c887d688 Remove the return type check for llvm.readio. This check is done for all
functions and is not needed here.
Simplify the pointer type check per Chris's suggestions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12945 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 15:06:48 +00:00
John Criswell
17f64258cf Added code to verify that llvm.readio's pointer argument returns something
that matches its return type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12944 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 14:49:36 +00:00
John Criswell
994a765e5c Finish adding the llvm.readio and llvm.writeio intrinsics.
Sorry these didn't get in yesterday.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12942 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 13:46:52 +00:00
Chris Lattner
d9955aaa61 ADd a trivial instcombine: load null -> null
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12940 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 03:28:36 +00:00
Chris Lattner
098e945fbd This is the real fix for Codegen/X86/2004-04-13-FPCMOV-Crash.llx which works
even when the "optimization" I added before is turned off.  It generates this
extremely pointless code:

test:
        fld QWORD PTR [%ESP + 4]
        mov %AL, 0
        test %AL, %AL
        fcmove %ST(0), %ST(0)
        ret

Good thing the optimizer will have removed this before code generation
anyway.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12939 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 02:42:32 +00:00
John Criswell
e5a4c15da6 Added support for the llvm.readio and llvm.writeio intrinsics.
On x86, memory operations occur in-order, so these are just lowered into
volatile loads and stores.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12936 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 22:13:14 +00:00
Chris Lattner
82c5a9990f Implement a small optimization, which papers over the problem in
X86/2004-04-13-FPCMOV-Crash.llx

A more robust fix is to follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12935 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 21:56:09 +00:00
Chris Lattner
58b7b08ad7 Add SCCP support for constant folding calls, implementing:
test/Regression/Transforms/SCCP/calltest.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12921 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 19:43:54 +00:00
Chris Lattner
25b8390bf2 Add a simple call constant propagation interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12919 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 19:28:52 +00:00
Chris Lattner
4647b7cd69 Constant propagation should remove the dead instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12917 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 19:28:20 +00:00
Brian Gaeke
ef8e48aae0 I don't think we have to have 4 extra allocated (but unused) bytes on the stack.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12905 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 18:28:37 +00:00
Brian Gaeke
3d11e8a6d3 I started working on casts, but I don't have anything compilable yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12903 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 18:27:46 +00:00
Chris Lattner
87e18deabc Emit the immediate form of in/out when possible.
Fix several bugs in the intrinsics:
  1. Make sure to copy the input registers before the instructions that use them
  2. Make sure to copy the value returned by 'in' out of EAX into the register
     it is supposed to be in.

This fixes assertions when using in/out and linear scan.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12896 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 17:20:37 +00:00
Chris Lattner
440bbc257e Add immediate forms of in/out. Use let to shorten lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12895 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 17:19:31 +00:00
Chris Lattner
e47f4ff9f6 Add support for new instruction type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12894 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 17:18:51 +00:00
Chris Lattner
266538350a Add support for the printImplicitDefsBefore flag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12893 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 17:18:39 +00:00
Chris Lattner
4b66242c54 Fix LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll
LoopSimplify was not updating dominator frontiers correctly in some cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12890 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 16:23:25 +00:00
Chris Lattner
1f62f82b05 Refactor code a bit to make it simpler and eliminate the goto
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12888 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 15:21:18 +00:00
Chris Lattner
529b28da45 This patch addresses PR35: Loop simplify should reconstruct nested loops.
This is fairly straight-forward, but was a real nightmare to get just
perfect.  aarg.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12884 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 05:05:33 +00:00
Brian Gaeke
5f0b51547c We don't need to insert TargetData into the PassManager here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12874 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 21:46:31 +00:00
Alkis Evlogimenos
6e4d0d6546 Fix bug introduced in previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12872 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 20:26:39 +00:00
Chris Lattner
46758a894f Add some methods that are useful for updating loop information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12871 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 20:26:17 +00:00
Alkis Evlogimenos
43b61f724e Correctly compute spill weights
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12869 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 17:39:20 +00:00
Alkis Evlogimenos
e633352fd5 Print def lists a bit more compactly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12866 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 15:57:58 +00:00
Chris Lattner
ce1a3a292d Actually update the call graph as the inliner changes it. This allows us to
execute other CallGraphSCCPasses after the inliner without crashing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12861 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:37:29 +00:00
Chris Lattner
b81c021f14 Change the call graph class to have TWO external nodes, making call graph
SCC passes much more useful.  In particular, this should fix the incredibly
stupid missed inlining opportunities that the inliner suffered from.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12860 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:36:32 +00:00
Chris Lattner
7512c08bfd Hrm, operator new and new[] do not belong here. We should not CSE them! :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12859 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:16:42 +00:00
Chris Lattner
1708d12916 Add support for removing invoke instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12858 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:15:13 +00:00
Chris Lattner
85eb157d96 Stop printing Function*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12857 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 04:06:56 +00:00
Chris Lattner
d08ddd3300 Simplify code a bit, and be sure to mark the external node as potentially throwing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12856 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 04:06:38 +00:00
Chris Lattner
133dbb1285 Fix issues that the local allocator has dealing with instructions that implicitly use ST(0)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12855 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 03:02:48 +00:00
Chris Lattner
284b496aae No really, fix printing for LLC. I gotta get a way for CVS to whine at me if
I have unsaved emacs buffers, geeze...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12854 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 01:52:04 +00:00
Chris Lattner
2fc83a5ba6 Correct printing for LLC and the encoding for the JIT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12853 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 01:50:04 +00:00
Chris Lattner
8d2822e7f1 Use the fucomi[p] instructions to perform floating point comparisons instead
of the fucom[p][p] instructions.  This allows us to code generate this function

bool %test(double %X, double %Y) {
        %C = setlt double %Y, %X
        ret bool %C
}

... into:

test:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [%ESP + 12]
        fucomip %ST(1)
        fstp %ST(0)
        setb %AL
        movsx %EAX, %AL
        ret

where before we generated:

test:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [%ESP + 12]
        fucompp
**      fnstsw
**      sahf
        setb %AL
        movsx %EAX, %AL
        ret

The two marked instructions (which are the ones eliminated) are very bad,
because they serialize execution of the processor.  These instructions are
available on the PPRO and later, but since we already use cmov's we aren't
losing any portability.

I retained the old code for the day when we decide we want to support back
to the 386.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12852 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 01:43:36 +00:00
Chris Lattner
c040bca4b9 Add support for the FUCOMIr instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12851 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 01:39:15 +00:00
Chris Lattner
a1b5e160ed Add two new instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12850 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 01:38:55 +00:00
Chris Lattner
9938286325 Fix a bug in my load/cast folding patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12849 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 00:23:04 +00:00
Chris Lattner
13c07feb20 Adjust some comments, fix a bug in my previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12848 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 00:12:04 +00:00
Chris Lattner
feac3e18aa On X86, casting an integer to floating point requires going through memory.
If the source of the cast is a load, we can just use the source memory location,
without having to create a temporary stack slot entry.

Before we code generated this:

double %int(int* %P) {
        %V = load int* %P
        %V2 = cast int %V to double
        ret double %V2
}

into:

int:
        sub %ESP, 4
        mov %EAX, DWORD PTR [%ESP + 8]
        mov %EAX, DWORD PTR [%EAX]
        mov DWORD PTR [%ESP], %EAX
        fild DWORD PTR [%ESP]
        add %ESP, 4
        ret

Now we produce this:

int:
        mov %EAX, DWORD PTR [%ESP + 4]
        fild DWORD PTR [%EAX]
        ret

... which is nicer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12846 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 23:21:26 +00:00
Chris Lattner
95157f7638 Implement folding of loads into floating point operations. This implements:
test/Regression/CodeGen/X86/fp_load_fold.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12844 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 22:05:45 +00:00
Chris Lattner
6621ed94cc Unify all of the code for floating point +,-,*,/ into one function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12842 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 21:23:56 +00:00
Chris Lattner
8ebf1c35a1 This implements folding of constant operands into floating point operations
for mul and div.

Instead of generating this:

test_divr:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [.CPItest_divr_0]
        fdivrp %ST(1)
        ret

We now generate this:

test_divr:
        fld QWORD PTR [%ESP + 4]
        fdivr QWORD PTR [.CPItest_divr_0]
        ret

This code desperately needs refactoring, which will come in the next
patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12841 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 21:09:14 +00:00
Chris Lattner
462fa82270 Restructure the mul/div/rem handling code to follow the pattern the other
instructions use.  This doesn't change any functionality except that long
constant expressions of these operations will now magically start working.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12840 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 20:56:28 +00:00
Chris Lattner
48b0c97e20 Codegen FP adds and subtracts with a constant more efficiently, generating:
fld QWORD PTR [%ESP + 4]
        fadd QWORD PTR [.CPItest_add_0]

instead of:

        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [.CPItest_add_0]
        faddp %ST(1)

I also intend to do this for mul & div, but it appears that I have to
refactor a bit of code before I can do so.

This is tested by: test/Regression/CodeGen/X86/fp_constant_op.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12839 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 20:26:20 +00:00
Chris Lattner
490e86fed5 Add some new instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12838 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 20:24:15 +00:00
Chris Lattner
4cf15e7a3b Relax assertion to make this function work with a broader class of instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12836 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 20:21:06 +00:00
Chris Lattner
427aeb476f Two changes:
1. If an incoming argument is dead, don't load it from the stack
  2. Do not code gen noop copies at all (ie, cast int -> uint), not even to
     a move.  This should reduce register pressure for allocators that are
     unable to coallesce away these copies in some cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12835 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 19:21:59 +00:00
Chris Lattner
bec63d606f operator new & operator new[] do not kill any legal memory locations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12833 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 18:16:34 +00:00
Chris Lattner
65585aa3fc Allow clients to be more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12831 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 16:43:07 +00:00
Chris Lattner
fbede52af4 Fix a bug in my select transformation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12826 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 01:39:19 +00:00
Chris Lattner
a0ae8196a1 Add a missing break, which caused a crash in an obscure situation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12825 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 01:29:30 +00:00
Chris Lattner
adb7c0de39 Update the value numbering interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12824 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:33:34 +00:00
Chris Lattner
d76956d444 Implement InstCombine/select.ll:test13*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12821 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:21:27 +00:00
Chris Lattner
66331a4e33 Implement InstCombine/add.ll:test20
Canonicalize add of sign bit constant into a xor


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12819 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:01:55 +00:00
Chris Lattner
38e66bd9d1 Rewrite the GCSE pass to be *substantially* simpler, a bit more efficient,
and a bit more powerful


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12817 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 21:11:11 +00:00
Chris Lattner
326c0f3013 Fix spurious warning in release mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12816 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 19:15:56 +00:00
Chris Lattner
85aa7097c2 Silence a spurious warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12815 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 18:32:01 +00:00
Chris Lattner
a5f4103931 Simplify code a bit, and fix a bug that was breaking perlbmk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12814 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 18:06:21 +00:00
Chris Lattner
562cb66b84 Fix a bug in my checkin last night that was breaking programs using invoke.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12813 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 16:53:29 +00:00
Chris Lattner
27c694bacb Fix previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12811 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 07:27:48 +00:00
Chris Lattner
17177601fb Correctly update counters
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12810 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 07:02:02 +00:00
Chris Lattner
b903fc5c1b Add a couple of more functions that cannot access memory (the intrinsics) and
don't write to memory


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12808 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 06:55:27 +00:00
Chris Lattner
ede6ac60a5 Simplify code a bit, and use alias analysis to allow us to delete unused
call and invoke instructions that are known to not write to memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12807 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 06:53:09 +00:00
Chris Lattner
e576b91948 Implement select.ll:test12*
This transforms code like this:

   %C = or %A, %B
   %D = select %cond, %C, %A
into:
   %C = select %cond, %B, 0
   %D = or %A, %C

Since B is often a constant, the select can often be eliminated.  In any case,
this reduces the usage count of A, allowing subsequent optimizations to happen.

This xform applies when the operator is any of:
  add, sub, mul, or, xor, and, shl, shr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12800 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 23:46:01 +00:00
Chris Lattner
570751c2a7 Fold code like:
if (C)
    V1 |= V2;

into:
  Vx = V1 | V2;
  V1 = select C, V1, Vx

when the expression can be evaluated unconditionally and is *cheap* to
execute.  This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:

int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;

void mux(void) {
  output =
      (in0   ?  0x00000001 : 0) | (in1   ?  0x00000002 : 0) |
      (in2   ?  0x00000004 : 0) | (in3   ?  0x00000008 : 0) |
      (in4   ?  0x00000010 : 0) | (in5   ?  0x00000020 : 0) |
      (in6   ?  0x00000040 : 0) | (in7   ?  0x00000080 : 0) |
      (in8   ?  0x00000100 : 0) | (in9   ?  0x00000200 : 0) |
      (in10  ?  0x00000400 : 0) | (in11  ?  0x00000800 : 0) |
      (in12  ?  0x00001000 : 0) | (in13  ?  0x00002000 : 0) |
      (in14  ?  0x00004000 : 0) | (in15  ?  0x00008000 : 0) ;
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12798 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 22:50:22 +00:00
John Criswell
6d804f408a Reversed the order of the llvm.writeport() operands so that the value
is listed first and the address is listed second.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12795 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 19:09:14 +00:00
Chris Lattner
2eefe518de Fold binary operators with a constant operand into select instructions
that have a constant operand.  This implements
add.ll:test19, shift.ll:test15*, and others that are not tested


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12794 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 19:05:30 +00:00
Chris Lattner
82e14fe168 Implement select.ll:test11
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 18:19:44 +00:00
Alkis Evlogimenos
9a8b490735 Add definition list to each live interval.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12791 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 18:07:57 +00:00
John Criswell
aee0cf3fca Changed assertions to error messages.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12787 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 15:10:15 +00:00
John Criswell
ca6ea0f137 Changes recommended by Chris:
InstSelectSimple.cpp:
  Change the checks for proper I/O port address size into an exit() instead
  of an assertion.  Assertions aren't used in Release builds, and handling
  this error should be graceful (not that this counts as graceful, but it's
  more graceful).

  Modified the generation of the IN/OUT instructions to have 0 arguments.
X86InstrInfo.td:
  Added the OpSize attribute to the 16 bit IN and OUT instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12786 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 22:39:13 +00:00
Chris Lattner
f499eaca36 Implement InstCombine/cast-propagate.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12784 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 20:39:49 +00:00
John Criswell
4ffff9e2fa Added the llvm.readport and llvm.writeport intrinsics for x86. These do
I/O port instructions on x86.  The specific code sequence is tailored to
the parameters and return value of the intrinsic call.
Added the ability for implicit defintions to be printed in the Instruction
Printer.
Added the ability for RawFrm instruction to print implict uses and
defintions with correct comma output.  This required adjustment to some
methods so that a leading comma would or would not be printed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12782 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 20:31:47 +00:00
John Criswell
9570301ee8 Added the llvm.readport and llvm.writeport intrinsics.
The Verifier ensures that their parameters are of integral types and have
the correct sign, but it does not enforce any size restrictions because
such restrictions are platform dependent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12781 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 20:27:38 +00:00
Chris Lattner
8ba725b456 Implement ScalarRepl/select_promote.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12779 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 19:59:34 +00:00
Chris Lattner
775cbdd51a Remove the "really gross hacks" that are there to deal with recursive functions.
Now we collect all of the call sites we are interested in inlining, then inline
them.  This entirely avoids issues with trying to inline a call site we got by
inlining another call site.  This also eliminates iterator invalidation issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12770 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 06:34:31 +00:00
Chris Lattner
0c199a7628 Implement InstCombine/select.ll:test[7-10]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12769 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 04:43:23 +00:00
Brian Gaeke
8089822a8c Don't include InstrSelectionSupport.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12766 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 20:55:32 +00:00
Brian Gaeke
1523aac530 Move ChooseRegOrImmed() prototype here, from InstrSelectionSupport.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12765 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 20:38:57 +00:00
Brian Gaeke
92976137df Don't include InstrSelectionSupport.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12764 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 20:38:56 +00:00
Chris Lattner
cb69a4ed64 Implement test/Regression/Transforms/InstCombine/getelementptr_index.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12762 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 18:38:20 +00:00
Brian Gaeke
58fe7695b9 Fix insertion of SelectInsts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12760 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 18:31:47 +00:00
Brian Gaeke
8005ed3bd7 Don't print [%reg + 0], just print [%reg]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12759 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 17:33:56 +00:00
Brian Gaeke
f3334ebbe3 First version of code to handle loads. Stub function for handling stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12758 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 17:29:37 +00:00
Brian Gaeke
562cb16381 Support loading arguments from %I0...%I5 into virtual registers in
function prologues, and fix an off-by-one in visitCallInst that was
putting call args into the wrong registers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12757 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 17:04:09 +00:00
Brian Gaeke
d54c38b2f4 It's setting up the call args right now, but on the callee side, it's
trying to get incoming args off the stack, instead of the %i0...%i6 regs,
which is wrong.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12756 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 16:41:22 +00:00
Chris Lattner
627018b4b3 Fix a bug Brian found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12754 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 16:16:11 +00:00
Chris Lattner
4d0cda4d5c This is a start on handling setcc instructions. As the comment notes, we
have no good way of handling this until the code generator is improved.
We should probably just emit V9 instructions in the meantime.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12745 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 05:04:51 +00:00
Chris Lattner
6179047661 andd subcc instructions which is used to create the 'cmp' pseudo instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12744 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 05:04:01 +00:00
Chris Lattner
0d538bbec2 Avoid emitting an extra copy on each 32-bit operation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12743 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:36:53 +00:00
Brian Gaeke
88ddd4a07d Make generation of stack-slot loads and copies less ugly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12742 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:29:14 +00:00
Brian Gaeke
fa4bb09cf0 Fix bug in printing loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12741 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:29:03 +00:00
Chris Lattner
4be7ca5721 Add support for shift instructions, wrap some long lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:27:16 +00:00
Chris Lattner
a562efce35 Fix encoding of existing shift instructions, add rr shifts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12739 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:26:57 +00:00
Chris Lattner
22ede709f6 Add a bunch more instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12737 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:06:46 +00:00
Chris Lattner
f97b31e9cf Merge my changes with brians
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12736 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:05:49 +00:00
Brian Gaeke
0f51cc1759 Add in some things I forgot, which Chris helpfully reminded me of...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12735 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:05:12 +00:00
Brian Gaeke
59e04e4889 Add support for the "Y" register, used by MUL & DIV.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12734 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:01:11 +00:00
Brian Gaeke
e88c9dc860 Add UDIV, SDIV, and a few variants of WR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12733 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:01:00 +00:00
Brian Gaeke
2d4fa8faac Preliminary support for getting 64-bit integer constants into registers.
Preliminary support for division. It's gross because you have to initialize
the "Y" register, which is the top 32 bits of the thing you're dividing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12732 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 04:00:49 +00:00
Brian Gaeke
ff8282604a Prune unnecessary #includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12731 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 23:25:07 +00:00
Brian Gaeke
20117102c2 Simple delay slot filler pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12730 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 23:21:45 +00:00
Brian Gaeke
86a8790826 Add references to delay slot filler pass.
Fill in addPassesToJITCompile method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12729 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 23:21:24 +00:00
Brian Gaeke
3a8ad62d4f First attempt at handling frame index elimination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12728 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 22:10:22 +00:00
Brian Gaeke
1c38175d6b First attempt at special-casing printing of [%reg + offset] for
ld/st instructions - doesn't seem to work yet, but I think it's
just a typo or something somewhere.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12727 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 22:10:11 +00:00
Brian Gaeke
856e4fc59e Delete reference to "the Mach-O Runtime ABI".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12726 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 22:09:59 +00:00
Brian Gaeke
ea8494bb89 Deal with call return values.
Don't put NOPs in delay slots at all. We'll have a fix-up pass later.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12725 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 22:09:23 +00:00
Jakub Staszak
8ac0009979 file based off InstSelectSimple.cpp, slowly being replaced by generated code from the really simple X86 instruction selector tablegen backend
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12715 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 19:35:17 +00:00
Jakub Staszak
0a8fd30c1b Tablgen files for really simple instruction selector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12714 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 19:34:00 +00:00
Chris Lattner
7b92de1e7d Fix PR313: [x86] JIT miscompiles unsigned short to floating point
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12711 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 19:29:36 +00:00
Chris Lattner
43ab3a8f45 Fix incorrect encoding of some ADC and SBB instuctions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12710 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 19:20:32 +00:00
Chris Lattner
48c937e5c9 Fix a minor bug in previous checking
Enable folding of long seteq/setne comparisons into branches and select instructions
Implement unfolded long relational comparisons against a constants a bit more efficiently

Folding comparisons changes code that looks like this:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EDX, DWORD PTR [%ESP + 8]
        mov %ECX, %EAX
        or %ECX, %EDX
        sete %CL
        test %CL, %CL
        je .LBB2 # PC rel: F

into code that looks like this:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EDX, DWORD PTR [%ESP + 8]
        mov %ECX, %EAX
        or %ECX, %EDX
        jne .LBB2 # PC rel: F

This speeds up 186.crafty by 6% with llc-ls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 17:34:50 +00:00
Chris Lattner
e80e637793 Improve codegen of long == and != comparisons against constants. Before,
comparing a long against zero got us this:

        sub %ESP, 8
        mov DWORD PTR [%ESP + 4], %ESI
        mov DWORD PTR [%ESP], %EDI
        mov %EAX, DWORD PTR [%ESP + 12]
        mov %EDX, DWORD PTR [%ESP + 16]
        mov %ECX, 0
        mov %ESI, 0
        mov %EDI, %EAX
        xor %EDI, %ECX
        mov %ECX, %EDX
        xor %ECX, %ESI
        or %EDI, %ECX
        sete %CL
        test %CL, %CL
        je .LBB2 # PC rel: F

Now it gets us this:

        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EDX, DWORD PTR [%ESP + 8]
        mov %ECX, %EAX
        or %ECX, %EDX
        sete %CL
        test %CL, %CL
        je .LBB2 # PC rel: F


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12696 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 16:02:27 +00:00
Chris Lattner
6ab06d5d19 Handle various other important cases of multiplying a long constant immediate. For
example, multiplying X*(1 + (1LL << 32)) now produces:

test:
        mov %ECX, DWORD PTR [%ESP + 4]
        mov %EDX, DWORD PTR [%ESP + 8]
        mov %EAX, %ECX
        add %EDX, %ECX
        ret

[[[Note to Alkis: why isn't linear scan generating this code??  This might be a
 problem with your intervals being too conservative:

test:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EDX, DWORD PTR [%ESP + 8]
        add %EDX, %EAX
        ret

end note]]]

Whereas GCC produces this:

T:
        sub     %esp, 12
        mov     %edx, DWORD PTR [%esp+16]
        mov     DWORD PTR [%esp+8], %edi
        mov     %ecx, DWORD PTR [%esp+20]
        xor     %edi, %edi
        mov     DWORD PTR [%esp], %ebx
        mov     %ebx, %edi
        mov     %eax, %edx
        mov     DWORD PTR [%esp+4], %esi
        add     %ebx, %edx
        mov     %edi, DWORD PTR [%esp+8]
        lea     %edx, [%ecx+%ebx]
        mov     %esi, DWORD PTR [%esp+4]
        mov     %ebx, DWORD PTR [%esp]
        add     %esp, 12
        ret

I'm not sure example what GCC is smoking here, but it looks like it has just
confused itself with a bunch of stack slots or something.  The intel compiler
is better, but still not good:

T:
        movl      4(%esp), %edx                                 #2.11
        movl      8(%esp), %eax                                 #2.11
        lea       (%eax,%edx), %ecx                             #3.12
        movl      $1, %eax                                      #3.12
        mull      %edx                                          #3.12
        addl      %ecx, %edx                                    #3.12
        ret                                                     #3.12


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12693 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 04:55:43 +00:00
Chris Lattner
028adc422d Efficiently handle a long multiplication by a constant. For this testcase:
long %test(long %X) {
        %Y = mul long %X, 123
        ret long %Y
}

we used to generate:

test:
        sub %ESP, 12
        mov DWORD PTR [%ESP + 8], %ESI
        mov DWORD PTR [%ESP + 4], %EDI
        mov DWORD PTR [%ESP], %EBX
        mov %ECX, DWORD PTR [%ESP + 16]
        mov %ESI, DWORD PTR [%ESP + 20]
        mov %EDI, 123
        mov %EBX, 0
        mov %EAX, %ECX
        mul %EDI
        imul %ESI, %EDI
        add %ESI, %EDX
        imul %ECX, %EBX
        add %ESI, %ECX
        mov %EDX, %ESI
        mov %EBX, DWORD PTR [%ESP]
        mov %EDI, DWORD PTR [%ESP + 4]
        mov %ESI, DWORD PTR [%ESP + 8]
        add %ESP, 12
        ret

Now we emit:
test:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, DWORD PTR [%ESP + 8]
        mov %EDX, 123
        mul %EDX
        imul %ECX, %ECX, 123
        add %ECX, %EDX
        mov %EDX, %ECX
        ret

Which, incidently, is substantially nicer than what GCC manages:
T:
        sub     %esp, 8
        mov     %eax, 123
        mov     DWORD PTR [%esp], %ebx
        mov     %ebx, DWORD PTR [%esp+16]
        mov     DWORD PTR [%esp+4], %esi
        mov     %esi, DWORD PTR [%esp+12]
        imul    %ecx, %ebx, 123
        mov     %ebx, DWORD PTR [%esp]
        mul     %esi
        mov     %esi, DWORD PTR [%esp+4]
        add     %esp, 8
        lea     %edx, [%ecx+%edx]
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12692 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 04:29:36 +00:00
Chris Lattner
722070e0ba Improve code generation of long shifts by 32.
On this testcase:

long %test(long %X) {
        %Y = shr long %X, ubyte 32
        ret long %Y
}

instead of:
t:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%ESP + 8]
        sar %EAX, 0
        mov %EDX, 0
        ret


we now emit:
test:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%ESP + 8]
        mov %EDX, 0
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12688 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 03:42:38 +00:00
Chris Lattner
0652167bea Bugfixes: inc/dec don't set the carry flag!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12687 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 03:36:57 +00:00