Compare commits

...

1871 Commits

Author SHA1 Message Date
John Criswell
b094f912b0 Note that a work-around is available.
llvm-svn: 24237
2005-11-08 15:40:22 +00:00
John Criswell
358cb80e7d Add a note about the Solaris configure problem that Tanya's seen.
llvm-svn: 24236
2005-11-08 15:38:11 +00:00
John Criswell
ec29828344 Include the CVS tag for the 1.6 release.
llvm-svn: 24167
2005-11-03 18:26:14 +00:00
John Criswell
1ea1e7ac4d Merge in hack from Chris that discards libg.
llvm-svn: 24166
2005-11-03 15:42:27 +00:00
John Criswell
398d2e2c28 Updated the version number.
Get the UIUC copyright to actually print.

llvm-svn: 24165
2005-11-03 15:25:04 +00:00
John Criswell
072467d8a9 Merged in revision 1.60.
llvm-svn: 24160
2005-11-02 19:38:00 +00:00
John Criswell
39a12ac598 Don't use -q; this option is not available on Solaris grep (and probably
other, traditional UNIX greps).

llvm-svn: 24156
2005-11-02 18:06:28 +00:00
John Criswell
89d3246c03 Mark these as failing on sparc instead of sparcv9.
The configure script no longer tells us that we're configuring for SparcV9
specifically.
2004-06-17-UnorderedCompares may work on SparcV8, but it's experiental
anyway.
2005-02-20-AggregateSAVEEXPR should fail on any Solaris machine, as Solaris
doesn't provide complex number support.

llvm-svn: 24155
2005-11-02 18:05:50 +00:00
CVS to SVN Conversion
53bd0b0175 This commit was manufactured by cvs2svn to create branch 'release_16'.
llvm-svn: 24138
2005-11-01 18:04:06 +00:00
Jeff Cohen
9e1784d738 Keep VC++ happy.
llvm-svn: 24137
2005-11-01 18:04:06 +00:00
Chris Lattner
1deb86dbf4 Let people who run the nightly tester specify paths to external tests, instead
of having to hack the nightly tester script itself.

as an example, I use the following for my machine:

$HOME/llvm/utils/NightlyTest.pl -parallel -release -enable-llcbeta \
     -spec2000path /Volumes/ProjectsDisk/cvs/benchmarks/speccpu2000-llvm/benchspec/ \
     -povraypath /Volumes/ProjectsDisk/cvs/benchmarks/povray31 \
     -namdpath /Volumes/ProjectsDisk/cvs/benchmarks/namd

llvm-svn: 24136
2005-11-01 17:59:42 +00:00
Duraid Madina
5a087ff8c3 heh, scheduling was easy?
need to send chris, jim and sampo a box of fish each

llvm-svn: 24135
2005-11-01 05:49:08 +00:00
Duraid Madina
9b61d3c1e2 FORTRAN!!! :( and other similarly unfortunate things mean that on ia64
one sometimes needs to pass FP args in both FP *and* integer registers.

llvm-svn: 24134
2005-11-01 05:46:16 +00:00
Duraid Madina
b81b61330e so tablegen was thinking I might want to convert FPs to predicates.
clever little tablegen!

llvm-svn: 24133
2005-11-01 03:32:15 +00:00
Duraid Madina
6c912bffd6 add support for int->FP and FP->int ops, and add ia64 patterns for these
llvm-svn: 24132
2005-11-01 03:07:25 +00:00
Duraid Madina
a284b6636f add zeroextend predicate->integer
llvm-svn: 24131
2005-11-01 01:29:55 +00:00
Chris Lattner
7432ceef5c Add a flag to enable a darwin linker optimization
llvm-svn: 24130
2005-11-01 00:12:36 +00:00
Chris Lattner
6b63e0c6fd Make constant pool entries use private labels. This is important when you're
not compiling a whole program at a time :)

llvm-svn: 24129
2005-10-31 22:12:06 +00:00
Andrew Lenharth
d44a8f546d Updated alpha known problems.
llvm-svn: 24126
2005-10-31 19:07:29 +00:00
Chris Lattner
b7147f6027 Apparently these do pass on some alphas
llvm-svn: 24125
2005-10-31 19:06:13 +00:00
Chris Lattner
71d73eb411 Fix an iterator invalidation problem in code used by the -strip pass
llvm-svn: 24124
2005-10-31 18:42:37 +00:00
Chris Lattner
09efd4e5b6 Limit the search depth of MaskedValueIsZero to 6 instructions, to avoid
bad cases.  This fixes Markus's second testcase in PR639, and should
seal it for good.

llvm-svn: 24123
2005-10-31 18:35:52 +00:00
Jim Laskey
0433df136f Emit itinerary class in instruction info.
llvm-svn: 24122
2005-10-31 17:16:46 +00:00
Jim Laskey
3763a50d82 Generate cpu to itinerary map.
llvm-svn: 24121
2005-10-31 17:16:01 +00:00
Chris Lattner
14ada0fd4e these tests fail on alpha for some reason
llvm-svn: 24120
2005-10-31 16:15:49 +00:00
Jim Laskey
5ce0538253 1. Embed and not inherit vector for NodeGroup.
2. Iterate operands and not uses (performance.)

3. Some long pending comment changes.

llvm-svn: 24119
2005-10-31 12:49:09 +00:00
Duraid Madina
88fc69f627 add FP compares and implicit register defs to the dag isel
llvm-svn: 24118
2005-10-31 01:42:11 +00:00
Jeff Cohen
94d1562071 Update Getting Started for Visual Studio page.
llvm-svn: 24117
2005-10-30 21:00:24 +00:00
Chris Lattner
6871b23d02 Significantly simplify this code and make it more aggressive. Instead of having
a special case hack for X86, make the hack more general: if an incoming argument
register is not used in any block other than the entry block, don't copy it to
a vreg.  This helps us compile code like this:

%struct.foo = type { int, int, [0 x ubyte] }
int %test(%struct.foo* %X) {
        %tmp1 = getelementptr %struct.foo* %X, int 0, uint 2, int 100
        %tmp = load ubyte* %tmp1                ; <ubyte> [#uses=1]
        %tmp2 = cast ubyte %tmp to int          ; <int> [#uses=1]
        ret int %tmp2
}

to:

_test:
        lbz r3, 108(r3)
        blr

instead of:

_test:
        lbz r2, 108(r3)
        or r3, r2, r2
        blr

The (dead) copy emitted to copy r3 into a vreg for extra-block uses was
increasing the live range of r3 past the load, preventing the coallescing.

This implements CodeGen/PowerPC/reg-coallesce-simple.ll

llvm-svn: 24115
2005-10-30 19:42:35 +00:00
Chris Lattner
6beef90324 new testcase
llvm-svn: 24112
2005-10-30 19:42:18 +00:00
Chris Lattner
dd5663dfa0 Reduce the number of copies emitted as machine instructions by
generating results in vregs that will need them.  In the case of something
like this:  CopyToReg((add X, Y), reg1024), we no longer emit code like
this:

   reg1025 = add X, Y
   reg1024 = reg 1025

Instead, we emit:

   reg1024 = add X, Y

Whoa! :)

llvm-svn: 24111
2005-10-30 18:54:27 +00:00
Chris Lattner
5c7d731832 If the module has no t-t and the host is an alpha, default to using the Alpha BE
llvm-svn: 24110
2005-10-30 16:44:01 +00:00
Duraid Madina
57b7ee9da8 fix some broken comparisons, this affected the Pattern isel too.
llvm-svn: 24109
2005-10-30 10:14:19 +00:00
Chris Lattner
48131a8254 The pass was removed, but the spirit lives on
llvm-svn: 24108
2005-10-30 07:22:15 +00:00
Chris Lattner
e507a15184 This is implemented
llvm-svn: 24107
2005-10-30 06:42:12 +00:00
Chris Lattner
a70878d4fb Codegen mul by negative power of two with a shift and negate.
This implements test/Regression/CodeGen/PowerPC/mul-neg-power-2.ll,
producing:

_foo:
        slwi r2, r3, 1
        subfic r3, r2, 63
        blr

instead of:

_foo:
        mulli r2, r3, -2
        addi r3, r2, 63
        blr

llvm-svn: 24106
2005-10-30 06:41:49 +00:00
Chris Lattner
9cc9f0fca1 new testcase
llvm-svn: 24103
2005-10-30 06:37:33 +00:00
Chris Lattner
f0b77f9acc Fix a problem that Nate noticed with LSR:
When inserting code for an addrec expression with a non-unit stride, be
more careful where we insert the multiply.  In particular, insert the multiply
in the outermost loop we can, instead of the requested insertion point.

This allows LSR to notice the mul in the right loop, reducing it when it gets
to it.  This allows it to reduce the multiply, where before it missed it.

This happens quite a bit in the test suite, for example, eliminating 2
multiplies in art, 3 in ammp, 4 in apsi, reducing from 1050 multiplies to
910 muls in galgel (!), from 877 to 859 in applu, and 36 to 30 in bzip2.

This speeds up galgel from 16.45s to 16.01s, applu from 14.21 to 13.94s and
fourinarow from 66.67s to 63.48s.

This implements Transforms/LoopStrengthReduce/nested-reduce.ll

llvm-svn: 24102
2005-10-30 06:24:33 +00:00
Chris Lattner
67315dc888 new testcase
llvm-svn: 24099
2005-10-30 05:14:02 +00:00
Chris Lattner
af6b34ff44 Revert an accidental commit.
llvm-svn: 24098
2005-10-29 17:01:41 +00:00
Jeff Cohen
99a71ef891 More files deleted.
llvm-svn: 24097
2005-10-29 16:51:48 +00:00
Chris Lattner
85b184b292 Make -time-passes output prettier
llvm-svn: 24096
2005-10-29 16:45:02 +00:00
Chris Lattner
d91df9d941 Make negative immediates in patterns work correctly, silence some warnings
building the itanium backend.

llvm-svn: 24095
2005-10-29 16:39:40 +00:00
Duraid Madina
7abaf906e2 add some FP stuff, some mix.* stuff, and constant pool support to the
DAG instruction selector, which should be destroyed one day (in the pattern
isel also) since ia64 can pack any constant in the instruction stream

llvm-svn: 24094
2005-10-29 16:08:30 +00:00
Chris Lattner
42f905691e Fix <> in html
llvm-svn: 24093
2005-10-29 07:08:19 +00:00
Chris Lattner
a69595ee0d First hack-and-slash on the release notes. Comments and improvements welcome
llvm-svn: 24092
2005-10-29 07:07:09 +00:00
Chris Lattner
d66c42facb Remove the lowerconstantexprs pass
llvm-svn: 24091
2005-10-29 05:34:40 +00:00
Chris Lattner
27d351f159 This pass is now obsolete since all targets have moved to the SelectionDAG
infrastructure and the simple isels have been removed.

llvm-svn: 24090
2005-10-29 05:33:46 +00:00
Chris Lattner
de63fba075 Remove the LowerConstantExpressionsPass pass
llvm-svn: 24089
2005-10-29 05:32:20 +00:00
Chris Lattner
dcceae104e remove reference to this pass
llvm-svn: 24088
2005-10-29 05:28:34 +00:00
Chris Lattner
8ad30360cf Basic updates
llvm-svn: 24087
2005-10-29 05:14:01 +00:00
Chris Lattner
c86bd2b1cd Buh bye Expression.(cpp|h)
llvm-svn: 24086
2005-10-29 04:55:57 +00:00
Chris Lattner
21193ac3c0 remove a dead file
llvm-svn: 24085
2005-10-29 04:43:38 +00:00
Chris Lattner
29b04e1021 remove a dead header
llvm-svn: 24084
2005-10-29 04:43:10 +00:00
Chris Lattner
752717d4ec Remove dead #include
llvm-svn: 24083
2005-10-29 04:41:30 +00:00
Chris Lattner
ceb9d5adaa Now that instcombine does this xform, remove it from the -raise pass
llvm-svn: 24082
2005-10-29 04:40:23 +00:00
Chris Lattner
8f663e8bbc Pull some code out into a function, give it the ability to see through +.
This allows us to turn code like malloc(4*x+4) -> malloc int, (x+1)

llvm-svn: 24081
2005-10-29 04:36:15 +00:00
Duraid Madina
c252f33fdb add shladd
llvm-svn: 24080
2005-10-29 04:13:40 +00:00
Duraid Madina
e71426f581 test for the formation of shladd
llvm-svn: 24077
2005-10-29 04:06:49 +00:00
Chris Lattner
8270c33606 Remove a special case, allowing the general case to handle it. No functionality
change.

llvm-svn: 24076
2005-10-29 03:19:53 +00:00
Nate Begeman
00cea9b2e0 New case to handle someday
llvm-svn: 24075
2005-10-28 23:26:57 +00:00
Chris Lattner
742606ad30 Switch more code over to using getValueAsListOfDefs. Look at all the -'s. :)
llvm-svn: 24074
2005-10-28 22:59:53 +00:00
Chris Lattner
7ca53a5783 Don't emit "32" for unordered comparison
llvm-svn: 24073
2005-10-28 22:58:07 +00:00
Chris Lattner
7ad0bed89f Rename Record::getValueAsListDef to getValueAsListOfDefs, to more accurately
reflect what it is.
Convert some more code over to use it.

llvm-svn: 24072
2005-10-28 22:49:02 +00:00
Chris Lattner
802bd8d94f Use the new interface Jim added
llvm-svn: 24071
2005-10-28 22:43:25 +00:00
Jim Laskey
dffe5978a3 Removed Mr. Smith from the code.
llvm-svn: 24070
2005-10-28 21:47:29 +00:00
Jim Laskey
b04feb633f Added method to return a vector of records for a ListInit of Def field. This
simplifies using list of records.

llvm-svn: 24069
2005-10-28 21:46:31 +00:00
Chris Lattner
f8899a6877 add a hack to get code with ordered comparisons working. This hack is
tracked as PR642

llvm-svn: 24068
2005-10-28 20:49:47 +00:00
Chris Lattner
5d6cb604de add support for branch on ordered/unordered.
llvm-svn: 24067
2005-10-28 20:32:44 +00:00
Chris Lattner
e2fb63ea95 add the xfail lines
llvm-svn: 24066
2005-10-28 19:57:55 +00:00
Chris Lattner
225022e4b0 New testcase. Probably many targets don't support this, so they should probably
add themselves as xfails until they do (at least for the release).

llvm-svn: 24065
2005-10-28 19:52:02 +00:00
Chris Lattner
97d72c80e4 Do not globalize internal symbols
llvm-svn: 24064
2005-10-28 18:44:07 +00:00
Chris Lattner
12fca42062 These are autogenerated
llvm-svn: 24063
2005-10-28 18:26:52 +00:00
Duraid Madina
f221c261f3 DAG->DAG instruction selection for ia64! "hello world" works, not much else.
use -enable-ia64-dag-isel to turn this on

TODO: delete lowering stuff from the pattern isel
    : get operations on predicate bits working
    : get other bits of pseudocode going
    : use sampo's mulh/mull-using divide-by-constant magic
    : *so* many patterns ("extr", "tbit" and "dep" will be fun :)
    : add FP
    : add a JIT!
    : get it working 100%

in short: this'll be happier in a couple of weeks, but it's here now so
the tester can make me feel guilty sooner.

OTHER: there are a couple of fixes to the pattern isel, in particular
making the linker happy with big blobs of fun like pypy.

llvm-svn: 24058
2005-10-28 17:46:35 +00:00
Chris Lattner
db53c998de The nightly tester report doesn't report JIT code size anymore, remove it
from the olden graph.

llvm-svn: 24057
2005-10-28 16:35:18 +00:00
Chris Lattner
b9d3ca5c3c Fix a bit of backwards logic that broke exptree and smg2000
llvm-svn: 24056
2005-10-28 16:27:35 +00:00
Jim Laskey
1959575208 Add some commentary.
llvm-svn: 24055
2005-10-28 15:20:43 +00:00
Chris Lattner
529169cab2 remove dead stuff
llvm-svn: 24054
2005-10-28 04:58:24 +00:00
Chris Lattner
e68a807025 Eliminate getClass, it is not needed
llvm-svn: 24053
2005-10-28 04:57:11 +00:00
Jeff Cohen
b0aa47b043 Keep Visual Studio happy.
llvm-svn: 24052
2005-10-28 01:43:09 +00:00
Chris Lattner
a0dfc67ae6 a bad case for bitfield insert
llvm-svn: 24051
2005-10-28 00:20:45 +00:00
Jim Laskey
86f002cc32 Now generating instruction itineraries for scheduling. Not my best work, but...
llvm-svn: 24050
2005-10-27 19:47:21 +00:00
Jim Laskey
5946b90266 Structures used to hold scheduling information.
llvm-svn: 24049
2005-10-27 18:18:05 +00:00
Chris Lattner
26682519c9 update project file
llvm-svn: 24048
2005-10-27 17:39:48 +00:00
Chris Lattner
c4f67e67d2 Do not sink any instruction with side effects, including vaarg. This fixes
PR640

llvm-svn: 24046
2005-10-27 17:13:11 +00:00
Chris Lattner
479911f971 Fix #include order
llvm-svn: 24044
2005-10-27 16:34:00 +00:00
Chris Lattner
525b923a8a unbreak the build again
llvm-svn: 24041
2005-10-27 16:30:44 +00:00
John Criswell
970af11af8 Move some constant folding functions into LLVMAnalysis since they are used
by Analysis and Transformation passes.

llvm-svn: 24038
2005-10-27 16:00:10 +00:00
John Criswell
fe5f33b120 Move some constant folding code shared by Analysis and Transform passes
into the LLVMAnalysis library.
This allows LLVMTranform and LLVMTransformUtils to be archives and linked
with LLVMAnalysis.a, which provides any missing definitions.

llvm-svn: 24036
2005-10-27 15:54:34 +00:00
Chris Lattner
4b6d583d7a Fix DSE to not nuke dead stores unless they redundant store is the same
VT as the killing one.  Fix fixes PR491

llvm-svn: 24034
2005-10-27 07:10:34 +00:00
Chris Lattner
c6372cca78 Fix typo
llvm-svn: 24033
2005-10-27 06:26:26 +00:00
Chris Lattner
0fe7551bc0 Teach instcombine to promote stuff like (cast (malloc sbyte, 8*X) to int*)
into: malloc int, (2*X)

llvm-svn: 24032
2005-10-27 06:24:46 +00:00
Chris Lattner
b3ecf96900 Promote cases like cast (malloc sbyte, 100) to int* into
(malloc [25 x int]) directly without having to convert to
(malloc [100 x sbyte]) first.

llvm-svn: 24031
2005-10-27 06:12:00 +00:00
Chris Lattner
bb17180a23 Minor change to this file to support obscure cases with constant array amounts
llvm-svn: 24030
2005-10-27 05:53:56 +00:00
Chris Lattner
d8c5c066a1 Add a simple xform that is useful for bitfield operations.
llvm-svn: 24029
2005-10-27 05:06:38 +00:00
Jeff Cohen
97cbaf5c89 Fine tune Visual Studio's use of bison/flex.
llvm-svn: 24025
2005-10-27 01:10:36 +00:00
Chris Lattner
6d92ce7be7 Make sure to build things in the right order, build with the .o file, not the
.a file to unbreak the build after john's change

llvm-svn: 24024
2005-10-27 00:53:16 +00:00
John Criswell
94b7bea733 1. Remove libraries no longer created from the list of libraries linked into the
SparcV9 JIT.
2. Make LLVMTransformUtils a relinked object file and always link it before
   LLVMAnalysis.a.  These two libraries have circular dependencies on each
   other which creates problem when building the SparcV9 JIT.  This change
   fixes the dependency on all platforms problems with a minimum of fuss.

llvm-svn: 24023
2005-10-26 20:35:13 +00:00
Andrew Lenharth
381cab36ed int comparison patterns
llvm-svn: 24020
2005-10-26 18:44:45 +00:00
Chris Lattner
3c7974aade Fix some spello's pointed out by Gabor Greif
llvm-svn: 24019
2005-10-26 18:41:41 +00:00
Jim Laskey
75eab3ca63 Typo made worse x 2 - take 2.
llvm-svn: 24018
2005-10-26 18:07:50 +00:00
Chris Lattner
f718a9e17b Fix an assert compiling MallocBench/gs
llvm-svn: 24017
2005-10-26 18:01:11 +00:00
Jim Laskey
b1f2cedbaa Typo x 2
llvm-svn: 24016
2005-10-26 17:50:22 +00:00
Jim Laskey
777a26efc3 Simplify.
llvm-svn: 24015
2005-10-26 17:49:21 +00:00
Andrew Lenharth
7ac194560e Simplify instinfo, set random bits on more fp insts, and fix 1 opcode
llvm-svn: 24014
2005-10-26 17:41:46 +00:00
Jim Laskey
a2b5235fac Give full control of subtarget features over to table generated code.
llvm-svn: 24013
2005-10-26 17:30:34 +00:00
Jim Laskey
53ad110490 Add attribute name and type to SubtargetFeatures.
llvm-svn: 24012
2005-10-26 17:28:23 +00:00
Chris Lattner
38a1b00a0f fold nested and's early to avoid inefficiencies in MaskedValueIsZero. This
fixes a very slow compile in PR639.

llvm-svn: 24011
2005-10-26 17:18:16 +00:00
Chris Lattner
f277ac7caa Condcodes are in the ISD namespace
llvm-svn: 24010
2005-10-26 17:02:02 +00:00
Chris Lattner
ce9580fce4 Add nodes for CondCodeSDNode and setcc, and add a bunch of pattern fragments
to make it easy to use them.  This lets you write patterns like:

(set PRRC:$rd, (setne GPRC:$rS, imm:$SH))

and stuff.

llvm-svn: 24009
2005-10-26 17:00:25 +00:00
Chris Lattner
611b0c634c Add support for CondCode's
llvm-svn: 24008
2005-10-26 16:59:37 +00:00
Jeff Cohen
821694ada9 Fix comment.
llvm-svn: 24004
2005-10-26 15:02:21 +00:00
Jeff Cohen
9e4c9cdc16 Eliminate use of sed in Visual Studio builds.
llvm-svn: 24003
2005-10-26 14:48:53 +00:00
Jeff Cohen
81560caccf Eliminate need for bison/flex in Visual Studio builds.
llvm-svn: 23999
2005-10-26 05:37:34 +00:00
Jeff Cohen
2b8cbf319c Update Visual Studio projects to reflect moved file.
llvm-svn: 23998
2005-10-26 05:36:51 +00:00
Nate Begeman
b2f9801555 Add a regression test for the recent fix for FP_TO_UINT lowering in the ppc
backend.

llvm-svn: 23995
2005-10-25 23:53:21 +00:00
Nate Begeman
ff1796534f Add a note about some bitfield stuff we could be doing better.
llvm-svn: 23994
2005-10-25 23:50:02 +00:00
Nate Begeman
762bf809b5 Correctly Expand or Promote FP_TO_UINT based on the capabilities of the
machine.  This allows us to generate great code for i32 FP_TO_UINT now on
targets with 64 bit extensions.

llvm-svn: 23993
2005-10-25 23:48:36 +00:00
Nate Begeman
d8f2a1a0f3 Allow custom lowered FP_TO_SINT ops in the check for whether a larger
FP_TO_SINT is preferred to a larger FP_TO_UINT.  This seems to be begging
for a TLI.isOperationCustom() helper function.

llvm-svn: 23992
2005-10-25 23:47:25 +00:00
Chris Lattner
81ff73ec46 autogen undef
llvm-svn: 23991
2005-10-25 21:03:41 +00:00
Chris Lattner
3a4b141e8c Add undef
llvm-svn: 23990
2005-10-25 21:03:14 +00:00
Chris Lattner
c967838d79 Add a method
llvm-svn: 23989
2005-10-25 21:02:21 +00:00
Chris Lattner
b439dad538 Allow pseudos to have patterns, no functionality change
llvm-svn: 23988
2005-10-25 20:58:43 +00:00
Chris Lattner
261009a4df Autogen fsel
llvm-svn: 23987
2005-10-25 20:55:47 +00:00
Chris Lattner
65845a2f7c Expose the fextend on the DAG instead of doing it in the matcher
llvm-svn: 23986
2005-10-25 20:54:57 +00:00
Chris Lattner
cd7f101c9a Autogen a few new ppc-specific nodes
llvm-svn: 23985
2005-10-25 20:41:46 +00:00
Chris Lattner
26ee5953f7 The dag isel generator generates this now
llvm-svn: 23984
2005-10-25 20:36:10 +00:00
Chris Lattner
d980c46f52 Emit some boilerplate for targets
llvm-svn: 23983
2005-10-25 20:35:14 +00:00
Chris Lattner
c0a201c318 Be a bit more paranoid about calling SelectNodeTo
llvm-svn: 23982
2005-10-25 20:26:41 +00:00
Chris Lattner
e1fd05ebde Fix a couple of minor bugs. The first fixes povray, the second fixes things
if the dag combiner isn't run

llvm-svn: 23981
2005-10-25 19:32:37 +00:00
Chris Lattner
3b409a85eb Clear a bit in this file that was causing a miscompilation of 178.galgel.
llvm-svn: 23980
2005-10-25 18:57:30 +00:00
Chris Lattner
64b830bc0c Remove some dead argument names which irritates GCC at certain warning levels.
llvm-svn: 23979
2005-10-25 17:59:28 +00:00
Chris Lattner
d22a788d69 Add a missing Module::setTargetTriple method.
Remove Function::aiterator and Module::giterator typedefs (and const versions)
as they should have been removed when abegin/gbegin were removed.  Thanks to
alkis for bringing this to my attn.

llvm-svn: 23978
2005-10-25 17:58:00 +00:00
Chris Lattner
768e272abd analyses after transformations
llvm-svn: 23977
2005-10-25 17:54:19 +00:00
Chris Lattner
aad5452c2e transforms before analyses
llvm-svn: 23976
2005-10-25 17:10:30 +00:00
Jim Laskey
1b7369b1ae Refactored to make room for more stuff (scheduling info.)
llvm-svn: 23975
2005-10-25 15:16:36 +00:00
Jim Laskey
db4621a5f5 Preparation of supporting scheduling info. Need to find info based on selected
CPU.

llvm-svn: 23974
2005-10-25 15:15:28 +00:00
Alkis Evlogimenos
cb67b650b5 Stop using deprecated types
llvm-svn: 23973
2005-10-25 11:18:06 +00:00
John Criswell
f23e971627 Updated bytecode version numbers.
llvm-svn: 23972
2005-10-24 17:10:57 +00:00
Jeff Cohen
dd24d7c477 Fix spelling of 'separate'.
llvm-svn: 23971
2005-10-24 16:54:55 +00:00
John Criswell
84800c0246 Fixed spelling.
llvm-svn: 23970
2005-10-24 16:47:40 +00:00
John Criswell
6140e5d03c Added a note to remove CVS directories when copying the sample project to
a new project.
Kudos to Rob for suggesting that I add this important step.

llvm-svn: 23969
2005-10-24 16:43:08 +00:00
John Criswell
93c7fff611 Attempt to make terminology more consistent.
llvm-svn: 23968
2005-10-24 16:37:24 +00:00
Chris Lattner
0e18bdff07 Andrew says that alpha basically works
llvm-svn: 23967
2005-10-24 16:36:36 +00:00
John Criswell
2bbe711c88 Fixed a grammar issue.
llvm-svn: 23966
2005-10-24 16:20:10 +00:00
John Criswell
4c0cf7f205 Grammar and punctuation fixes.
llvm-svn: 23965
2005-10-24 16:17:18 +00:00
Jeff Cohen
2448381eb6 Keep Visual Studio up to date.
llvm-svn: 23964
2005-10-24 15:21:58 +00:00
Chris Lattner
fc9f5773d0 Fix an incompatibility with GCC 4.1, thanks to Vladimir Merzliakov
for pointing this out!

llvm-svn: 23963
2005-10-24 15:04:15 +00:00
Chris Lattner
76b12c4d95 do not wrap this whole file in namespace llvm
llvm-svn: 23962
2005-10-24 06:38:35 +00:00
Chris Lattner
46705b2f2d Handle allocations that, even after removing dead uses, still have more than
one use (but one is a cast).  This handles the very common case of:

 X = alloc [n x byte]
 Y = cast X to somethingbetter
 seteq X, null

In order to avoid infinite looping when there are multiple casts, we only
allow this if the xform is strictly increasing the alignment of the
allocation.

llvm-svn: 23961
2005-10-24 06:35:18 +00:00
Chris Lattner
355ecc09f8 Fix a bug where we would 'promote' an allocation from one type to another
where the second has less alignment required.  If we had explicit alignment
support in the IR, we could handle this case, but we can't until we do.

llvm-svn: 23960
2005-10-24 06:26:18 +00:00
Chris Lattner
ac87beb03a Before promoting a malloc type, remove dead uses. This makes instcombine
more effective at promoting these allocations, catching them earlier in the
compile process.

llvm-svn: 23959
2005-10-24 06:22:12 +00:00
Chris Lattner
216be91817 Pull some code out into a function, no functionality change
llvm-svn: 23958
2005-10-24 06:03:58 +00:00
Chris Lattner
e175996c9a Move the END_WITH_NULL marker. Vladimir suggests that this works better with
GCC 4.1.  I tried it with 4.0 and 3.3 and it seems fine.

llvm-svn: 23957
2005-10-24 05:03:46 +00:00
Chris Lattner
2a65d7b633 Make this build with GCC 4.1, patch contributed by Vladimir A. Merzliakov!
llvm-svn: 23956
2005-10-24 04:51:35 +00:00
Chris Lattner
b8709e3c25 This pass is gone
llvm-svn: 23955
2005-10-24 04:18:05 +00:00
Chris Lattner
629481c8e0 this pass is gone
llvm-svn: 23954
2005-10-24 04:17:31 +00:00
Chris Lattner
62534530f6 This RA no longer exists
llvm-svn: 23953
2005-10-24 04:15:09 +00:00
Chris Lattner
476b8ddd55 Alkis agrees that that iterative scan allocator isn't going to be worked on
in the future, remove it.

llvm-svn: 23952
2005-10-24 04:14:30 +00:00
Chris Lattner
5cf068a5b7 Remove a prototype
llvm-svn: 23951
2005-10-24 04:13:21 +00:00
Jeff Cohen
68e320ccd6 Update Visual Studio projects to account for recent changes.
llvm-svn: 23950
2005-10-24 02:57:24 +00:00
Chris Lattner
90b0c99066 Remove this pass, it is not useful
llvm-svn: 23949
2005-10-24 02:35:43 +00:00
Chris Lattner
43143d9fe8 This pass is very old and quite useless, remove it.
llvm-svn: 23946
2005-10-24 02:35:24 +00:00
Chris Lattner
7f37ab41ee Three of these have been removed, as warned
llvm-svn: 23945
2005-10-24 02:33:44 +00:00
Chris Lattner
b37336978f Remove some beta code that no longer has an owner.
llvm-svn: 23944
2005-10-24 02:32:41 +00:00
Chris Lattner
f9998d9704 Do not build the ProfilePaths directory anymore
llvm-svn: 23943
2005-10-24 02:31:49 +00:00
Chris Lattner
788318cb69 Remove a now-unneeded library
llvm-svn: 23942
2005-10-24 02:31:05 +00:00
Chris Lattner
496a666266 Don't link these three passes in anymore
llvm-svn: 23941
2005-10-24 02:30:25 +00:00
Chris Lattner
bde3845548 DONT_BUILD_RELINKED is gone and implied by BUILD_ARCHIVE now
llvm-svn: 23940
2005-10-24 02:26:13 +00:00
Chris Lattner
1b91cbd627 Now that all libraries are built in either .o or .a form, make BUILD_ARCHIVE
default to turning off building of relinked objects.

llvm-svn: 23939
2005-10-24 02:21:45 +00:00
Chris Lattner
df88d79c08 only build .a version of this library
llvm-svn: 23938
2005-10-24 02:14:49 +00:00
Chris Lattner
f07e354d8c Only build .a file versions of these libraries, instead of .a and .o versions.
This should speed up build times.

llvm-svn: 23937
2005-10-24 02:11:51 +00:00
Chris Lattner
437b6116c9 There is no need to build an archive version of this library
llvm-svn: 23936
2005-10-24 02:09:03 +00:00
Chris Lattner
87d4e1c130 This file is hopelessly out of date
llvm-svn: 23935
2005-10-24 02:07:08 +00:00
Chris Lattner
1e050bd88b Only build .a file versions of these libraries, instead of .a and .o versions.
This should speed up build times.

llvm-svn: 23934
2005-10-24 02:05:35 +00:00
Chris Lattner
8c087e962c Only build .a file versions of these libraries, instead of .a and .o versions.
This should speed up build times.

llvm-svn: 23933
2005-10-24 01:59:48 +00:00
Chris Lattner
c64f3de8d5 use archives when possible
llvm-svn: 23932
2005-10-24 01:52:15 +00:00
Chris Lattner
bd77fac034 Make sure that anything using the ADCE pass pulls in the UnifyFunctionExitNodes
code

llvm-svn: 23931
2005-10-24 01:40:23 +00:00
Chris Lattner
8788942988 pull in the .a version of scalaropts lib to reduce the size of programs
using the JIT

llvm-svn: 23930
2005-10-24 01:15:14 +00:00
Chris Lattner
2a5442f365 pull in the archive version of this lib to reduce exe size
llvm-svn: 23929
2005-10-24 01:13:21 +00:00
Chris Lattner
f4d2a4b3bf Pull in the archive versions of these libs to reduce executable size
llvm-svn: 23928
2005-10-24 01:12:14 +00:00
Chris Lattner
8df7c01299 don't bother building the archive version of this library
llvm-svn: 23927
2005-10-24 01:08:20 +00:00
Chris Lattner
1f001771b2 Link in datastructure as a relinked o file
llvm-svn: 23926
2005-10-24 01:07:56 +00:00
Chris Lattner
652ce549ec Link to archive versions of libraries instead of the relinked ones
llvm-svn: 23925
2005-10-24 01:05:53 +00:00
Chris Lattner
ca014adf8e expose a ctor
llvm-svn: 23924
2005-10-24 01:00:45 +00:00
Chris Lattner
71a15b5b83 add a proto
llvm-svn: 23923
2005-10-24 01:00:32 +00:00
Chris Lattner
8f16bb6c3c Use the new LinkAllAnalyses.h header instead of forcing passes to be
in relinked object files

llvm-svn: 23922
2005-10-24 01:00:13 +00:00
Chris Lattner
1c5b428ff8 new header
llvm-svn: 23921
2005-10-24 00:59:49 +00:00
Chris Lattner
75d4f6fbcb implement some prototypes
llvm-svn: 23920
2005-10-24 00:38:38 +00:00
Chris Lattner
2a40d3aa90 add some prototypes
llvm-svn: 23919
2005-10-24 00:38:25 +00:00
Chris Lattner
b45e57c2dd move this to the analyze tool
llvm-svn: 23918
2005-10-24 00:27:36 +00:00
Chris Lattner
edfdf36c69 Don't invade the system namespace
llvm-svn: 23917
2005-10-24 00:16:03 +00:00
Chris Lattner
672471fbed Use archive versions of these libraries, using the LinkAllPasses header.
llvm-svn: 23916
2005-10-24 00:12:20 +00:00
Chris Lattner
63e504ff43 There is no need for this to be VC++ only
llvm-svn: 23915
2005-10-24 00:08:51 +00:00
Chris Lattner
a551033ea8 Fix a nasty bug that was causing miscompilation of global variables
on big endian 32-bit targets in some cases (e.g. PPC).  This fixes several
PPC JIT failures.

llvm-svn: 23914
2005-10-23 23:54:56 +00:00
Chris Lattner
ac23014355 Shrinkify to match llc
llvm-svn: 23912
2005-10-23 22:39:01 +00:00
Chris Lattner
41548484f4 Shrinkify to make --help output look better
llvm-svn: 23911
2005-10-23 22:37:13 +00:00
Chris Lattner
0b2bf4c255 shrinkify the option name a bit
llvm-svn: 23910
2005-10-23 22:35:42 +00:00
Chris Lattner
d36c34822e Simplify this, matching changes in the tblgen emitter
llvm-svn: 23909
2005-10-23 22:34:25 +00:00
Chris Lattner
03bf3a1763 Simplify this due to changes in the tblgen side
llvm-svn: 23908
2005-10-23 22:33:22 +00:00
Chris Lattner
4f48e67c6c Add the needed #include, emit enums with the sizes of tables, remove
definitions from the LLVM namespace, since they are all static.

llvm-svn: 23907
2005-10-23 22:33:08 +00:00
Chris Lattner
abcce5c4b3 mark this as beta
llvm-svn: 23906
2005-10-23 22:23:45 +00:00
Chris Lattner
8ff9df29a9 If a user requests help, give them help on both features and processors
llvm-svn: 23905
2005-10-23 22:23:13 +00:00
Chris Lattner
766361e8f4 Autogen subtarget information from .td files.
llvm-svn: 23904
2005-10-23 22:15:34 +00:00
Chris Lattner
4b5921d4d8 Add subtarget feature/processor defns to the .td file
llvm-svn: 23903
2005-10-23 22:08:45 +00:00
Chris Lattner
a389f0d8fa rearrange things a bit so that instructions can use subtarget features in the
future.

llvm-svn: 23902
2005-10-23 22:08:13 +00:00
Chris Lattner
437fd559d7 add a marker
llvm-svn: 23901
2005-10-23 22:07:20 +00:00
Chris Lattner
b54070745e add a note that Nate mentioned last week
llvm-svn: 23898
2005-10-23 21:44:59 +00:00
Chris Lattner
2e81fba9cd Put some of my random notes somewhere public
llvm-svn: 23897
2005-10-23 19:52:42 +00:00
Jeff Cohen
b92e9c57d5 Work around GCC's dislike of attributes on function definitions.
llvm-svn: 23896
2005-10-23 15:22:50 +00:00
Jeff Cohen
c55b4cd773 Remove deleted files from Visual Studio.
llvm-svn: 23895
2005-10-23 15:21:52 +00:00
Chris Lattner
49f7b69997 Remove the obsolete instr selector emitter
llvm-svn: 23894
2005-10-23 05:47:52 +00:00
Chris Lattner
f64f8407c2 Improve help output.
llvm-svn: 23893
2005-10-23 05:33:39 +00:00
Chris Lattner
0d4923b975 improve -help output
llvm-svn: 23892
2005-10-23 05:28:51 +00:00
Chris Lattner
18a70c35b8 Move static functions from .h file, reduce #includes, pass strings by const&,
use LowercaseString from StringExtras.h, remove extraneous space from help
output.

llvm-svn: 23891
2005-10-23 05:26:26 +00:00
Chris Lattner
e70c297044 Move static functions to .cpp file, reduce #includes, pass strings by
const&.

llvm-svn: 23890
2005-10-23 05:25:19 +00:00
Jeff Cohen
8b7b47ca88 Remove redundant flag.
llvm-svn: 23889
2005-10-23 04:51:22 +00:00
Jeff Cohen
11e26b52b2 When a function takes a variable number of pointer arguments, with a zero
pointer marking the end of the list, the zero *must* be cast to the pointer
type.  An un-cast zero is a 32-bit int, and at least on x86_64, gcc will
not extend the zero to 64 bits, thus allowing the upper 32 bits to be
random junk.

The new END_WITH_NULL macro may be used to annotate a such a function
so that GCC (version 4 or newer) will detect the use of un-casted zero
at compile time.

llvm-svn: 23888
2005-10-23 04:37:20 +00:00
Andrew Lenharth
c6072af580 Add several things.
loads
branches
setcc
working calls
Global address
External addresses

now I can manage malloc calls.

llvm-svn: 23887
2005-10-23 03:43:48 +00:00
Andrew Lenharth
4b3932aa89 add TargetExternalSymbol
llvm-svn: 23886
2005-10-23 03:40:17 +00:00
Jeff Cohen
5ec46cdf5c Add new files to Visual Studio.
llvm-svn: 23885
2005-10-23 01:22:33 +00:00
Andrew Lenharth
5a990417f8 Well, the Constant matching pattern works. Can't say much about calls or globals yet.
llvm-svn: 23884
2005-10-22 22:06:58 +00:00
Chris Lattner
711a5fe009 document this as experimental
llvm-svn: 23883
2005-10-22 22:00:45 +00:00
Chris Lattner
42b3a5d596 This file is entirely ifdef'd out
llvm-svn: 23882
2005-10-22 19:37:08 +00:00
Chris Lattner
9faa5b7a9a BuildSDIV and BuildUDIV only work for i32/i64, but they don't check that
the input is that type, this caused a failure on gs on X86 last night.
Move the hard checks into Build[US]Div since that is where decisions like
this should be made.

llvm-svn: 23881
2005-10-22 18:50:15 +00:00
Jim Laskey
13a19453d2 Add g3 back to the mix and reorder to irritate them anal folk. Actually, it's
to group appropriately and provide cues to maintainers that the lists don't
need to be ordered.

llvm-svn: 23880
2005-10-22 08:04:24 +00:00
Jim Laskey
a1beea6c7d Sort the features and processor lists for the sake of search (and maintainers.)
llvm-svn: 23879
2005-10-22 07:59:56 +00:00
Chris Lattner
c5d511c4d9 64-bit reg support should not be enabled by default, as support isn't complete.
llvm-svn: 23878
2005-10-21 22:15:43 +00:00
Chris Lattner
75ea5b10bf add a case missing from the dag combiner that exposed the failure on
2005-10-21-longlonggtu.ll.

llvm-svn: 23875
2005-10-21 21:23:25 +00:00
Chris Lattner
e296949fbe Instead of aborting if not a case we can handle specially, break out and
let the generic code handle it.  This fixes CodeGen/Generic/2005-10-21-longlonggtu.ll on ppc.

also, reindent this code

llvm-svn: 23874
2005-10-21 21:17:10 +00:00
Chris Lattner
68b61a8c8f New testcase that crashes the ppc backend
llvm-svn: 23871
2005-10-21 21:09:13 +00:00
Jim Laskey
9ed9032e22 Plugin new subtarget backend into the build.
llvm-svn: 23870
2005-10-21 19:05:19 +00:00
Jim Laskey
cfda85ad91 New TableGen backends for subtarget information. Only command line stuff
active now.  Scheduling itinerary next.

llvm-svn: 23869
2005-10-21 19:00:04 +00:00
Chris Lattner
229878b7bc silence a release mode warning
llvm-svn: 23868
2005-10-21 16:01:26 +00:00
Chris Lattner
c82a034580 add missing prototype
llvm-svn: 23867
2005-10-21 15:49:28 +00:00
Chris Lattner
e95b5745c0 Make the coallescer a bit smarter, allowing it to join more live ranges.
For example, we can now join things like [0-30:0)[31-40:1)[52-59:2)
with [40:60:0) if the 52-59 range is defined by a copy from the 40-60 range.
The resultant range ends up being [0-30:0)[31-60:1).

This fires a lot through-out the test suite (e.g. shrinking bc from
19492 -> 18509 machineinstrs) though most gains are smaller (e.g. about
50 copies eliminated from crafty).

llvm-svn: 23866
2005-10-21 06:49:50 +00:00
Chris Lattner
76c97afbbc Fix LiveInterval::getOverlapingRanges to take things in the right order
(an unused method).

Fix the merger so that it can merge ranges like this  [10:12)[16:40) with
[12:38) into [10:40) instead of bogus ranges.  This sort of input will be
possible for the merger coming shortly

llvm-svn: 23865
2005-10-21 06:41:30 +00:00
Nate Begeman
fd0d55ec69 Match rotate. This does actually match the rotates in an rc5 cipher, but I
haven't seen it fire on our testsuite.

llvm-svn: 23863
2005-10-21 06:36:18 +00:00
Chris Lattner
5df0e36e98 My previous patch was too conservative. Reject FP and void types, but do
allow pointer types.

llvm-svn: 23859
2005-10-21 05:45:41 +00:00
Nate Begeman
ae5d9bd65b Don't generate operations that aren't yet supported
llvm-svn: 23858
2005-10-21 01:52:45 +00:00
Nate Begeman
62e9e5462c Kill some now-dead code.
llvm-svn: 23857
2005-10-21 01:52:20 +00:00
Nate Begeman
8f62cd32ad Fix a typo in the dag combiner, so that this can work on i64 targets
llvm-svn: 23856
2005-10-21 01:51:45 +00:00
Andrew Lenharth
a099c0131e byte zap not immediate goodness
llvm-svn: 23855
2005-10-21 01:24:05 +00:00
Chris Lattner
8bda5afd91 Make tblgen emit:
tblgen: In ZAPNOTi: Cannot use 'IZAPX' in an input pattern!
for a bad pattern, instead of an ugly assertion.

llvm-svn: 23854
2005-10-21 01:19:59 +00:00
Nate Begeman
4dd383120f Invert the TargetLowering flag that controls divide by consant expansion.
Add a new flag to TargetLowering indicating if the target has really cheap
  signed division by powers of two, make ppc use it.  This will probably go
  away in the future.
Implement some more ISD::SDIV folds in the dag combiner
Remove now dead code in the x86 backend.

llvm-svn: 23853
2005-10-21 00:02:42 +00:00
Andrew Lenharth
a6a23b5874 Inst cleanup. As a bonus, operands are in the correct order for cmovs. Expect new stuff to pass in the JIT tonight
llvm-svn: 23852
2005-10-20 23:58:36 +00:00
Chris Lattner
a553780e98 Use a literal to define ineg instead of immzero
llvm-svn: 23851
2005-10-20 23:30:37 +00:00
Chris Lattner
b7b75e1b68 Fix a conditional so we don't access past the end of the range. Thanks to
Andrew for bringing this to my attn.

llvm-svn: 23850
2005-10-20 22:50:10 +00:00
Andrew Lenharth
d4c0ed74e4 added a few 1 operand form stuff. Seems to break regalloc on alpha. sigh
llvm-svn: 23849
2005-10-20 19:39:24 +00:00
Andrew Lenharth
7e0e8234f6 add cttz and ctpop
llvm-svn: 23848
2005-10-20 19:38:11 +00:00
Nate Begeman
7efe53d90b Fix a couple bugs in the const div stuff where we'd generate MULHS/MULHU
for types that aren't legal, and fail a divisor is less than zero
comparison, which would cause us to drop a subtract.

llvm-svn: 23846
2005-10-20 17:45:03 +00:00
Chris Lattner
a6efeb01f9 don't use llabs with apparently VC++ doesn't have
llvm-svn: 23845
2005-10-20 17:01:00 +00:00
Chris Lattner
35852fc391 Fix order of eval problem from when I refactored this into a function.
llvm-svn: 23844
2005-10-20 16:56:40 +00:00
Andrew Lenharth
eb0ad1863b Sounds good, finish the intop conversion.
llvm-svn: 23843
2005-10-20 14:42:48 +00:00
Nate Begeman
60bbe2d1e5 Add some more patterns for i64 on ppc
llvm-svn: 23842
2005-10-20 07:51:08 +00:00
Chris Lattner
3cf40798ab add a new method, play around with some code.
Fix a *bug* in the extendIntervalEndTo method.  In particular, if adding
[2:10) to an interval containing [0:2),[10:30), we produced [0:10),[10,30).
Which is not the most smart thing to do.  Now produce [0:30).

llvm-svn: 23841
2005-10-20 07:39:25 +00:00
Chris Lattner
6380f3c96d add a new method
llvm-svn: 23840
2005-10-20 07:37:59 +00:00
Chris Lattner
8816353040 Refactor some code, pulling it out into a function. No functionality change.
llvm-svn: 23839
2005-10-20 06:06:30 +00:00
Chris Lattner
0c0b38bb4c Do NOT touch FP ops with LSR. This fixes a testcase Nate sent me from an
inner loop like this:

LBB_RateConvertMono8AltiVec_2:  ; no_exit
        lis r2, ha16(.CPI_RateConvertMono8AltiVec_0)
        lfs f3, lo16(.CPI_RateConvertMono8AltiVec_0)(r2)
        fmr f3, f3
        fadd f0, f2, f0
        fadd f3, f0, f3
        fcmpu cr0, f3, f1
        bge cr0, LBB_RateConvertMono8AltiVec_2  ; no_exit

to an inner loop like this:

LBB_RateConvertMono8AltiVec_1:  ; no_exit
        fsub f2, f2, f1
        fcmpu cr0, f2, f1
        fmr f0, f2
        bge cr0, LBB_RateConvertMono8AltiVec_1  ; no_exit

Doh! good catch!

llvm-svn: 23838
2005-10-20 04:47:10 +00:00
Chris Lattner
fd07fcda67 Add some pattern fragments to simplify the repetitive parts of the patterns
for some common ops and use them for a few examples.  Andrew, if you like
this, feel free to convert the rest over, if you hate it, feel free to
revert.

llvm-svn: 23837
2005-10-20 04:21:06 +00:00
Chris Lattner
cd4be8798f simplify this a bit by using immediates
llvm-svn: 23836
2005-10-20 03:57:03 +00:00
Nate Begeman
c6f067a8c4 Move the target constant divide optimization up into the dag combiner, so
that the nodes can be folded with other nodes, and we can not duplicate
code in every backend.  Alpha will probably want this too.

llvm-svn: 23835
2005-10-20 02:15:44 +00:00
Nate Begeman
5765717aad Enable targets to say that integer divide is expensive, which will trigger
an upcoming optimization in the DAG Combiner.

llvm-svn: 23834
2005-10-20 02:14:14 +00:00
Andrew Lenharth
794f15868a forgot this one
llvm-svn: 23833
2005-10-20 00:29:02 +00:00
Andrew Lenharth
7b69867052 ret 0; works, not much else
still lots of uglyness.
Maybe calls will come soon.
Fixing the return value of things will be necessary to make alpha work.

llvm-svn: 23832
2005-10-20 00:28:31 +00:00
John Criswell
196e8c1f58 This fixes PR638:
Regression/CodeGen/Generic/2004-02-08-UnwindSupport.llx

llvm-svn: 23831
2005-10-19 20:07:15 +00:00
Jim Laskey
74ab9960f2 Added InstrSchedClass to each of the PowerPC Instructions.
Note that when adding new instructions that you should refer to the table at the
bottom of PPCSchedule.td.

llvm-svn: 23830
2005-10-19 19:51:16 +00:00
John Criswell
b2544ff7a7 Moved to Regression/Codegen/Generic.
llvm-svn: 23829
2005-10-19 18:52:52 +00:00
John Criswell
14582b1a73 This is a generic test for all code generators. It originally came from
Regression/Codegen/X86.

llvm-svn: 23826
2005-10-19 18:51:07 +00:00
Nate Begeman
9f3c26c4ea Write patterns for the various shl and srl patterns that don't involve
doing something clever.

llvm-svn: 23824
2005-10-19 18:42:01 +00:00
John Criswell
6b7df0ef4e Force i386 code generation for an i386 specific test.
llvm-svn: 23821
2005-10-19 18:30:39 +00:00
Jim Laskey
9761100055 Push processor descriptions to the top of target and add command line info.
llvm-svn: 23820
2005-10-19 13:34:52 +00:00
Chris Lattner
c9ad735e78 add support for literal immediates in patterns to match, allowing us to
write things like this:

def : Pat<(add GPRC:$in, 12),
          (ADD12 GPRC:$in)>;

Andrew: if this isn't enough or doesn't work for you, please lemme know.
llvm-svn: 23819
2005-10-19 04:41:05 +00:00
Chris Lattner
c16b0c387f now that tblgen is smarter, use integers directly. This should help Andrew too
llvm-svn: 23818
2005-10-19 04:32:04 +00:00
Chris Lattner
7f6f565846 Add basic support for integer constants in pattern results.
llvm-svn: 23817
2005-10-19 04:30:56 +00:00
Chris Lattner
2ae2f99326 Fix some checking that was causing duraid to get a perplexing assertion
instead of a happy error message

llvm-svn: 23816
2005-10-19 04:12:14 +00:00
Chris Lattner
b8014e10ae Add support for patterns that have physical registers in them. Testcase:
def : Pat<(trunc G8RC:$in),
          (OR8To4 G8RC:$in, X0)>;

Even though this doesn't make any sense on PPC :)

llvm-svn: 23815
2005-10-19 02:07:26 +00:00
Chris Lattner
c8f899f98d Asserting here is to violent
llvm-svn: 23814
2005-10-19 01:55:23 +00:00
Chris Lattner
5f37623218 teach ppc backend these are copies
llvm-svn: 23813
2005-10-19 01:50:36 +00:00
Chris Lattner
62041778e6 Make this work with the internalize change
llvm-svn: 23812
2005-10-19 01:41:47 +00:00
Chris Lattner
5b6f4dc623 Convert these cases to patterns
llvm-svn: 23811
2005-10-19 01:38:02 +00:00
Chris Lattner
8baf5043a8 Nate wants to define 'Pat's which turn into instructions that don't have
patterns.  Certainly a logical request.

llvm-svn: 23810
2005-10-19 01:27:22 +00:00
Nate Begeman
9eaa6bac06 Woo, it kinda works. We now generate this atrociously bad, but correct,
code for long long foo(long long a, long long b) { return a + b; }

_foo:
        or r2, r3, r3
        or r3, r4, r4
        or r4, r5, r5
        or r5, r6, r6
        rldicr r2, r2, 32, 31
        rldicl r3, r3, 0, 32
        rldicr r4, r4, 32, 31
        rldicl r5, r5, 0, 32
        or r2, r3, r2
        or r3, r5, r4
        add r4, r3, r2
        rldicl r2, r4, 32, 32
        or r4, r4, r4
        or r3, r2, r2
        blr

llvm-svn: 23809
2005-10-19 01:12:32 +00:00
Chris Lattner
38d7f2be4c Testcase that crashes llvmgcc in type layout
llvm-svn: 23806
2005-10-19 00:52:21 +00:00
Chris Lattner
ecdf842311 apply some tblgen majik to simplify the X register definitions
llvm-svn: 23805
2005-10-19 00:17:55 +00:00
Nate Begeman
5172ce641e Teach Legalize how to do something with EXTRACT_ELEMENT when the type of
the pair of elements is a legal type.

llvm-svn: 23804
2005-10-19 00:06:56 +00:00
Nate Begeman
92e77502f3 Make a new reg class for 64 bit regs that aliases the 32 bit regs. This
will have to tide us over until we get real subreg support, but it prevents
the PrologEpilogInserter from spilling 8 byte GPRs on a G4 processor.

Add some initial support for TRUNCATE and ANY_EXTEND, but they don't
currently work due to issues with ScheduleDAG.  Something wll have to be
figured out.

llvm-svn: 23803
2005-10-19 00:05:37 +00:00
Nate Begeman
78afac2ddd Add the ability to lower return instructions to TargetLowering. This
allows us to lower legal return types to something else, to meet ABI
requirements (such as that i64 be returned in two i32 regs on Darwin/ppc).

llvm-svn: 23802
2005-10-18 23:23:37 +00:00
Chris Lattner
0a71a9ac86 Fix Generic/2005-10-18-ZeroSizeStackObject.ll by not requesting a zero
sized stack object if either the array size or the type size is zero.

llvm-svn: 23801
2005-10-18 22:14:06 +00:00
Chris Lattner
84b36df7e9 new testcase
llvm-svn: 23798
2005-10-18 22:13:39 +00:00
Chris Lattner
8396a308a7 remove hack
llvm-svn: 23797
2005-10-18 22:11:42 +00:00
Chris Lattner
13a57822a1 This was never updated for the project makefile changes
llvm-svn: 23790
2005-10-18 18:50:26 +00:00
Chris Lattner
46a97ab3e8 This never got updated to reflect the project makefile changes
llvm-svn: 23789
2005-10-18 18:48:30 +00:00
Jim Laskey
d812a2e449 Simple edits; remove unimplimented cases and clarify long haul SLU cases.
llvm-svn: 23788
2005-10-18 16:59:23 +00:00
Chris Lattner
5a2fb9787b Fix the JIT encoding of LWA, LD, STD, and STDU.
llvm-svn: 23787
2005-10-18 16:51:22 +00:00
Jim Laskey
c6533006c8 Checking in first round of scheduling tablegen files. Not tied in as yet.
llvm-svn: 23786
2005-10-18 16:23:40 +00:00
Chris Lattner
53b9c3ad4c add a case
llvm-svn: 23785
2005-10-18 06:30:51 +00:00
Chris Lattner
727671a3dc Fix PR637
llvm-svn: 23784
2005-10-18 06:29:43 +00:00
Chris Lattner
45517baf9f Add an option to this pass. If it is set, we are allowed to internalize
all but main.  If it's not set, we can still internalize, but only if an
explicit symbol list is provided.

llvm-svn: 23783
2005-10-18 06:29:22 +00:00
Chris Lattner
f09e38ccac add an option to the internalize pass
llvm-svn: 23782
2005-10-18 06:28:16 +00:00
Chris Lattner
6c14c35bd7 Fold (select C, load A, load B) -> load (select C, A, B). This happens quite
a lot throughout many programs.  In particular, specfp triggers it a bunch for
constant FP nodes when you have code like  cond ? 1.0 : -1.0.

If the PPC ISel exposed the loads implicit in pic references to external globals,
we would be able to eliminate a load in cases like this as well:

%X = external global int
%Y = external global int
int* %test4(bool %C) {
        %G = select bool %C, int* %X, int* %Y
        ret int* %G
}

Note that this breaks things that use SrcValue's (see the fixme), but since nothing
uses them yet, this is ok.

Also, simplify some code to use hasOneUse() on an SDOperand instead of hasNUsesOfValue directly.

llvm-svn: 23781
2005-10-18 06:04:22 +00:00
Chris Lattner
ed653cbe43 Duraid pointed out that it is impolite to emit PPC:: into the IA64 backend
llvm-svn: 23780
2005-10-18 04:41:01 +00:00
Nate Begeman
e74dfbb9ce Do the right thing and enable 64 bit regs under the control of a subtarget
option.  Currently the only way to enable this is to specify the
64bitregs mattr flag.  It is never enabled by default on any config yet.

llvm-svn: 23779
2005-10-18 00:56:42 +00:00
Nate Begeman
0b71e007ef First bits of 64 bit PowerPC stuff, currently disabled. A lot of this is
purely mechanical.

llvm-svn: 23778
2005-10-18 00:28:58 +00:00
Nate Begeman
418c6e4045 Implement some feedback from Chris re: constant canonicalization
llvm-svn: 23777
2005-10-18 00:28:13 +00:00
Nate Begeman
bd5f41a6a6 Legalize BUILD_PAIR appropriately for upcoming 64 bit PowerPC work.
llvm-svn: 23776
2005-10-18 00:27:41 +00:00
John Criswell
d122b68735 Use %s instead of hard coding the input filename.
This allows the test to work when srcdir != objdir.

llvm-svn: 23775
2005-10-17 21:54:18 +00:00
Nate Begeman
ec48a1bfbd fold fmul X, +2.0 -> fadd X, X;
llvm-svn: 23774
2005-10-17 20:40:11 +00:00
Chris Lattner
da1b152c43 Make this work for FP constantexprs
llvm-svn: 23773
2005-10-17 20:18:38 +00:00
Chris Lattner
7fde91e365 Oops, X+0.0 isn't foldable, but X+-0.0 is.
llvm-svn: 23772
2005-10-17 17:56:38 +00:00
Chris Lattner
32979336a7 relax this a bit, as we only support the default rounding mode
llvm-svn: 23771
2005-10-17 17:49:32 +00:00
Chris Lattner
8113c67003 Apparently, people object to floating pointers. Picky picky.
llvm-svn: 23770
2005-10-17 15:19:24 +00:00
Jim Laskey
87ce5d85bb As requested, a blurb on sub-targets.
llvm-svn: 23769
2005-10-17 12:19:10 +00:00
Chris Lattner
721f3ce90f fix some grammar-o's I noticed
llvm-svn: 23768
2005-10-17 04:18:41 +00:00
Chris Lattner
9fcf000d9e Feedback from Nate.
llvm-svn: 23767
2005-10-17 03:09:31 +00:00
Chris Lattner
776c73f032 Document -view-isel-dags and -view-sched-dags
llvm-svn: 23766
2005-10-17 01:40:33 +00:00
Chris Lattner
ed54f2f5e7 Add notes about MF.viewCFG() and friends.
llvm-svn: 23765
2005-10-17 01:36:23 +00:00
Chris Lattner
eeb2bda2fa add a trivial fold
llvm-svn: 23764
2005-10-17 01:07:11 +00:00
Chris Lattner
17acad625c Add a bunch of info about the isel autogenerator. Review appreciated!
llvm-svn: 23763
2005-10-16 20:02:19 +00:00
Chris Lattner
d6f1a33d26 Fill this out some more. Add description of MBB/MF. Fix some broken links,
turn some broken <a name> into <a href>'s.

llvm-svn: 23762
2005-10-16 18:31:08 +00:00
Chris Lattner
c9afa28b92 Add a stub for the TargetSubtarget class. Jim, please fill a blurb in here
when you get a chance.

llvm-svn: 23761
2005-10-16 17:06:07 +00:00
Chris Lattner
bf589c5129 Update this significantly, mention subtarget and isel generation support.
llvm-svn: 23760
2005-10-16 17:03:22 +00:00
Nate Begeman
6cca84e43c More PPC32 -> PPC changes, as well as merging some classes that were
redundant after the change.

llvm-svn: 23759
2005-10-16 05:39:50 +00:00
Chris Lattner
825298b060 Make the generated code significantly more memory efficient, by using
SelectNodeTo instead of getTargetNode when possible.

llvm-svn: 23758
2005-10-16 01:41:58 +00:00
Chris Lattner
acf3d627b9 update this a little bit to talk about the dag combiner and remove inaccuracies.
This still doesn't talk about autogen much

llvm-svn: 23757
2005-10-16 00:36:38 +00:00
Chris Lattner
e540800d5a Fix this logic.
llvm-svn: 23756
2005-10-15 22:35:40 +00:00
Chris Lattner
17cc9edd33 Add a case we were missing that was causing us to fail CodeGen/PowerPC/rlwinm.ll:test3
llvm-svn: 23755
2005-10-15 22:18:08 +00:00
Nate Begeman
c0896117d3 Remove some dead code now that the dag combiner exists.
llvm-svn: 23754
2005-10-15 22:08:02 +00:00
Chris Lattner
d869bec4fe Remove some dead code: the ORI/ORIS cases are autogen'd. This makes
SelectIntImmediateExpr dead.

llvm-svn: 23753
2005-10-15 22:06:18 +00:00
Chris Lattner
03354280eb prune #includes
llvm-svn: 23752
2005-10-15 21:58:54 +00:00
Chris Lattner
a52969c8d6 These instructions are now autogenerated
llvm-svn: 23751
2005-10-15 21:44:56 +00:00
Chris Lattner
286c1d7cfa Add a pattern for FSQRTS
llvm-svn: 23750
2005-10-15 21:44:15 +00:00
Chris Lattner
efa382616b remove dead code
llvm-svn: 23749
2005-10-15 21:40:12 +00:00
Chris Lattner
6b22d2554a Implement the last major missing piece in the DAG isel generator: when emitting
a pattern match, make sure to emit the (minimal number of) type checks that
verify the pattern matches this specific instruction.  This allows FMA32
patterns to not match double expressions for example.

llvm-svn: 23748
2005-10-15 21:34:21 +00:00
Chris Lattner
b986f471be Use getExtLoad here instead of getNode, as extloads produce two values. This
fixes a legalize failure on SPASS for itanium.

llvm-svn: 23747
2005-10-15 20:24:07 +00:00
Chris Lattner
e33870d154 remove broken SRA/rlwimi case
llvm-svn: 23746
2005-10-15 19:04:48 +00:00
Chris Lattner
6f3b954662 Rename PPC32*.h to PPC*.h
This completes the grand PPC file renaming

llvm-svn: 23745
2005-10-14 23:59:06 +00:00
Chris Lattner
0aa794ba5b Merge PPCJITInfo.h and PPC32JITInfo.h. Note that the PowerPCJITInfo
and PPC32JITInfo classes should be merged.

llvm-svn: 23744
2005-10-14 23:53:41 +00:00
Chris Lattner
bfca1ab79d Rename PowerPC*.h to PPC*.h
llvm-svn: 23743
2005-10-14 23:51:18 +00:00
Chris Lattner
e80bf1b33a Rename PowerPCInstrBuilder.h -> PPC*
llvm-svn: 23742
2005-10-14 23:45:43 +00:00
Chris Lattner
2ed745a905 Nuke the PowerPCTargetMachine.h header. Note that the PowerPCTargetMachine
still should be merged into the PPC32TargetMachine class

llvm-svn: 23741
2005-10-14 23:44:05 +00:00
Chris Lattner
7503d46feb Rename PowerPC*.td -> PPC*.td
llvm-svn: 23740
2005-10-14 23:40:39 +00:00
Chris Lattner
f3b97f53b9 These are dead
llvm-svn: 23739
2005-10-14 23:38:51 +00:00
Chris Lattner
0921e3bfc1 Eliminate PowerPC.td and PPC32.td, consolidating them into PPC.td
llvm-svn: 23738
2005-10-14 23:37:35 +00:00
Chris Lattner
09cd9e7661 Like the comment says...
llvm-svn: 23737
2005-10-14 22:48:24 +00:00
Chris Lattner
2121f3ca50 Nuke PowerPCInstrFormats.h, its contents are dead. Remove the definitions
from the .td file that correspond to it

llvm-svn: 23736
2005-10-14 22:44:13 +00:00
Nate Begeman
9d7008b08d Properly split f32 and f64 into separate register classes for scalar sse fp
fixing a bunch of nasty hackery

llvm-svn: 23735
2005-10-14 22:06:00 +00:00
Nate Begeman
c41e1be2e8 Remove an unnecsesary file. PPC32 and PPC64 share architected registers.
We will decide with subtarget support whether we ever use an i64 register
class.

llvm-svn: 23734
2005-10-14 18:58:46 +00:00
Chris Lattner
56f31f5408 add the integer truncate/extension operations
llvm-svn: 23733
2005-10-14 06:40:20 +00:00
Chris Lattner
95866d3923 Make sure targets depend on TargetSelectionDAG.td
llvm-svn: 23732
2005-10-14 06:31:58 +00:00
Chris Lattner
7d9f719d42 These are now autogenerated
llvm-svn: 23731
2005-10-14 06:26:29 +00:00
Chris Lattner
c4db8f4163 Now that we have int/fp lattice values, implement the SDTCisOpSmallerThanOp
type constraint.  This lets tblgen realize that it doesn't need any dynamic
type checks for fextend/fround on PPC (and many other targets), because there
are only two fp types.

llvm-svn: 23730
2005-10-14 06:25:00 +00:00
Chris Lattner
ecaf56b21a Fairly serious rework of the typing code to add new int/fp lattice values.
Overall, no functionality change yet though.

llvm-svn: 23729
2005-10-14 06:12:03 +00:00
Chris Lattner
cdf483556f simplify the code a bit
llvm-svn: 23728
2005-10-14 05:08:37 +00:00
Chris Lattner
9c0d3c5932 Add patterns for FP round/extend
llvm-svn: 23727
2005-10-14 04:55:50 +00:00
Chris Lattner
6e83cbf7f3 add a new SDTCisOpSmallerThanOp type constraint, and implement fround/fextend in terms of it
llvm-svn: 23726
2005-10-14 04:55:10 +00:00
Chris Lattner
4892df38f3 Add basic support for recognizing a new SDTCisOpSmallerThanOp type constraint
llvm-svn: 23725
2005-10-14 04:53:53 +00:00
Chris Lattner
7b0275ba8c Implement a couple of new (important) features.
1. If an operation has to be int or fp and the target only supports one
   int or fp type, relize that the op has to have that type.
2. If a target has operations on multiple types, do not emit matching code
   for patterns involving those operators, since we do not emit the code to
   check for them yet.  This prevents PPC from generating FP ops currently.

Also move some code around into more logical places.

llvm-svn: 23724
2005-10-14 04:11:13 +00:00
Chris Lattner
90c5b9c83c Do not let getLegalValueTypes return a list with duplicates in it
llvm-svn: 23723
2005-10-14 03:54:49 +00:00
Nate Begeman
6e673b24d3 fold sext_in_reg, sext_in_reg where both have the same VT. This was
popping up in Fourinarow.

llvm-svn: 23722
2005-10-14 01:29:07 +00:00
Chris Lattner
e3870fbe4a Allow $
llvm-svn: 23721
2005-10-14 01:28:34 +00:00
Nate Begeman
d59e5a7abb Relax the checking on zextload generation a bit, since as sabre pointed out
you could be AND'ing with the result of a shift that shifts out all the
bits you care about, in addition to a constant.

Also, move over an add/sub_parts fold from legalize to the dag combiner,
where it works for things other than constants.  Woot!

llvm-svn: 23720
2005-10-14 01:12:21 +00:00
Chris Lattner
a6d62322e5 Fix errors when compiling with -pedantic
llvm-svn: 23719
2005-10-14 00:33:05 +00:00
Chris Lattner
b8282987f4 Fix the trunc(load) case, finally allowing crafty and povray to pass
llvm-svn: 23718
2005-10-13 22:10:05 +00:00
Chris Lattner
dbc5ae3109 Fix some bugs in (sext (load x))
llvm-svn: 23717
2005-10-13 21:52:31 +00:00
Chris Lattner
258521d7ea When ExpandOp'ing a [SZ]EXTLOAD, make sure to remember that the chain
is also legal.  Add support for ExpandOp'ing raw EXTLOADs too.

llvm-svn: 23716
2005-10-13 21:44:47 +00:00
Chris Lattner
d23f4b7411 Implement PromoteOp for *EXTLOAD, allowing MallocBench/gs to Legalize
llvm-svn: 23715
2005-10-13 20:07:41 +00:00
Nate Begeman
8e022b3d89 Fix the remaining DAGCombiner issues pointed out by sabre. This should fix
the remainder of the failures introduced by my patch last night.

llvm-svn: 23714
2005-10-13 18:34:58 +00:00
Chris Lattner
a80f1f6e72 Fix a minor bug in the dag combiner that broke pcompress2 and some other
tests.

llvm-svn: 23713
2005-10-13 18:16:34 +00:00
Patrick Meredith
16fe45c91b Updated to be less restrictive on what is matched
llvm-svn: 23712
2005-10-13 17:31:30 +00:00
Nate Begeman
c3a89c5259 Add support to Legalize for expanding i64 sextload/zextload into hi and lo
parts. This should fix the crafty and signed long long unit test failure
on x86 last night.

llvm-svn: 23711
2005-10-13 17:15:37 +00:00
Jim Laskey
5d7a50ac44 Inhibit instructions from being pushed before function calls. This will
minimize unnecessary spilling.

llvm-svn: 23710
2005-10-13 16:44:00 +00:00
Chris Lattner
e70b0d37c3 apparently one of the makefile changes changed libprofile.so to profile.so
llvm-svn: 23709
2005-10-13 16:34:24 +00:00
Patrick Meredith
fd377d9033 This script is used to remove nodes with the label %tmp(.#)* and all
edges associated with said node from the dot files produced by
DSA.

llvm-svn: 23708
2005-10-13 16:26:50 +00:00
Chris Lattner
eeaf2094b8 Nate implemented this :)
llvm-svn: 23707
2005-10-13 06:04:34 +00:00
Nate Begeman
02b23c6065 Move some Legalize functionality over to the DAGCombiner where it belongs.
Kill some dead code.

llvm-svn: 23706
2005-10-13 03:11:28 +00:00
Nate Begeman
b96e50ccbd SimplifySelectCC is dead
llvm-svn: 23705
2005-10-13 03:10:46 +00:00
Nate Begeman
70d28c5e32 Fix a potential bug with two combine-to's back to back that chris pointed
out, where after the first CombineTo() call, the node the second CombineTo
wishes to replace may no longer exist.

Fix a very real bug with the truncated load optimization on little endian
targets, which do not need a byte offset added to the load.

llvm-svn: 23704
2005-10-12 23:18:53 +00:00
Nate Begeman
8caf81d617 More cool stuff for the dag combiner. We can now finally handle things
like turning:

_foo:
        fctiwz f0, f1
        stfd f0, -8(r1)
        lwz r2, -4(r1)
        rlwinm r3, r2, 0, 16, 31
        blr

into
_foo:
        fctiwz f0,f1
        stfd f0,-8(r1)
        lhz r3,-2(r1)
        blr

Also removed an unncessary constraint from sra -> srl conversion, which
should take care of hte only reason we would ever need to handle sra in
MaskedValueIsZero, AFAIK.

llvm-svn: 23703
2005-10-12 20:40:40 +00:00
Jim Laskey
63b1419b74 Finally committing to the new scheduler. Still -sched=none by default.
llvm-svn: 23702
2005-10-12 18:29:35 +00:00
Jim Laskey
d00db257c7 Added graphviz/gv support for MF.
llvm-svn: 23700
2005-10-12 12:09:05 +00:00
Chris Lattner
e1832ccf63 this passes with the change in predicate
llvm-svn: 23699
2005-10-11 18:42:26 +00:00
Chris Lattner
192cd18f53 Fix (hopefully the last) issue where LSR is nondeterminstic. When pulling
out CSE's of base expressions it could build a result whose order was
nondet.

llvm-svn: 23698
2005-10-11 18:41:04 +00:00
Chris Lattner
5c9d63da31 Fix another problem where LSR was being nondeterminstic. Also remove elements
from the end of a vector instead of the beginning

llvm-svn: 23697
2005-10-11 18:30:57 +00:00
Chris Lattner
eb1579d308 lsr doesn't emit gep instructions anymore
llvm-svn: 23696
2005-10-11 18:28:48 +00:00
Chris Lattner
b7a3894e7c Fix another lsr-is-nondeterministic case
llvm-svn: 23695
2005-10-11 18:17:57 +00:00
Chris Lattner
514f058be1 Fix a powerpc crash on CodeGen/Generic/llvm-ct-intrinsics.ll
llvm-svn: 23694
2005-10-11 17:56:34 +00:00
Chris Lattner
c38fb8e2a1 Add a canonicalization that got lost, fixing PowerPC/fold-li.ll:SUB
llvm-svn: 23693
2005-10-11 06:07:15 +00:00
Chris Lattner
cc6e53e6ee clean up some corner cases
llvm-svn: 23692
2005-10-10 23:00:08 +00:00
Chris Lattner
04c737091f Implement trivial DSE. If two stores are neighbors and store to the same
location, replace them with a new store of the last value.  This occurs
in the same neighborhood in 197.parser, speeding it up about 1.5%

llvm-svn: 23691
2005-10-10 22:31:19 +00:00
Chris Lattner
e260ed8628 Add support for CombineTo, allowing the dag combiner to replace nodes with
multiple results.

Use this support to implement trivial store->load forwarding, implementing
CodeGen/PowerPC/store-load-fwd.ll.  Though this is the most simple case and
can be extended in the future, it is still useful.  For example, it speeds
up 197.parser by 6.2% by avoiding an LSU reject in xalloc:

        stw r6, lo16(l5_end_of_array)(r2)
        addi r2, r5, -4
        stwx r5, r4, r2
-       lwzx r5, r4, r2
-       rlwinm r5, r5, 0, 0, 30
        stwx r5, r4, r2
        lwz r2, -4(r4)
        ori r2, r2, 1

llvm-svn: 23690
2005-10-10 22:04:48 +00:00
Chris Lattner
89a39f1508 new testcase
llvm-svn: 23689
2005-10-10 21:57:37 +00:00
Nate Begeman
6828ed9bfd Teach the DAGCombiner several new tricks, teaching it how to turn
sext_inreg into zext_inreg based on the signbit (fires a lot), srem into
urem, etc.

llvm-svn: 23688
2005-10-10 21:26:48 +00:00
Chris Lattner
4653985b86 A testcase sitting in my tree
llvm-svn: 23687
2005-10-10 21:21:36 +00:00
Chris Lattner
7730924067 Fix comment
llvm-svn: 23686
2005-10-10 16:52:03 +00:00
Chris Lattner
3d1d4a3d12 Add ISD::ADD to MaskedValueIsZero
llvm-svn: 23685
2005-10-10 16:51:40 +00:00
Chris Lattner
56e44a6da5 This function is now dead
llvm-svn: 23684
2005-10-10 16:49:22 +00:00
Chris Lattner
bcfebebf22 Enable Nate's excellent DAG combiner work by default. This allows the
removal of a bunch of ad-hoc and crufty code from SelectionDAG.cpp.

llvm-svn: 23682
2005-10-10 16:47:10 +00:00
Chris Lattner
d59a57a8d5 These definitions have been moved to common code.
llvm-svn: 23681
2005-10-10 06:01:00 +00:00
Chris Lattner
d83571bbf2 Pull DAG ISel generation nodes out of the PowerPC backend to where they
can be used by other targets.  For those targets that want to use it,
have at.  :)

llvm-svn: 23680
2005-10-10 06:00:30 +00:00
Chris Lattner
6a49b7cabb add a todo for something I noticed
llvm-svn: 23679
2005-10-09 22:59:08 +00:00
Chris Lattner
1d3dc00674 (X & Y) & C == 0 if either X&C or Y&C are zero
llvm-svn: 23678
2005-10-09 22:12:36 +00:00
Chris Lattner
03b9eb506c Make MaskedValueIsZero a bit more aggressive
llvm-svn: 23677
2005-10-09 22:08:50 +00:00
Andrew Lenharth
1dfb85c7af This seems useful from the original patch that added the function. If there is a reason it is not useful on a RISC type target, let me know and I will pull it out
llvm-svn: 23676
2005-10-09 20:11:35 +00:00
Chris Lattner
62010c450f Fix funky xcode indentation
llvm-svn: 23674
2005-10-09 06:36:35 +00:00
Chris Lattner
eb4be8b942 Hrm, you didn't see this.
llvm-svn: 23673
2005-10-09 06:24:02 +00:00
Chris Lattner
4ea0a3eaac Fix a source of non-determinism in the backend: the order of processing
IV strides dependend on the pointer order of the strides in memory.
Non-determinism is bad.

llvm-svn: 23672
2005-10-09 06:20:55 +00:00
Chris Lattner
0832f2635a When emiting a CopyFromReg and the source is already a vreg, do not bother
creating a new vreg and inserting a copy: just use the input vreg directly.

This speeds up the compile (e.g. about 5% on mesa with a debug build of llc)
by not adding a bunch of copies and vregs to be coallesced away.  On mesa,
for example, this reduces the number of intervals from 168601 to 129040
going into the coallescer.

llvm-svn: 23671
2005-10-09 05:58:56 +00:00
Chris Lattner
89c7fa22b1 Disable formation of rlwinm instructions from SRA bases. This fixes
the 177.mesa failure from last night, and fixes the
CodeGen/PowerPC/2005-10-08-ArithmeticRotate.ll regression test I added.
If this code cannot be fixed, it should be removed for good, but I'll leave
it to Nate to decide its fate.

llvm-svn: 23670
2005-10-09 05:36:17 +00:00
Chris Lattner
905c752559 Testcase that is miscompiled by the ppc backend
llvm-svn: 23669
2005-10-09 05:31:47 +00:00
Nate Begeman
967ce74980 Remove another unused file. Preparing for the great "enable i64 on ppc32"
merge, and using subtarget info for ptr size.

llvm-svn: 23668
2005-10-08 01:32:34 +00:00
Chris Lattner
af4f0d3647 remove a comma to compile with pedantic gcc
llvm-svn: 23667
2005-10-08 01:24:19 +00:00
Nate Begeman
af72457fc4 Remove a file that is no longer used
llvm-svn: 23666
2005-10-08 01:21:27 +00:00
Nate Begeman
2042aa5b92 Lo and behold, the last bits of SelectionDAG.cpp have been moved over.
llvm-svn: 23665
2005-10-08 00:29:44 +00:00
Chris Lattner
dae96f8881 When preselecting, favor things that have low depth to select first. This
is faster and uses less stack space.  This reduces our stack requirement
enough to compile sixtrack, and though it's a hack, should be enough until
we switch to iterative isel

llvm-svn: 23664
2005-10-07 22:10:27 +00:00
Chris Lattner
be4bbca0ba remove debugging code
llvm-svn: 23663
2005-10-07 15:31:26 +00:00
Chris Lattner
fb12624a3f implement CodeGen/PowerPC/div-2.ll:test2-4 by propagating zero bits through
C-X's

llvm-svn: 23662
2005-10-07 15:30:32 +00:00
Chris Lattner
db5d47e4dd These don't need to be sdivs.
llvm-svn: 23661
2005-10-07 15:27:12 +00:00
Chris Lattner
b27a4147d3 fix indentation
llvm-svn: 23660
2005-10-07 06:37:02 +00:00
Chris Lattner
5bcd0dd811 Turn sdivs into udivs when we can prove the sign bits are clear. This
implements CodeGen/PowerPC/div-2.ll

llvm-svn: 23659
2005-10-07 06:10:46 +00:00
Chris Lattner
437b9aa632 New testcase, should turn into a ushr
llvm-svn: 23658
2005-10-07 06:10:03 +00:00
Jeff Cohen
394f436c39 Remove prolific source of VC++ truncation warnings.
llvm-svn: 23657
2005-10-07 05:29:25 +00:00
Jeff Cohen
572910c9a2 Remove useless variable.
llvm-svn: 23656
2005-10-07 05:28:29 +00:00
Chris Lattner
20a244577d add a hack to work around broken VC++ scoping rules. Thx to JeffC for pointing
this out to me

llvm-svn: 23655
2005-10-07 05:23:36 +00:00
Chris Lattner
e373592258 Fix a CQ regression from my patch to split F32/F64 into seperate register
classes on PPC.  We were emitting fmr instructions to do fp extensions, which
weren't getting coallesced.  This fixes Regression/CodeGen/PowerPC/fpcopy.ll

llvm-svn: 23654
2005-10-07 05:00:52 +00:00
Chris Lattner
bb6211bbe8 double to float casts should nto result in an fmr
llvm-svn: 23653
2005-10-07 04:59:41 +00:00
Chris Lattner
cd8b421799 Fix CodeGen/Generic/bool-to-double.ll
llvm-svn: 23652
2005-10-07 04:50:48 +00:00
Chris Lattner
684e6cac7a test broken in the IA64 backend.
llvm-svn: 23651
2005-10-07 04:49:00 +00:00
Chris Lattner
318622fb9f Pull out Call, reducing stack frame size from 6032 bytes to 5184 bytes.
llvm-svn: 23650
2005-10-06 19:07:45 +00:00
Chris Lattner
491b8294f4 Pull out setcc, this reduces stack frame size from 7520 to 6032 bytes
llvm-svn: 23649
2005-10-06 19:03:35 +00:00
Chris Lattner
502a36935e Pull two more methods out, reducing stack frame size from 8224 -> 7520 bytes
llvm-svn: 23648
2005-10-06 18:56:10 +00:00
Chris Lattner
259e6c76f2 Add a recursive-iterative hybrid stage to attempt to reduce stack space, this
helps but not enough.

Start pulling cases out of PPC32DAGToDAGISel::Select.  With GCC 4, this function
required 8512 bytes of stack space for each invocation (GCC 3 required less
than 700 bytes).  Pulling this first function out gets us down to 8224.  More
to come :(

llvm-svn: 23647
2005-10-06 18:45:51 +00:00
Chris Lattner
7bf8d06f02 silence a bogus GCC warning
llvm-svn: 23646
2005-10-06 17:39:10 +00:00
Chris Lattner
fabe55f155 Fix the LLC regressions on X86 last night. In particular, when undoing
previous copy elisions and we discover we need to reload a register, make
sure to use the regclass of the original register for the reload, not the
class of the current register.  This avoid using 16-bit loads to reload 32-bit
values.

llvm-svn: 23645
2005-10-06 17:19:06 +00:00
Andrew Lenharth
e4c91fc9e8 This is suppose to work now
llvm-svn: 23644
2005-10-06 16:54:29 +00:00
Andrew Lenharth
332df13b9e remove VAX compatibility instruction, we will never use this
llvm-svn: 23643
2005-10-06 16:53:32 +00:00
Chris Lattner
4bbbb9eed7 Make the legalizer completely non-recursive
llvm-svn: 23642
2005-10-06 01:20:27 +00:00
Nate Begeman
558beb3729 Let the combiner handle more cases
llvm-svn: 23641
2005-10-05 21:44:43 +00:00
Nate Begeman
f8221c5e2c Remove some bad code from Legalize
llvm-svn: 23640
2005-10-05 21:44:10 +00:00
Nate Begeman
bd7df030d2 Check in some more DAGCombiner pieces
llvm-svn: 23639
2005-10-05 21:43:42 +00:00
Chris Lattner
55149d7835 Fix a bug in the local spiller, where we could take code like this:
store r12 -> [ss#2]
  R3 = load [ss#1]
  use R3
  R3 = load [ss#2]
  R4 = load [ss#1]

and turn it into this code:

  store R12 -> [ss#2]
  R3 = load [ss#1]
  use R3
  R3 = R12
  R4 = R3    <- oops!

The problem was that promoting R3 = load[ss#2] to a copy missed the fact that
the instruction invalidated R3 at that point.

llvm-svn: 23638
2005-10-05 18:30:19 +00:00
Chris Lattner
05da0d966e silence some warnings
llvm-svn: 23637
2005-10-05 17:15:09 +00:00
Chris Lattner
a49e16fefa implement visitBR_CC so that PowerPC/inverted-bool-compares.ll passes
with the dag combiner.  This speeds up espresso by 8%, reaching performance
parity with the dag-combiner-disabled llc.

llvm-svn: 23636
2005-10-05 06:47:48 +00:00
Chris Lattner
b11d15637a fix some pastos
llvm-svn: 23635
2005-10-05 06:37:22 +00:00
Chris Lattner
06f1d0f73a Add a new HandleNode class, which is used to handle (haha) cases in the
dead node elim and dag combiner passes where the root is potentially updated.
This fixes a fixme in the dag combiner.

llvm-svn: 23634
2005-10-05 06:35:28 +00:00
Chris Lattner
5fc3672722 add a helper class
llvm-svn: 23633
2005-10-05 06:34:34 +00:00
Chris Lattner
a6895d180e Implement the code for PowerPC/inverted-bool-compares.ll, even though it
that testcase still does not pass with the dag combiner.  This is because
not all forms of br* are folded yet.

Also, when we combine a node into another one, delete the node immediately
instead of waiting for the node to potentially come up in the future.

llvm-svn: 23632
2005-10-05 06:11:08 +00:00
Chris Lattner
6bd8fd09b6 make sure that -view-isel-dags is the input to the isel, not the input to
the second phase of dag combining

llvm-svn: 23631
2005-10-05 06:09:10 +00:00
Chris Lattner
746d50a01a Fix a crash compiling Olden/tsp
llvm-svn: 23630
2005-10-05 04:45:43 +00:00
Chris Lattner
bb08795695 Add some rules for building preprocessed files
llvm-svn: 23629
2005-10-05 00:28:41 +00:00
Chris Lattner
3b793c6521 refactor a bit of code.
When moving constant entries in 'Map' if the entry is the representative
constant for the abstractypemap, make sure to update it as well.  This
fixes the bcreader failures from last night on several C++ apps.

llvm-svn: 23628
2005-10-04 21:35:50 +00:00
Chris Lattner
dff59118c6 Minor speedup to avoid array searches given a Use*. This speeds up bc reading
of the python test from 1:00 to 54s.

llvm-svn: 23627
2005-10-04 18:47:09 +00:00
Chris Lattner
7a1450dbc6 Change the signature of replaceUsesOfWithOnConstant. The bool was always
true dynamically.  Finally, pass the Use* that replaceAllUsesWith has into
the method for future use.

llvm-svn: 23626
2005-10-04 18:13:04 +00:00
Chris Lattner
5188716344 Change the signature of replaceUsesOfWithOnConstant to take a Use* and not
take the bool.  The bool is always true dynamically.

llvm-svn: 23625
2005-10-04 18:12:13 +00:00
Chris Lattner
935aa922e3 For large constants (e.g. arrays and structs with many elements) just
creating the keys and doing comparisons to index into 'Map' takes a lot
of time.  For these large constants, keep an inverse map so that 'remove'
and move operations are much faster.

This speeds up a release build of the bc reader on Eric's nasty python
bytecode file from 1:39 to 1:00s.

llvm-svn: 23624
2005-10-04 17:48:46 +00:00
Chris Lattner
5bbf60a5b6 minor cleanup/fastpath for the bcreader. This speeds up the bcreader
from 1:41 -> 1:39 on the large python .bc file in a release build.

llvm-svn: 23623
2005-10-04 16:52:46 +00:00
Jim Laskey
327d4298e1 Reverting to version - until problem isolated.
llvm-svn: 23622
2005-10-04 16:41:51 +00:00
Chris Lattner
d1a5bc8dbd Add a forward def
llvm-svn: 23621
2005-10-04 05:09:20 +00:00
Nate Begeman
5da6908d65 Fix some faulty logic in the libcall inserter.
Since calls return more than one value, don't bail if one of their uses
happens to be a node that's not an MVT::Other when following the chain
from CALLSEQ_START to CALLSEQ_END.

Once we've found a CALLSEQ_START, we can just return; there's no need to
tail-recurse further up the graph.

Most importantly, just because something only has one use doesn't mean we
should use it's one use to follow from start to end.  This faulty logic
caused us to follow a chain of one-use FP operations back to a much earlier
call, putting a cycle in the graph from a later start to an earlier end.

This is a better fix that reverting to the workaround committed earlier
today.

llvm-svn: 23620
2005-10-04 02:10:55 +00:00
Chris Lattner
8760ec73d8 implement the struct version of the array speedup, speeding up the
testcase a bit more from 1:48 -> 1.40.

llvm-svn: 23619
2005-10-04 01:17:50 +00:00
Chris Lattner
20b0754c41 Fix DemoteRegToStack on an invoke. This fixes PR634.
llvm-svn: 23618
2005-10-04 00:44:01 +00:00
Nate Begeman
54fb5002e5 Add back a workaround that fixes some breakages from chris's last change.
Neither of us have yet figured out why this code is necessary, but stuff
breaks if its not there.  Still tracking this down...

llvm-svn: 23617
2005-10-04 00:37:37 +00:00
Chris Lattner
4c3b2b536c Clean up the code a bit. Use isInstructionTriviallyDead to be more aggressive
and more correct than use_empty().  This fixes PR635 and
SimplifyCFG/2005-10-02-InvokeSimplify.ll

llvm-svn: 23616
2005-10-03 23:43:43 +00:00
Chris Lattner
a6e98f2e85 new testcase for PR635
llvm-svn: 23615
2005-10-03 23:42:54 +00:00
Chris Lattner
b64419ac40 Change ConstantArray::replaceUsesOfWithOnConstant to attempt to update
constant arrays in place instead of reallocating them and replaceAllUsesOf'ing
the result.  This speeds up a release build of the bcreader from:

136.987u 120.866s 4:24.38
to
49.790u 49.890s 1:40.14

... a 2.6x speedup parsing a large python bc file.

llvm-svn: 23614
2005-10-03 22:51:37 +00:00
Chris Lattner
c4062ba65f move some methods, no other changes
llvm-svn: 23613
2005-10-03 21:58:36 +00:00
Chris Lattner
0144fadc17 minor microoptimizations
llvm-svn: 23612
2005-10-03 21:56:24 +00:00
Chris Lattner
bad09e71d0 Use a map to cache the ModuleType information, so we can do logarithmic
lookups instead of linear time lookups.  This speeds up bc parsing of a
large file from

137.834u 118.256s 4:27.96
to
132.611u 114.436s 4:08.53

with a release build.

llvm-svn: 23611
2005-10-03 21:26:53 +00:00
Jim Laskey
409a6b204e Refactor gathering node info and emission.
llvm-svn: 23610
2005-10-03 12:30:32 +00:00
Chris Lattner
57b21f9f10 clean up this code a bit, no functionality change
llvm-svn: 23609
2005-10-03 07:22:07 +00:00
Chris Lattner
afef68baff Speed up the asm printer a lot by not printing formatted LLVM asm output
for globals

llvm-svn: 23608
2005-10-03 07:08:36 +00:00
Chris Lattner
5f096e2847 Break the body of the loop out into a new method
llvm-svn: 23606
2005-10-03 04:47:08 +00:00
Chris Lattner
1687459559 Fix case of path
llvm-svn: 23605
2005-10-03 03:32:39 +00:00
Chris Lattner
f07a587c79 Make IVUseShouldUsePostIncValue more aggressive when the use is a PHI. In
particular, it should realize that phi's use their values in the pred block
not the phi block itself.  This change turns our em3d loop from this:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r2, 0
        b LBB_test_6    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        or r2, r6, r6
        lwz r6, 0(r3)
        cmpw cr0, r6, r5
        beq cr0, LBB_test_6     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r2, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; endif.loopexit.loopexit_crit_edge
        addi r3, r2, 1
        blr
LBB_test_6:     ; loopexit
        or r3, r2, r2
        blr

into:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r2, 0
        b LBB_test_5    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        lwz r2, 0(r3)
        cmpw cr0, r2, r5
        or r2, r6, r6
        beq cr0, LBB_test_5     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r6, 1
        cmpw cr0, r6, r4
        or r2, r6, r6
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; loopexit
        or r3, r2, r2
        blr


Unfortunately, this is actually worse code, because the register coallescer
is getting confused somehow.  If it were doing its job right, it could turn the
code into this:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r6, 0
        b LBB_test_5    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        lwz r2, 0(r3)
        cmpw cr0, r2, r5
        beq cr0, LBB_test_5     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r6, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; loopexit
        or r3, r6, r6
        blr

... which I'll work on next. :)

llvm-svn: 23604
2005-10-03 02:50:05 +00:00
Chris Lattner
e4ed42a426 Refactor some code into a function
llvm-svn: 23603
2005-10-03 01:04:44 +00:00
Chris Lattner
360928dbed This break is bogus and I have no idea why it was there. Basically it prevents
memoizing code when IV's are used by phinodes outside of loops.  In a simple
example, we were getting this code before (note that r6 and r7 are isomorphic
IV's):

        li r6, 0
        or r7, r6, r6
LBB_test_3:     ; no_exit
        lwz r2, 0(r3)
        cmpw cr0, r2, r5
        or r2, r7, r7
        beq cr0, LBB_test_5     ; loopexit
LBB_test_4:     ; endif
        addi r2, r7, 1
        addi r7, r7, 1
        addi r3, r3, 4
        addi r6, r6, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit

Now we get:

        li r6, 0
LBB_test_3:     ; no_exit
        or r2, r6, r6
        lwz r6, 0(r3)
        cmpw cr0, r6, r5
        beq cr0, LBB_test_6     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r2, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit

this was noticed in em3d.

llvm-svn: 23602
2005-10-03 00:37:33 +00:00
Chris Lattner
8fcce170cf when checking if we should move a split edge block outside of a loop,
check the presplit pred, not the post-split pred.  This was causing us
to make the wrong decision in some cases, leaving the critical edge block
in the loop.

llvm-svn: 23601
2005-10-03 00:31:52 +00:00
Chris Lattner
77676d5bc2 This member can be const too
llvm-svn: 23600
2005-10-03 00:21:25 +00:00
Chris Lattner
e51d6a9f70 put the right labels on the data
llvm-svn: 23599
2005-10-02 21:51:38 +00:00
Chris Lattner
9cfccfb517 Fix a problem where the legalizer would run out of stack space on extremely
large basic blocks because it was purely recursive.  This switches it to an
iterative/recursive hybrid.

llvm-svn: 23596
2005-10-02 17:49:46 +00:00
Chris Lattner
7f718e61e8 silence a bogus warning
llvm-svn: 23595
2005-10-02 16:30:51 +00:00
Chris Lattner
9982da2703 silence some warnings
llvm-svn: 23594
2005-10-02 16:29:36 +00:00
Chris Lattner
c0e655b65d silence a warning
llvm-svn: 23593
2005-10-02 16:27:59 +00:00
Chris Lattner
68303a78ff add patterns for float binops and fma ops
llvm-svn: 23592
2005-10-02 07:46:28 +00:00
Chris Lattner
98da1d9910 Sort the cpu and features table, so that the alpha backend doesn't fail EVERY
compile with an assertion that the tables are not sorted!

llvm-svn: 23591
2005-10-02 07:13:52 +00:00
Chris Lattner
704d97f8b2 Add assertions to the trivial scheduler to check that the value types match
up between defs and uses.

llvm-svn: 23590
2005-10-02 07:10:55 +00:00
Chris Lattner
3734d204b8 another solution to the fsel issue. Instead of having 4 variants, just force
the comparison to be 64-bits.  This is fine because extensions from float
to double are free.

llvm-svn: 23589
2005-10-02 07:07:49 +00:00
Chris Lattner
9e98672962 fsel can take a different FP type for the comparison and for the result. As such
split the FSEL family into 4 things instead of just two.

llvm-svn: 23588
2005-10-02 06:58:23 +00:00
Chris Lattner
a17e6c486c fix an f32/f64 type mismatch
llvm-svn: 23587
2005-10-02 06:37:13 +00:00
Chris Lattner
a038d901fb Codegen CopyFromReg using the regclass that matches the valuetype of the
destination vreg.

llvm-svn: 23586
2005-10-02 06:34:16 +00:00
Chris Lattner
4155ae0f74 Adjust to change in ctor
llvm-svn: 23585
2005-10-02 06:23:51 +00:00
Chris Lattner
d4ff3c1324 Emit the value type for each register class.
llvm-svn: 23584
2005-10-02 06:23:37 +00:00
Chris Lattner
0bc697eae7 Expose the actual valuetype of each register class
llvm-svn: 23583
2005-10-02 06:23:19 +00:00
Chris Lattner
5ab9d42bb4 Minor tweak to the branch selector. When emitting a two-way branch, and if
we're in a single-mbb loop, make sure to emit the backwards branch as the
conditional branch instead of the uncond branch.  For example, emit this:

LBBl29_z__44:
        stw r9, 0(r15)
        stw r9, 4(r15)
        stw r9, 8(r15)
        stw r9, 12(r15)
        addi r15, r15, 16
        addi r8, r8, 1
        cmpw cr0, r8, r28
        ble cr0, LBBl29_z__44
        b LBBl29_z__48                   *** NOT PART OF LOOP

Instead of:

LBBl29_z__44:
        stw r9, 0(r15)
        stw r9, 4(r15)
        stw r9, 8(r15)
        stw r9, 12(r15)
        addi r15, r15, 16
        addi r8, r8, 1
        cmpw cr0, r8, r28
        bgt cr0, LBBl29_z__48            *** PART OF LOOP!
        b LBBl29_z__44

The former sequence has one fewer dispatch group for the loop body.

llvm-svn: 23582
2005-10-01 23:06:26 +00:00
Chris Lattner
6f4dc51d6f like the comment says, enable this
llvm-svn: 23581
2005-10-01 23:02:40 +00:00
Chris Lattner
5a7bfe0b72 Add some very paranoid checking for operand/result reg class matchup
For instructions that define multiple results, use the right regclass
to define the result, not always the rc of result #0

llvm-svn: 23580
2005-10-01 07:45:09 +00:00
Jeff Cohen
f8a5e5ae6e Fix VC++ warnings.
llvm-svn: 23579
2005-10-01 03:57:14 +00:00
Chris Lattner
8713ebf37c fix typo
llvm-svn: 23578
2005-10-01 02:51:36 +00:00
Chris Lattner
d3eee1a09b Modify the ppc backend to use two register classes for FP: F8RC and F4RC.
These are used to represent float and double values, and the two regclasses
contain the same physical registers.

llvm-svn: 23577
2005-10-01 01:35:02 +00:00
Chris Lattner
afdc9d25db Annotate nodes with their addresses if a graph requests it.
This is Jim's feature implemented so that graphs could 'opt-in' and get
this behavior.  This is currently used by selection dags.

llvm-svn: 23576
2005-10-01 00:19:21 +00:00
Chris Lattner
fda6944c5b add a method
llvm-svn: 23575
2005-10-01 00:17:07 +00:00
Jim Laskey
d3850457a1 typo
llvm-svn: 23574
2005-10-01 00:08:23 +00:00
Jim Laskey
9d96932879 1. Simplify the gathering of node groups.
2. Printing node groups when displaying nodes.

llvm-svn: 23573
2005-10-01 00:03:07 +00:00
Jim Laskey
f61232354f Should be using flag and not chain.
llvm-svn: 23572
2005-09-30 23:43:37 +00:00
Nate Begeman
fbfad0b565 Remove some now-dead code.
llvm-svn: 23571
2005-09-30 21:28:27 +00:00
Andrew Lenharth
5b8bd94ab2 more specific tests of subtarget stuff
llvm-svn: 23570
2005-09-30 20:30:24 +00:00
Andrew Lenharth
49e48f6234 subtarget support for CIX and FIX extentions (the only 2 I care about right now)
llvm-svn: 23569
2005-09-30 20:24:38 +00:00
Jim Laskey
90b34c1865 Reverting change moving to selection dag graph.
llvm-svn: 23568
2005-09-30 19:33:41 +00:00
Jim Laskey
3059965a4b Added allnodes_size for scheduling support.
llvm-svn: 23567
2005-09-30 19:27:01 +00:00
Jim Laskey
3fe3841c2a 1. Made things node-centric (from operand).
2. Added node groups to handle flagged nodes.

3. Started weaning simple scheduling off existing emitter.

llvm-svn: 23566
2005-09-30 19:15:27 +00:00
Jim Laskey
fe59ae2b11 Add the node name (thus the address) to node label.
llvm-svn: 23565
2005-09-30 19:11:53 +00:00
Chris Lattner
c9f4219cfc Rename MRegisterDesc -> TargetRegisterDesc for consistency
llvm-svn: 23564
2005-09-30 17:49:27 +00:00
Chris Lattner
57b8ae71e0 Update the discussion of TargetRegisterDesc
llvm-svn: 23563
2005-09-30 17:46:55 +00:00
Chris Lattner
3e020bb619 remove some more initializers
llvm-svn: 23562
2005-09-30 17:41:05 +00:00
Chris Lattner
81f32a2acb trim down the target info structs now that we have a preferred spill register class for each callee save register
Why is V9 maintaining these tables manually? ugh!

llvm-svn: 23561
2005-09-30 17:38:36 +00:00
Chris Lattner
ddc69bbbba trim down the target info structs now that we have a preferred spill register class for each callee save register
llvm-svn: 23560
2005-09-30 17:35:22 +00:00
Chris Lattner
2e794c9198 now that we have a reg class to spill with, get this info from the regclass
llvm-svn: 23559
2005-09-30 17:19:22 +00:00
Chris Lattner
88025e17c5 constant fold these calls
llvm-svn: 23558
2005-09-30 17:16:59 +00:00
Chris Lattner
bb1c9ecb17 simplify this code using the new regclass info passed in
llvm-svn: 23557
2005-09-30 17:12:38 +00:00
Chris Lattner
51878189c5 Now that we have getCalleeSaveRegClasses() info, use it to pass the register
class into the spill/reload methods.  Targets can now rely on that argument.

llvm-svn: 23556
2005-09-30 16:59:07 +00:00
Chris Lattner
fbc60722b9 expose a new virtual method
llvm-svn: 23555
2005-09-30 07:06:37 +00:00
Chris Lattner
8688b92b86 stub out a virtual method
llvm-svn: 23554
2005-09-30 06:55:18 +00:00
Chris Lattner
da6fcc9f49 Compute a preferred spill register class for each callee-save register
llvm-svn: 23553
2005-09-30 06:44:45 +00:00
Chris Lattner
4984e99b83 CR registers are not used by this "target"
llvm-svn: 23552
2005-09-30 06:43:58 +00:00
Chris Lattner
6169a78f46 these registers don't belong to any register classes, so don't mark them
as callee save.  They can never be generated by the compiler.

llvm-svn: 23551
2005-09-30 06:42:24 +00:00
Chris Lattner
26f5fb1277 Fix a warning
llvm-svn: 23550
2005-09-30 06:09:50 +00:00
Chris Lattner
1916ef75cf Regenerate
llvm-svn: 23549
2005-09-30 04:53:25 +00:00
Chris Lattner
b509577605 Refactor this a bit to move ParsingTemplateArgs to only apply to classes,
not defs.

Implement support for forward definitions of classes.  This implements
TableGen/ForwardRef.td.

llvm-svn: 23548
2005-09-30 04:53:04 +00:00
Chris Lattner
41815f2aa2 Add a test that you can forward ref a class.
llvm-svn: 23547
2005-09-30 04:52:43 +00:00
Chris Lattner
20b0e3cee4 Regenerate
llvm-svn: 23546
2005-09-30 04:42:56 +00:00
Chris Lattner
ad61925e27 Generate a parse error instead of a checked exception if template args are
used on a def.

llvm-svn: 23545
2005-09-30 04:42:31 +00:00
Chris Lattner
33ce5f8a73 Now that self referential classes are supported, get rid of a work-around.
llvm-svn: 23544
2005-09-30 04:13:23 +00:00
Chris Lattner
6e60c8fe05 regenerate
llvm-svn: 23543
2005-09-30 04:11:27 +00:00
Chris Lattner
e04e1384fc Refactor the grammar a bit to implement TableGen/ForwardRef.td
llvm-svn: 23542
2005-09-30 04:10:49 +00:00
Chris Lattner
08321aa8cb Check that we can refer to the same class we are defining.
llvm-svn: 23541
2005-09-30 04:10:17 +00:00
Chris Lattner
2a6fd61dfc allow regs to be in multiple reg classes
llvm-svn: 23540
2005-09-30 01:33:48 +00:00
Chris Lattner
f6d4173f75 pass extra args
llvm-svn: 23539
2005-09-30 01:31:52 +00:00
Chris Lattner
64ca7cda3f these methods get extra args
llvm-svn: 23538
2005-09-30 01:30:55 +00:00
Chris Lattner
a654525c1c Pass extra regclasses into spilling code
llvm-svn: 23537
2005-09-30 01:29:42 +00:00
Chris Lattner
5a6199f387 Change this code ot pass register classes into the stack slot spiller/reloader
code.  PrologEpilogInserter hasn't been updated yet though, so targets cannot
use this info.

llvm-svn: 23536
2005-09-30 01:29:00 +00:00
Chris Lattner
b7d89db484 Change these methods to take RC's
llvm-svn: 23535
2005-09-30 01:28:14 +00:00
Chris Lattner
08f157c5b2 Use the 32-bit version for now
llvm-svn: 23534
2005-09-30 00:05:05 +00:00
Chris Lattner
027a2671ef Add a bunch of patterns for F64 FP ops, add some more integer ops
llvm-svn: 23533
2005-09-29 23:34:24 +00:00
Chris Lattner
1de5706e68 Remove code for patterns that are autogenerated
llvm-svn: 23532
2005-09-29 23:33:31 +00:00
Andrew Lenharth
a7a83b9255 begining alpha subtarget support
llvm-svn: 23531
2005-09-29 22:54:56 +00:00
Chris Lattner
0a1cd715d4 tblgen autogens this pattern now
llvm-svn: 23530
2005-09-29 22:37:24 +00:00
Chris Lattner
366fe04301 Teach tablegen to reassociate operators when possible. This allows it to
find all of teh pattern matches for EQV from one definition

llvm-svn: 23529
2005-09-29 22:36:54 +00:00
Andrew Lenharth
bae1f9d790 copy and paste error
llvm-svn: 23528
2005-09-29 21:11:57 +00:00
Chris Lattner
a748e3ae5b now that tblgen is smarter, this pattern is not needed. Also, tblgen
now inverts commuted versions of ANDC/ORC with the current .td file.

llvm-svn: 23527
2005-09-29 19:29:15 +00:00
Chris Lattner
e86824e57a Teach tblgen to build permutations of instructions, so that the target author
doesn't have to specify them manually.  It currently handles associativity,
e.g. knowing that (X*Y)+Z  also matches  X+(Y*Z)  and will be extended in
the future.

It is smart enough to not introduce duplicate patterns or patterns that can
never match.

llvm-svn: 23526
2005-09-29 19:28:10 +00:00
Chris Lattner
a554c9470b Insert stores after phi nodes in the normal dest. This fixes
LowerInvoke/2005-08-03-InvokeWithPHI.ll

llvm-svn: 23525
2005-09-29 17:44:20 +00:00
Chris Lattner
02d3ba3db8 consistency with other cases, no functionality change
llvm-svn: 23524
2005-09-29 17:38:52 +00:00
Chris Lattner
eca4f56646 Make the JIT default to the DAG isel instead of the pattern isel, like LLC.
The Pattern isel has some strange memory corruption issues going on. :(

This should have been converted over anyway, but it got forgotten somehow
when switching to the dag isel.

llvm-svn: 23523
2005-09-29 17:31:03 +00:00
Chris Lattner
5b2be1f890 Fix two bugs in my patch earlier today that broke int->fp conversion on X86.
llvm-svn: 23522
2005-09-29 06:44:39 +00:00
Chris Lattner
87ef943a4c Fold isascii into a simple comparison. This speeds up 197.parser by 7.4%,
bringing the LLC time down to the CBE time.

llvm-svn: 23521
2005-09-29 06:17:27 +00:00
Chris Lattner
5de939e791 new testcase for isascii
llvm-svn: 23520
2005-09-29 06:16:37 +00:00
Chris Lattner
5f6035feb0 remove a bunch of unneeded stuff, or self evident comments
llvm-svn: 23519
2005-09-29 06:16:11 +00:00
Chris Lattner
e94e6a9e62 add a new testcase
llvm-svn: 23518
2005-09-29 06:11:34 +00:00
Chris Lattner
c244e7c178 Implement a couple of memcmp folds from the todo list
llvm-svn: 23517
2005-09-29 04:54:20 +00:00
Jeff Cohen
b01a41a06d Silence VC++ redeclaration warnings.
llvm-svn: 23516
2005-09-29 01:59:49 +00:00
Chris Lattner
08c319fbdd Never rely on ReplaceAllUsesWith when selecting, use CodeGenMap instead.
ReplaceAllUsesWith does not replace scalars SDOperand floating around on
the stack, permitting things to be selected multiple times.

llvm-svn: 23515
2005-09-29 00:59:32 +00:00
Chris Lattner
d4e9e8b7ec Codegen ADD X, IMM -> addis/addi if needed.
This implements PowerPC/fold-li.ll

llvm-svn: 23514
2005-09-28 23:07:13 +00:00
Chris Lattner
a22f7a2e16 add a testcase for a feature we regressed on because noone wrote the test! :(
llvm-svn: 23513
2005-09-28 23:03:11 +00:00
Chris Lattner
b9b2e77295 Autogen MUL, move FP cases together
llvm-svn: 23512
2005-09-28 22:53:16 +00:00
Chris Lattner
5769311c92 disentangle FP from INT versions of div/mul
llvm-svn: 23511
2005-09-28 22:50:24 +00:00
Chris Lattner
585131baaf Use the autogenerated matcher for ADD/SUB
llvm-svn: 23510
2005-09-28 22:47:28 +00:00
Chris Lattner
f023b2cda2 add a patter for SUBFIC
llvm-svn: 23509
2005-09-28 22:47:06 +00:00
Chris Lattner
21551ea5ab Mark int binops as int-only, add FP binops. Mark FADD/FMUL as commutative but
not associative.  Add [SU]REM.

llvm-svn: 23508
2005-09-28 22:38:27 +00:00
Chris Lattner
cd002b2461 wrap a long line
llvm-svn: 23507
2005-09-28 22:30:58 +00:00
Chris Lattner
d3ea19b51a Add FP versions of the binary operators, keeping the int and fp worlds seperate.
llvm-svn: 23506
2005-09-28 22:29:58 +00:00
Chris Lattner
0815dcae3f Add FP versions of the binary operators, keeping the int and fp worlds seperate.
Though I have done extensive testing, it is possible that this will break
things in configs I can't test.  Please let me know if this causes a problem
and I'll fix it ASAP.

llvm-svn: 23505
2005-09-28 22:29:17 +00:00
Chris Lattner
6f3b577ee6 Add FP versions of the binary operators, keeping the int and fp worlds seperate.
Though I have done extensive testing, it is possible that this will break
things in configs I can't test.  Please let me know if this causes a problem
and I'll fix it ASAP.

llvm-svn: 23504
2005-09-28 22:28:18 +00:00
Chris Lattner
7fe6734dff Mark associative nodes as associative
llvm-svn: 23503
2005-09-28 20:58:39 +00:00
Chris Lattner
492e70f4ec add support for an associative marker
llvm-svn: 23502
2005-09-28 20:58:06 +00:00
Chris Lattner
8bb25cd68a Emit an error if instructions or patterns are defined but can never match.
Currently we check that immediate values live on the RHS of commutative
operators.  Defining ORI like this, for example:

def ORI   : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
                    "ori $dst, $src1, $src2",
                    [(set GPRC:$dst, (or immZExt16:$src2, GPRC:$src1))]>;

results in:

tblgen: In ORI: Instruction can never match: Immediate values must be on the RHS of commutative operators!
llvm-svn: 23501
2005-09-28 19:27:25 +00:00
Chris Lattner
b97b054ba7 Nate pointed out that mulh[us] are commutative as well. Thanks!
llvm-svn: 23500
2005-09-28 19:01:44 +00:00
Chris Lattner
f74c30c281 collect commutativity information
llvm-svn: 23499
2005-09-28 18:28:29 +00:00
Chris Lattner
89d168ceb3 expose commutativity information
llvm-svn: 23498
2005-09-28 18:27:58 +00:00
Chris Lattner
fab48b3285 All (xor *) cases are autogenerated now
llvm-svn: 23497
2005-09-28 18:12:37 +00:00
Chris Lattner
037d69a404 add support for missed eqv tests
llvm-svn: 23496
2005-09-28 18:10:51 +00:00
Chris Lattner
afc5ba4f3a add testcase for nand
llvm-svn: 23495
2005-09-28 18:08:58 +00:00
Chris Lattner
33f8e08c8f Implement PowerPC/eqv-andc-orc-nor.ll:EQV3
llvm-svn: 23494
2005-09-28 18:04:52 +00:00
Chris Lattner
380fd4a413 Consolidate the eqv.ll and nor.ll files together.
Add a missed eqv case.

llvm-svn: 23493
2005-09-28 18:04:22 +00:00
Chris Lattner
3622f15491 Prefer cheaper patterns to more expensive ones. Print the costs to the generated
file

llvm-svn: 23492
2005-09-28 17:57:56 +00:00
Chris Lattner
e2b772b0ae simple tests for nor generation
llvm-svn: 23491
2005-09-28 17:55:10 +00:00
Chris Lattner
8cd7b88a88 learn to codegen not as NOR instead of xoris/xori
llvm-svn: 23490
2005-09-28 17:13:15 +00:00
Chris Lattner
bb5939a436 These nodes are all autogenerated
llvm-svn: 23489
2005-09-28 17:07:09 +00:00
Chris Lattner
75b4c5d868 Select Constant nodes to TargetConstant nodes
llvm-svn: 23488
2005-09-28 16:58:06 +00:00
Chris Lattner
ea7214b23d Constant fold llvm.sqrt
llvm-svn: 23487
2005-09-28 01:34:32 +00:00
Chris Lattner
3b63bb375c add a note about a way to improve this code further, that I won't be getting
to right now.

llvm-svn: 23485
2005-09-27 22:44:59 +00:00
Chris Lattner
eb953f0ef8 Fix a regression in my previous patch, fixing GlobalOpt/2005-09-27-Crash.ll
and PR632.

llvm-svn: 23484
2005-09-27 22:28:11 +00:00
Chris Lattner
b1fb4da271 Testcase for PR632
llvm-svn: 23483
2005-09-27 22:27:19 +00:00
Chris Lattner
a028e7a39c Darwin, like many BSD systems, has a setjmp/longjmp which saves the signal mask
on setjmp calls and restores it on longjmp calls (both of which require syscalls).

This makes the calls REALLY slow.  Use _setjmp/_longjmp instead.  This speeds up
hexxagon from 120.31s to 15.68s: from 5.53x slower than GCC to 28% faster than GCC.

llvm-svn: 23482
2005-09-27 22:18:25 +00:00
Chris Lattner
0fd8f9fbc9 If the target prefers it, use _setjmp/_longjmp should be used instead of setjmp/longjmp for llvm.setjmp/llvm.longjmp.
llvm-svn: 23481
2005-09-27 22:15:53 +00:00
Chris Lattner
59dc1e082c initialize new flag
llvm-svn: 23480
2005-09-27 22:13:56 +00:00
Chris Lattner
a458a2e472 Add a new flag for targets where setjmp/longjmp saves/restores the signal mask,
and _setjmp/_longjmp should be used instead (for llvm.setjmp/llvm.longjmp).

llvm-svn: 23479
2005-09-27 22:13:36 +00:00
Chris Lattner
e285f5ed8f Avoid spilling stack slots... to stack slots.
llvm-svn: 23478
2005-09-27 21:33:12 +00:00
Chris Lattner
87eb249300 Completely rewrite 'correct' eh support. This changes how setjmp insertion
is performed so it is only at most once per function that contains an invoke
instead of once per invoke in the function.  This patch has the following perks:

1. It fixes PR631, which complains about slowness.
2. If fixes PR240, which complains about non-volatile vars being live across
   setjmp/longjmps.
3. It improves (but does not fix) the jmpbuf alignment issue on itanium by not
   forcing the jmpbufs to always be 8-bytes off the alignment of the structure.
4. It speeds up 253.perlbmk from 338s to 13.70s (a 25x improvement!), making us
   now about 4% faster than GCC.

Further improvements are also possible.

llvm-svn: 23477
2005-09-27 21:18:17 +00:00
Chris Lattner
92233d2175 Make the pass name simpler
llvm-svn: 23476
2005-09-27 21:10:32 +00:00
Chris Lattner
5635cc069f fix CBackend/2005-09-27-VolatileFuncPtr.ll
llvm-svn: 23475
2005-09-27 20:52:44 +00:00
Chris Lattner
e338f05ba6 new testcase the CBE creates invalid C code for
llvm-svn: 23474
2005-09-27 20:52:30 +00:00
Chris Lattner
16cd356fb2 allow demotion to volatile values, add support for invoke
llvm-svn: 23473
2005-09-27 19:39:00 +00:00
Chris Lattner
cce0355fc0 allow demotion to volatile values
llvm-svn: 23472
2005-09-27 19:38:43 +00:00
Chris Lattner
6f726d2c1a Add a simple testcase for lowerinvoke
llvm-svn: 23471
2005-09-27 18:34:31 +00:00
Chris Lattner
c628f00845 Make sure to clear the CodeGenMap after each basic block is selected to avoid
cross MBB pollution.

llvm-svn: 23470
2005-09-27 17:45:33 +00:00
Jim Laskey
63523f98d5 Remove some redundancies.
llvm-svn: 23469
2005-09-27 17:32:45 +00:00
Chris Lattner
57432e717e Make this slightly more efficient by pushing actual type information down
into the evaluator.  This shrinks a release build of instcombine's text
section from 216363 to 215975 bytes (on PPC).

llvm-svn: 23468
2005-09-27 06:38:05 +00:00
Chris Lattner
e7e139e8e8 Split SimpleConstantVal up into its components, so each Constant subclass getsa different enum value. This allows 'classof' for these to be really simple,not needing to call getType() anymore.
This speeds up isa/dyncast/etc for constants, and also makes them smaller.
For example, the text section of a release build of InstCombine.cpp shrinks
from 230037 bytes to 216363 bytes, a 6% reduction.

llvm-svn: 23467
2005-09-27 06:09:08 +00:00
Chris Lattner
555fb9c984 Split SimpleConstantVal up into its components, so each Constant subclass gets
a different enum value.  This allows 'classof' for these to be really simple,
not needing to call getType() anymore.

This speeds up isa/dyncast/etc for constants, and also makes them smaller.
For example, the text section of a release build of InstCombine.cpp shrinks
from 230037 bytes to 216363 bytes, a 6% reduction.

llvm-svn: 23466
2005-09-27 06:08:32 +00:00
Chris Lattner
3d27e7f27f Add support for external calls that we know how to constant fold. This implements
ctor-list-opt.ll:CTOR8

llvm-svn: 23465
2005-09-27 05:02:43 +00:00
Chris Lattner
1f1fd227fb add a new testcase for constant foldable calls
llvm-svn: 23464
2005-09-27 05:02:03 +00:00
Chris Lattner
29b2780c8a Fix a bug where we would evaluate stores into linkonce objects which could be
potentially replaced at link-time.

llvm-svn: 23463
2005-09-27 04:50:03 +00:00
Chris Lattner
65a3a0918f Implement support for static constructors with calls in them. This is useful
because gccas runs globalopt before inlining.

This implements ctor-list-opt.ll:CTOR7

llvm-svn: 23462
2005-09-27 04:45:34 +00:00
Chris Lattner
3803cbb196 Add a more difficult testcase which uses a call to a helper function to do
the initialization

llvm-svn: 23461
2005-09-27 04:44:04 +00:00
Chris Lattner
da1889b778 Refactor this code a bit, no functionality changes.
llvm-svn: 23460
2005-09-27 04:27:01 +00:00
Chris Lattner
54ec5f2089 Move the post-lsr simplify cfg pass after lowereh, so it can clean up after
eh lowering as well.

llvm-svn: 23459
2005-09-27 00:14:41 +00:00
Chris Lattner
4435b149a0 minor pattern shuffling
llvm-svn: 23458
2005-09-26 22:20:16 +00:00
Chris Lattner
d455c36c91 memoize the assert results
llvm-svn: 23457
2005-09-26 22:10:24 +00:00
Chris Lattner
c9153266c6 Emit the switch stmt cases in alphabetical order instead of pointer order,
which is not stable.

llvm-svn: 23456
2005-09-26 21:59:35 +00:00
Jim Laskey
5f2443c8a3 Addition of a simple two pass scheduler. This version is currently hacked up
for testing and will require target machine info to do a proper scheduling.
The simple scheduler can be turned on using -sched=simple (defaults
to -sched=none)

llvm-svn: 23455
2005-09-26 21:57:04 +00:00
Chris Lattner
d5de8544f8 implement a fixme: only select values once, even if used multiple times.
llvm-svn: 23454
2005-09-26 21:53:26 +00:00
Chris Lattner
f2f89af69a Remove some dead code. ctor evaluation subsumes empty ctor elim
llvm-svn: 23453
2005-09-26 20:38:20 +00:00
Chris Lattner
6bf2cd5735 Add support for alloca, implementing ctor-list-opt.ll:CTOR6
llvm-svn: 23452
2005-09-26 17:07:09 +00:00
Chris Lattner
46eeed89e5 Testcase that uses an alloca
llvm-svn: 23451
2005-09-26 17:06:32 +00:00
Chris Lattner
46d9ff081d Add a debug printout, fix a crash on kc++
llvm-svn: 23450
2005-09-26 07:34:35 +00:00
Chris Lattner
46af55e0e4 Implement loads/stores through GEP's of globals. This implements
ctor-list-opt.ll:CTOR5.

llvm-svn: 23449
2005-09-26 06:52:44 +00:00
Chris Lattner
636fa212b9 add another case, this one that uses getelementptr instructions
llvm-svn: 23448
2005-09-26 06:51:50 +00:00
Chris Lattner
61ff32cd70 Replace TraverseGEPInitializer with ConstantFoldLoadThroughGEPConstantExpr
llvm-svn: 23447
2005-09-26 05:34:07 +00:00
Chris Lattner
02ae21e1e0 Eliminate GetGEPGlobalInitializer in favor of the more powerful
ConstantFoldLoadThroughGEPConstantExpr function in the utils lib.

llvm-svn: 23446
2005-09-26 05:28:52 +00:00
Chris Lattner
0b011ec8e2 Factor the GetGEPGlobalInitializer out of this pass and into Transforms/Utils
as ConstantFoldLoadThroughGEPConstantExpr.

llvm-svn: 23445
2005-09-26 05:28:06 +00:00
Chris Lattner
c13c7b9376 Move the ConstantFoldLoadThroughGEPConstantExpr function out of the InstCombine
pass.

llvm-svn: 23444
2005-09-26 05:27:10 +00:00
Chris Lattner
348a39982e add a new function
llvm-svn: 23443
2005-09-26 05:26:32 +00:00
Chris Lattner
b009663e27 add a comment
llvm-svn: 23442
2005-09-26 05:16:34 +00:00
Chris Lattner
4b05c322d5 Add support for getelementptr, load, and correctly reject volatile stores.
llvm-svn: 23441
2005-09-26 05:15:37 +00:00
Chris Lattner
05035fe970 add a test for load
llvm-svn: 23440
2005-09-26 05:14:48 +00:00
Chris Lattner
3e9ea5ffec Add support for br/brcond/switch and phi
llvm-svn: 23439
2005-09-26 04:57:38 +00:00
Chris Lattner
543efbb71f add another testcase with simple control flow
llvm-svn: 23438
2005-09-26 04:57:10 +00:00
Chris Lattner
99e23fa74c Add a simple interpreter to this code, allowing us to statically evaluate
global ctors that are simple enough.  This implements ctor-list-opt.ll:CTOR2.

llvm-svn: 23437
2005-09-26 04:44:35 +00:00
Chris Lattner
6debcf3071 make this harder: put some code into it
llvm-svn: 23436
2005-09-26 04:43:01 +00:00
Chris Lattner
696beefabb factor some code into a InstallGlobalCtors method, add comments. No functionality change.
llvm-svn: 23435
2005-09-26 02:31:18 +00:00
Chris Lattner
838bdc1836 Make the global opt optimizer work on modules with a null terminator, by
accepting the null even with a non-65535 init prio

llvm-svn: 23434
2005-09-26 02:19:27 +00:00
Chris Lattner
41b6a5a693 Factor this code out into a few methods.
Implement the start of global ctor optimization.  It is currently smart
enough to remove the global ctor for cases like this:

struct foo {
  foo() {}
} x;

... saving a bit of startup time for the program.

llvm-svn: 23433
2005-09-26 01:43:45 +00:00
Chris Lattner
9db3c91a51 new testcase for static ctor list optimizations
llvm-svn: 23432
2005-09-26 01:42:03 +00:00
Jeff Cohen
23b1d28e69 Fix VC++ build errors.
llvm-svn: 23431
2005-09-25 19:04:43 +00:00
Chris Lattner
f487768062 Fix some logic I broke that caused a regression on
SimplifyLibCalls/2005-05-20-sprintf-crash.ll

llvm-svn: 23430
2005-09-25 07:06:48 +00:00
Chris Lattner
0b3557f54a Move MaskedValueIsZero up.
Match a bunch of idioms for sign extensions, implementing InstCombine/signext.ll

llvm-svn: 23428
2005-09-24 23:43:33 +00:00
Chris Lattner
04d4a725ca All of these should turn into sign extends (e.g. extsh/extsb on PPC)
llvm-svn: 23427
2005-09-24 23:42:18 +00:00
Chris Lattner
699c80eebe Add long-overdue helpers for getting constants with known upper bits
llvm-svn: 23426
2005-09-24 22:57:28 +00:00
Chris Lattner
175463a165 Simplify this code a bit by relying on recursive simplification. Support
sprintf("%s", P)'s that have uses.

s/hasNUses(0)/use_empty()/

llvm-svn: 23425
2005-09-24 22:17:06 +00:00
Chris Lattner
906d705644 Enhance this to check for a crash, add a case that crashes simplifylibcalls,
and add a case that has uses.

llvm-svn: 23424
2005-09-24 22:16:04 +00:00
Chris Lattner
379dea1999 new testcase that crashes the CFE
llvm-svn: 23423
2005-09-24 20:54:33 +00:00
Chris Lattner
a88736647b new testcase for PR630
llvm-svn: 23422
2005-09-24 08:38:28 +00:00
Chris Lattner
cc9c03386f Add support for a marker byte that indicates that we shouldn't add the user
prefix to a symbol name

llvm-svn: 23421
2005-09-24 08:24:28 +00:00
Chris Lattner
7cd3c2d151 change proto slightly
llvm-svn: 23420
2005-09-24 08:23:53 +00:00
Chris Lattner
cc1d38160d memoize translations
llvm-svn: 23419
2005-09-24 00:50:51 +00:00
Chris Lattner
6736a6cdd2 Teach the dag isel generator how to construct arbitrary immediates. The
generated isel now tries li then lis, then lis+ori.

llvm-svn: 23418
2005-09-24 00:41:58 +00:00
Chris Lattner
0afb14cade Teach the DAG isel generator to emit code that creates nodes.
Fix a few corner cases parsing things like (i32 imm:$foo)

llvm-svn: 23417
2005-09-24 00:40:24 +00:00
Chris Lattner
cd093e868e Emit better code (no more copies for var references), and support DAG patterns
(e.g. things like rotates).

llvm-svn: 23416
2005-09-23 23:16:51 +00:00
Chris Lattner
8ffb99b4fe Fix a fixme by passing around SDOperand's instead of SDNode*'s
llvm-svn: 23415
2005-09-23 21:53:45 +00:00
Chris Lattner
cc8a564cb1 Emit code that matches the incoming DAG pattern and checks predicates.
This does not check that types match yet, but PPC only has one integer type
;-).

This also doesn't have the code to build the resultant dag.

llvm-svn: 23414
2005-09-23 21:33:23 +00:00
Chris Lattner
323a47970e emit information about the order patterns are to be matched.
llvm-svn: 23413
2005-09-23 20:52:47 +00:00
Chris Lattner
abb430bad2 start filling in the switch stmt
llvm-svn: 23412
2005-09-23 19:36:15 +00:00
Chris Lattner
499e33646e remove some debugging code
llvm-svn: 23411
2005-09-23 18:49:09 +00:00
Chris Lattner
c59a371d45 Fold two consequtive branches that share a common destination between them.
This implements SimplifyCFG/branch-fold.ll, and is useful on ?:/min/max heavy
code

llvm-svn: 23410
2005-09-23 18:47:20 +00:00
Chris Lattner
62f565d198 new testcase
llvm-svn: 23409
2005-09-23 18:43:57 +00:00
Chris Lattner
3a978bf66d simplify some logic further
llvm-svn: 23408
2005-09-23 07:23:18 +00:00
Chris Lattner
cc14ebc17b pull a bunch of logic out of SimplifyCFG into a helper fn
llvm-svn: 23407
2005-09-23 06:39:30 +00:00
Chris Lattner
1e3d3148bb speed up Archive::isBytecodeArchive in the case when the archive doesn't have
an llvm-ranlib symtab.  This speeds up gccld -native on an almost empty .o file
from 1.63s to 0.18s.

llvm-svn: 23406
2005-09-23 06:22:58 +00:00
Chris Lattner
f20941116b Speed up isBytecodeLPath from 20s to .01s in common cases. This makes -native
not completely painful to use.  Once we decide a directory has a bytecode
library, we know it this function returns true, no need to scan entire directories.

llvm-svn: 23405
2005-09-23 06:11:24 +00:00
Chris Lattner
9b9b510084 1. Do not use .c_str() to keep a persistent handle on a temporary string.
2. Concatenate -lfoo and -L/bar options into a single option instead of
   passing "-L /bar" (for example) which doesn't work on Darwin.
3. Send -v output to stderr instead of stdout

llvm-svn: 23404
2005-09-23 06:05:46 +00:00
Chris Lattner
59a05bdde6 Turn (X^C1) == C2 into X == C1^C2 iff X&~C1 = 0 (and move a function)
This happens all the time on PPC for bool values, e.g. eliminating a xori
in inverted-bool-compares.ll.

This should be added to the dag combiner as well.

llvm-svn: 23403
2005-09-23 00:55:52 +00:00
Chris Lattner
c619d43155 new testcase
llvm-svn: 23402
2005-09-23 00:53:06 +00:00
Chris Lattner
5ff606401b Testcase for PR629
llvm-svn: 23401
2005-09-21 06:53:56 +00:00
Chris Lattner
b1f8982ff0 Expose the LiveInterval interfaces as public headers.
llvm-svn: 23400
2005-09-21 04:19:09 +00:00
Chris Lattner
bc6f0d296c move the live interval headers out of lib/CodeGen/
llvm-svn: 23399
2005-09-21 04:18:25 +00:00
Chris Lattner
993a2ec38c Recommend what I actually test
llvm-svn: 23398
2005-09-21 03:56:26 +00:00
Chris Lattner
6c70106053 Start threading across blocks with code in them, so long as the code does
not define a value that is used outside of it's block.  This catches many
more simplifications, e.g. 854 in 176.gcc, 137 in vpr, etc.

This implements branch-phi-thread.ll:test3.ll

llvm-svn: 23397
2005-09-20 01:48:40 +00:00
Chris Lattner
cb6d8173d2 make this test harder: add a case where instructions are in the bb to be
threaded over

llvm-svn: 23396
2005-09-20 01:43:41 +00:00
Chris Lattner
f0bd8d0107 Implement merging of blocks with the same condition if the block has multiple
predecessors.  This implements branch-phi-thread.ll::test1

llvm-svn: 23395
2005-09-20 00:43:16 +00:00
Chris Lattner
168d2e5343 new testcase
llvm-svn: 23394
2005-09-20 00:41:55 +00:00
Chris Lattner
049cb4482f Reject a case we don't handle yet
llvm-svn: 23393
2005-09-19 23:57:04 +00:00
Chris Lattner
a160924d57 remove debugging code :-/
llvm-svn: 23392
2005-09-19 23:50:15 +00:00
Chris Lattner
748f903046 Implement SimplifyCFG/branch-phi-thread.ll, the most trivial case of threading
control across branches with determined outcomes.  More generality to follow.
This triggers a couple thousand times in specint.

llvm-svn: 23391
2005-09-19 23:49:37 +00:00
Chris Lattner
b2a9e8115b new testcase.
llvm-svn: 23390
2005-09-19 23:48:04 +00:00
Nate Begeman
c760f80fed Stub out the rest of the DAG Combiner. Just need to fill in the
select_cc bits and then wrap it in a convenience function for  use with
regular select.

llvm-svn: 23389
2005-09-19 22:34:01 +00:00
Chris Lattner
2f838f2192 Teach the local spiller to turn stack slot loads into register-register copies
when possible, avoiding the load (and avoiding the copy if the value is already
in the right register).

This patch came about when I noticed code like the following being generated:

  store R17 -> [SS1]
  ...blah...
  R4 = load [SS1]

This was causing an LSU reject on the G5.  This problem was due to the register
allocator folding spill code into a reg-reg copy (producing the load), which
prevented the spiller from being able to rewrite the load into a copy, despite
the fact that the value was already available in a register.  In the case
above, we now rip out the R4 load and replace it with a R4 = R17 copy.

This speeds up several programs on X86 (which spills a lot :) ), e.g.
smg2k from 22.39->20.60s, povray from 12.93->12.66s, 168.wupwise from
68.54->53.83s (!), 197.parser from 7.33->6.62s (!), etc.  This may have a larger
impact in some cases on the G5 (by avoiding LSU rejects), though it probably
won't trigger as often (less spilling in general).

Targets that implement folding of loads/stores into copies should implement
the isLoadFromStackSlot hook to get this.

llvm-svn: 23388
2005-09-19 06:56:21 +00:00
Chris Lattner
de3c87a2ab Implement the isLoadFromStackSlot interface
llvm-svn: 23387
2005-09-19 05:23:44 +00:00
Chris Lattner
b4b2530a1a Refactor this code a bit and make it more general. This now compiles:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) { b.j += x; }

To:

_plus2:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        slwi r3, r3, 6
        add r3, r4, r3
        rlwimi r3, r4, 0, 26, 14
        stw r3, 0(r2)
        blr


instead of:

_plus2:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        rlwinm r5, r4, 26, 21, 31
        add r3, r5, r3
        rlwimi r4, r3, 6, 15, 25
        stw r4, 0(r2)
        blr

by eliminating an 'and'.

I'm pretty sure this is as small as we can go :)

llvm-svn: 23386
2005-09-18 07:22:02 +00:00
Chris Lattner
797dee7705 Compile
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) {
  b.j += x;
}

to:

plus2:
        mov %EAX, DWORD PTR [b]
        mov %ECX, %EAX
        and %ECX, 131008
        mov %EDX, DWORD PTR [%ESP + 4]
        shl %EDX, 6
        add %EDX, %ECX
        and %EDX, 131008
        and %EAX, -131009
        or %EDX, %EAX
        mov DWORD PTR [b], %EDX
        ret

instead of:

plus2:
        mov %EAX, DWORD PTR [b]
        mov %ECX, %EAX
        shr %ECX, 6
        and %ECX, 2047
        add %ECX, DWORD PTR [%ESP + 4]
        shl %ECX, 6
        and %ECX, 131008
        and %EAX, -131009
        or %ECX, %EAX
        mov DWORD PTR [b], %ECX
        ret

llvm-svn: 23385
2005-09-18 06:30:59 +00:00
Chris Lattner
01f56c68e9 Generalize this transform, using MaskedValueIsZero, allowing us to compile:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) { b.k += x; }

To:

plus3:
        mov %EAX, DWORD PTR [%ESP + 4]
        shl %EAX, 17
        add DWORD PTR [b], %EAX
        ret

instead of:

plus3:
        mov %EAX, DWORD PTR [%ESP + 4]
        shl %EAX, 17
        mov %ECX, DWORD PTR [b]
        add %EAX, %ECX
        and %EAX, -131072
        and %ECX, 131071
        or %ECX, %EAX
        mov DWORD PTR [b], %ECX
        ret

llvm-svn: 23384
2005-09-18 06:02:59 +00:00
Chris Lattner
4ebc8ab4e0 fix typeo
llvm-svn: 23383
2005-09-18 05:25:20 +00:00
Chris Lattner
e5b23a6d67 Remove unintentionally committed code
llvm-svn: 23382
2005-09-18 05:12:51 +00:00
Chris Lattner
27cb9dbd35 implement shift.ll:test25. This compiles:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) {
  b.k += x;
}

to:

_plus3:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r3, 0(r2)
        rlwinm r4, r3, 0, 0, 14
        add r4, r4, r3
        rlwimi r4, r3, 0, 15, 31
        stw r4, 0(r2)
        blr

instead of:

_plus3:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        srwi r5, r4, 17
        add r3, r5, r3
        slwi r3, r3, 17
        rlwimi r3, r4, 0, 15, 31
        stw r3, 0(r2)
        blr

llvm-svn: 23381
2005-09-18 05:12:10 +00:00
Chris Lattner
1813aabcf2 new testcase
llvm-svn: 23380
2005-09-18 05:10:39 +00:00
Chris Lattner
af517574ce Implement add.ll:test29. Codegening:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus1 (unsigned int x) {
  b.i += x;
}

as:
_plus1:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        add r3, r4, r3
        rlwimi r3, r4, 0, 0, 25
        stw r3, 0(r2)
        blr

instead of:

_plus1:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        rlwinm r5, r4, 0, 26, 31
        add r3, r5, r3
        rlwimi r3, r4, 0, 0, 25
        stw r3, 0(r2)
        blr

llvm-svn: 23379
2005-09-18 04:24:45 +00:00
Chris Lattner
9136c832c4 new testcase
llvm-svn: 23378
2005-09-18 04:22:59 +00:00
Chris Lattner
027eaf01cf remove debug output
llvm-svn: 23377
2005-09-18 03:50:25 +00:00
Chris Lattner
1521298993 Implement or.ll:test21. This teaches instcombine to be able to turn this:
struct {
   unsigned int bit0:1;
   unsigned int ubyte:31;
} sdata;

void foo() {
  sdata.ubyte++;
}

into this:

foo:
        add DWORD PTR [sdata], 2
        ret

instead of this:

foo:
        mov %EAX, DWORD PTR [sdata]
        mov %ECX, %EAX
        add %ECX, 2
        and %ECX, -2
        and %EAX, 1
        or %EAX, %ECX
        mov DWORD PTR [sdata], %EAX
        ret

llvm-svn: 23376
2005-09-18 03:42:07 +00:00
Chris Lattner
c6d63a9832 new testcase
llvm-svn: 23375
2005-09-18 03:39:02 +00:00
Chris Lattner
4d9cf68023 Implement hook for ppc
llvm-svn: 23374
2005-09-17 01:03:26 +00:00
Chris Lattner
6db5887db5 add a new callback
llvm-svn: 23373
2005-09-17 01:02:45 +00:00
Nate Begeman
24a7eca282 More DAG combining. Still need the branch instructions, and select_cc
llvm-svn: 23371
2005-09-16 00:54:12 +00:00
Chris Lattner
7884fffb00 Fix a minor bug, add comments
llvm-svn: 23370
2005-09-16 00:29:46 +00:00
Chris Lattner
59e96143a2 teach the type inference code how to infer types for instructions and node
xforms.  Run type inference on result patterns, so we always have fully typed
results (and to catch errors in .td files).

llvm-svn: 23369
2005-09-15 22:23:50 +00:00
Chris Lattner
fedd9a5e1d put instructions into a map instead of a vector for quick lookup
llvm-svn: 23368
2005-09-15 21:57:35 +00:00
Chris Lattner
f38ce8f756 when parsing instructions remember information about the types taken and
returned.

llvm-svn: 23367
2005-09-15 21:51:12 +00:00
Chris Lattner
0ebec06671 disable this for now
llvm-svn: 23366
2005-09-15 21:44:00 +00:00
Chris Lattner
a0a986c9ae Start parsing "Pattern" nodes
llvm-svn: 23365
2005-09-15 21:42:00 +00:00
Chris Lattner
f79ad4cb32 rename a couple of methods, add structure for pattern parsing
llvm-svn: 23364
2005-09-15 02:38:02 +00:00
Chris Lattner
a155256a71 Verify that xform functions only occur in logical places
llvm-svn: 23363
2005-09-14 23:05:13 +00:00
Chris Lattner
991c7c973a Promote xform fns to be explicit nodes in result patterns, and clean off
predicates since they will have already matched at this point.

llvm-svn: 23362
2005-09-14 23:01:59 +00:00
Chris Lattner
bc7aabce12 start building the instruction dest pattern correctly. Change the xform
functions to preserve the Record for the xform instead of making it into a
function name.

llvm-svn: 23361
2005-09-14 22:55:26 +00:00
Chris Lattner
e389c6154e catch unnamed inputs
llvm-svn: 23360
2005-09-14 22:06:36 +00:00
Chris Lattner
030f876cf2 check that there are no unexpected operands
llvm-svn: 23359
2005-09-14 21:59:34 +00:00
Chris Lattner
3ced3f8b82 force all instruction operands to be named.
llvm-svn: 23358
2005-09-14 21:13:50 +00:00
Chris Lattner
9e4a4ee3dc Give all operands names
llvm-svn: 23357
2005-09-14 21:11:13 +00:00
Chris Lattner
2e84be22a8 give all operands names
llvm-svn: 23356
2005-09-14 21:10:24 +00:00
Chris Lattner
f02994d782 Check that operands have unique names. REJECT instructions with broken operand
lists: only don't parse them if they are entirely missing (sparcv9).

llvm-svn: 23355
2005-09-14 21:05:02 +00:00
Chris Lattner
24ae3494f0 fix a broke range check
llvm-svn: 23354
2005-09-14 21:04:12 +00:00
Chris Lattner
3ba60bf644 Parse significantly more of the instruction pattern, now collecting and
verifying information about the operands.

llvm-svn: 23353
2005-09-14 20:53:42 +00:00
Chris Lattner
f006d15e7f Fix some issues exposed by more testing. XORIS had the wrong operands
specified.  The various *imm operands defined by PPC are really all i32,
even though the actual immediate is restricted to a smaller value in it.

llvm-svn: 23352
2005-09-14 20:53:05 +00:00
Chris Lattner
22e60c99ce Verify that set destinations occur first in the instruction operand list.
llvm-svn: 23351
2005-09-14 18:19:25 +00:00
Chris Lattner
6b013fc923 Fix some bugs noticed by new checking code
llvm-svn: 23350
2005-09-14 18:18:39 +00:00
Chris Lattner
fcffc98b05 add an accessor
llvm-svn: 23349
2005-09-14 18:02:53 +00:00
Chris Lattner
a393e4d4b3 Fix the regression last night compiling povray
llvm-svn: 23348
2005-09-14 17:32:56 +00:00
Chris Lattner
b42e962d23 fix a major regression from my patch this afternoon
llvm-svn: 23347
2005-09-14 06:06:45 +00:00
Chris Lattner
1c8d6ce015 remove some code that isn't ready for prime time
llvm-svn: 23346
2005-09-14 06:03:10 +00:00
Chris Lattner
3361eab530 Switch to a slightly more structured representation for instructions
llvm-svn: 23345
2005-09-14 04:03:16 +00:00
Chris Lattner
4cfcb544bf Add some more checking/verification code
llvm-svn: 23344
2005-09-14 02:11:12 +00:00
Chris Lattner
4c7b604091 start parsing instructions into patterns, start doing many more checks of
'set's.

llvm-svn: 23343
2005-09-14 00:09:24 +00:00
Chris Lattner
b011cb2746 we don't need this proto any longer
llvm-svn: 23342
2005-09-13 22:05:21 +00:00
Chris Lattner
bb9b01644e don't emit the namespace inside the class!
llvm-svn: 23341
2005-09-13 22:05:02 +00:00
Chris Lattner
70a7234111 Emit code suitable for emission into the ISel class, allowing us to use/define
methods.

llvm-svn: 23340
2005-09-13 22:03:37 +00:00
Chris Lattner
03e08eefc7 move the #include for the generated code into the isel class body so we
can use/define class methods

llvm-svn: 23339
2005-09-13 22:03:06 +00:00
Chris Lattner
3556d849da continue xform function parsing
llvm-svn: 23338
2005-09-13 21:59:15 +00:00
Chris Lattner
2617de498d Start parsing node transformation information
llvm-svn: 23337
2005-09-13 21:51:00 +00:00
Chris Lattner
ae939eb6bb Add a new Record::getValueAsCode method to mirror the other getValueAs*
methods.  Use it to simplify some code.

llvm-svn: 23336
2005-09-13 21:44:28 +00:00
Chris Lattner
f365e25a5c completely eliminate TreePattern::PatternType
llvm-svn: 23335
2005-09-13 21:20:49 +00:00
Chris Lattner
0f965a615e Change the arg lowering code to use copyfromreg from vregs associated
with incoming arguments instead of the pregs themselves.  This fixes
the scheduler from causing problems by moving a copyfromreg for an argument
to after a select_cc node (now it can, and bad things won't happen).

llvm-svn: 23334
2005-09-13 19:33:40 +00:00
Chris Lattner
ee8113293e This has been moved to the target-indep code
llvm-svn: 23333
2005-09-13 19:32:18 +00:00
Chris Lattner
fb96e50b8c This code is no longer needed, it is moved to the target-indep code
llvm-svn: 23332
2005-09-13 19:31:44 +00:00
Chris Lattner
d4382f0afa If a function has liveins, and if the target requested that they be plopped
into particular vregs, emit copies into the entry MBB.

llvm-svn: 23331
2005-09-13 19:30:54 +00:00
Chris Lattner
64685b4ca2 Majik numbers are bad
llvm-svn: 23330
2005-09-13 19:03:13 +00:00
Chris Lattner
aa6cbd90c5 Remove some dead vectors
llvm-svn: 23329
2005-09-13 18:47:49 +00:00
Chris Lattner
2a8932960d Add a simple xform to simplify array accesses with casts in the way.
This is useful for 178.galgel where resolution of dope vectors (by the
optimizer) causes the scales to become apparent.

llvm-svn: 23328
2005-09-13 18:36:04 +00:00
Chris Lattner
fd018c8dfe Fix an issue where LSR would miss rewriting a use of an IV expression by a PHI node that is not the original PHI.
This fixes up a dot-product loop in galgel, speeding it up from 18.47s to
16.13s.

llvm-svn: 23327
2005-09-13 02:09:55 +00:00
Duraid Madina
a78635c1f0 fails since linux-itanium headers are Different
llvm-svn: 23326
2005-09-13 01:03:53 +00:00
Chris Lattner
567b81f0d2 Add a helper function, allowing us to simplify some code a bit, changing
indentation, no functionality change

llvm-svn: 23325
2005-09-13 00:40:14 +00:00
Chris Lattner
219175c84d Implement a simple xform to turn code like this:
if () { store A -> P; } else { store B -> P; }

into a PHI node with one store, in the most trival case.  This implements
load.ll:test10.

llvm-svn: 23324
2005-09-12 23:23:25 +00:00
Chris Lattner
42a6cefa49 new testcase
llvm-svn: 23323
2005-09-12 23:22:17 +00:00
Chris Lattner
e0bfdf1485 Another load-peephole optimization: do gcse when two loads are next to
each other.  This implements InstCombine/load.ll:test9

llvm-svn: 23322
2005-09-12 22:21:03 +00:00
Chris Lattner
20c1cc0741 new testcase
llvm-svn: 23321
2005-09-12 22:19:46 +00:00
Chris Lattner
b990f7d8ed Implement a trivial form of store->load forwarding where the store and the
load are exactly consequtive.  This is picked up by other passes, but this
triggers thousands of times in fortran programs that use static locals
(and is thus a compile-time speedup).

llvm-svn: 23320
2005-09-12 22:00:15 +00:00
Chris Lattner
4cd474ebbd new testcase
llvm-svn: 23319
2005-09-12 21:59:22 +00:00
Chris Lattner
8048b85e8f Fix a regression from last night, which caused this pass to create invalid
code for IV uses outside of loops that are not dominated by the latch block.
We should only convert these uses to use the post-inc value if they ARE
dominated by the latch block.

Also use a new LoopInfo method to simplify some code.

This fixes Transforms/LoopStrengthReduce/2005-09-12-UsesOutOutsideOfLoop.ll

llvm-svn: 23318
2005-09-12 17:11:27 +00:00
Chris Lattner
2ee807c70f relax pattern match on name
llvm-svn: 23317
2005-09-12 17:09:40 +00:00
Chris Lattner
7efb86dc11 new testcase
llvm-svn: 23316
2005-09-12 17:08:15 +00:00
Chris Lattner
b35df5f5bc Add a new getLoopLatch() method.
llvm-svn: 23315
2005-09-12 17:03:55 +00:00
Chris Lattner
589e605f42 new method
llvm-svn: 23314
2005-09-12 17:03:16 +00:00
Chris Lattner
a67648396a _test:
li r2, 0
LBB_test_1:     ; no_exit.2
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmpwi cr0, r2, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r2, 1
        stw r2, 0(r4)
        blr
[zion ~/llvm]$ cat > ~/xx
Uses of IV's outside of the loop should use hte post-incremented version
of the IV, not the preincremented version.  This helps many loops (e.g. in sixtrack)
which used to generate code like this (this is the code from the
dont-hoist-simple-loop-constants.ll testcase):

_test:
        li r2, 0                 **** IV starts at 0
LBB_test_1:     ; no_exit.2
        or r5, r2, r2            **** Copy for loop exit
        li r2, 0
        stw r2, 0(r3)
        addi r3, r3, 4
        addi r2, r5, 1
        addi r6, r5, 2           **** IV+2
        cmpwi cr0, r6, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r5, 2       ****  IV+2
        stw r2, 0(r4)
        blr

And now generated code like this:

_test:
        li r2, 1               *** IV starts at 1
LBB_test_1:     ; no_exit.2
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmpwi cr0, r2, 701     *** IV.postinc + 0
        blt cr0, LBB_test_1
LBB_test_2:     ; loopexit.2.loopexit
        stw r2, 0(r4)          *** IV.postinc + 0
        blr

llvm-svn: 23313
2005-09-12 06:04:47 +00:00
Chris Lattner
2bb00dda5a new testcase
llvm-svn: 23312
2005-09-12 05:50:15 +00:00
Chris Lattner
d0c7a5eeb7 Regenerate
llvm-svn: 23311
2005-09-12 05:30:06 +00:00
Chris Lattner
564d240799 Rearrange two rules, which apparently makes some versions of bison happier.
llvm-svn: 23310
2005-09-12 05:29:43 +00:00
Chris Lattner
ecd98d5d77 Make sure to disable 64-bit extensions for this test
llvm-svn: 23309
2005-09-11 03:50:38 +00:00
Jeff Cohen
e19ca3ab0c Fix more Visual Studio build problems.
llvm-svn: 23308
2005-09-10 02:33:17 +00:00
Jeff Cohen
0dce12dd90 Fix miscellaneous Visual Studio build problems.
llvm-svn: 23307
2005-09-10 02:00:02 +00:00
Chris Lattner
530fe6ab30 implement Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll.
We used to emit this code for it:

_test:
        li r2, 1     ;; Value tying up a register for the whole loop
        li r5, 0
LBB_test_1:     ; no_exit.2
        or r6, r5, r5
        li r5, 0
        stw r5, 0(r3)
        addi r5, r6, 1
        addi r3, r3, 4
        add r7, r2, r5  ;; should be addi r7, r5, 1
        cmpwi cr0, r7, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r6, 2
        stw r2, 0(r4)
        blr

now we emit this:

_test:
        li r2, 0
LBB_test_1:     ; no_exit.2
        or r5, r2, r2
        li r2, 0
        stw r2, 0(r3)
        addi r3, r3, 4
        addi r2, r5, 1
        addi r6, r5, 2   ;; whoa, fold those adds!
        cmpwi cr0, r6, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r5, 2
        stw r2, 0(r4)
        blr

more improvement coming.

llvm-svn: 23306
2005-09-10 01:18:45 +00:00
Chris Lattner
0c7728e4d6 new testcase
llvm-svn: 23305
2005-09-10 01:14:37 +00:00
Chris Lattner
4309c3a785 PowerPC cannot truncstore i1 natively
llvm-svn: 23304
2005-09-10 00:21:06 +00:00
Chris Lattner
2d454bf5be Allow targets to say they don't support truncstore i1 (which includes a mask
when storing to an 8-bit memory location), as most don't.

llvm-svn: 23303
2005-09-10 00:20:18 +00:00
Chris Lattner
bd39c1a4c6 Add a missing #include, patch courtesy of Baptiste Lepilleur.
llvm-svn: 23302
2005-09-09 23:53:39 +00:00
Chris Lattner
331b311f7b Fix a problem duraid encountered on itanium where this folding:
select (x < y), 1, 0 -> (x < y) incorrectly: the setcc returns i1 but the
select returned i32.  Add the zero extend as needed.

llvm-svn: 23301
2005-09-09 23:00:07 +00:00
Chris Lattner
16e5cb87ba Fix a crash viewing dags that have target nodes in them
llvm-svn: 23300
2005-09-09 22:35:03 +00:00
Chris Lattner
0f2146bb5d I forgot that we always spill fp values as 64-bits. Implement spill folding
for FP as well.  This triggers a couple dozen times on 177.mesa (for example).

llvm-svn: 23299
2005-09-09 21:59:44 +00:00
Chris Lattner
712e78ee28 Fix a problem that Nate noticed, where spill code was not getting coallesced
with copies, leading to code like this:

       lwz r4, 380(r1)
       or r10, r4, r4    ;; Last use of r4

By teaching the PPC backend how to fold spills into copies, we now get this
code:

       lwz r10, 380(r1)

wow. :)

This reduces a testcase nate sent me from 1505 instructions to 1484.

Note that this could handle FP values but doesn't currently, for reasons
mentioned in the patch

llvm-svn: 23298
2005-09-09 21:46:49 +00:00
Chris Lattner
f540c1a2e8 code cleanup
llvm-svn: 23297
2005-09-09 20:51:08 +00:00
Chris Lattner
1410003751 Use continue in the use-processing loop to make it clear what the early exits
are, simplify logic, and cause things to not be nested as deeply.  This also
uses MRI->areAliases instead of an explicit loop.

No functionality change, just code cleanup.

llvm-svn: 23296
2005-09-09 20:29:51 +00:00
Nate Begeman
049b748c76 Last round of 2-node folds from SD.cpp. Will move on to 3 node ops such
as setcc and select next.

llvm-svn: 23295
2005-09-09 19:49:52 +00:00
Chris Lattner
ce3662f2a2 remove debugging code *slaps head*
llvm-svn: 23294
2005-09-09 19:19:20 +00:00
Chris Lattner
c9053083eb When spilling a live range that is used multiple times by one instruction,
only add a reload live range once for the instruction.  This is one step
towards fixing a regalloc pessimization that Nate notice, but is later undone
by the spiller (so no code is changed).

llvm-svn: 23293
2005-09-09 19:17:47 +00:00
Chris Lattner
c37a2f13c4 Teach the code generator that rlwimi is commutable if the rotate amount
is zero.  This lets the register allocator elide some copies in some cases.

This implements CodeGen/PowerPC/rlwimi-commute.ll

llvm-svn: 23292
2005-09-09 18:17:41 +00:00
Jim Laskey
48356a50f3 Added targets to speed up build of llc.
llvm-svn: 23291
2005-09-09 17:50:20 +00:00
Chris Lattner
db9f4b9db4 New testcase, neither should require a register-register copy
llvm-svn: 23290
2005-09-09 17:48:57 +00:00
Chris Lattner
ce2173d098 add an accessor to provide more checking
llvm-svn: 23289
2005-09-09 01:15:01 +00:00
Chris Lattner
7a82c06f34 use new accessors to simplify code. Add checking to make sure top-level instr
definitions are void

llvm-svn: 23288
2005-09-09 01:11:44 +00:00
Chris Lattner
91d8672be1 add some accessors
llvm-svn: 23287
2005-09-09 01:11:17 +00:00
Chris Lattner
39b4d83f6a Introduce two new concepts:
1. Add support for defining Pattern's, which can match expressions when there
   is no instruction that directly implements something.  Instructions usually
   implicitly define patterns.
2. Add support for defining SDNodeXForm's, which are node transformations.
   This seperates the concept of a node xform out from the existing predicate
   support.

Using this new stuff, we add a few instruction patterns, one for testing, and
two for OR/XOR by an arbitrary immediate.

llvm-svn: 23286
2005-09-09 00:39:56 +00:00
Chris Lattner
debd6e95ab Fix incorrect comment
llvm-svn: 23285
2005-09-08 23:26:30 +00:00
Chris Lattner
d7d31f3b06 Implement a complete type inference system for dag patterns, based on the
constraints defined in the DAG node definitions in the .td files.  This
allows us to infer (and check!) the types for all nodes in the current
ppc .td file.  For example, instead of:

Inst pattern EQV:       (set GPRC:i32:$rT, (xor (xor GPRC:i32:$rA, GPRC:i32:$rB), (imm)<<Predicate_immAllOnes>>))

we now fully infer:

Inst pattern EQV:       (set:void GPRC:i32:$rT, (xor:i32 (xor:i32 GPRC:i32:$rA, GPRC:i32:$rB), (imm:i32)<<Predicate_immAllOnes>>))

from:  (set GPRC:$rT, (not (xor GPRC:$rA, GPRC:$rB)))
llvm-svn: 23284
2005-09-08 23:22:48 +00:00
Chris Lattner
4b09f3c6f5 whitespace/comment changes, no functionality diffs
llvm-svn: 23283
2005-09-08 23:17:26 +00:00
Chris Lattner
cee994b464 Compute the value types that are natively supported by a target.
llvm-svn: 23282
2005-09-08 21:43:21 +00:00
Chris Lattner
1c33104010 Parse information about type constraints on SDNodes
llvm-svn: 23281
2005-09-08 21:27:15 +00:00
Chris Lattner
a3b89dfcef use node info in the one place we currently use it
llvm-svn: 23280
2005-09-08 21:04:46 +00:00
Chris Lattner
35bcd1488a start parsing SDNode info records
llvm-svn: 23279
2005-09-08 21:03:01 +00:00
Nate Begeman
85c1cc4523 Move yet more folds over to the dag combiner from sd.cpp
llvm-svn: 23278
2005-09-08 20:18:10 +00:00
Chris Lattner
0ec8fa0880 Add a bunch of stuff needed for node type inference. Move 'BLR' down with
the rest of the instructions, add comment markers to seperate portions of
the file into logical parts

llvm-svn: 23277
2005-09-08 19:50:41 +00:00
Chris Lattner
07f1e4597e Fix indentation
llvm-svn: 23276
2005-09-08 19:47:28 +00:00
Chris Lattner
bd6b164965 regenerate
llvm-svn: 23275
2005-09-08 18:48:47 +00:00
Chris Lattner
972cccd77a Add support for automatically created anonymous definitions.
This implements Regression/TableGen/AnonDefinitionOnDemand.td

llvm-svn: 23274
2005-09-08 18:48:23 +00:00
Chris Lattner
1872ea3227 x and X should be structurally identical
llvm-svn: 23273
2005-09-08 18:47:43 +00:00
Chris Lattner
808c642e62 new expression type
llvm-svn: 23272
2005-09-08 18:47:21 +00:00
Chris Lattner
5a699e621f regenerate
llvm-svn: 23271
2005-09-08 18:22:57 +00:00
Chris Lattner
8a41b214b3 Tabs to spaces.
llvm-svn: 23270
2005-09-08 18:22:35 +00:00
Chris Lattner
399f59f643 Keep names even when inlining. This allows us to realize that ADDI is:
(set GPRC:i32:$rD, (add GPRC:i32:$rA, (imm)<<Predicate_immSExt16>>:$imm))

not:

(set GPRC:i32:$rD, (add GPRC:i32:$rA, (imm)<<Predicate_immSExt16>>))

(we keep the ":$imm")

llvm-svn: 23269
2005-09-08 17:45:12 +00:00
Chris Lattner
76cb006e2c add patterns for x?oris?
llvm-svn: 23268
2005-09-08 17:40:49 +00:00
Chris Lattner
2d8032b54c add patterns to the addi/addis/mulli etc instructions. Define predicates
for matching signed 16-bit and shifted 16-bit ppc immediates

llvm-svn: 23267
2005-09-08 17:33:10 +00:00
Chris Lattner
cf9b0e6673 Add patterns for some new instructions, allowing the use of the ineg fragment.
llvm-svn: 23266
2005-09-08 17:01:54 +00:00
Chris Lattner
f18935a598 add some missing PPC backend files
llvm-svn: 23265
2005-09-07 23:57:00 +00:00
Chris Lattner
a0d936cdc5 Add tblgen fpcmp and the nightly tester to the utils folder
llvm-svn: 23264
2005-09-07 23:53:49 +00:00
Chris Lattner
7c8dba750c ignore generated files
llvm-svn: 23263
2005-09-07 23:47:44 +00:00
Chris Lattner
498915dafa Remove some cases handled by the generated portion of the isel
llvm-svn: 23262
2005-09-07 23:45:15 +00:00
Chris Lattner
d2a5b366f5 Initial cut of the dag isel generator. This is still very much a work in
progress.  It correctly parses instructions and pattern fragments and glues
together pattern fragments into instructions.

The only code it generates currently is some boilerplate code for things
like the EntryNode.

llvm-svn: 23261
2005-09-07 23:44:43 +00:00
Nate Begeman
2cc2c9a79c Another round of dag combiner changes. This fixes some missing XOR folds
as well as fixing how we replace old values with new values.

llvm-svn: 23260
2005-09-07 23:25:52 +00:00
Chris Lattner
5d16dbd5bb Fix a bug that Tzu-Chien Chiu noticed: live interval analysis does NOT
preserve livevar

llvm-svn: 23259
2005-09-07 17:34:39 +00:00
Nate Begeman
6791d63e55 Implement a common missing fold, (add (add x, c1), c2) -> (add x, c1+c2).
This restores all of stanford to being identical with and without the dag
combiner with the add folding turned off in sd.cpp.

llvm-svn: 23258
2005-09-07 16:09:19 +00:00
Chris Lattner
5ea0ee7b19 On non-apple systems, when using -march=ppc32, do not print:
'' is not a recognized processor for this target (ignoring processor)

Default to "generic" instead of "" for the default CPU.

llvm-svn: 23257
2005-09-07 05:45:33 +00:00
Chris Lattner
8d0e9d90aa Print:
'' is not a recognized processor for this target (ignoring processor)

instead of:

 is not a recognized processor for this target (ignoring processor)

llvm-svn: 23256
2005-09-07 05:44:14 +00:00
Chris Lattner
fe883adfd2 Fix a bug nate ran into with replacealluseswith. In the recursive cse case,
we were losing a node, causing an assertion to fail.  Now we eagerly delete
discovered CSE's, and provide an optional vector to keep track of these
discovered equivalences.

llvm-svn: 23255
2005-09-07 05:37:01 +00:00
Chris Lattner
3852fd0e49 Add a new argument to ReplaceAllUsesWith to keep track of nodes deleted by
this method

llvm-svn: 23254
2005-09-07 05:36:18 +00:00
Nate Begeman
007c650699 Add an option to the DAG Combiner to enable it for beta runs, and turn on
that option for PowerPC's beta.

llvm-svn: 23253
2005-09-07 00:15:36 +00:00
Chris Lattner
c59a1dbce2 Rename a class. These files are being migrated to the new isel and I want to
reuse the names

llvm-svn: 23252
2005-09-06 22:51:34 +00:00
Nate Begeman
a53a310d8c Test the new 64bit i64<->fp functionality
llvm-svn: 23251
2005-09-06 22:23:15 +00:00
Nate Begeman
6095214bf0 Implement i64<->fp using the fctidz/fcfid instructions on PowerPC when we
are allowed to generate 64-bit-only PowerPC instructions for 32 bit hosts,
such as the PowerPC 970.

This speeds up 189.lucas from 81.99 to 32.64 seconds.

llvm-svn: 23250
2005-09-06 22:03:27 +00:00
Chris Lattner
784e44443d regenerate
llvm-svn: 23249
2005-09-06 21:23:27 +00:00
Chris Lattner
ab9eba1014 Tighten up the specification to allow TableGen/nested-comment.td to pass
(fixing a bug where / in a /* */ comment would cause it to not close).

llvm-svn: 23248
2005-09-06 21:23:09 +00:00
Chris Lattner
23e2499ee4 new testcase: tblgen should grok this.
llvm-svn: 23247
2005-09-06 21:22:15 +00:00
Andrew Lenharth
a63a066205 Fix up the AssertXext problem, as well as adding it at calls
llvm-svn: 23246
2005-09-06 17:00:23 +00:00
Nate Begeman
e9e2c6d314 Add note about future optimization noted in the ppc compiler writer's guide
llvm-svn: 23245
2005-09-06 15:30:48 +00:00
Nate Begeman
2dded8302a Add accessor for 64bit flag, so that we can tell when it is safe to
generate the fun in-register fp<->long instructions.

llvm-svn: 23244
2005-09-06 15:30:12 +00:00
Nate Begeman
d23739d020 Next round of DAGCombiner changes. This version now passes all the tests
I have run so far when run before Legalize.  It still needs to pick up the
SetCC folds, and nodes that use SetCC.

llvm-svn: 23243
2005-09-06 04:43:02 +00:00
Chris Lattner
f1705fdda4 Add a requirement, patch contributed by Henrik Bach.
llvm-svn: 23242
2005-09-06 04:07:15 +00:00
Andrew Lenharth
c8bd5bda59 revert part of the last change, should fix regressions
llvm-svn: 23241
2005-09-04 06:12:19 +00:00
Chris Lattner
aa833d4571 explicitly specify an operands list for patterns with inputs (e.g. neg)
llvm-svn: 23240
2005-09-03 01:28:40 +00:00
Chris Lattner
8ae9525bd0 include the dag isel fragment
llvm-svn: 23239
2005-09-03 01:17:22 +00:00
Chris Lattner
0442dcfabc ask for a dag isel
llvm-svn: 23238
2005-09-03 01:15:41 +00:00
Chris Lattner
33f98bdddf allow for a target to ask for a dag isel
llvm-svn: 23237
2005-09-03 01:15:25 +00:00
Chris Lattner
90d000417f Add an option and stuff implementation of a dag isel emitter
llvm-svn: 23236
2005-09-03 01:14:03 +00:00
Chris Lattner
821628ff2a Fix a checking failure in gs
llvm-svn: 23235
2005-09-03 01:04:40 +00:00
Chris Lattner
5f12cf14be Change the isel to not break out of the big giant switch. Instead, the
switch should never be exited, so its bottom is now unreachable.

llvm-svn: 23234
2005-09-03 00:53:47 +00:00
Chris Lattner
9220f92c41 rearrange logical ops to group them together more consistently.
Define the PatFrag class which can be used to define subpatterns to match
things with.  Define 'not', and use it to define the patterns for andc,
nand, etc.

llvm-svn: 23233
2005-09-03 00:21:51 +00:00
Chris Lattner
dcbb561b76 Add AND/OR/XOR
llvm-svn: 23232
2005-09-02 22:35:53 +00:00
Nate Begeman
7cea6ef16e Next round of DAG Combiner changes. Just need to support multiple return
values, and then we should be able to hook it up.

llvm-svn: 23231
2005-09-02 21:18:40 +00:00
Chris Lattner
3a1002d529 Add some initial patterns to simple binary instructions, though they
currently don't do anything.  This elides patterns for binary operators
that ping on the carry flag, since we don't model it yet.

This patch also removes PPC::SUB, because it is dead.

llvm-svn: 23230
2005-09-02 21:18:00 +00:00
Chris Lattner
1a570f1fe4 Clean up some code from the last checkin
llvm-svn: 23229
2005-09-02 20:32:45 +00:00
Chris Lattner
630226697f Fix a bug in legalize where it would emit two calls to libcalls that return
i64 values on targets that need that expanded to 32-bit registers.  This fixes
PowerPC/2005-09-02-LegalizeDuplicatesCalls.ll and speeds up 189.lucas from
taking 122.72s to 81.96s on my desktop.

llvm-svn: 23228
2005-09-02 20:26:58 +00:00
Chris Lattner
63fab495bb Test that converting from double to int64 results in one libcall, not one
and a dead one.  This is a legalize bug

llvm-svn: 23227
2005-09-02 20:24:10 +00:00
Chris Lattner
06e237f253 turn on dag isel by default
llvm-svn: 23226
2005-09-02 19:53:54 +00:00
Chris Lattner
b95b280bee Make sure to auto-cse nullary ops
llvm-svn: 23224
2005-09-02 19:36:17 +00:00
Chris Lattner
5ba7b615ed add a map for nullary ops
llvm-svn: 23223
2005-09-02 19:35:42 +00:00
Jim Laskey
27d628dfc9 Add help support for -mcpu and -mattr.
llvm-svn: 23222
2005-09-02 19:27:43 +00:00
Chris Lattner
1e89e36dcd Fix some buggy logic where we would try to remove nodes with two operands
from the binary ops map, even if they had multiple results.  This latent bug
caused a few failures with the dag isel last night.

To prevent stuff like this from happening in the future, add some really
strict checking to make sure that the CSE maps always match up with reality!

llvm-svn: 23221
2005-09-02 19:15:44 +00:00
Andrew Lenharth
9690a4f321 Pull out Lowering in preperation for multiple ISels. Oh, and get rid of some stuff
llvm-svn: 23220
2005-09-02 18:46:02 +00:00
Chris Lattner
b0b4ec5655 Don't create zero sized stack objects even for array allocas with a zero
number of elements.

llvm-svn: 23219
2005-09-02 18:41:28 +00:00
Chris Lattner
aa3b1fcc58 Decouple fsqrt from gpul optimizations, implementing fsqrt.ll.
Remove the -enable-gpopt option which is subsumed by feature flags.

llvm-svn: 23218
2005-09-02 18:33:05 +00:00
Chris Lattner
ffb99034cf new testcase to ensure fsqrt is generated for correct subtargets only, and
that the fsqrt feature works.

llvm-svn: 23217
2005-09-02 18:32:22 +00:00
Chris Lattner
38ad3f6948 Move a bunch of non-deprecated methods above the "deprecated line"
llvm-svn: 23216
2005-09-02 18:16:20 +00:00
Chris Lattner
b6cde17d29 Fix the release build, noticed by Eric van Riet Paap
llvm-svn: 23215
2005-09-02 07:09:28 +00:00
Chris Lattner
b5e381a8cf Fix a problem that Dan Berlin noticed, where reassociation would not succeed
in building maximal expressions before simplifying them.  In particular, i
cases like this:

X-(A+B+X)

the code would consider A+B+X to be a maximal expression (not understanding
that the single use '-' would be turned into a + later), simplify it (a noop)
then later get simplified again.

Each of these simplify steps is where the cost of reassociation comes from,
so this patch should speed up the already fast pass a bit.

Thanks to Dan for noticing this!

llvm-svn: 23214
2005-09-02 07:07:58 +00:00
Chris Lattner
9fe263aa75 Avoid creating garbage instructions, just move the old add instruction
to where we need it when converting -(A+B+C) -> -A + -B + -C.

llvm-svn: 23213
2005-09-02 06:38:04 +00:00
Chris Lattner
b944d5a491 new testcase for recent bugfix
llvm-svn: 23212
2005-09-02 06:12:12 +00:00
Chris Lattner
d1325da091 add some assertions and fix problems where reassociate could access the
Ops vector out of range

llvm-svn: 23211
2005-09-02 05:23:22 +00:00
Jeff Cohen
a6dde9962d Fix VC++ build errors
llvm-svn: 23210
2005-09-02 02:51:42 +00:00
Chris Lattner
763a3a0fa7 Restore this patch now that the latent bug has been fixed
llvm-svn: 23209
2005-09-02 01:24:55 +00:00
Chris Lattner
d9af1aab51 Make sure to legalize assert[zs]ext's operand correctly
llvm-svn: 23208
2005-09-02 01:15:01 +00:00
Chris Lattner
06d440f2ee Revert the previous patch which causes a mysterious regression in toast.
llvm-svn: 23207
2005-09-02 00:47:05 +00:00
Chris Lattner
7138f91424 Teach live intervals to not crash on dead livein regs
llvm-svn: 23206
2005-09-02 00:20:32 +00:00
Chris Lattner
a66403dbf7 For values that are live across basic blocks and need promotion, use ANY_EXTEND
instead of ZERO_EXTEND to eliminate extraneous extensions.  This eliminates
dead zero extensions on formal arguments and other cases on PPC, implementing
the newly tightened up test/Regression/CodeGen/PowerPC/small-arguments.ll test.

llvm-svn: 23205
2005-09-02 00:19:37 +00:00
Chris Lattner
7753f175e6 legalize ANY_EXTEND appropriately
llvm-svn: 23204
2005-09-02 00:18:10 +00:00
Chris Lattner
8c393c218b Add support for ANY_EXTEND and add a few minor folds for it
llvm-svn: 23203
2005-09-02 00:17:32 +00:00
Chris Lattner
210975cfbb Handle any_extend like zext
llvm-svn: 23202
2005-09-02 00:16:09 +00:00
Chris Lattner
2493f0e5fd Handle ANY_EXTEND like ZERO_EXTEND. Simplify the extend/truncate code on
the observation that it only has to handle i1 -> i64 and i64 -> i1.

llvm-svn: 23201
2005-09-02 00:15:30 +00:00
Chris Lattner
969af57d65 Add a new ANY_EXTEND node, which operates like an extension but has undefined
top bits.

llvm-svn: 23200
2005-09-02 00:14:40 +00:00
Chris Lattner
97ac77fd91 This should permit NOT and's, not even dead ones.
llvm-svn: 23199
2005-09-02 00:13:56 +00:00
Chris Lattner
9ee867b93b Implement small-arguments.ll:test3 by teaching the DAG optimizer that
the results of calls to functions returning small values are properly
sign/zero extended.

llvm-svn: 23198
2005-09-01 23:44:32 +00:00
Chris Lattner
907123b1ab Another case that shouldn't have sign extends: functions returning short
are known to return properly sign extended values, no need for an explicit
extension.

llvm-svn: 23197
2005-09-01 23:43:58 +00:00
Nate Begeman
d78d975437 Fix some code in the current node combining code, spotted when it was moved
over to DAGCombiner.cpp

1. Don't assume that SetCC returns i1 when folding (xor (setcc) constant)
2. Don't duplicate code in folding AND with AssertZext that is handled by
   MaskedValueIsZero

llvm-svn: 23196
2005-09-01 23:25:49 +00:00
Nate Begeman
2504fe2613 Implement first round of feedback from chris (there's still a couple things
left to do).

llvm-svn: 23195
2005-09-01 23:24:04 +00:00
Chris Lattner
68d15fdfea Align functions to 16-byte boundaries, to eliminate noise in performance measurements. This improves the performance of 'treeadd' by about 20% with the dag
isel, restoring it to the pattern-isel level (which happens to get the alignment right).

llvm-svn: 23194
2005-09-01 23:08:50 +00:00
Chris Lattner
e40a3ccd60 Local labels on darwin apparently start with just 'L', not .L like other
platforms.  This reduces executable size and makes shark realize the actual
bounds of functions instead of showing each MBB as a function :)

llvm-svn: 23193
2005-09-01 21:48:35 +00:00
Jim Laskey
19058c3989 1. Use SubtargetFeatures in llc/lli.
2. Propagate feature "string" to all targets.

3. Implement use of SubtargetFeatures in PowerPCTargetSubtarget.

llvm-svn: 23192
2005-09-01 21:38:21 +00:00
Jim Laskey
3fee6a51a9 This new class provides support for platform specific "features". The intent
is to manage processor specific attributes from the command line.  See examples
of use in llc/lli and PowerPCTargetSubtarget.

llvm-svn: 23191
2005-09-01 21:36:18 +00:00
Chris Lattner
a305d28cf6 Implement dynamic allocas correctly. In particular, because we were copying
directly out of R1 (without using a CopyFromReg, which uses a chain), multiple
allocas were getting CSE'd together, producing bogus code.  For this:

int %foo(bool %X, int %A, int %B) {
        br bool %X, label %T, label %F
F:
        %G = alloca int
        %H = alloca int
        store int %A, int* %G
        store int %B, int* %H
        %R = load int* %G
        ret int %R
T:
        ret int 0
}

We were generating:

_foo:
        stwu r1, -16(r1)
        stw r31, 4(r1)
        or r31, r1, r1
        stw r1, 12(r31)
        cmpwi cr0, r3, 0
        bne cr0, .LBB_foo_2     ; T
.LBB_foo_1:     ; F
        li r2, 16
        subf r2, r2, r1   ;; One alloca
        or r1, r2, r2
        or r3, r1, r1
        or r1, r2, r2
        or r2, r1, r1
        stw r4, 0(r3)
        stw r5, 0(r2)
        lwz r3, 0(r3)
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr
.LBB_foo_2:     ; T
        li r3, 0
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr

Now we generate:

_foo:
        stwu r1, -16(r1)
        stw r31, 4(r1)
        or r31, r1, r1
        stw r1, 12(r31)
        cmpwi cr0, r3, 0
        bne cr0, .LBB_foo_2     ; T
.LBB_foo_1:     ; F
        or r2, r1, r1
        li r3, 16
        subf r2, r3, r2  ;; Alloca 1
        or r1, r2, r2
        or r2, r1, r1
        or r6, r1, r1
        subf r3, r3, r6  ;; Alloca 2
        or r1, r3, r3
        or r3, r1, r1
        stw r4, 0(r2)
        stw r5, 0(r3)
        lwz r3, 0(r2)
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr
.LBB_foo_2:     ; T
        li r3, 0
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr

This fixes Povray and SPASS with the dag isel, the last two failing cases.
Tommorow we will hopefully turn it on by default! :)

llvm-svn: 23190
2005-09-01 21:31:30 +00:00
Chris Lattner
293b3a68e0 Fix a bug where we were useing HA to get the high part, which seems like it
could cause a miscompile.  Fixing this didn't fix the two programs that fail
though.  :(

This also changes the implementation to follow the pattern selector more
closely, causing us to select 0 to li instead of lis.

llvm-svn: 23189
2005-09-01 19:38:28 +00:00
Chris Lattner
34182aff7f Do not select the operands being passed into SelectCC. IT does this itself
and selecting early prevents folding immediates into the cmpw* instructions

llvm-svn: 23188
2005-09-01 19:20:44 +00:00
Chris Lattner
975f5c9f46 It is NDEBUG not _NDEBUG
llvm-svn: 23186
2005-09-01 18:44:10 +00:00
Nate Begeman
e8f78d1aab Add the rest of the currently implemented visit routines to the switch
statement in visit().

llvm-svn: 23185
2005-09-01 00:33:32 +00:00
Nate Begeman
21158fc485 First pass at the DAG Combiner. It isn't used anywhere yet, but it should
be mostly functional.  It currently has all folds from SelectionDAG.cpp
that do not involve a condition code.

llvm-svn: 23184
2005-09-01 00:19:25 +00:00
Nate Begeman
13990fc286 Add regression test for efficient codegen of i32 x i32 -> hi32(i64) as
mulhs.

llvm-svn: 23183
2005-09-01 00:04:03 +00:00
Chris Lattner
b3d2e7905f remove an inappropriate comment
llvm-svn: 23182
2005-08-31 22:49:51 +00:00
Chris Lattner
d4d10fff99 If a function has live ins/outs, print them
llvm-svn: 23181
2005-08-31 22:34:59 +00:00
Chris Lattner
da2e04c69d Move FCTIWZ handling out of the instruction selectors and into legalization,
getting them out of the business of making stack slots.

llvm-svn: 23180
2005-08-31 21:09:52 +00:00
Chris Lattner
6bad1fb19e Remove dead code
llvm-svn: 23179
2005-08-31 20:25:15 +00:00
Chris Lattner
e675a08e10 Move SHL,SHR i64 -> legalizer
llvm-svn: 23178
2005-08-31 20:23:54 +00:00
Chris Lattner
3a04a4b767 Remove code that is now dead from the pattern isel.
llvm-svn: 23177
2005-08-31 19:11:36 +00:00
Chris Lattner
2f03896a0f lower sra_parts on the dag, implementing it for the dag isel, and exposing
the ops to dag optimization.

llvm-svn: 23176
2005-08-31 19:09:57 +00:00
Chris Lattner
8a1a5f2818 Allow targets to custom expand shifts that are too large for their registers
llvm-svn: 23173
2005-08-31 19:01:53 +00:00
Chris Lattner
0e6b11da03 Add a testcase for nate's patch
llvm-svn: 23172
2005-08-31 18:19:50 +00:00
Chris Lattner
2bd2af8ecd add assert zext/sext to the dag isel
llvm-svn: 23171
2005-08-31 18:08:46 +00:00
Chris Lattner
46ff6aa993 Handle AssertSext/AssertZext nodes, fixing the regressions last night.
llvm-svn: 23170
2005-08-31 17:48:04 +00:00
Jeff Cohen
d8c84e3c7e Fix VC++ precedence warnings
llvm-svn: 23169
2005-08-31 02:47:06 +00:00
Nate Begeman
e3287b85b7 Enable generation of AssertSext and AssertZext in the PPC backend.
llvm-svn: 23168
2005-08-31 01:58:39 +00:00
Chris Lattner
f4d594370b Fix 'ret long' to return the high and lo parts in the right registers. This
fixes crafty and probably others.

llvm-svn: 23167
2005-08-31 01:34:29 +00:00
Nate Begeman
539e7c892c Sigh, not my day. Fix typo.
llvm-svn: 23166
2005-08-31 00:43:49 +00:00
Nate Begeman
d513d8a662 Fix a mistake in my previous patch pointed out by sabre; the AssertZext
case in MaskedValueIsZero was wrong.

llvm-svn: 23165
2005-08-31 00:43:08 +00:00
Nate Begeman
e07bc28cca Remove some unnecessary casts, and add the AssertZext case to
MaskedValueIsZero.

llvm-svn: 23164
2005-08-31 00:27:53 +00:00
Nate Begeman
ad688ddb20 Add support for count trailing zeroes, and population count. These are
needed for folding constants in the upcoming dag combiner.

llvm-svn: 23163
2005-08-31 00:25:01 +00:00
Chris Lattner
69e9a9a94c now that physregs can exist in the same dag with multiple types, remove some
ugly hacks

llvm-svn: 23162
2005-08-30 22:59:48 +00:00
Chris Lattner
5764da422a Allow physregs to occur in the dag with multiple types. Though I don't likethis, it is a requirement on PPC, which can have an f32 value in r3 at onepoint in a function and a f64 value in r3 at another point. :(
This fixes compilation of mesa

llvm-svn: 23161
2005-08-30 22:38:38 +00:00
Chris Lattner
1864662d5c Allow physregs to occur in the dag with multiple types. Though I don't like
this, it is a requirement on PPC, which can have an f32 value in r3 at one
point in a function and a f64 value in r3 at another point.  :(

llvm-svn: 23160
2005-08-30 22:38:05 +00:00
Chris Lattner
8f8d539746 Fix type mismatches when passing f32 values to calls
llvm-svn: 23159
2005-08-30 21:28:19 +00:00
Chris Lattner
4d602bed10 When checking the fixed intervals, don't forget to check for register aliases.
This fixes PR621 and Regression/CodeGen/X86/2005-08-30-RegAllocAliasProblem.ll

llvm-svn: 23158
2005-08-30 21:03:36 +00:00
Chris Lattner
38b3704d28 new testcase corresponding to PR621
llvm-svn: 23157
2005-08-30 21:02:51 +00:00
Chris Lattner
2188b4363f The dag isel misses both of these, the pattern isel just misses the second
one.  TODO :)

llvm-svn: 23156
2005-08-30 18:44:09 +00:00
Chris Lattner
9f23ae226f Fix some indentation (first hunks).
Remove code (last hunk) that miscompiled immediate and's, such as
  and uint %tmp.30, 4294958079

into

 andi. r8, r8, 56319
 andis. r8, r8, 65535

instead of:

 li r9, -9217
 and r8, r8, r9

The first always generates zero.

This fixes espresso.

llvm-svn: 23155
2005-08-30 18:37:48 +00:00
Chris Lattner
6a41fd75cd Fix a problem Nate found where we swapped the operands of SHL/SHR_PARTS. This
fixes fourinarow

llvm-svn: 23153
2005-08-30 17:42:59 +00:00
Chris Lattner
bdf3d3defb codegen ADD_PARTS correctly: put the results in the right registers! This
fixes fhourstones

llvm-svn: 23152
2005-08-30 17:40:13 +00:00
Chris Lattner
61d21b1f3c Fix FreeBench/fourinarow with the dag isel, by not adding a bogus result
to SHIFT_PARTS nodes

llvm-svn: 23151
2005-08-30 17:21:17 +00:00
Chris Lattner
45706e9fb8 add operands in the right order, fixing McCat/18-imp with the dag isel
llvm-svn: 23150
2005-08-30 17:13:58 +00:00
Chris Lattner
9a4ad487f0 Fix a miscompile of PtrDist/bc. Sign extending bools is not the right thing,
at least tends to expose problems elsewhere.

llvm-svn: 23149
2005-08-30 16:56:19 +00:00
Nate Begeman
a3da8c4819 Remove a bogus piece of my AssertSext/AssertZext patch. oops.
llvm-svn: 23148
2005-08-30 02:54:28 +00:00
Nate Begeman
43144a2fe0 Add support for AssertSext and AssertZext, folding other extensions with
them.  This allows for elminination of redundant extends in the entry
blocks of functions on PowerPC.

Add support for i32 x i32 -> i64 multiplies, by recognizing when the inputs
to ISD::MUL in ExpandOp are actually just extended i32 values and not real
i64 values.  this allows us to codegen

int mulhs(int a, int b) { return ((long long)a * b) >> 32; }
as:
_mulhs:
        mulhw r3, r4, r3
        blr

instead of:
_mulhs:
        mulhwu r2, r4, r3
        srawi r5, r3, 31
        mullw r5, r4, r5
        add r2, r2, r5
        srawi r4, r4, 31
        mullw r3, r4, r3
        add r3, r2, r3
        blr

with a similar improvement on x86.

llvm-svn: 23147
2005-08-30 02:44:00 +00:00
Nate Begeman
c9d1e370a5 Add AssertSext, AssertZext nodes for targets that pass arguments in
registers, and the incoming values have already been zero or sign extended
from the appopriate type to the register width.

llvm-svn: 23146
2005-08-30 02:39:32 +00:00
Chris Lattner
08a1e38730 Name this variable to be what it really is!
llvm-svn: 23145
2005-08-30 01:58:51 +00:00
Chris Lattner
04cb82278a Handle CopyToReg nodes with flag operands correctly
llvm-svn: 23144
2005-08-30 01:57:23 +00:00
Chris Lattner
7a59b1cf90 Make sure the selector emits register register copies with flag operands
linking them to calls when appropriate, this prevents the scheduler from
pulling these copies away from the call.

This fixes Ptrdist/yacr2

llvm-svn: 23143
2005-08-30 01:57:02 +00:00
Chris Lattner
709190d540 add some method variants
llvm-svn: 23142
2005-08-30 01:56:13 +00:00
Chris Lattner
e413b60632 The first operand to AND does not always have more than two operands. This
fixes MediaBench/toast with the dag selector

llvm-svn: 23141
2005-08-30 00:59:16 +00:00
Chris Lattner
e75b5e63a7 Fix a bug in my patch for legalizing to fsel. It cannot handle seteq/setne,
which I failed to include when I moved the code over.  This fixes
MallocBench/gs.

llvm-svn: 23140
2005-08-30 00:45:18 +00:00
Chris Lattner
61f7c3e843 emit FMR instructions to convert f64<->f32 instructions, so things like
STOREs, know the right type to store.

llvm-svn: 23139
2005-08-30 00:30:43 +00:00
Chris Lattner
62b9a5d1f8 Fix some really strange indentation that xcode likes to use.
no xcode, this is not right:

   if (!foo) break;
     X;

llvm-svn: 23138
2005-08-30 00:19:00 +00:00
Chris Lattner
12357281b8 fix a crash in cfrac
llvm-svn: 23137
2005-08-29 23:49:25 +00:00
Chris Lattner
1cbbe1015a Implement DYNAMIC_STACKALLOC, wrap some long lines
llvm-svn: 23136
2005-08-29 23:30:11 +00:00
Chris Lattner
f7e5ec84c6 Add a hack to avoid some horrible code in some cases by always emitting
token chains first.  For this C function:

int test() {
  int i;
  for (i = 0; i < 100000; ++i)
    foo();
}

Instead of emitting this (condition before call)

.LBB_test_1:    ; no_exit
        addi r30, r30, 1
        lis r2, 1
        ori r2, r2, 34464
        cmpw cr2, r30, r2
        bl L_foo$stub
        bne cr2, .LBB_test_1    ; no_exit

Emit this:

.LBB_test_1:    ; no_exit
        bl L_foo$stub
        addi r30, r30, 1
        lis r2, 1
        ori r2, r2, 34464
        cmpw cr0, r30, r2
        bne cr0, .LBB_test_1    ; no_exit

Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.

This also makes the code much more similar to what the pattern isel produces.

llvm-svn: 23135
2005-08-29 23:21:29 +00:00
Chris Lattner
0d45ee4a06 improve comment
llvm-svn: 23134
2005-08-29 22:48:32 +00:00
Chris Lattner
b2b418509b Fix a dumb bug of mine where we were mishandling the PPC ABI (undef handling).
This fixes voronoi and bh in Olden, allowing all of olden to pass!

llvm-svn: 23133
2005-08-29 22:22:57 +00:00
Chris Lattner
3439ccce4d Add a new API for nate
llvm-svn: 23132
2005-08-29 22:00:00 +00:00
Chris Lattner
c738d000d5 Add a new API for Nate
llvm-svn: 23131
2005-08-29 21:59:31 +00:00
Andrew Lenharth
835cbb364d Some of us cared about the the promote path
llvm-svn: 23130
2005-08-29 20:46:51 +00:00
Chris Lattner
dcde1b2b6a Fix an infinite loop on x86
llvm-svn: 23129
2005-08-29 17:30:00 +00:00
Chris Lattner
1a1ecf0679 Allow bugpoint+PPC codegen to use fsqrt
llvm-svn: 23128
2005-08-29 13:14:24 +00:00
Chris Lattner
c429ab2fb1 Fix a bug the last patch exposed in treeadd among others
llvm-svn: 23127
2005-08-29 01:07:02 +00:00
Chris Lattner
d4d683a47b A hack to fix a problem folding immedaites. This fixes Olden/power.
llvm-svn: 23126
2005-08-29 01:01:01 +00:00
Chris Lattner
3ccad3fb8c Fix order of operands for copytoreg node when emitting calls. This fixes
Olden/msFix order of operands for copytoreg node when emitting calls.  This fixes
Olden/mstt.

llvm-svn: 23125
2005-08-29 00:26:57 +00:00
Chris Lattner
46d4c75cd1 Fix a bug in my previous patch that was using the wrong iterator. This fixes
Olden/bisort among others.

llvm-svn: 23124
2005-08-29 00:10:46 +00:00
Chris Lattner
66ddc8d3bf add operands in the correct order
llvm-svn: 23123
2005-08-29 00:02:01 +00:00
Chris Lattner
87421c8658 Fix a bug in ReplaceAllUsesWith
llvm-svn: 23122
2005-08-28 23:59:36 +00:00
Chris Lattner
dfcde88d07 Fix a bug in FP_EXTEND, implement FP_TO_SINT
llvm-svn: 23121
2005-08-28 23:59:09 +00:00
Chris Lattner
38660c6666 fix an assertion failure in treeadd
llvm-svn: 23120
2005-08-28 23:39:22 +00:00
Reid Spencer
aa7fbca285 Adjust to member variable name change.
llvm-svn: 23119
2005-08-27 19:09:48 +00:00
Reid Spencer
85d93a3ec9 Change the names of member variables per Chris' instructions, and document
them more clearly.

llvm-svn: 23118
2005-08-27 19:09:02 +00:00
Reid Spencer
3f0a2493a5 Fix a typo.
llvm-svn: 23117
2005-08-27 19:06:05 +00:00
Reid Spencer
dfb3fb4a25 Implement PR614:
These changes modify the makefiles so that the output of flex and bison are
placed in the SRC directory, not the OBJ directory. It is intended that they
be checked in as any other LLVM source so that platforms without convenient
access to flex/bison can be compiled. From now on, if you change a .y or
.l file you *must* also commit the generated .cpp and .h files.

llvm-svn: 23115
2005-08-27 18:50:39 +00:00
Chris Lattner
075250bda1 Disable this code, which broke many tests last night
llvm-svn: 23114
2005-08-27 16:16:51 +00:00
Chris Lattner
5ee85e89b6 fix PHI node emission for basic blocks that have select_cc's in them on ppc32
llvm-svn: 23113
2005-08-27 00:58:02 +00:00
Chris Lattner
787e962795 The condition register being branched on may not be cr0, as such, print it.
This fixes: UnitTests/2005-07-17-INT-To-FP.c

llvm-svn: 23112
2005-08-26 23:42:05 +00:00
Chris Lattner
29bfaa7ef0 Propagate cr# from COND_BRANCH to the actual branch instruction as appropriate
llvm-svn: 23111
2005-08-26 23:41:27 +00:00
Chris Lattner
56ca46ee04 Nate noticed that Andrew never did this. This fixes PR600
llvm-svn: 23110
2005-08-26 22:50:40 +00:00
Chris Lattner
e7a2998064 Don't copy regs that are only used in the entry block into a vreg. This
changes the code generated for:

short %test(short %A) {
  %B = xor short %A, -32768
  ret short %B
}

to:

_test:
        xori r2, r3, 32768
        xoris r2, r2, 65535
        extsh r3, r2
        blr

instead of:

_test:
        rlwinm r2, r3, 0, 16, 31
        xori r2, r3, 32768
        xoris r2, r2, 65535
        extsh r3, r2
        blr

llvm-svn: 23109
2005-08-26 22:49:59 +00:00
Chris Lattner
d4f43f7967 Make this code safe for when loadRegFromStackSlot inserts multiple instructions.
llvm-svn: 23108
2005-08-26 22:18:32 +00:00
Chris Lattner
422e23dd02 allow code using mtcrf to assemble
llvm-svn: 23107
2005-08-26 22:05:54 +00:00
Nate Begeman
72f23815bc Remove operand type 'crbit', since it is no longer used
llvm-svn: 23106
2005-08-26 22:04:17 +00:00
Chris Lattner
c3d1bdd0a9 teach getClass what a condition reg is
llvm-svn: 23105
2005-08-26 21:51:29 +00:00
Chris Lattner
97345405a6 Minor cleanups:
* avoid calling getClass() multiple times (it is relatively expensive)
  * Allow -disable-fp-elim to turn of frame pointer elimination.

llvm-svn: 23104
2005-08-26 21:49:18 +00:00
Chris Lattner
4a5ebe94ba Checking types here is not safe, because multiple types can map to the same
register class.

llvm-svn: 23103
2005-08-26 21:39:15 +00:00
Chris Lattner
9b577f108a implement SELECT_CC fully for the DAG->DAG isel!
llvm-svn: 23101
2005-08-26 21:23:58 +00:00
Chris Lattner
db88626603 add some forward defs
llvm-svn: 23100
2005-08-26 21:06:40 +00:00
Chris Lattner
c6a0338c04 spell this right
llvm-svn: 23099
2005-08-26 20:55:40 +00:00
Chris Lattner
13d7c252e5 Call the InsertAtEndOfBasicBlock hook if the usesCustomDAGSchedInserter
flag is set on an instruction.

llvm-svn: 23098
2005-08-26 20:54:47 +00:00
Chris Lattner
17c28fa36b spell this right!
llvm-svn: 23097
2005-08-26 20:53:44 +00:00
Chris Lattner
84a1100dab Add a hook
llvm-svn: 23096
2005-08-26 20:53:09 +00:00
Chris Lattner
63dc7f569a spell this variable right
llvm-svn: 23095
2005-08-26 20:42:52 +00:00
Chris Lattner
3d9fbefbf7 Expose a new flag to TargetInstrInfo
llvm-svn: 23094
2005-08-26 20:40:46 +00:00
Chris Lattner
fada82fbb5 Add a new instruction flag
llvm-svn: 23093
2005-08-26 20:31:24 +00:00
Chris Lattner
0081dfa91e Add a flag
llvm-svn: 23092
2005-08-26 20:29:01 +00:00
Chris Lattner
b2854fadda Make fsel emission work with both the pattern and dag-dag selectors, by
giving it a non-instruction opcode.  The dag->dag selector used to not
select the operands of the fsel, because it thought that whole tree was
already selected.

llvm-svn: 23091
2005-08-26 20:25:03 +00:00
Chris Lattner
c36c9bdb5d add a marker at the end of the instruction enum list
llvm-svn: 23090
2005-08-26 20:17:00 +00:00
Chris Lattner
bec817ce6f implement the fold for:
bool %test(int %X, int %Y) {
        %C = setne int %X, 0
        ret bool %C
}

to:

_test:
        addic r2, r3, -1
        subfe r3, r2, r3
        blr

llvm-svn: 23089
2005-08-26 18:46:49 +00:00
Chris Lattner
a9e6a82d66 Changes to adjust to new ReplaceAllUsesWith syntax. Change FP_EXTEND to
just return its input, instead of emitting an explicit copy.

llvm-svn: 23088
2005-08-26 18:37:23 +00:00
Chris Lattner
373f048a79 Revampt ReplaceAllUsesWith to be more efficient and easier to use.
llvm-svn: 23087
2005-08-26 18:36:28 +00:00
Chris Lattner
fa0be24960 Add a new version of ReplaceAllUsesWith, make the comments more useful.
llvm-svn: 23086
2005-08-26 18:35:58 +00:00
Nate Begeman
76eea9a480 Remove some code made dead by the fsel patch
llvm-svn: 23085
2005-08-26 17:45:06 +00:00
Chris Lattner
c75e047245 now that fsel is formed during legalization, this code is dead
llvm-svn: 23084
2005-08-26 17:40:39 +00:00
Chris Lattner
7f1fa8eaef implement the other half of the select_cc -> fsel lowering, which handles
when the RHS of the comparison is 0.0.  Turn this on by default.

llvm-svn: 23083
2005-08-26 17:36:52 +00:00
Chris Lattner
d0dc6f4299 Fix a bug in my previous checkin
llvm-svn: 23082
2005-08-26 17:18:44 +00:00
Chris Lattner
c30405e0ee Change ConstantPoolSDNode to actually hold the Constant itself instead of
putting it into the constant pool.  This allows the isel machinery to
create constants that it will end up deciding are not needed, without them
ending up in the resultant function constant pool.

llvm-svn: 23081
2005-08-26 17:15:30 +00:00
Chris Lattner
7bbdae53d6 Fix some warnings in an optimized build
llvm-svn: 23080
2005-08-26 16:38:51 +00:00
Chris Lattner
2091a36631 Fix a huge annoyance: SelectNodeTo took types before the opcode unlike
every other SD API.  Fix it to take the opcode before the types.

llvm-svn: 23079
2005-08-26 16:36:26 +00:00
Jim Laskey
d6281ce4fe Changed unsigned long to unsigned.
llvm-svn: 23078
2005-08-26 09:25:54 +00:00
Jim Laskey
6e07862be6 Change unsigned lng to unsigned.
llvm-svn: 23077
2005-08-26 09:24:46 +00:00
Nate Begeman
7b809f593b Fix JIT encoding of conditional branches
llvm-svn: 23076
2005-08-26 04:11:42 +00:00
Chris Lattner
f3d06c6417 add initial support for converting select_cc -> fsel in the legalizer
instead of in the backend.  This currently handles fsel cases with registers,
but doesn't have the 0.0 and -0.0 optimization enabled yet.

Once this is finished, special hack for fp immediates can go away.

llvm-svn: 23075
2005-08-26 00:52:45 +00:00
Chris Lattner
c6d481db7a the 5th operand is the 4th number
llvm-svn: 23074
2005-08-26 00:43:46 +00:00
Nate Begeman
89093ca62a SUBFIC produces two results, not one.
llvm-svn: 23073
2005-08-26 00:34:06 +00:00
Nate Begeman
bed4f2b982 Implement SHL_PARTS and SRL_PARTS
llvm-svn: 23072
2005-08-26 00:28:00 +00:00
Chris Lattner
5f573416cd Add support for targets that want to custom expand select_cc in some cases.
llvm-svn: 23071
2005-08-26 00:23:59 +00:00
Chris Lattner
dff50cadaa Allow LowerOperation to return a null SDOperand in case it wants to lower
some things given to it, but not all.

llvm-svn: 23070
2005-08-26 00:14:16 +00:00
Chris Lattner
1cb550c603 Fix a nasty bug from a previous patch of mine
llvm-svn: 23069
2005-08-26 00:13:12 +00:00
Chris Lattner
b81431b012 Emit the lo/hi parts in the right order :)
llvm-svn: 23068
2005-08-25 23:36:49 +00:00
Jim Laskey
fb855ee072 Added cl::bits option type (bit vectors). See "Collecting options as a set
of flags" in the Command Line doc.

llvm-svn: 23067
2005-08-25 23:31:45 +00:00
Chris Lattner
02884fe41c implement support for 64-bit add/sub, fix a broken assertion for 64-bit
return.  Allow the udiv breaker-upper to work with any non-zero constant
operand.

llvm-svn: 23066
2005-08-25 23:21:06 +00:00
Chris Lattner
abbd8ea048 simplify the add/sub_parts code
llvm-svn: 23065
2005-08-25 23:19:58 +00:00
Jim Laskey
a82d08f8ba Tweak of multiple occurance paragraph.
llvm-svn: 23064
2005-08-25 23:01:25 +00:00
Jim Laskey
295810d53f Documentation updated to include upcoming support for bit vector support
(flags.)

llvm-svn: 23063
2005-08-25 22:52:43 +00:00
Chris Lattner
6e184f2b3d Finish implementing SDIV/UDIV by copying over the majik constant code from
ISelPattern

llvm-svn: 23062
2005-08-25 22:04:30 +00:00
Chris Lattner
717f97a5c8 Simplify some code. It's not clear why the UDIV expanded sequence
doesn't work for large uint constants, but we'll keep the current behavior

llvm-svn: 23061
2005-08-25 22:03:50 +00:00
Chris Lattner
b746dd1cf6 Implement setcc correctly for G5 and non-G5 systems
llvm-svn: 23060
2005-08-25 21:39:42 +00:00
Chris Lattner
3dcd75bc54 implement setcc on the G5. We're still missing the non-g5 specific bits, but
they will come later.

llvm-svn: 23059
2005-08-25 20:08:18 +00:00
Nate Begeman
33840c3268 New fold for SELECT_CC
llvm-svn: 23058
2005-08-25 20:04:38 +00:00
Nate Begeman
65ffd8fbf4 Remove option to make SetCC illegal on PowerPC after long discussion with
Chris.  This will be accomplished through correctly modeling CR's and
subregs.

llvm-svn: 23056
2005-08-25 20:01:10 +00:00
Chris Lattner
f9c19157df Don't auto-cse nodes that return flags
llvm-svn: 23055
2005-08-25 19:12:10 +00:00
Chris Lattner
12756be53b add printer support for flag operands
llvm-svn: 23054
2005-08-25 17:59:23 +00:00
Chris Lattner
9d28a56d55 simplify the code a bit using isOperationLegal
llvm-svn: 23053
2005-08-25 17:54:58 +00:00
Chris Lattner
dc66457022 Add support for sdiv by 2^k and -2^k. Producing code like:
_test:
        srawi r2, r3, 2
        addze r3, r2
        blr

llvm-svn: 23052
2005-08-25 17:50:06 +00:00
Chris Lattner
4bd2aab6c1 fit in 80 cols
llvm-svn: 23051
2005-08-25 17:49:31 +00:00
Chris Lattner
8a93f64efa Add support for flag operands
llvm-svn: 23050
2005-08-25 17:48:54 +00:00
Chris Lattner
5ac0805b5e add a method
llvm-svn: 23049
2005-08-25 17:24:09 +00:00
Chris Lattner
d24ad52efa add an enum value
llvm-svn: 23048
2005-08-25 17:07:09 +00:00
Jim Laskey
7da6420a23 Remove Support/Search.h entry
llvm-svn: 23047
2005-08-25 16:44:13 +00:00
Jim Laskey
9fda3a799c Recommended to use std::algorithms instead.
llvm-svn: 23046
2005-08-25 16:21:56 +00:00
Jim Laskey
807c3460d7 Added Support/Search.h to project.
llvm-svn: 23045
2005-08-25 13:42:04 +00:00
Jim Laskey
aabf3e2bf1 Added support for generic linear/binary search.
llvm-svn: 23044
2005-08-25 13:32:25 +00:00
Chris Lattner
1db9de30ea Fix a problem Duraid noticed, where we weren't removing values from the kills
list when doing two-address and phi node lowering during register allocation.

llvm-svn: 23043
2005-08-25 05:45:31 +00:00
Chris Lattner
25db699671 Implement support for taking the address of constant pool indices, which
is used by the int -> FP code among other things.  This gets
2005-05-12-Int64ToFP past that failure, to dying on lack of support for add_parts

llvm-svn: 23042
2005-08-25 05:04:11 +00:00
Chris Lattner
407c6415b4 ADd support for TargetConstantPool nodes
llvm-svn: 23041
2005-08-25 05:03:06 +00:00
Chris Lattner
79b8dad7ea Add support for TargetConstantPool node
llvm-svn: 23040
2005-08-25 05:02:41 +00:00
Reid Spencer
53846bcdb6 For PR614:
Move the implementation of the fix from Makefile.rules to Makefile. This
ensures that it is only checked on a top-level rebuild, and not in every
single subdirectory. This removes some annoying messages from the build and
numerous executions of config.status if the .in file changes but not
substantively enough to cause the .h file to be modified by config.status.

llvm-svn: 23039
2005-08-25 04:59:49 +00:00
Chris Lattner
666512c832 Add support for FP constants, fixing UnitTests/2004-02-02-NegativeZero
llvm-svn: 23038
2005-08-25 04:47:18 +00:00
Reid Spencer
83bde55c64 Don't attempt to update LLVM configured header files from a build in a
project. Thanks to Chris for pointing out this deficiency.

llvm-svn: 23037
2005-08-25 04:44:18 +00:00
Chris Lattner
e4c338d0d8 Fully implement frame index, so that we can pass the address of alloca's
around to functions and stuff

llvm-svn: 23036
2005-08-25 00:45:43 +00:00
Chris Lattner
bbe0e7df2c add a new TargetFrameIndex node
llvm-svn: 23035
2005-08-25 00:43:01 +00:00
Chris Lattner
66a6a13225 implement unconditional branches, fixing UnitTests/2003-05-02-DependentPHI.c
llvm-svn: 23034
2005-08-25 00:29:58 +00:00
Chris Lattner
4ae278a760 LFS/STFS load and store FP values, not integer ones. This change allows us
to codegen this: float foo() { return 1.245; }

into this:

_foo:
        lis r2, ha16(.CPI_foo_0)
        lfs f1, lo16(.CPI_foo_0)(r2)
        blr

instead of this:

_foo:
        lis r2, ha16(.CPI_foo_0)
        lfs r2, lo16(.CPI_foo_0)(r2)   <-- ouch
        or f1, r2, r2                  <-- ouch
        blr

with the dag isel.

llvm-svn: 23033
2005-08-25 00:26:22 +00:00
Chris Lattner
794eb6684d Fix a broken assertion
llvm-svn: 23032
2005-08-25 00:19:12 +00:00
Chris Lattner
c146940f0d Fix a warning
llvm-svn: 23031
2005-08-25 00:05:15 +00:00
Chris Lattner
daae1e10f7 fix a warning in optimized build
llvm-svn: 23030
2005-08-25 00:03:21 +00:00
Chris Lattner
751c6c3944 Fix some warnings
llvm-svn: 23029
2005-08-25 00:00:26 +00:00
Chris Lattner
a3fbdae515 Split IMPLICIT_DEF into IMPLICIT_DEF_GPR and IMPLICIT_DEF_FP, so that the
instructions take a consistent reg class.  Implement ISD::UNDEF in the dag->dag
selector to generate this, fixing UnitTests/2003-07-06-IntOverflow.

llvm-svn: 23028
2005-08-24 23:08:16 +00:00
Chris Lattner
45e1ce4e28 add a method
llvm-svn: 23027
2005-08-24 23:00:29 +00:00
Chris Lattner
d83cd354bd implement support for calls
llvm-svn: 23026
2005-08-24 22:45:17 +00:00
Chris Lattner
d7ee4d8671 Add ReplaceAllUsesWith that can take a vector of replacement values.
Add some foldings to hopefully help the illegal setcc issue, and move some code around.

llvm-svn: 23025
2005-08-24 22:44:39 +00:00
Chris Lattner
9130192229 add two new methods
llvm-svn: 23024
2005-08-24 22:43:53 +00:00
Chris Lattner
1fc2a7f006 Remove some dead cases.
Emit the indcall sequence as:

mtctr inreg
mr R12, inreg
btctr

If inreg and R12 aren't coallesced, this reduces the odds of having the mtctr
and btctr in the same dispatch group.  :)

llvm-svn: 23023
2005-08-24 22:21:47 +00:00
Chris Lattner
ad9565dfbe Add support for external symbols, and support for variable arity instructions
llvm-svn: 23022
2005-08-24 22:02:41 +00:00
Chris Lattner
bb8cc0acb2 Fix pasto that prevented VT ndoes from showing up in -view-isel-dags correctly
llvm-svn: 23021
2005-08-24 18:30:00 +00:00
Chris Lattner
1e98a330f2 add an idea
llvm-svn: 23020
2005-08-24 18:15:24 +00:00
Chris Lattner
8ca5b2a6d2 Fix Regression/Transforms/Reassociate/2005-08-24-Crash.ll
llvm-svn: 23019
2005-08-24 17:55:32 +00:00
Chris Lattner
347f5cb985 new testcase that crashes -reassociate
llvm-svn: 23018
2005-08-24 17:54:56 +00:00
Chris Lattner
4201cd1bbc Transform floor((double)FLT) -> (double)floorf(FLT), implementing
Regression/Transforms/SimplifyLibCalls/floor.ll.  This triggers 19 times in
177.mesa.

llvm-svn: 23017
2005-08-24 17:22:17 +00:00
Chris Lattner
16a382df29 new testcase
llvm-svn: 23016
2005-08-24 17:20:30 +00:00
Chris Lattner
898e50ecb3 floor/ceil don't read/write memory. This allows gcse to eliminate 6 calls
in mesa.

llvm-svn: 23015
2005-08-24 16:58:56 +00:00
Chris Lattner
03e64f6c1e Make sure this doesn't break when we're improving the isels
llvm-svn: 23014
2005-08-24 16:48:49 +00:00
Chris Lattner
86b1658d58 teach selection dag mask tracking about the fact that select_cc operates like
select.  Also teach it that the bit count instructions can only set the low bits
of the result, depending on the size of the input.

This allows us to compile this:

int %eq0(int %a) {
        %tmp.1 = seteq int %a, 0                ; <bool> [#uses=1]
        %tmp.2 = cast bool %tmp.1 to int                ; <int> [#uses=1]
        ret int %tmp.2
}

To this:

_eq0:
        cntlzw r2, r3
        srwi r3, r2, 5
        blr

instead of this:

_eq0:
        cntlzw r2, r3
        rlwinm r3, r2, 27, 31, 31
        blr

when setcc is marked illegal on ppc (which restores parity to non-illegal
setcc).  Thanks to Nate for pointing this out.

llvm-svn: 23013
2005-08-24 16:46:55 +00:00
Chris Lattner
f12eb4d676 Start using isOperationLegal and isTypeLegal to simplify the code
llvm-svn: 23012
2005-08-24 16:35:28 +00:00
Chris Lattner
5ff1bf4f0a rename hasNativeSupportFor* -> is(Operation|Type)Legal.
llvm-svn: 23011
2005-08-24 16:34:59 +00:00
Chris Lattner
ade525491f Adjust to new interface
llvm-svn: 23010
2005-08-24 16:34:12 +00:00
Misha Brukman
28a0d918c1 Wrap long lines
llvm-svn: 23009
2005-08-24 14:03:07 +00:00
Reid Spencer
87f95722b2 Remove some tabs.
Wrap a line.

llvm-svn: 23008
2005-08-24 10:57:30 +00:00
Reid Spencer
bfb0c16606 Whoops, don't use PROJ variables, these are all LLVM headers. This allows
projects to compile properly.

llvm-svn: 23007
2005-08-24 10:55:07 +00:00
Reid Spencer
b48e3f8b74 For PR619:
Make any header files that are automatically generated be preconditions of
the compilation. This ensures that if a *.h.in file is changed then its
corresponding *.h file gets updated on the next rebuild. Note that this can
lead to confusing (but correct) results if the *.h.in file changed
unsubstantially so that autoheader doesn't update the *.h file. In that case,
manually touch the *.h file in question to restore order. Moral of the story,
if you're going to "touch" a *.in file then modify it substantially.

llvm-svn: 23006
2005-08-24 10:43:10 +00:00
Reid Spencer
f85fabeb71 For PR616:
These patches make threading optional in LLVM. The configuration scripts are now
modified to accept a --disable-threads switch. If this is used, the Mutex class
will be implemented with all functions as no-op. Furthermore, linking against
libpthread will not be done. Finally, the ParallelJIT example needs libpthread
so its makefile was changed to always add -lpthread to the link line.

llvm-svn: 23003
2005-08-24 10:07:20 +00:00
Nate Begeman
7c1ba938be Whoops, fix a thinko. All cases except SETNE are now handled by the
target independent code in SelectionDAG.cpp

llvm-svn: 23002
2005-08-24 05:06:48 +00:00
Nate Begeman
a1e0a2f72b Remove unused statistic
Prefer 'neg X' to 'subfic 0, X' since neg does not set XER[CA]

llvm-svn: 23001
2005-08-24 05:03:20 +00:00
Nate Begeman
6948b79b26 Add the "ppc specific" setcc-equivalent select_cc cases
Prefer 'neg X' to 'subfic 0, X' since it does not set XER[CA]

llvm-svn: 23000
2005-08-24 04:59:21 +00:00
Nate Begeman
45bbbb3f11 Teach SelectionDAG how to simplify a few more setcc-equivalent select_cc
nodes so that backends don't have to.

llvm-svn: 22999
2005-08-24 04:57:57 +00:00
Chris Lattner
b6d034a841 Add callseq_begin/end support
Call stil not supported yet

llvm-svn: 22998
2005-08-24 00:47:15 +00:00
Chris Lattner
99282c7b92 Make -view-isel-dags show the dag before instruction selecting, in case
the target isel crashes due to unimplemented features like calls :)

llvm-svn: 22997
2005-08-24 00:34:29 +00:00
Nate Begeman
72eab5dd5c Fix optimization of select_cc seteq X, 0, 1, 0 -> srl (ctlz X), log2 X size
llvm-svn: 22995
2005-08-24 00:21:28 +00:00
Chris Lattner
eeacce5a60 Implement LiveVariables.h change
llvm-svn: 22994
2005-08-24 00:09:33 +00:00
Chris Lattner
ff978b6d76 Keep the killed/dead sets sorted, so that "KillsRegister" can do a quick
binary search to test for membership.  This speeds up LLC a bit more on KC++,
e.g. on itanium from 16.6974s to 14.8272s, PPC from 11.4926s to 10.7089s and
X86 from 10.8128s to 9.7943s, with no difference in generated code (like all
of the RA patches).

With these changes, isel is the slowest pass for PPC/X86, but linscan+live
intervals is still > 50% of the compile time for itanium.  More work could
be done, but this is the last for now.

llvm-svn: 22993
2005-08-24 00:09:02 +00:00
Chris Lattner
469652752c adjust to new live variables interface
llvm-svn: 22992
2005-08-23 23:42:17 +00:00
Chris Lattner
cdc0cbbcd0 Adjust to new livevars interface
llvm-svn: 22991
2005-08-23 23:41:14 +00:00
Chris Lattner
9fa2f949ae Change live variables from using multimaps to using maps of vectors and
rearrange some of the accessors to be more efficient.

This makes it much more efficient to iterate over all of the things with the
same value.  This speeds up liveintervals analysis from 8.63s to 3.79s with
a release build of llc on kc++ with -march=ia64.  This also speeds up live
var from 1.66s -> 0.87s as well, reducing total llc time from 20.1s->15.2s.

This also speeds up other targets slightly, e.g. llc time on X86 from 16.84
-> 16.45s, and PPC from 17.64->17.03s.

llvm-svn: 22990
2005-08-23 23:40:41 +00:00
Chris Lattner
774158239b Simplify this code by using higher-level LiveVariables methods
llvm-svn: 22989
2005-08-23 22:51:41 +00:00
Chris Lattner
7c1c6e06f3 Simplify this code by using LiveVariables::KillsRegister
llvm-svn: 22988
2005-08-23 22:49:55 +00:00
Chris Lattner
59057175ee Add RegisterDefIsDead to correspond to KillsRegister, mark both const
llvm-svn: 22987
2005-08-23 22:43:24 +00:00
Chris Lattner
22e91cc3b5 Keep track of which registers are related to which other registers.
Use this information to avoid doing expensive interval intersections for
registers that could not possible be interesting.  This speeds up linscan
on ia64 compiling kc++ in release mode from taking 7.82s to 4.8s(!), total
itanium llc time on this program is 27.3s now.  This marginally speeds up
PPC and X86, but they appear to be limited by other parts of linscan, not
this code.

On this program, on itanium, live intervals now takes 41% of llc time.

llvm-svn: 22986
2005-08-23 22:27:31 +00:00
Chris Lattner
808a9bdb13 add a method
llvm-svn: 22985
2005-08-23 21:45:31 +00:00
Chris Lattner
9c0a243ce5 Fix PR618 and Regression/CodeGen/CBackend/2005-08-23-Fmod.ll by not emitting
x%y for 'rem' on fp values.

llvm-svn: 22984
2005-08-23 20:22:50 +00:00
Chris Lattner
65de2689b4 New testcase for PR618
llvm-svn: 22983
2005-08-23 20:22:07 +00:00
Chris Lattner
5e3953d761 add a note
llvm-svn: 22982
2005-08-23 06:27:59 +00:00
Nate Begeman
f3ce09b36e Ack, typo
llvm-svn: 22981
2005-08-23 05:45:10 +00:00
Nate Begeman
7216ad415b Add an option to make SetCC illegal as a beta option
llvm-svn: 22979
2005-08-23 05:42:36 +00:00
Nate Begeman
bf8c3939d7 Teach the SelectionDAG how to transform select_cc eq, X, 0, 1, 0 into
either seteq X, 0 or srl (ctlz X), size(X-1), depending on what's legal
for the target.

llvm-svn: 22978
2005-08-23 05:41:12 +00:00
Nate Begeman
987121a61a Teach Legalize how to turn setcc into select_cc
llvm-svn: 22977
2005-08-23 04:29:48 +00:00
Nate Begeman
06436b2b7d Remove some instructions we no longer generate
llvm-svn: 22976
2005-08-23 01:16:46 +00:00
Chris Lattner
46323cf0e2 Remove some regs that are not used.
llvm-svn: 22975
2005-08-22 22:32:13 +00:00
Chris Lattner
956820d989 Nate noticed that 30% of the malloc/frees in llc come from calls to LowercaseString
in the asmprinter.  This changes the .td files to use lower case register names,
avoiding the need to do this call.  This speeds up the asmprinter from 1.52s
to 1.06s on kc++ in a release build.

llvm-svn: 22974
2005-08-22 22:00:02 +00:00
Chris Lattner
d2f2aff484 Fix a crash I introduced into the IA64 backend with my copyfromreg change.
It used to crash on any function that took float arguments.

llvm-svn: 22973
2005-08-22 21:33:11 +00:00
Chris Lattner
834a2316a3 Try to avoid scanning the fixed list. On architectures with a non-stupid
number of regs (e.g. most riscs), many functions won't need to use callee
clobbered registers.  Do a speculative check to see if we can get a free
register without processing the fixed list (which has all of these).  This
saves a lot of time on machines with lots of callee clobbered regs (e.g.
ppc and itanium, also x86).

This reduces ppc llc compile time from 184s -> 172s on kc++.  This is probably
worth FAR FAR more on itanium though.

llvm-svn: 22972
2005-08-22 20:59:30 +00:00
Chris Lattner
95a157ae1a Move some code in the register assignment case that only needs to happen if
we spill out of the fast path.  The scan of active_ and the calls to
updateSpillWeights don't need to happen unless a spill occurs.  This reduces
debug llc time of kc++ with ppc from 187.3s to 183.2s.

llvm-svn: 22971
2005-08-22 20:20:42 +00:00
Chris Lattner
9d46518e5c Add a pass name for -time-passes output
llvm-svn: 22970
2005-08-22 18:28:09 +00:00
Chris Lattner
7f9e078d11 Fix a problem where constant expr shifts would not have their shift amount
promoted to the right type.  This fixes: IA64/2005-08-22-LegalizerCrash.ll

llvm-svn: 22969
2005-08-22 17:28:31 +00:00
Chris Lattner
db5f4fd643 Testcase for a crash in the legalizer on ia64. This is reduced from kc++.
llvm-svn: 22968
2005-08-22 17:16:49 +00:00
Chris Lattner
2ea31c09da Add a long-overdue itanium regression test dir: hint hint Duraid :)
llvm-svn: 22967
2005-08-22 17:15:41 +00:00
Chris Lattner
83b821b584 Speed up this loop a bit, based on some observations that Nate made, and
add some comments.  This loop really needs to be reevaluated!

llvm-svn: 22966
2005-08-22 16:55:22 +00:00
Chris Lattner
d50b29a256 Revert my patch which changed the code to not work.
llvm-svn: 22965
2005-08-22 16:24:25 +00:00
Chris Lattner
60aba18664 Make the example a bit easier to understand, suggested by Jim.
llvm-svn: 22964
2005-08-22 16:11:46 +00:00
Chris Lattner
ca0c0d7550 Implement stores.
llvm-svn: 22963
2005-08-22 01:27:59 +00:00
Chris Lattner
92626b9bc5 Add a fast-path for register values. Add support for constant pool entries,
allowing us to compile this:

float %test2(float* %P) {
        %Q = load float* %P
        %R = add float %Q, 10.1
        ret float %R
}

to this:

_test2:
        lfs r2, 0(r3)
        lis r3, ha16(.CPI_test2_0)
        lfs r3, lo16(.CPI_test2_0)(r3)
        fadds f1, r2, r3
        blr

llvm-svn: 22962
2005-08-22 01:04:32 +00:00
Chris Lattner
1d634b2f44 Fix compilation of:
float %test2(float* %P) {
        %Q = load float* %P
        %R = add float %Q, %Q
        ret float %R
}

By returning the right result.

llvm-svn: 22961
2005-08-22 00:59:14 +00:00
Chris Lattner
b676e5a666 Make sure expressions only have one use before emitting them into a place that is conditionally executed
llvm-svn: 22960
2005-08-22 00:47:28 +00:00
Chris Lattner
c5292ec9de Implement most of load support. There is still a bug though.
llvm-svn: 22959
2005-08-21 22:31:09 +00:00
Chris Lattner
f4dcbc0b98 add a method
llvm-svn: 22958
2005-08-21 22:30:42 +00:00
Chris Lattner
466fecee19 add anew method
llvm-svn: 22957
2005-08-21 22:30:30 +00:00
Chris Lattner
4866356907 Add support for frame index nodes
llvm-svn: 22956
2005-08-21 19:56:04 +00:00
Chris Lattner
0548f50501 add a method
llvm-svn: 22955
2005-08-21 19:48:59 +00:00
Chris Lattner
433390fba2 ADd a method
llvm-svn: 22954
2005-08-21 19:48:53 +00:00
Chris Lattner
968aeb18b0 Don't print out the MBB label for the entry mbb
llvm-svn: 22953
2005-08-21 19:09:33 +00:00
Chris Lattner
519acbfb76 Simplify the logic for BRTWOWAY_CC handling. The isel code already
simplifies BRTWOWAY into BR if one of the results is a fall-through.
Unless I'm missing something, there is no reason to duplicate this
in the target-specific code.

llvm-svn: 22952
2005-08-21 19:03:28 +00:00
Chris Lattner
2a1823d178 Implement selection for branches.
llvm-svn: 22951
2005-08-21 18:50:37 +00:00
Chris Lattner
46059044c6 Add 5-operand version of SelectNodeTo
llvm-svn: 22950
2005-08-21 18:49:58 +00:00
Chris Lattner
707b39fb8c add a method
llvm-svn: 22949
2005-08-21 18:49:33 +00:00
Chris Lattner
154b2bc59b Add support for basic blocks, fix a bug in result # computation
llvm-svn: 22948
2005-08-21 18:49:29 +00:00
Chris Lattner
539c3fa863 When legalizing brcond ->brcc or select -> selectcc, make sure to truncate
the old condition to a one bit value.  The incoming value must have been
promoted, and the top bits are undefined.  This causes us to generate:

_test:
        rlwinm r2, r3, 0, 31, 31
        li r3, 17
        cmpwi cr0, r2, 0
        bne .LBB_test_2 ;
.LBB_test_1:    ;
        li r3, 1
.LBB_test_2:    ;
        blr

instead of:

_test:
        rlwinm r2, r3, 0, 31, 31
        li r2, 17
        cmpwi cr0, r3, 0
        bne .LBB_test_2 ;
.LBB_test_1:    ;
        li r2, 1
.LBB_test_2:    ;
        or r3, r2, r2
        blr

for:

int %test(bool %c) {
        %retval = select bool %c, int 17, int 1
        ret int %retval
}

llvm-svn: 22947
2005-08-21 18:03:09 +00:00
Chris Lattner
0500e362bf If the false value for a select_cc is really simple (has no inputs), evaluate
it in the block.  This codegens:

int %test(bool %c) {
        %retval = select bool %c, int 17, int 1
        ret int %retval
}

as:

_test:
        rlwinm r2, r3, 0, 31, 31
        li r2, 17
        cmpwi cr0, r3, 0
        bne .LBB_test_2 ;
.LBB_test_1:    ;
        li r2, 1
.LBB_test_2:    ;
        or r3, r2, r2
        blr

instead of:

_test:
        rlwinm r2, r3, 0, 31, 31
        li r2, 17
        li r4, 1
        cmpwi cr0, r3, 0
        bne .LBB_test_2 ;
.LBB_test_1:    ;
        or r2, r4, r4
.LBB_test_2:    ;
        or r3, r2, r2
        blr

... which is one fewer instruction.  The savings are more significant for
global address and constantfp nodes.

llvm-svn: 22946
2005-08-21 17:41:11 +00:00
Chris Lattner
7b6b326b2c Fix a bug in the RUN line
llvm-svn: 22945
2005-08-21 16:37:36 +00:00
Duraid Madina
3588ea9bf5 reenable collapse of loadimm+AND -> dep.z (thanks guys)
llvm-svn: 22944
2005-08-21 15:43:53 +00:00
Chris Lattner
4b08ba26d8 fix bogus warning
llvm-svn: 22943
2005-08-20 18:07:27 +00:00
Jim Laskey
9b0a275f04 Repair an out by one error for IA64.
llvm-svn: 22942
2005-08-20 11:05:23 +00:00
Chris Lattner
4564039498 add support for global address, including PIC support.
This REALLY should be lowered by the legalizer!

llvm-svn: 22941
2005-08-19 22:38:53 +00:00
Chris Lattner
319e65696d Add support for global address nodes
llvm-svn: 22940
2005-08-19 22:38:24 +00:00
Chris Lattner
7f618f4982 ADd support for TargetGlobalAddress nodes
llvm-svn: 22939
2005-08-19 22:31:34 +00:00
Chris Lattner
1be7eddecf Add support for TargetGlobalAddress nodes
llvm-svn: 22938
2005-08-19 22:31:04 +00:00
Chris Lattner
6d7f814b01 Implement CopyFromReg, TokenFactor, and fix a bug in CopyToReg. This allows
us to compile stuff like this:

double %test(double %A, double %B, double %C, double %E) {
        %F = mul double %A, %A
        %G = add double %F, %B
        %H = sub double -0.0, %G
        %I = mul double %H, %C
        %J = add double %I, %E
        ret double %J
}

to:

_test:
        fnmadd f0, f1, f1, f2
        fmadd f1, f0, f3, f4
        blr

woot!

llvm-svn: 22937
2005-08-19 21:43:53 +00:00
Chris Lattner
0875d1ab89 Fix a bug in previous commit
llvm-svn: 22936
2005-08-19 21:34:13 +00:00
Chris Lattner
65d66797a5 Fix a typeo, no wonder all tokenfactor edges were the same!
llvm-svn: 22935
2005-08-19 21:33:02 +00:00
Chris Lattner
4990335eb8 Print physreg register nodes with target names (e.g. F1) instead of numbers
llvm-svn: 22934
2005-08-19 21:21:16 +00:00
Chris Lattner
78b200eb74 Before implementing copyfromreg, we'll implement copytoreg correctly.
This gets us this for the previous testcase:

_test:
        lis r2, 0
        ori r3, r2, 65535
        blr

Note that we actually write to r3 (the return reg) correctly now :)

llvm-svn: 22933
2005-08-19 20:50:53 +00:00
Chris Lattner
cc3035e989 Now that we have operand info for machine instructions, use it to create
temporary registers for things that define a register.  This allows dag->dag
isel to compile this:

int %test() { ret int 65535 }

into:

_test:
        lis r2, 0
        ori r2, r2, 65535
        blr

Next up, getting CopyFromReg to work, allowing arguments and cross-bb values.

llvm-svn: 22932
2005-08-19 20:45:43 +00:00
Chris Lattner
96d0234845 Emit this:
static const TargetOperandInfo OperandInfo6[] = { { &PPC32::CRRCRegClass }, { 0 }, };

instead of this:

static const TargetOperandInfo OperandInfo6[] = { { PPC32::CRRCRegisterClass }, { 0 }, };

For operand information, which does not require dynamic (startup-time)
initialization.

llvm-svn: 22931
2005-08-19 20:29:14 +00:00
Chris Lattner
8ed3d0a0ce Expose the derived register classes to the public header, allowing them
to be accessed.

llvm-svn: 22930
2005-08-19 20:23:42 +00:00
Chris Lattner
bd26a82051 Split RegisterClass 'Methods' into MethodProtos and MethodBodies
llvm-svn: 22929
2005-08-19 19:13:20 +00:00
Chris Lattner
73ec2cb0f5 Split register class "Methods" into MethodProtos and MethodBodies
llvm-svn: 22928
2005-08-19 19:12:51 +00:00
Chris Lattner
248933eb39 put reg classes into namespace
llvm-svn: 22927
2005-08-19 18:53:43 +00:00
Chris Lattner
1dee9b1685 Put reg classes into namespaces
llvm-svn: 22926
2005-08-19 18:52:55 +00:00
Chris Lattner
757a770a57 Put register classes into namespaces
llvm-svn: 22925
2005-08-19 18:51:57 +00:00
Chris Lattner
8975de187f Put register classes in namespaces
llvm-svn: 22924
2005-08-19 18:50:46 +00:00
Chris Lattner
dc89d6be04 Fix code that assumes the register info will be dumped into a target
namespace instead of the reg class namespace.  Update getRegClassForType()
to use modified names due to tblgen change.

llvm-svn: 22923
2005-08-19 18:50:11 +00:00
Chris Lattner
cca0503c24 put reg classes in namespaces
llvm-svn: 22922
2005-08-19 18:49:22 +00:00
Chris Lattner
3fb85f2702 Require that targets specify a namespace for their register classes.
llvm-svn: 22921
2005-08-19 18:48:48 +00:00
Chris Lattner
74f60c306d Refactor to use Target.getRegisterClasses consistently, which provides
anonymous regclass definition renaming.

Change the generated code to emit register classes as properly namespace
qualified entities like everything else.

expose the actual class definition as an object, though this isn't quite
usable yet.

llvm-svn: 22920
2005-08-19 18:47:59 +00:00
Chris Lattner
d02bd5bb05 Emit real operand info for instructions. This currently works but is bad
in one way: the generated tables require dynamic initialization for the
register classes.  This will be fixed in a future patch.

llvm-svn: 22919
2005-08-19 18:46:26 +00:00
Chris Lattner
418d8cfcfe Read the namespace field from register classes
llvm-svn: 22918
2005-08-19 18:45:20 +00:00
Chris Lattner
3262673610 The skeleton target has never had an isel
llvm-svn: 22917
2005-08-19 18:35:41 +00:00
Chris Lattner
f391f286d7 This code has always been dead on itanium
llvm-svn: 22916
2005-08-19 18:34:37 +00:00
Chris Lattner
0faf0b7313 This code has always been dead for alpha
llvm-svn: 22915
2005-08-19 18:33:26 +00:00
Chris Lattner
8ad3700a3e The simple isel being gone makes this dead!
llvm-svn: 22914
2005-08-19 18:32:03 +00:00
Chris Lattner
ef6d8d8e94 Now that the simple isels are dead, so is this.
llvm-svn: 22913
2005-08-19 18:30:39 +00:00
Chris Lattner
f9b2edb91f add a setName method to record
llvm-svn: 22912
2005-08-19 17:58:49 +00:00
Chris Lattner
ac284259ac Add a setName method to Record.
llvm-svn: 22911
2005-08-19 17:58:11 +00:00
Chris Lattner
220d00109b For now, just emit empty operand info structures.
llvm-svn: 22910
2005-08-19 16:57:28 +00:00
Chris Lattner
63143a0609 Sparcv9 gets no operand info
llvm-svn: 22909
2005-08-19 16:56:56 +00:00
Chris Lattner
fa7c66bcea Add a new field to TargetInstrDescriptor for tracking information about
operands.

llvm-svn: 22908
2005-08-19 16:56:26 +00:00
Jeff Cohen
486e36cfde Fix VC++ constant truncation warning.
llvm-svn: 22907
2005-08-19 16:19:21 +00:00
Jeff Cohen
91e218fb1d Update Visual Studio projects for removed file.
llvm-svn: 22905
2005-08-19 13:51:22 +00:00
Duraid Madina
fcbb38077b a bugfix (up top) and a quick repair job: disable generation of dep.z
(which died about a week ago) so we're back to load-(2^n-1)-then-AND
sequences. slow, but things should now be Almost Completely Working,
modulo those pesky alignment/ABI issues.

llvm-svn: 22904
2005-08-19 13:25:50 +00:00
Chris Lattner
0899614152 Fix a problem jeffc noticed
llvm-svn: 22903
2005-08-19 06:16:04 +00:00
Jeff Cohen
d1f22b1282 Fix VC++ precedence warning.
llvm-svn: 22902
2005-08-19 04:39:48 +00:00
Nate Begeman
ce400dac21 Fix a bug where we were passing the wrong number of arguments to an
instruction.

llvm-svn: 22901
2005-08-19 03:42:28 +00:00
Chris Lattner
fd6afbc7f0 remove dead args
llvm-svn: 22900
2005-08-19 01:17:18 +00:00
Chris Lattner
298422f7e3 remove dead options
llvm-svn: 22899
2005-08-19 01:16:18 +00:00
Chris Lattner
4981e5248b remove dead flags
llvm-svn: 22898
2005-08-19 01:14:40 +00:00
Chris Lattner
04a5ae3f71 The code emitter generator only supports targets with 32-bit instruction
words.  There is no way for one of these targets to have a > 32-bit immediate!

llvm-svn: 22897
2005-08-19 01:04:33 +00:00
Chris Lattner
d18beab94c Fix computation of # operands, add a temporary hack for CopyToReg
llvm-svn: 22896
2005-08-19 01:01:34 +00:00
Chris Lattner
511ee687e5 now that all of the targets are clean w.r.t. the number of operands for each
instruction defined, actually emit this to the InstrInfoDescriptor, which
allows an assert in the machineinstrbuilder to do some checking for us,
and is required by the dag->dag emitter

llvm-svn: 22895
2005-08-19 00:59:49 +00:00
Nate Begeman
1d37296e02 Add support for target nodes with more than 3 operands, required by ppc
llvm-svn: 22894
2005-08-19 00:56:28 +00:00
Chris Lattner
8cbddfc8c5 mark variable arity instructions as such. Alpha wins the battle for
cleanest backend in this metric :)

llvm-svn: 22893
2005-08-19 00:51:37 +00:00
Chris Lattner
3e0335c9d1 Mark some instructions as variable_ops, and PSEUDO_ALLOC as taking a GPR.
I'm not convinced this is all of them,  but I can't do much testing, because
IA64 LLC crashes on big programs :(

llvm-svn: 22892
2005-08-19 00:47:42 +00:00
Chris Lattner
423d7cbbf8 add a few missing cases
llvm-svn: 22891
2005-08-19 00:41:29 +00:00
Chris Lattner
e2967ac53d Give ADJCALLSTACKDOWN/UP the correct operands.
Give a whole bunch of other stuff variable operands, particularly FP.  The
FP stackifier is playing fast and loose with operands here, so we have to
mark them all as variable.  This will have to be fixed before we can dag->dag
the X86 backend.  The solution is for the pre-stackifier and post-stackifier
instructions to all be disjoint.

llvm-svn: 22890
2005-08-19 00:38:22 +00:00
Nate Begeman
93c4bc6dca ISD::OR, and it's accompanying SelectBitfieldInsert
llvm-svn: 22889
2005-08-19 00:38:14 +00:00
Chris Lattner
a9d68f140e The variable SAR's only take one operand too
llvm-svn: 22888
2005-08-19 00:31:37 +00:00
Chris Lattner
145695927a Stop adding bogus operands to variable shifts on X86. These instructions
only take one operand.  The other comes implicitly in through CL.

llvm-svn: 22887
2005-08-19 00:16:17 +00:00
Nate Begeman
be1f314a47 Remove the X86 and PowerPC Simple instruction selectors; their time has
passed.

llvm-svn: 22886
2005-08-18 23:53:15 +00:00
Chris Lattner
17727bad02 Figure out how many operands each instruction has, keep track of whether
or not it's variable.

llvm-svn: 22885
2005-08-18 23:38:41 +00:00
Nate Begeman
33acb2c135 Add shifts.
llvm-svn: 22884
2005-08-18 23:38:00 +00:00
Chris Lattner
4bd805e785 Fix operand numbers by marking variable arity nodes as such and by fixing
the operand lists of a few other nodes.

llvm-svn: 22883
2005-08-18 23:25:33 +00:00
Chris Lattner
51e851d0e6 MFLR doesn't take an operand, the LR register is implicit
llvm-svn: 22882
2005-08-18 23:24:50 +00:00
Chris Lattner
5cfa377947 Add a new flag
llvm-svn: 22881
2005-08-18 23:17:07 +00:00
Chris Lattner
b015303c5e revert this change, which causes breakage, temporarily
llvm-svn: 22880
2005-08-18 22:12:31 +00:00
Chris Lattner
99df668f48 When emitting implicit use/def lists, only emit each unique list once. Though
LLVM is able to merge identical static const globals, GCC isn't, and this caused
some bloat in the generated data.  This has a marginal effect on PPC, shrinking
the implicit sets from 10->4, but shrinks X86 from 179 to 23, a much bigger
reduction.

This should speed up the register allocator as well by reducing the dcache
footprint for this static data.

llvm-svn: 22879
2005-08-18 21:36:47 +00:00
Chris Lattner
0c8c2c102d add a new -view-sched-dags option to view dags as they are sent to the scheduler.
llvm-svn: 22878
2005-08-18 20:11:49 +00:00
Chris Lattner
4e00ff6e70 Move this to the emitter
llvm-svn: 22877
2005-08-18 20:08:53 +00:00
Chris Lattner
d342de9aaa Implement the first chunk of a code emitter. This is sophisticated enough to
codegen:

_empty:
.LBB_empty_0:   ;
        blr

but can't do anything more (yet). :)

llvm-svn: 22876
2005-08-18 20:07:59 +00:00
Jim Laskey
e7b3cf73e5 Unmangled names.
llvm-svn: 22875
2005-08-18 20:06:09 +00:00
Chris Lattner
762c5e799c Add ScheduleDAG.cpp to the project
llvm-svn: 22874
2005-08-18 19:52:06 +00:00
Chris Lattner
6f52a04fc7 Fill in the numOperands field of the TargetInstrDescriptor struct from the
.td file.

llvm-svn: 22873
2005-08-18 19:45:37 +00:00
Jim Laskey
35ca73d335 1. Fix comment.
2. Get an exact count of 'li ' instructions.

llvm-svn: 22872
2005-08-18 19:38:57 +00:00
Jim Laskey
6645e001c3 Add regression test to make sure that constants are generated optimally.
llvm-svn: 22871
2005-08-18 19:32:46 +00:00
Jim Laskey
18b9b8df86 More optimal solution for loading constants.
llvm-svn: 22870
2005-08-18 18:58:23 +00:00
Chris Lattner
015d73996d After selecting the instructions for a basic block, emit the instructions
llvm-svn: 22869
2005-08-18 18:46:06 +00:00
Chris Lattner
1b4727de7d new file, obviously just a stub
llvm-svn: 22868
2005-08-18 18:45:24 +00:00
Chris Lattner
a88fa6085f add a method
llvm-svn: 22867
2005-08-18 18:44:33 +00:00
Chris Lattner
15b5c7ca84 remove some unused stuff
llvm-svn: 22866
2005-08-18 18:34:00 +00:00
Nate Begeman
d16a26a8d4 Fix int foo() { return 65535; } by using the top 16 bits of the constant
as the argument to LIS rather than the result of HA16(constant).

The DAG->DAG ISel was already doing the right thing.

llvm-svn: 22865
2005-08-18 18:14:49 +00:00
Nate Begeman
d32638706a Improve ISD::Constant codegen.
Now for int foo() { return -1; } we generate:
_foo:
        li r3, -1
        blr

instead of
_foo:
        lis r2, -1
        ori r3, r2, 65535
        blr

llvm-svn: 22864
2005-08-18 18:01:39 +00:00
Chris Lattner
1a908c8920 Enable critical edge splitting by default
llvm-svn: 22863
2005-08-18 17:35:14 +00:00
Chris Lattner
37faf35b35 replace switch stmt with an assert, generate li 0 instead of lis 0 for 0,
to make the code follow people's expectations better.

llvm-svn: 22861
2005-08-18 17:16:52 +00:00
Jim Laskey
32d4c85278 Handle loading of 0x????0000 constants with a single instruction.
llvm-svn: 22858
2005-08-18 15:52:30 +00:00
Nate Begeman
b3821a3943 Add support for ISD::AND, and its various optimized forms.
llvm-svn: 22857
2005-08-18 07:30:46 +00:00
Nate Begeman
19a271a67b Add support for target DAG nodes that take 4 operands, such as PowerPC's
rlwinm.

llvm-svn: 22856
2005-08-18 07:30:15 +00:00
Nate Begeman
cfb9a74c2e Maintain consistency in negating things
llvm-svn: 22855
2005-08-18 05:44:50 +00:00
Nate Begeman
72d6f8800d Implement XOR, remove a broken sign_extend_inreg case
llvm-svn: 22854
2005-08-18 05:00:13 +00:00
Chris Lattner
802080d812 Fix printing of VTSDNodes
llvm-svn: 22853
2005-08-18 03:31:02 +00:00
Nate Begeman
70d9c5c340 Add a testcase for load short -> uint, which is currently emitted as a
zextload + sign_extend_inreg rather than a sextload.

llvm-svn: 22852
2005-08-18 03:11:44 +00:00
Nate Begeman
4bfb4a215d Add a bunch more simple nodes.
llvm-svn: 22851
2005-08-18 03:04:18 +00:00
Nate Begeman
457367f14c Add a couple more nodes that are easy to handle
llvm-svn: 22850
2005-08-18 00:53:47 +00:00
Nate Begeman
74d5529b88 Be fruitful and multiply!
llvm-svn: 22849
2005-08-18 00:21:41 +00:00
Jim Laskey
04160c6d8d Better version of isIntImmediate.
llvm-svn: 22848
2005-08-18 00:15:15 +00:00
Jim Laskey
2a1f2df82a messed up
llvm-svn: 22847
2005-08-17 23:57:24 +00:00
Jim Laskey
5e56202916 include/llvm/Support/MathExtras.h
llvm-svn: 22846
2005-08-17 23:54:12 +00:00
Nate Begeman
3fcf47d8f0 Teach the DAG->DAG ISel about FNEG, and how it can be used to invert
several of the PowerPC opcodes that come in both negated and non-negated
forms.

llvm-svn: 22845
2005-08-17 23:46:35 +00:00
Nate Begeman
cc0132b2dc Add two new methods isTargetOpcode() which returns true if the node type
is greater than the range of building selection dag node types, and
getTargetOpcode(), which returns the node opcode less the value of
isd::builtin_op_end, which specifies the end of the builtin types.

llvm-svn: 22844
2005-08-17 23:44:54 +00:00
Chris Lattner
ea7dfd53d6 Fix Transforms/LoopStrengthReduce/2005-08-17-OutOfLoopVariant.ll, a crash
on 177.mesa

llvm-svn: 22843
2005-08-17 21:22:41 +00:00
Chris Lattner
9b2efaf9c8 new testcase distilled from mesa
llvm-svn: 22842
2005-08-17 21:21:47 +00:00
Jim Laskey
d66e616545 Move the code dependency for MathExtras.h from SelectionDAGNodes.h.
Added some class dividers in SelectionDAG.cpp.

llvm-svn: 22841
2005-08-17 20:08:02 +00:00
Jim Laskey
8ad8f71447 Move code dependency for MathExtras.h out of Constants.h.
llvm-svn: 22840
2005-08-17 20:06:22 +00:00
Jim Laskey
17e7599ecb Promote dependency for MathExtras.h out of Constants.h.
llvm-svn: 22839
2005-08-17 20:04:34 +00:00
Jim Laskey
b74c666186 Culling out use of unions for converting FP to bits and vice versa.
llvm-svn: 22838
2005-08-17 19:34:49 +00:00
Chris Lattner
c6aa80668e add a beta option for turning on dag->dag isel
llvm-svn: 22837
2005-08-17 19:33:30 +00:00
Chris Lattner
43ff01e2e6 initial hack at a dag->dag instruction selector. This is obviously woefully
incomplete, but it is a start.  It handles basic argument/retval stuff, immediates,
add and sub.

llvm-svn: 22836
2005-08-17 19:33:03 +00:00
Chris Lattner
f61cce952b add prototype, remove dead proto
llvm-svn: 22835
2005-08-17 19:32:03 +00:00
Chris Lattner
ab0de9d7fc Fix a bug in RemoveDeadNodes where it would crash when its "optional"
argument is not specified.

Implement ReplaceAllUsesWith.

llvm-svn: 22834
2005-08-17 19:00:20 +00:00
Chris Lattner
1c911aea08 add ReplaceAllUsesWith, and a helper to implemented it
llvm-svn: 22833
2005-08-17 18:59:17 +00:00
Chris Lattner
06d63f429f Make removeUser more efficient, add a matching addUser.
Fix the setOperands methods I added to update use/def information correctly.

llvm-svn: 22832
2005-08-17 18:58:38 +00:00
Jim Laskey
686d6a1cb2 Switched to using BitsToDouble for int_to_float to avoid aliasing problem.
llvm-svn: 22831
2005-08-17 17:42:52 +00:00
Jim Laskey
adc9c0c559 Added support for converting raw bits to FP, and FP to raw bits. The intent
is to avoid the distraction of the union declarations.

llvm-svn: 22830
2005-08-17 17:27:47 +00:00
Chris Lattner
33900811ee Fix some bugs in the alpha backend, some of which I introduced yesterday,
and some that were preexisting.  All alpha regtests pass now.

llvm-svn: 22829
2005-08-17 17:08:24 +00:00
Jim Laskey
898ba557d0 Change hex float constants for the sake of VC++.
llvm-svn: 22828
2005-08-17 09:44:59 +00:00
Chris Lattner
0381c73c4d This was moved to the .cpp file
llvm-svn: 22827
2005-08-17 06:46:50 +00:00
Chris Lattner
c9950c11a9 Add a new beta option for critical edge splitting, to avoid a problem that
Nate noticed in yacr2 (and I know occurs in other places as well).

This is still rough, as the critical edge blocks are not intelligently placed
but is added to get some idea to see if this improves performance.

llvm-svn: 22825
2005-08-17 06:37:43 +00:00
Chris Lattner
2bf7cb5213 Use a new helper to split critical edges, making the code simpler.
Do not claim to not change the CFG.  We do change the cfg to split critical
edges.  This isn't causing us a problem now, but could likely do so in the
future.

llvm-svn: 22824
2005-08-17 06:35:16 +00:00
Chris Lattner
79f8b62607 add a helper
llvm-svn: 22823
2005-08-17 06:34:37 +00:00
Chris Lattner
ba28c2733f Fix a regression on X86, where FP values can be promoted too.
llvm-svn: 22822
2005-08-17 06:06:25 +00:00
Misha Brukman
5fbf58a7b0 Fix grammar
llvm-svn: 22821
2005-08-17 02:38:56 +00:00
Chris Lattner
40f909ad04 make sure to remove a node from the use list of its operands when we replace
it.

llvm-svn: 22820
2005-08-17 01:54:00 +00:00
Chris Lattner
63f774ec6e Fix a few small typos I noticed when converting this over to the DAG->DAG
selector.  Also, there is no difference between addSImm and addImm, so just
use addImm, folding some branches.

llvm-svn: 22819
2005-08-17 01:25:14 +00:00
Jim Laskey
9828f26cf1 Removed UINT_TO_FP and SINT_TO_FP from ISel outright.
llvm-svn: 22818
2005-08-17 01:14:38 +00:00
Andrew Lenharth
73370ba5fd thinko. Should fix s4addl.ll regression
llvm-svn: 22817
2005-08-17 00:47:24 +00:00
Jim Laskey
5909c8b10a Remove ISel code generation for UINT_TO_FP and SINT_TO_FP. Now asserts if
marked as legal.

llvm-svn: 22816
2005-08-17 00:41:40 +00:00
Jim Laskey
6267b2c97c Make UINT_TO_FP and SINT_TO_FP use generic expansion.
llvm-svn: 22815
2005-08-17 00:40:22 +00:00
Jim Laskey
f2516a9180 Added generic code expansion for [signed|unsigned] i32 to [f32|f64] casts in the
legalizer.  PowerPC now uses this expansion instead of ISel version.

Example:

// signed integer to double conversion
double f1(signed x) {
  return (double)x;
}

// unsigned integer to double conversion
double f2(unsigned x) {
  return (double)x;
}

// signed integer to float conversion
float f3(signed x) {
  return (float)x;
}

// unsigned integer to float conversion
float f4(unsigned x) {
  return (float)x;
}


Byte Code:

internal fastcc double %_Z2f1i(int %x) {
entry:
        %tmp.1 = cast int %x to double          ; <double> [#uses=1]
        ret double %tmp.1
}

internal fastcc double %_Z2f2j(uint %x) {
entry:
        %tmp.1 = cast uint %x to double         ; <double> [#uses=1]
        ret double %tmp.1
}

internal fastcc float %_Z2f3i(int %x) {
entry:
        %tmp.1 = cast int %x to float           ; <float> [#uses=1]
        ret float %tmp.1
}

internal fastcc float %_Z2f4j(uint %x) {
entry:
        %tmp.1 = cast uint %x to float          ; <float> [#uses=1]
        ret float %tmp.1
}

internal fastcc double %_Z2g1i(int %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.2 = cast int %x to uint            ; <uint> [#uses=1]
        %tmp.3 = xor uint %tmp.2, 2147483648            ; <uint> [#uses=1]
        %tmp.5 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %tmp.3, uint* %tmp.5
        %tmp.9 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.10 = load double* %tmp.9           ; <double> [#uses=1]
        %tmp.13 = load double* cast (long* %signed_bias to double*)             ; <double> [#uses=1]
        %tmp.14 = sub double %tmp.10, %tmp.13           ; <double> [#uses=1]
        ret double %tmp.14
}

internal fastcc double %_Z2g2j(uint %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.1 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %x, uint* %tmp.1
        %tmp.4 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.5 = load double* %tmp.4            ; <double> [#uses=1]
        %tmp.8 = load double* cast (long* %unsigned_bias to double*)            ; <double> [#uses=1]
        %tmp.9 = sub double %tmp.5, %tmp.8              ; <double> [#uses=1]
        ret double %tmp.9
}

internal fastcc float %_Z2g3i(int %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.2 = cast int %x to uint            ; <uint> [#uses=1]
        %tmp.3 = xor uint %tmp.2, 2147483648            ; <uint> [#uses=1]
        %tmp.5 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %tmp.3, uint* %tmp.5
        %tmp.9 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.10 = load double* %tmp.9           ; <double> [#uses=1]
        %tmp.13 = load double* cast (long* %signed_bias to double*)             ; <double> [#uses=1]
        %tmp.14 = sub double %tmp.10, %tmp.13           ; <double> [#uses=1]
        %tmp.16 = cast double %tmp.14 to float          ; <float> [#uses=1]
        ret float %tmp.16
}

internal fastcc float %_Z2g4j(uint %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.1 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %x, uint* %tmp.1
        %tmp.4 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.5 = load double* %tmp.4            ; <double> [#uses=1]
        %tmp.8 = load double* cast (long* %unsigned_bias to double*)            ; <double> [#uses=1]
        %tmp.9 = sub double %tmp.5, %tmp.8              ; <double> [#uses=1]
        %tmp.11 = cast double %tmp.9 to float           ; <float> [#uses=1]
        ret float %tmp.11
}


PowerPC Code:

        .machine ppc970


        .const
        .align  2
.CPIl1__Z2f1i_0:                                        ; float 0x4330000080000000
        .long   1501560836      ; float 4.5036e+15
        .text
        .align  2
        .globl  l1__Z2f1i
l1__Z2f1i:
.LBBl1__Z2f1i_0:        ; entry
        xoris r2, r3, 32768
        stw r2, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl1__Z2f1i_0)
        lfs f1, lo16(.CPIl1__Z2f1i_0)(r2)
        fsub f1, f0, f1
        blr


        .const
        .align  2
.CPIl2__Z2f2j_0:                                        ; float 0x4330000000000000
        .long   1501560832      ; float 4.5036e+15
        .text
        .align  2
        .globl  l2__Z2f2j
l2__Z2f2j:
.LBBl2__Z2f2j_0:        ; entry
        stw r3, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl2__Z2f2j_0)
        lfs f1, lo16(.CPIl2__Z2f2j_0)(r2)
        fsub f1, f0, f1
        blr


        .const
        .align  2
.CPIl3__Z2f3i_0:                                        ; float 0x4330000080000000
        .long   1501560836      ; float 4.5036e+15
        .text
        .align  2
        .globl  l3__Z2f3i
l3__Z2f3i:
.LBBl3__Z2f3i_0:        ; entry
        xoris r2, r3, 32768
        stw r2, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl3__Z2f3i_0)
        lfs f1, lo16(.CPIl3__Z2f3i_0)(r2)
        fsub f0, f0, f1
        frsp f1, f0
        blr


        .const
        .align  2
.CPIl4__Z2f4j_0:                                        ; float 0x4330000000000000
        .long   1501560832      ; float 4.5036e+15
        .text
        .align  2
        .globl  l4__Z2f4j
l4__Z2f4j:
.LBBl4__Z2f4j_0:        ; entry
        stw r3, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl4__Z2f4j_0)
        lfs f1, lo16(.CPIl4__Z2f4j_0)(r2)
        fsub f0, f0, f1
        frsp f1, f0
        blr

llvm-svn: 22814
2005-08-17 00:39:29 +00:00
Chris Lattner
0d2456e1f0 add a new TargetConstant node
llvm-svn: 22813
2005-08-17 00:34:06 +00:00
Chris Lattner
12214cf577 add some helper methods, and a new TargetConstant node, which is not
subjected to folding.

llvm-svn: 22812
2005-08-17 00:33:30 +00:00
Nate Begeman
784c8068a7 Implement a couple improvements:
Remove dead code in ISD::Constant handling
Add support for add long, imm16

We now codegen 'long long foo(long long a) { return ++a; }'
as:
addic r4, r4, 1
addze r3, r3
blr

instead of:
li r2, 1
li r5, 0
addc r2, r4, r2
adde r3, r3, r5
blr

llvm-svn: 22811
2005-08-17 00:20:08 +00:00
Chris Lattner
2111aae8c1 remove a dead enum value, making a comment above correct again
llvm-svn: 22810
2005-08-16 22:04:58 +00:00
Chris Lattner
5a1d5e30e2 This is a dummy, it doesn't matter what the ValueType is
llvm-svn: 22809
2005-08-16 21:59:52 +00:00
Chris Lattner
79f5ebc7b9 updates for changes in nodes
llvm-svn: 22808
2005-08-16 21:58:15 +00:00
Chris Lattner
7c76278242 update the backends to work with the new CopyFromReg/CopyToReg/ImplicitDef nodes
llvm-svn: 22807
2005-08-16 21:56:37 +00:00
Chris Lattner
33182325f5 Eliminate the RegSDNode class, which 3 nodes (CopyFromReg/CopyToReg/ImplicitDef)
used to tack a register number onto the node.

Instead of doing this, make a new node, RegisterSDNode, which is a leaf
containing a register number.  These three operations just become normal
DAG nodes now, instead of requiring special handling.

Note that with this change, it is no longer correct to make illegal
CopyFromReg/CopyToReg nodes.  The legalizer will not touch them, and this
is bad, so don't do it. :)

llvm-svn: 22806
2005-08-16 21:55:35 +00:00
Nate Begeman
371e49515d Implement BR_CC and BRTWOWAY_CC. This allows the removal of a rather nasty
fixme from the PowerPC backend.  Emit slightly better code for legalizing
select_cc.

llvm-svn: 22805
2005-08-16 19:49:35 +00:00
Chris Lattner
bc89226527 Allow passing a dag into dump and getOperationName. If one is available
when printing a node, use it to render target operations with their
target instruction name instead of "<<unknown>>".

llvm-svn: 22804
2005-08-16 18:33:07 +00:00
Chris Lattner
577af48731 allow passing a dag into getOperationName and dump
llvm-svn: 22803
2005-08-16 18:32:18 +00:00
Chris Lattner
7e57d18b79 Use a extant helper to do this.
llvm-svn: 22802
2005-08-16 18:31:23 +00:00
Chris Lattner
1973278b38 Add some methods for dag->dag isel.
Split RemoveNodeFromCSEMaps out of DeleteNodesIfDead to do it.

llvm-svn: 22801
2005-08-16 18:17:10 +00:00
Chris Lattner
ba19325eae add some methods for dag->dag isel
llvm-svn: 22800
2005-08-16 18:16:24 +00:00
Chris Lattner
f22556d3ad Pull the LLVM -> DAG lowering code out of the pattern selector so that it
can be shared with the DAG->DAG selector.

llvm-svn: 22799
2005-08-16 17:14:42 +00:00
Chris Lattner
5cf983ee0f Fix a bad case in gzip where we put lots of things in registers across the
loop, because a IV-dependent value was used outside of the loop and didn't
have immediate-folding capability

llvm-svn: 22798
2005-08-16 00:38:11 +00:00
Chris Lattner
e515416396 Fix Transforms/LoopStrengthReduce/2005-08-15-AddRecIV.ll
llvm-svn: 22797
2005-08-16 00:37:01 +00:00
Chris Lattner
3cf8ef170a testcase that crashes lsr, distilled from 175.vpr
llvm-svn: 22796
2005-08-16 00:36:12 +00:00
Chris Lattner
73785d2ef2 Turn loop strength reduction on by default.
Only run createLowerConstantExpressionsPass for the simple isel.  The DAG
isel has no need for it.

llvm-svn: 22794
2005-08-15 23:47:04 +00:00
Chris Lattner
587a75b6e0 Teach LLVM to know how many times a loop executes when constructed with
a < expression, e.g.: for (i = m; i < n; ++i)

llvm-svn: 22793
2005-08-15 23:33:51 +00:00
Jim Laskey
24b84072ea Broke 80 column rule.
llvm-svn: 22792
2005-08-15 17:35:26 +00:00
Jim Laskey
42623a9539 Changed code gen for int to f32 to use rounding. This makes FP results
consistent with gcc.

llvm-svn: 22791
2005-08-15 17:14:19 +00:00
Andrew Lenharth
b65b1568ae isIntImmediate is a good Idea. Add a flavor that checks bounds while it is at it
llvm-svn: 22790
2005-08-15 14:31:37 +00:00
Nate Begeman
d5e739dcc2 Fix last night's PPC32 regressions by
1. Not selecting the false value of a select_cc in the false arm, which
   isn't legal for nested selects.
2. Actually returning the node we created and Legalized in the FP_TO_UINT
   Expander.

llvm-svn: 22789
2005-08-14 18:38:32 +00:00
Nate Begeman
e5394d453d Fix last night's X86 regressions by putting code for SSE in the if(SSE)
block.  nur.

llvm-svn: 22788
2005-08-14 18:37:02 +00:00
Andrew Lenharth
ed07233868 only build .a on alpha
llvm-svn: 22787
2005-08-14 15:14:34 +00:00
Nate Begeman
4d959f6627 Fix FP_TO_UINT with Scalar SSE2 now that the legalizer can handle it. We
now generate the relatively good code sequences:
unsigned short foo(float a) { return a; }
_foo:
        movss 4(%esp), %xmm0
        cvttss2si %xmm0, %eax
        movzwl %ax, %eax
        ret

and
unsigned bar(float a) { return a; }
_bar:
        movss .CPI_bar_0, %xmm0
        movss 4(%esp), %xmm1
        movapd %xmm1, %xmm2
        subss %xmm0, %xmm2
        cvttss2si %xmm2, %eax
        xorl $-2147483648, %eax
        cvttss2si %xmm1, %ecx
        ucomiss %xmm0, %xmm1
        cmovb %ecx, %eax
        ret

llvm-svn: 22786
2005-08-14 04:36:51 +00:00
Nate Begeman
36853ee1fd Teach the legalizer how to legalize FP_TO_UINT.
Teach the legalizer to promote FP_TO_UINT to FP_TO_SINT if the wider
  FP_TO_UINT is also illegal.  This allows us on PPC to codegen
  unsigned short foo(float a) { return a; }

as:
_foo:
.LBB_foo_0:     ; entry
        fctiwz f0, f1
        stfd f0, -8(r1)
        lwz r2, -4(r1)
        rlwinm r3, r2, 0, 16, 31
        blr

instead of:
_foo:
.LBB_foo_0:     ; entry
        fctiwz f0, f1
        stfd f0, -8(r1)
        lwz r2, -4(r1)
        lis r3, ha16(.CPI_foo_0)
        lfs f0, lo16(.CPI_foo_0)(r3)
        fcmpu cr0, f1, f0
        blt .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        fsubs f0, f1, f0
        fctiwz f0, f0
        stfd f0, -16(r1)
        lwz r2, -12(r1)
        xoris r2, r2, 32768
.LBB_foo_2:     ; entry
        rlwinm r3, r2, 0, 16, 31
        blr

llvm-svn: 22785
2005-08-14 01:20:53 +00:00
Nate Begeman
83f6b98c42 Make FP_TO_UINT Illegal. This allows us to generate significantly better
codegen for FP_TO_UINT by using the legalizer's SELECT variant.

Implement a codegen improvement for SELECT_CC, selecting the false node in
the MBB that feeds the phi node.  This allows us to codegen:
void foo(int *a, int b, int c) { int d = (a < b) ? 5 : 9; *a = d; }
as:
_foo:
        li r2, 5
        cmpw cr0, r4, r3
        bgt .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        li r2, 9
.LBB_foo_2:     ; entry
        stw r2, 0(r3)
        blr

insted of:
_foo:
        li r2, 5
        li r5, 9
        cmpw cr0, r4, r3
        bgt .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        or r2, r5, r5
.LBB_foo_2:     ; entry
        stw r2, 0(r3)
        blr

llvm-svn: 22784
2005-08-14 01:17:16 +00:00
Andrew Lenharth
107a0a7690 Testing a variable before it is defined doesn't work so well. It is a fairly small thing, so just let everyone build the .a file
llvm-svn: 22783
2005-08-13 14:58:23 +00:00
Chris Lattner
47d3ec3525 Ooops, don't forget to clear this. The real inner loop is now:
.LBB_foo_3:     ; no_exit.1
        lfd f2, 0(r9)
        lfd f3, 8(r9)
        fmul f4, f1, f2
        fmadd f4, f0, f3, f4
        stfd f4, 8(r9)
        fmul f3, f1, f3
        fmsub f2, f0, f2, f3
        stfd f2, 0(r9)
        addi r9, r9, 16
        addi r8, r8, 1
        cmpw cr0, r8, r4
        ble .LBB_foo_3  ; no_exit.1

llvm-svn: 22782
2005-08-13 07:42:01 +00:00
Chris Lattner
5949d49032 Recursively scan scev expressions for common subexpressions. This allows us
to handle nested loops much better, for example, by being able to tell that
these two expressions:

{( 8 + ( 16 * ( 1 +  %Tmp11 +  %Tmp12)) +  %c_),+,( 16 *  %Tmp 12)}<loopentry.1>

{(( 16 * ( 1 +  %Tmp11 +  %Tmp12)) +  %c_),+,( 16 *  %Tmp12)}<loopentry.1>

Have the following common part that can be shared:
{(( 16 * ( 1 +  %Tmp11 +  %Tmp12)) +  %c_),+,( 16 *  %Tmp12)}<loopentry.1>

This allows us to codegen an important inner loop in 168.wupwise as:

.LBB_foo_4:     ; no_exit.1
        lfd f2, 16(r9)
        fmul f3, f0, f2
        fmul f2, f1, f2
        fadd f4, f3, f2
        stfd f4, 8(r9)
        fsub f2, f3, f2
        stfd f2, 16(r9)
        addi r8, r8, 1
        addi r9, r9, 16
        cmpw cr0, r8, r4
        ble .LBB_foo_4  ; no_exit.1

instead of:

.LBB_foo_3:     ; no_exit.1
        lfdx f2, r6, r9
        add r10, r6, r9
        lfd f3, 8(r10)
        fmul f4, f1, f2
        fmadd f4, f0, f3, f4
        stfd f4, 8(r10)
        fmul f3, f1, f3
        fmsub f2, f0, f2, f3
        stfdx f2, r6, r9
        addi r9, r9, 16
        addi r8, r8, 1
        cmpw cr0, r8, r4
        ble .LBB_foo_3  ; no_exit.1

llvm-svn: 22781
2005-08-13 07:27:18 +00:00
Nate Begeman
dc3154ec66 Remove an unncessary argument to SimplifySelectCC and add an additional
assert when creating a select_cc node.

llvm-svn: 22780
2005-08-13 06:14:17 +00:00
Nate Begeman
b6651e81a0 Fix the fabs regression on x86 by abstracting the select_cc optimization
out into SimplifySelectCC.  This allows both ISD::SELECT and ISD::SELECT_CC
to use the same set of simplifying folds.

llvm-svn: 22779
2005-08-13 06:00:21 +00:00
Nate Begeman
a22bf778c9 Remove support for 64b PPC, it's been broken for a long time. It'll be
back once a DAG->DAG ISel exists.

llvm-svn: 22778
2005-08-13 05:59:16 +00:00
Andrew Lenharth
6b62b479fa Fix oversized GOT problem with gcc-4 on alpha
llvm-svn: 22777
2005-08-13 05:09:50 +00:00
Chris Lattner
89c1dfc733 Teach SplitCriticalEdge to update LoopInfo if it is alive. This fixes
a problem in LoopStrengthReduction, where it would split critical edges
then confused itself with outdated loop information.

llvm-svn: 22776
2005-08-13 01:38:43 +00:00
Chris Lattner
79396539d3 remove dead code. The exit block list is computed on demand, thus does not
need to be updated.  This code is a relic from when it did.

llvm-svn: 22775
2005-08-13 01:30:36 +00:00
Chris Lattner
21381e8424 implement a couple of simple shift foldings.
e.g.  (X & 7) >> 3   -> 0

llvm-svn: 22774
2005-08-12 23:54:58 +00:00
Jim Laskey
35960708b7 Fix for 2005-08-12-rlwimi-crash.ll. Make allowance for masks being shifted to
zero.

llvm-svn: 22773
2005-08-12 23:52:46 +00:00
Jim Laskey
461edda709 Added test cases to guarantee use of ORC and ANDC.
llvm-svn: 22772
2005-08-12 23:40:14 +00:00
Jim Laskey
a568700618 1. This changes handles the cases of (~x)&y and x&(~y) yielding ANDC, and
(~x)|y and x|(~y) yielding ORC.

llvm-svn: 22771
2005-08-12 23:38:02 +00:00
Chris Lattner
f6a762ada1 testcase that crashed the ppc backend, distilled from crafty
llvm-svn: 22770
2005-08-12 23:34:03 +00:00
Chris Lattner
8447b49526 When splitting critical edges, make sure not to leave the new block in the
middle of the loop.  This turns a critical loop in gzip into this:

.LBB_test_1:    ; loopentry
        or r27, r28, r28
        add r28, r3, r27
        lhz r28, 3(r28)
        add r26, r4, r27
        lhz r26, 3(r26)
        cmpw cr0, r28, r26
        bne .LBB_test_8 ; loopentry.loopexit_crit_edge
.LBB_test_2:    ; shortcirc_next.0
        add r28, r3, r27
        lhz r28, 5(r28)
        add r26, r4, r27
        lhz r26, 5(r26)
        cmpw cr0, r28, r26
        bne .LBB_test_7 ; shortcirc_next.0.loopexit_crit_edge
.LBB_test_3:    ; shortcirc_next.1
        add r28, r3, r27
        lhz r28, 7(r28)
        add r26, r4, r27
        lhz r26, 7(r26)
        cmpw cr0, r28, r26
        bne .LBB_test_6 ; shortcirc_next.1.loopexit_crit_edge
.LBB_test_4:    ; shortcirc_next.2
        add r28, r3, r27
        lhz r26, 9(r28)
        add r28, r4, r27
        lhz r25, 9(r28)
        addi r28, r27, 8
        cmpw cr7, r26, r25
        mfcr r26, 1
        rlwinm r26, r26, 31, 31, 31
        add r25, r8, r27
        cmpw cr7, r25, r7
        mfcr r25, 1
        rlwinm r25, r25, 29, 31, 31
        and. r26, r26, r25
        bne .LBB_test_1 ; loopentry

instead of this:

.LBB_test_1:    ; loopentry
        or r27, r28, r28
        add r28, r3, r27
        lhz r28, 3(r28)
        add r26, r4, r27
        lhz r26, 3(r26)
        cmpw cr0, r28, r26
        beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2:    ; loopentry.loopexit_crit_edge
        add r2, r30, r27
        add r8, r29, r27
        b .LBB_test_9   ; loopexit
.LBB_test_3:    ; shortcirc_next.0
        add r28, r3, r27
        lhz r28, 5(r28)
        add r26, r4, r27
        lhz r26, 5(r26)
        cmpw cr0, r28, r26
        beq .LBB_test_5 ; shortcirc_next.1
.LBB_test_4:    ; shortcirc_next.0.loopexit_crit_edge
        add r2, r11, r27
        add r8, r12, r27
        b .LBB_test_9   ; loopexit
.LBB_test_5:    ; shortcirc_next.1
        add r28, r3, r27
        lhz r28, 7(r28)
        add r26, r4, r27
        lhz r26, 7(r26)
        cmpw cr0, r28, r26
        beq .LBB_test_7 ; shortcirc_next.2
.LBB_test_6:    ; shortcirc_next.1.loopexit_crit_edge
        add r2, r9, r27
        add r8, r10, r27
        b .LBB_test_9   ; loopexit
.LBB_test_7:    ; shortcirc_next.2
        add r28, r3, r27
        lhz r26, 9(r28)
        add r28, r4, r27
        lhz r25, 9(r28)
        addi r28, r27, 8
        cmpw cr7, r26, r25
        mfcr r26, 1
        rlwinm r26, r26, 31, 31, 31
        add r25, r8, r27
        cmpw cr7, r25, r7
        mfcr r25, 1
        rlwinm r25, r25, 29, 31, 31
        and. r26, r26, r25
        bne .LBB_test_1 ; loopentry

Next up, improve the code for the loop.

llvm-svn: 22769
2005-08-12 22:22:17 +00:00
Chris Lattner
e09bbc800c Add a helper method
llvm-svn: 22768
2005-08-12 22:14:06 +00:00
Chris Lattner
1344253e3f add a helper method
llvm-svn: 22767
2005-08-12 22:13:27 +00:00
Chris Lattner
4fec86d348 Fix a FIXME: if we are inserting code for a PHI argument, split the critical
edge so that the code is not always executed for both operands.  This
prevents LSR from inserting code into loops whose exit blocks contain
PHI uses of IV expressions (which are outside of loops).  On gzip, for
example, we turn this ugly code:

.LBB_test_1:    ; loopentry
        add r27, r3, r28
        lhz r27, 3(r27)
        add r26, r4, r28
        lhz r26, 3(r26)
        add r25, r30, r28    ;; Only live if exiting the loop
        add r24, r29, r28    ;; Only live if exiting the loop
        cmpw cr0, r27, r26
        bne .LBB_test_5 ; loopexit

into this:

.LBB_test_1:    ; loopentry
        or r27, r28, r28
        add r28, r3, r27
        lhz r28, 3(r28)
        add r26, r4, r27
        lhz r26, 3(r26)
        cmpw cr0, r28, r26
        beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2:    ; loopentry.loopexit_crit_edge
        add r2, r30, r27
        add r8, r29, r27
        b .LBB_test_9   ; loopexit
.LBB_test_2:    ; shortcirc_next.0
        ...
        blt .LBB_test_1


into this:

.LBB_test_1:    ; loopentry
        or r27, r28, r28
        add r28, r3, r27
        lhz r28, 3(r28)
        add r26, r4, r27
        lhz r26, 3(r26)
        cmpw cr0, r28, r26
        beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2:    ; loopentry.loopexit_crit_edge
        add r2, r30, r27
        add r8, r29, r27
        b .LBB_t_3:    ; shortcirc_next.0
.LBB_test_3:    ; shortcirc_next.0
        ...
        blt .LBB_test_1


Next step: get the block out of the loop so that the loop is all
fall-throughs again.

llvm-svn: 22766
2005-08-12 22:06:11 +00:00
Chris Lattner
b7ebe65c56 Change break critical edges to not remove, then insert, PHI node entries.
Instead, just update the BB in-place.  This is both faster, and it prevents
split-critical-edges from shuffling the PHI argument list unneccesarily.

llvm-svn: 22765
2005-08-12 21:58:07 +00:00
Andrew Lenharth
8c6701be6e match gcc's use of tabs, makes diffs easier
llvm-svn: 22764
2005-08-12 16:14:08 +00:00
Andrew Lenharth
ca94102d3e .section cleanup, patch from Nicholas Riley
llvm-svn: 22763
2005-08-12 16:13:43 +00:00
Chris Lattner
4ac8b3f781 First rev of Xcode 2.1 project
llvm-svn: 22762
2005-08-11 22:19:26 +00:00
Jim Laskey
a50f770a2c 1. Added the function isOpcWithIntImmediate to simplify testing of operand with
specified opcode and an integer constant right operand.

2. Modified ISD::SHL, ISD::SRL, ISD::SRA to use rlwinm when applied after a mask.

llvm-svn: 22761
2005-08-11 21:59:23 +00:00
Chris Lattner
d418d752f4 Tidied up the use of dyn_cast<ConstantSDNode> by using isIntImmediate more.
Patch by Jim Laskey.

llvm-svn: 22760
2005-08-11 17:56:50 +00:00
Chris Lattner
c5e1312baa Use a more efficient method of creating integer and float virtual registers
(avoids an extra level of indirection in MakeReg).

  defined MakeIntReg using RegMap->createVirtualRegister(PPC32::GPRCRegisterClass)
  defined MakeFPReg using RegMap->createVirtualRegister(PPC32::FPRCRegisterClass)

  s/MakeReg(MVT::i32)/MakeIntReg/
  s/MakeReg(MVT::f64)/MakeFPReg/

Patch by Jim Laskey!

llvm-svn: 22759
2005-08-11 17:15:31 +00:00
Nate Begeman
5c7656fd53 Add a select_cc optimization for recognizing abs(int). This speeds up an
integer MPEG encoding loop by a factor of two.

llvm-svn: 22758
2005-08-11 02:18:13 +00:00
Nate Begeman
180b08897f Some SELECT_CC cleanups:
1. move assertions for node creation to getNode()
2. legalize the values returned in ExpandOp immediately
3. Move select_cc optimizations from SELECT's getNode() to SELECT_CC's,
   allowing them to be cleaned up significantly.

This paves the way to pick up additional optimizations on SELECT_CC, such
as sum-of-absolute-differences.

llvm-svn: 22757
2005-08-11 01:12:20 +00:00
Nate Begeman
5646b181e8 Make SELECT illegal on PPC32, switch to using SELECT_CC, which more closely
reflects what the hardware is capable of.  This significantly simplifies
the CC handling logic throughout the ISel.

llvm-svn: 22756
2005-08-10 20:52:09 +00:00
Nate Begeman
e5b86d7442 Add new node, SELECT_CC. This node is for targets that don't natively
implement SELECT.

llvm-svn: 22755
2005-08-10 20:51:12 +00:00
Chris Lattner
3428b95634 Changes for PPC32ISelPattern.cpp
1. Clean up how SelectIntImmediateExpr handles use counts.
2. "Subtract from" was not clearing hi 16 bits.

Patch by Jim Laskey

llvm-svn: 22754
2005-08-10 18:11:33 +00:00
Chris Lattner
21c0fd9e8f Fix an oversight that may be causing PR617.
llvm-svn: 22753
2005-08-10 17:37:53 +00:00
Chris Lattner
1a92cb2cd1 now that we handle non-constant strides, this testcase passes
llvm-svn: 22752
2005-08-10 17:17:45 +00:00
Chris Lattner
62df798919 remove some trickiness that broke yacr2 and some other programs last night
llvm-svn: 22751
2005-08-10 17:15:20 +00:00
Chris Lattner
aeedcc7fc2 Changed the XOR case to use the isOprNot predicate.
Patch by Jim Laskey!

llvm-svn: 22750
2005-08-10 16:35:46 +00:00
Chris Lattner
67d0753773 1. Refactored handling of integer immediate values for add, or, xor and sub.
New routine: ISel::SelectIntImmediateExpr
  2. Now checking use counts of large constants.  If use count is > 2 then drop
  thru so that the constant gets loaded into a register.
  Source:

int %test1(int %a) {
entry:
       %tmp.1 = add int %a,      123456789      ; <int> [#uses=1]
       %tmp.2 = or  int %tmp.1,  123456789      ; <int> [#uses=1]
       %tmp.3 = xor int %tmp.2,  123456789      ; <int> [#uses=1]
       %tmp.4 = sub int %tmp.3, -123456789      ; <int> [#uses=1]
       ret int %tmp.4
}

Did Emit:

       .machine ppc970


       .text
       .align  2
       .globl  _test1
_test1:
.LBB_test1_0:   ; entry
       addi r2, r3, -13035
       addis r2, r2, 1884
       ori r2, r2, 52501
       oris r2, r2, 1883
       xori r2, r2, 52501
       xoris r2, r2, 1883
       addi r2, r2, 52501
       addis r3, r2, 1883
       blr


Now Emits:

       .machine ppc970


       .text
       .align  2
       .globl  _test1
_test1:
.LBB_test1_0:   ; entry
       lis r2, 1883
       ori r2, r2, 52501
       add r3, r3, r2
       or r3, r3, r2
       xor r3, r3, r2
       add r3, r3, r2
       blr

Patch by Jim Laskey!

llvm-svn: 22749
2005-08-10 16:34:52 +00:00
Duraid Madina
1c2f9fdf71 sorry!! this is temporary; for some reason the nasty constmul code seems to
be an infinite loop when using g++-4.0.1*, this kills the ia64 nightly
tester. A proper fix shall be forthcoming!!! thanks for not killing me. :)

llvm-svn: 22748
2005-08-10 12:38:57 +00:00
Chris Lattner
5f56d71cd7 Fix a bug compiling: select (i32 < i32), f32, f32
llvm-svn: 22747
2005-08-10 03:40:09 +00:00
Chris Lattner
f83ce5faee Make loop-simplify produce better loops by turning PHI nodes like X = phi [X, Y]
into just Y.  This often occurs when it seperates loops that have collapsed loop
headers.  This implements LoopSimplify/phi-node-simplify.ll

llvm-svn: 22746
2005-08-10 02:07:32 +00:00
Chris Lattner
d54879c136 New testcase
llvm-svn: 22745
2005-08-10 02:06:35 +00:00
Chris Lattner
677d85784a Allow indvar simplify to canonicalize ANY affine IV, not just affine IVs with
constant stride.  This implements Transforms/IndVarsSimplify/variable-stride-ivs.ll

llvm-svn: 22744
2005-08-10 01:12:06 +00:00
Chris Lattner
9af011cc11 new testcase
llvm-svn: 22743
2005-08-10 01:11:24 +00:00
Chris Lattner
35c0e2ee33 Fix an obvious oops
llvm-svn: 22742
2005-08-10 00:59:40 +00:00
Chris Lattner
08c7fd19e1 new testcase we handle
llvm-svn: 22741
2005-08-10 00:48:11 +00:00
Chris Lattner
edff91a49a Teach LSR to strength reduce IVs that have a loop-invariant but non-constant stride.
For code like this:

void foo(float *a, float *b, int n, int stride_a, int stride_b) {
  int i;
  for (i=0; i<n; i++)
      a[i*stride_a] = b[i*stride_b];
}

we now emit:

.LBB_foo2_2:    ; no_exit
        lfs f0, 0(r4)
        stfs f0, 0(r3)
        addi r7, r7, 1
        add r4, r2, r4
        add r3, r6, r3
        cmpw cr0, r7, r5
        blt .LBB_foo2_2 ; no_exit

instead of:

.LBB_foo_2:     ; no_exit
        mullw r8, r2, r7     ;; multiply!
        slwi r8, r8, 2
        lfsx f0, r4, r8
        mullw r8, r2, r6     ;; multiply!
        slwi r8, r8, 2
        stfsx f0, r3, r8
        addi r2, r2, 1
        cmpw cr0, r2, r5
        blt .LBB_foo_2  ; no_exit

loops with variable strides occur pretty often.  For example, in SPECFP2K
there are 317 variable strides in 177.mesa, 3 in 179.art, 14 in 188.ammp,
56 in 168.wupwise, 36 in 172.mgrid.

Now we can allow indvars to turn functions written like this:

void foo2(float *a, float *b, int n, int stride_a, int stride_b) {
  int i, ai = 0, bi = 0;
  for (i=0; i<n; i++)
    {
      a[ai] = b[bi];
      ai += stride_a;
      bi += stride_b;
    }
}

into code like the above for better analysis.  With this patch, they generate
identical code.

llvm-svn: 22740
2005-08-10 00:45:21 +00:00
Chris Lattner
dde7dc525e Fix Regression/Transforms/LoopStrengthReduce/phi_node_update_multiple_preds.ll
by being more careful about updating PHI nodes

llvm-svn: 22739
2005-08-10 00:35:32 +00:00
Chris Lattner
832105d511 new testcase
llvm-svn: 22738
2005-08-10 00:33:01 +00:00
Chris Lattner
c6c4d99a21 Fix some 80 column violations.
Once we compute the evolution for a GEP, tell SE about it.  This allows users
of the GEP to know it, if the users are not direct.  This allows us to compile
this testcase:

void fbSolidFillmmx(int w, unsigned char *d) {
    while (w >= 64) {
        *(unsigned long long *) (d +  0) = 0;
        *(unsigned long long *) (d +  8) = 0;
        *(unsigned long long *) (d + 16) = 0;
        *(unsigned long long *) (d + 24) = 0;
        *(unsigned long long *) (d + 32) = 0;
        *(unsigned long long *) (d + 40) = 0;
        *(unsigned long long *) (d + 48) = 0;
        *(unsigned long long *) (d + 56) = 0;
        w -= 64;
        d += 64;
    }
}

into:

.LBB_fbSolidFillmmx_2:  ; no_exit
        li r2, 0
        stw r2, 0(r4)
        stw r2, 4(r4)
        stw r2, 8(r4)
        stw r2, 12(r4)
        stw r2, 16(r4)
        stw r2, 20(r4)
        stw r2, 24(r4)
        stw r2, 28(r4)
        stw r2, 32(r4)
        stw r2, 36(r4)
        stw r2, 40(r4)
        stw r2, 44(r4)
        stw r2, 48(r4)
        stw r2, 52(r4)
        stw r2, 56(r4)
        stw r2, 60(r4)
        addi r4, r4, 64
        addi r3, r3, -64
        cmpwi cr0, r3, 63
        bgt .LBB_fbSolidFillmmx_2       ; no_exit

instead of:

.LBB_fbSolidFillmmx_2:  ; no_exit
        li r11, 0
        stw r11, 0(r4)
        stw r11, 4(r4)
        stwx r11, r10, r4
        add r12, r10, r4
        stw r11, 4(r12)
        stwx r11, r9, r4
        add r12, r9, r4
        stw r11, 4(r12)
        stwx r11, r8, r4
        add r12, r8, r4
        stw r11, 4(r12)
        stwx r11, r7, r4
        add r12, r7, r4
        stw r11, 4(r12)
        stwx r11, r6, r4
        add r12, r6, r4
        stw r11, 4(r12)
        stwx r11, r5, r4
        add r12, r5, r4
        stw r11, 4(r12)
        stwx r11, r2, r4
        add r12, r2, r4
        stw r11, 4(r12)
        addi r4, r4, 64
        addi r3, r3, -64
        cmpwi cr0, r3, 63
        bgt .LBB_fbSolidFillmmx_2       ; no_exit

llvm-svn: 22737
2005-08-09 23:39:36 +00:00
Chris Lattner
b310ac4a86 implement two helper methods
llvm-svn: 22736
2005-08-09 23:36:33 +00:00
Chris Lattner
67017db5c6 add two helper methods
llvm-svn: 22735
2005-08-09 23:36:18 +00:00
Chris Lattner
679f5b0b40 Fix spelling, fix some broken canonicalizations by my last patch
llvm-svn: 22734
2005-08-09 23:09:05 +00:00
Chris Lattner
fc070f1fd2 I can't believe I caught this before Misha! :)
llvm-svn: 22733
2005-08-09 23:08:53 +00:00
Chris Lattner
54ee86aca7 add a optimization note
llvm-svn: 22732
2005-08-09 22:30:57 +00:00
Chris Lattner
14e060f743 add cc nodes to the AllNodes list so they show up in Graphviz output
llvm-svn: 22731
2005-08-09 20:40:02 +00:00
Chris Lattner
080f741f50 Add testcases for new rlwinm cases handled, patch by Jim Laskey!
llvm-svn: 22730
2005-08-09 20:24:16 +00:00
Chris Lattner
6ec7745e80 Update the targets to the new SETCC/CondCodeSDNode interfaces.
llvm-svn: 22729
2005-08-09 20:21:10 +00:00
Chris Lattner
d47675ed24 Eliminate the SetCCSDNode in favor of a CondCodeSDNode class. This pulls the
CC out of the SetCC operation, making SETCC a standard ternary operation and
CC's a standard DAG leaf.  This will make it possible for other node to use
CC's as operands in the future...

llvm-svn: 22728
2005-08-09 20:20:18 +00:00
Chris Lattner
2035c4f7f8 Minor cleanup patch, no functionality changes. Written by Jim Laskey.
llvm-svn: 22727
2005-08-09 18:29:55 +00:00
Chris Lattner
4c62c647c2 Fix CodeGen/Generic/div-neg-power-2.ll, a regression from last night.
llvm-svn: 22726
2005-08-09 18:08:41 +00:00
Chris Lattner
91fca092db new reg test for a failure last night on ppc/darwin
llvm-svn: 22725
2005-08-09 18:07:45 +00:00
Chris Lattner
02742710f3 SCEVAddExpr::get() of an empty list is invalid.
llvm-svn: 22724
2005-08-09 01:13:47 +00:00
Chris Lattner
23e3fb9e83 This is now implemented
llvm-svn: 22723
2005-08-09 00:19:44 +00:00
Chris Lattner
a091ff1764 Implement: LoopStrengthReduce/share_ivs.ll
Two changes:
  * Only insert one PHI node for each stride.  Other values are live in
    values.  This cannot introduce higher register pressure than the
    previous approach, and can take advantage of reg+reg addressing modes.
  * Factor common base values out of uses before moving values from the
    base to the immediate fields.  This improves codegen by starting the
    stride-specific PHI node out at a common place for each IV use.

As an example, we used to generate this for a loop in swim:

.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2:        ; no_exit.7.i
        lfd f0, 0(r8)
        stfd f0, 0(r3)
        lfd f0, 0(r6)
        stfd f0, 0(r7)
        lfd f0, 0(r2)
        stfd f0, 0(r5)
        addi r9, r9, 1
        addi r2, r2, 8
        addi r5, r5, 8
        addi r6, r6, 8
        addi r7, r7, 8
        addi r8, r8, 8
        addi r3, r3, 8
        cmpw cr0, r9, r4
        bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1

now we emit:

.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2:        ; no_exit.7.i
        lfdx f0, r8, r2
        stfdx f0, r9, r2
        lfdx f0, r5, r2
        stfdx f0, r7, r2
        lfdx f0, r3, r2
        stfdx f0, r6, r2
        addi r10, r10, 1
        addi r2, r2, 8
        cmpw cr0, r10, r4
        bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1

As another more dramatic example, we used to emit this:

.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2:       ; no_exit.1.i19
        lfd f0, 8(r21)
        lfd f4, 8(r3)
        lfd f5, 8(r27)
        lfd f6, 8(r22)
        lfd f7, 8(r5)
        lfd f8, 8(r6)
        lfd f9, 8(r30)
        lfd f10, 8(r11)
        lfd f11, 8(r12)
        fsub f10, f10, f11
        fadd f5, f4, f5
        fmul f5, f5, f1
        fadd f6, f6, f7
        fadd f6, f6, f8
        fadd f6, f6, f9
        fmadd f0, f5, f6, f0
        fnmsub f0, f10, f2, f0
        stfd f0, 8(r4)
        lfd f0, 8(r25)
        lfd f5, 8(r26)
        lfd f6, 8(r23)
        lfd f9, 8(r28)
        lfd f10, 8(r10)
        lfd f12, 8(r9)
        lfd f13, 8(r29)
        fsub f11, f13, f11
        fadd f4, f4, f5
        fmul f4, f4, f1
        fadd f5, f6, f9
        fadd f5, f5, f10
        fadd f5, f5, f12
        fnmsub f0, f4, f5, f0
        fnmsub f0, f11, f3, f0
        stfd f0, 8(r24)
        lfd f0, 8(r8)
        fsub f4, f7, f8
        fsub f5, f12, f10
        fnmsub f0, f5, f2, f0
        fnmsub f0, f4, f3, f0
        stfd f0, 8(r2)
        addi r20, r20, 1
        addi r2, r2, 8
        addi r8, r8, 8
        addi r10, r10, 8
        addi r12, r12, 8
        addi r6, r6, 8
        addi r29, r29, 8
        addi r28, r28, 8
        addi r26, r26, 8
        addi r25, r25, 8
        addi r24, r24, 8
        addi r5, r5, 8
        addi r23, r23, 8
        addi r22, r22, 8
        addi r3, r3, 8
        addi r9, r9, 8
        addi r11, r11, 8
        addi r30, r30, 8
        addi r27, r27, 8
        addi r21, r21, 8
        addi r4, r4, 8
        cmpw cr0, r20, r7
        bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1

we now emit:

.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2:       ; no_exit.1.i19
        lfdx f0, r21, r20
        lfdx f4, r3, r20
        lfdx f5, r27, r20
        lfdx f6, r22, r20
        lfdx f7, r5, r20
        lfdx f8, r6, r20
        lfdx f9, r30, r20
        lfdx f10, r11, r20
        lfdx f11, r12, r20
        fsub f10, f10, f11
        fadd f5, f4, f5
        fmul f5, f5, f1
        fadd f6, f6, f7
        fadd f6, f6, f8
        fadd f6, f6, f9
        fmadd f0, f5, f6, f0
        fnmsub f0, f10, f2, f0
        stfdx f0, r4, r20
        lfdx f0, r25, r20
        lfdx f5, r26, r20
        lfdx f6, r23, r20
        lfdx f9, r28, r20
        lfdx f10, r10, r20
        lfdx f12, r9, r20
        lfdx f13, r29, r20
        fsub f11, f13, f11
        fadd f4, f4, f5
        fmul f4, f4, f1
        fadd f5, f6, f9
        fadd f5, f5, f10
        fadd f5, f5, f12
        fnmsub f0, f4, f5, f0
        fnmsub f0, f11, f3, f0
        stfdx f0, r24, r20
        lfdx f0, r8, r20
        fsub f4, f7, f8
        fsub f5, f12, f10
        fnmsub f0, f5, f2, f0
        fnmsub f0, f4, f3, f0
        stfdx f0, r2, r20
        addi r19, r19, 1
        addi r20, r20, 8
        cmpw cr0, r19, r7
        bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1

llvm-svn: 22722
2005-08-09 00:18:09 +00:00
Chris Lattner
37c24cc98c Suck the base value out of the UsersToProcess vector into the BasedUser
class to simplify the code.  Fuse two loops.

llvm-svn: 22721
2005-08-08 22:56:21 +00:00
Chris Lattner
37ed895bf1 Split MoveLoopVariantsToImediateField out from MoveImmediateValues. The
first is a correctness thing, and the later is an optzn thing.  This also
is needed to support a future change.

llvm-svn: 22720
2005-08-08 22:32:34 +00:00
Nate Begeman
c92787e1f5 Factor out some common code, and be smarter about when to emit load hi/lo
code sequences.

llvm-svn: 22719
2005-08-08 22:22:56 +00:00
Chris Lattner
319292a666 A testcase I don't want to break in the future
llvm-svn: 22718
2005-08-08 22:13:49 +00:00
Chris Lattner
d09a9a788b Allow tools with "consume after" options (like lli) to take more positional
opts than they take directly.  Thanks to John C for pointing this problem
out to me!

llvm-svn: 22717
2005-08-08 21:57:27 +00:00
Chris Lattner
64068eb7da Remove getImmediateForOpcode, which is now dead.
Patch by Jim Laskey.

llvm-svn: 22716
2005-08-08 21:34:13 +00:00
Chris Lattner
25388199a2 Add new immediate handling support for mul/div.
Patch by Jim Laskey!

llvm-svn: 22715
2005-08-08 21:33:23 +00:00
Chris Lattner
8e9dc31928 Add support for OR/XOR/SUB immediates that are handled with the new immediate
way.  This allows ORI/ORIS pairs, for example.

llvm-svn: 22714
2005-08-08 21:30:29 +00:00
Chris Lattner
fd0fe76ba6 Modify the ISD::AND opcode case to use new immediate constant predicates.
Includes wider support for rotate and mask cases.

Patch by Jim Laskey.

I've requested that Jim add new regression tests the newly handled cases.

llvm-svn: 22712
2005-08-08 21:24:57 +00:00
Chris Lattner
81e0e3e933 Modify the ISD::ADD opcode case to use new immediate constant predicates.
Includes support for 32-bit constants using addi/addis.

Patch by Jim Laskey.

llvm-svn: 22711
2005-08-08 21:21:03 +00:00
Chris Lattner
4c54dae243 Modify existing support functions to use new immediate constant predicates.
Patch by Jim Laskey

llvm-svn: 22710
2005-08-08 21:12:35 +00:00
Chris Lattner
3cc070cc36 Add support predicates for future immediate constant changes.
Patch by Jim Laskey

llvm-svn: 22709
2005-08-08 21:10:27 +00:00
Chris Lattner
f2267ed5c5 Move IsRunOfOnes to a more logical place and rename to a proper predicate form
(lowercase isXXX).

Patch by Jim Laskey.

llvm-svn: 22708
2005-08-08 21:08:09 +00:00
Nate Begeman
9a838678b0 Fix JIT encoding of ppc mfocrf instruction; the operands were reversed
llvm-svn: 22707
2005-08-08 20:04:52 +00:00
Chris Lattner
9f269e40c9 Use the new 'moveBefore' method to simplify some code. Really, which is
easier to understand?  :)

llvm-svn: 22706
2005-08-08 19:11:57 +00:00
Chris Lattner
d380d8412d Reject command lines that have too many positional arguments passed (e.g.,
'opt x y').  This fixes PR493.

Patch contributed by Owen Anderson!

llvm-svn: 22705
2005-08-08 17:25:38 +00:00
Chris Lattner
14203e85b2 Not all constants are legal immediates in load/store instructions.
llvm-svn: 22704
2005-08-08 06:25:50 +00:00
Chris Lattner
ac86efb6a3 new testcase, not implemented yet
llvm-svn: 22703
2005-08-08 06:23:47 +00:00
Chris Lattner
c70bbc0c41 Implement LoopStrengthReduce/share_code_in_preheader.ll by having one
rewriter for all code inserted into the preheader, which is never flushed.

llvm-svn: 22702
2005-08-08 05:47:49 +00:00
Chris Lattner
03b6275fb8 It is better to not depend on CSE to share multiplies due to IV insertion.
This testcase checks that only one mul is present in the output code, as it
should be.

llvm-svn: 22701
2005-08-08 05:46:51 +00:00
Chris Lattner
7eecc6cb24 These are both implemented by a recent LSR patch
llvm-svn: 22700
2005-08-08 05:29:51 +00:00
Chris Lattner
9bfa6f8784 Implement a simple optimization for the termination condition of the loop.
The termination condition actually wants to use the post-incremented value
of the loop, not a new indvar with an unusual base.

On PPC, for example, this allows us to compile
LoopStrengthReduce/exit_compare_live_range.ll to:

_foo:
        li r2, 0
.LBB_foo_1:     ; no_exit
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        cmpw cr0, r2, r4
        bne .LBB_foo_1  ; no_exit
        blr

instead of:

_foo:
        li r2, 1                ;; IV starts at 1, not 0
.LBB_foo_1:     ; no_exit
        li r5, 0
        stw r5, 0(r3)
        addi r5, r2, 1
        cmpw cr0, r2, r4
        or r2, r5, r5           ;; Reg-reg copy, extra live range
        bne .LBB_foo_1  ; no_exit
        blr

This implements LoopStrengthReduce/exit_compare_live_range.ll

llvm-svn: 22699
2005-08-08 05:28:22 +00:00
Chris Lattner
24a0a43cb0 add new helper function
llvm-svn: 22698
2005-08-08 05:21:50 +00:00
Chris Lattner
9dae86a54d add a new helper method
llvm-svn: 22697
2005-08-08 05:21:33 +00:00
Chris Lattner
88e2d2ee6b Handle 64-bit constant exprs on 64-bit targets.
llvm-svn: 22696
2005-08-08 04:26:32 +00:00
Chris Lattner
579b20b747 All stats are "Number of ..."
llvm-svn: 22694
2005-08-07 20:02:04 +00:00
Chris Lattner
2c14cf7b74 Add some simple folds that occur in bitfield cases. Fix a minor bug in
isHighOnes, where it would consider 0 to have high ones.

llvm-svn: 22693
2005-08-07 07:03:10 +00:00
Chris Lattner
134ebd0801 Fix typoCVS: ----------------------------------------------------------------------
llvm-svn: 22692
2005-08-07 07:00:52 +00:00
Chris Lattner
0c26a0b902 add a small simplification that can be exposed after promotion/expansion
llvm-svn: 22691
2005-08-07 05:00:44 +00:00
Chris Lattner
f4dd8c445c * Use the new PHINode::hasConstantValue method to simplify some code
* Teach this code to move allocas out of the loop when tail call eliminating
  a call marked 'tail'.  This implements TailCallElim/move_alloca_for_tail_call.ll
* Do not perform this transformation if a call is marked 'tail' and if there
  are allocas that we cannot move out of the loop in #2.  Doing so would increase
  the stack usage of the function.  This implements fixes
  PR615 and TailCallElim/dont-tce-tail-marked-call.ll.

llvm-svn: 22690
2005-08-07 04:27:41 +00:00
Chris Lattner
d670e5c88a New testcases for PR615
llvm-svn: 22689
2005-08-07 04:25:39 +00:00
Chris Lattner
983a415b6a Consolidate the GPOpt stuff to all use the Subtarget, instead of still
depending on the command line option.  Now the command line option just
sets the subtarget as appropriate.  G5 opts will now default to on on
G5-enabled nightly testers among other machines.

llvm-svn: 22688
2005-08-05 22:05:03 +00:00
Chris Lattner
158acab986 adjust to change in getSubtarget() api
llvm-svn: 22687
2005-08-05 21:54:27 +00:00
Chris Lattner
b5887385c4 Since getSubtarget() always provides a const Subtarget, dont' require the user
to pass it in.  Also, since it always returns a non-null pointer, make it
return a reference instead for easier use.

llvm-svn: 22686
2005-08-05 21:53:21 +00:00
Chris Lattner
431b8d80bd Enable gp optimizations by default when available, even when a target triple
is available, since the target triple doesn't specify whether to use gpopts
or not.

llvm-svn: 22685
2005-08-05 21:25:13 +00:00
Chris Lattner
d01cf9cfd0 teach TestRunner about prcontext
llvm-svn: 22683
2005-08-05 19:48:29 +00:00
Chris Lattner
8a9f9f4735 two simple testcases loopreduce should handle but does not yet currently
llvm-svn: 22682
2005-08-05 19:47:39 +00:00
Chris Lattner
11fc319b5d add a note
llvm-svn: 22681
2005-08-05 19:18:32 +00:00
Chris Lattner
96ad31321a Change FindEarliestCallSeqEnd (used by libcall insertion) to use a set to
avoid revisiting nodes more than once.  This eliminates a source of
potentially exponential behavior.  For a small function in 191.fma3d
(hexah_stress_divergence_), this speeds up isel from taking > 20mins to
taking 0.07s.

llvm-svn: 22680
2005-08-05 18:10:27 +00:00
Chris Lattner
1095dc94a9 Fix a use-of-dangling-pointer bug, from the introduction of SrcValue's.
llvm-svn: 22679
2005-08-05 16:55:31 +00:00
Chris Lattner
cabdc34563 Fix a latent bug in the libcall inserter that was exposed by Nate's patch
yesterday.  This fixes whetstone and a bunch of programs in the External tests.

llvm-svn: 22678
2005-08-05 16:23:57 +00:00
Chris Lattner
8c636bf8b2 don't crash when running the PPC backend on non-ppc hosts without specifying
a subtarget.

llvm-svn: 22677
2005-08-05 16:17:22 +00:00
Chris Lattner
6e709c1318 PHINode::hasConstantValue should never return the PHI itself, even if the
PHI is its only operand.

llvm-svn: 22676
2005-08-05 15:37:31 +00:00
Chris Lattner
1749aaa5e6 Fix an iterator invalidation problem when we decide a phi has a constant value
llvm-svn: 22675
2005-08-05 15:34:10 +00:00
Chris Lattner
11e7a5eda7 Make sure to clean CastedPointers after casts are potentially deleted.
This fixes LSR crashes on 301.apsi, 191.fma3d, and 189.lucas

llvm-svn: 22673
2005-08-05 01:30:11 +00:00
Chris Lattner
9f9c260b8c now that hasConstantValue defaults to only returning values that dominate
the PHI node, this ugly code can vanish.

llvm-svn: 22672
2005-08-05 01:04:30 +00:00
Chris Lattner
37774affb1 Invoke instructions do not dominate all successors
llvm-svn: 22671
2005-08-05 01:03:27 +00:00
Chris Lattner
6f58350daf Now that hasConstantValue is more careful w.r.t. returning values that only
dominate the PHI node, this code can go away.  This also makes passes more
aggressive, e.g. implementing Transforms/CondProp/phisimplify2.ll

llvm-svn: 22670
2005-08-05 01:02:04 +00:00
Chris Lattner
bcd8d2c6e5 Use the bool argument to hasConstantValue to decide whether the client is
prepared to deal with return values that do not dominate the PHI.  If we
cannot prove that the result dominates the PHI node, do not return it if
the client can't cope.

llvm-svn: 22669
2005-08-05 01:00:58 +00:00
Chris Lattner
f4c5ad8d61 new testcase that condprop should handle. The PHI node becomes useless
after threading the branch, because both operands are the same value.

llvm-svn: 22668
2005-08-05 00:59:55 +00:00
Chris Lattner
257efb2ad3 This code can handle non-dominating instructions
llvm-svn: 22667
2005-08-05 00:57:45 +00:00
Chris Lattner
1d8b24878f Mark hasConstantValue as a const method
llvm-svn: 22666
2005-08-05 00:49:06 +00:00
Nate Begeman
0a94dec78a Add an extra parameter that Chris requested
llvm-svn: 22665
2005-08-04 23:50:43 +00:00
Nate Begeman
b392321cae Fix a fixme in CondPropagate.cpp by moving a PhiNode optimization into
BasicBlock's removePredecessor routine.  This requires shuffling around
the definition and implementation of hasContantValue from Utils.h,cpp into
Instructions.h,cpp

llvm-svn: 22664
2005-08-04 23:24:19 +00:00
Chris Lattner
a75342d89f add a testcase nate requested
llvm-svn: 22663
2005-08-04 22:49:32 +00:00
Chris Lattner
45f8b6e7aa Modify how immediates are removed from base expressions to deal with the fact
that the symbolic evaluator is not always able to use subtraction to remove
expressions.  This makes the code faster, and fixes the last crash on 178.galgel.
Finally, add a statistic to see how many phi nodes are inserted.

On 178.galgel, we get the follow stats:

2562 loop-reduce  - Number of PHIs inserted
3927 loop-reduce  - Number of GEPs strength reduced

llvm-svn: 22662
2005-08-04 22:34:05 +00:00
Nate Begeman
77558da546 Fix a fixme in LegalizeDAG
llvm-svn: 22661
2005-08-04 21:43:28 +00:00
Nate Begeman
e3cbe1027d Hack to naturally align doubles in the constant pool. Remove this once we
know what The Right Thing To Do is.

llvm-svn: 22660
2005-08-04 21:04:09 +00:00
Nate Begeman
295ea90634 Use the new subtarget support to automatically choose the correct ABI
and asm printer for PowerPC if one is not specified.

llvm-svn: 22659
2005-08-04 20:49:48 +00:00
Chris Lattner
a6d7c355bc * Refactor some code into a new BasedUser::RewriteInstructionToUseNewBase
method.
* Fix a crash on 178.galgel, where we would insert expressions before PHI
  nodes instead of into the PHI node predecessor blocks.

llvm-svn: 22657
2005-08-04 20:03:32 +00:00
Chris Lattner
ed87aa97d4 This should not run lli, that is for llvm-test.
llvm-svn: 22656
2005-08-04 19:56:35 +00:00
Chris Lattner
af783c58cf None of these tests should require a working lli, they are codegen tests,
not execution tests.

llvm-svn: 22655
2005-08-04 19:55:39 +00:00
Chris Lattner
0f7c0fa2a7 Fix a case that caused this to crash on 178.galgel
llvm-svn: 22653
2005-08-04 19:26:19 +00:00
Chris Lattner
acc42c4df1 Teach LSR about loop-variant expressions, such as loops like this:
for (i = 0; i < N; ++i)
    A[i][foo()] = 0;

here we still want to strength reduce the A[i] part, even though foo() is
l-v.

This also simplifies some of the 'CanReduce' logic.

This implements Transforms/LoopStrengthReduce/ops_after_indvar.ll

llvm-svn: 22652
2005-08-04 19:08:16 +00:00
Chris Lattner
faf17b43da This testcase now passes
llvm-svn: 22651
2005-08-04 19:08:07 +00:00
Nate Begeman
456044b724 Remove some more dead code.
llvm-svn: 22650
2005-08-04 18:13:56 +00:00
Chris Lattner
eaf24725b2 Refactor this code substantially with the following improvements:
1. We only analyze instructions once, guaranteed
  2. AnalyzeGetElementPtrUsers has been ripped apart and replaced with
     something much simpler.

The next step is to handle expressions that are not all indvar+loop-invariant
values (e.g. handling indvar+loopvariant).

llvm-svn: 22649
2005-08-04 17:40:30 +00:00
Andrew Lenharth
5adb830b30 No, IDEFs shouldn't be JITed
llvm-svn: 22648
2005-08-04 15:32:36 +00:00
Misha Brukman
a54e201edf * Unbreak release build
* Add comments to #endif pragmas for readability

llvm-svn: 22647
2005-08-04 14:22:41 +00:00
Misha Brukman
41acd5e08d * Unbreak optimized build (noticed by Eric van Riet Paap)
* Comment #endif clauses for readability

llvm-svn: 22646
2005-08-04 14:16:48 +00:00
Nate Begeman
3bcfcd9474 Add Subtarget support to PowerPC. Next up, using it.
llvm-svn: 22644
2005-08-04 07:12:09 +00:00
Chris Lattner
6f286b760f refactor some code
llvm-svn: 22643
2005-08-04 01:19:13 +00:00
Chris Lattner
9969c8613a this is not implemented by lsr yet
llvm-svn: 22642
2005-08-04 01:18:48 +00:00
Chris Lattner
6510749050 invert to if's to make the logic simpler
llvm-svn: 22641
2005-08-04 00:40:47 +00:00
Chris Lattner
a0102fbc4f When processing outer loops and we find uses of an IV in inner loops, make
sure to handle the use, just don't recurse into it.

This permits us to generate this code for a simple nested loop case:

.LBB_foo_0:     ; entry
        stwu r1, -48(r1)
        stw r29, 44(r1)
        stw r30, 40(r1)
        mflr r11
        stw r11, 56(r1)
        lis r2, ha16(L_A$non_lazy_ptr)
        lwz r30, lo16(L_A$non_lazy_ptr)(r2)
        li r29, 1
.LBB_foo_1:     ; no_exit.0
        bl L_bar$stub
        li r2, 1
        or r3, r30, r30
.LBB_foo_2:     ; no_exit.1
        lfd f0, 8(r3)
        stfd f0, 0(r3)
        addi r4, r2, 1
        addi r3, r3, 8
        cmpwi cr0, r2, 100
        or r2, r4, r4
        bne .LBB_foo_2  ; no_exit.1
.LBB_foo_3:     ; loopexit.1
        addi r30, r30, 800
        addi r2, r29, 1
        cmpwi cr0, r29, 100
        or r29, r2, r2
        bne .LBB_foo_1  ; no_exit.0
.LBB_foo_4:     ; return
        lwz r11, 56(r1)
        mtlr r11
        lwz r30, 40(r1)
        lwz r29, 44(r1)
        lwz r1, 0(r1)
        blr

instead of this:

_foo:
.LBB_foo_0:     ; entry
        stwu r1, -48(r1)
        stw r28, 44(r1)                   ;; uses an extra register.
        stw r29, 40(r1)
        stw r30, 36(r1)
        mflr r11
        stw r11, 56(r1)
        li r30, 1
        li r29, 0
        or r28, r29, r29
.LBB_foo_1:     ; no_exit.0
        bl L_bar$stub
        mulli r2, r28, 800           ;; unstrength-reduced multiply
        lis r3, ha16(L_A$non_lazy_ptr)   ;; loop invariant address computation
        lwz r3, lo16(L_A$non_lazy_ptr)(r3)
        add r2, r2, r3
        mulli r4, r29, 800           ;; unstrength-reduced multiply
        addi r3, r3, 8
        add r3, r4, r3
        li r4, 1
.LBB_foo_2:     ; no_exit.1
        lfd f0, 0(r3)
        stfd f0, 0(r2)
        addi r5, r4, 1
        addi r2, r2, 8                 ;; multiple stride 8 IV's
        addi r3, r3, 8
        cmpwi cr0, r4, 100
        or r4, r5, r5
        bne .LBB_foo_2  ; no_exit.1
.LBB_foo_3:     ; loopexit.1
        addi r28, r28, 1               ;;; Many IV's with stride 1
        addi r29, r29, 1
        addi r2, r30, 1
        cmpwi cr0, r30, 100
        or r30, r2, r2
        bne .LBB_foo_1  ; no_exit.0
.LBB_foo_4:     ; return
        lwz r11, 56(r1)
        mtlr r11
        lwz r30, 36(r1)
        lwz r29, 40(r1)
        lwz r28, 44(r1)
        lwz r1, 0(r1)
        blr

llvm-svn: 22640
2005-08-04 00:14:11 +00:00
Chris Lattner
fc62470466 Teach loop-reduce to see into nested loops, to pull out immediate values
pushed down by SCEV.

In a nested loop case, this allows us to emit this:

        lis r3, ha16(L_A$non_lazy_ptr)
        lwz r3, lo16(L_A$non_lazy_ptr)(r3)
        add r2, r2, r3
        li r3, 1
.LBB_foo_2:     ; no_exit.1
        lfd f0, 8(r2)        ;; Uses offset of 8 instead of 0
        stfd f0, 0(r2)
        addi r4, r3, 1
        addi r2, r2, 8
        cmpwi cr0, r3, 100
        or r3, r4, r4
        bne .LBB_foo_2  ; no_exit.1

instead of this:

        lis r3, ha16(L_A$non_lazy_ptr)
        lwz r3, lo16(L_A$non_lazy_ptr)(r3)
        add r2, r2, r3
        addi r3, r3, 8
        li r4, 1
.LBB_foo_2:     ; no_exit.1
        lfd f0, 0(r3)
        stfd f0, 0(r2)
        addi r5, r4, 1
        addi r2, r2, 8
        addi r3, r3, 8
        cmpwi cr0, r4, 100
        or r4, r5, r5
        bne .LBB_foo_2  ; no_exit.1

llvm-svn: 22639
2005-08-03 23:44:42 +00:00
Chris Lattner
bb78c97e24 improve debug output
llvm-svn: 22638
2005-08-03 23:30:08 +00:00
Nate Begeman
8d394eb703 Scalar SSE: load +0.0 -> xorps/xorpd
Scalar SSE: a < b ? c : 0.0 -> cmpss, andps
Scalar SSE: float -> i16 needs to be promoted

llvm-svn: 22637
2005-08-03 23:26:28 +00:00
Chris Lattner
47b5732252 this now passes
llvm-svn: 22636
2005-08-03 22:51:40 +00:00
Chris Lattner
db23c74e5e Move from Stage 0 to Stage 1.
Only emit one PHI node for IV uses with identical bases and strides (after
moving foldable immediates to the load/store instruction).

This implements LoopStrengthReduce/dont_insert_redundant_ops.ll, allowing
us to generate this PPC code for test1:

        or r30, r3, r3
.LBB_test1_1:   ; Loop
        li r2, 0
        stw r2, 0(r30)
        stw r2, 4(r30)
        bl L_pred$stub
        addi r30, r30, 8
        cmplwi cr0, r3, 0
        bne .LBB_test1_1        ; Loop

instead of this code:

        or r30, r3, r3
        or r29, r3, r3
.LBB_test1_1:   ; Loop
        li r2, 0
        stw r2, 0(r29)
        stw r2, 4(r30)
        bl L_pred$stub
        addi r30, r30, 8        ;; Two iv's with step of 8
        addi r29, r29, 8
        cmplwi cr0, r3, 0
        bne .LBB_test1_1        ; Loop

llvm-svn: 22635
2005-08-03 22:51:21 +00:00
Andrew Lenharth
3a18a39587 Alpha ABI specifies stack is always 16 byte alligned, and gcc does it, so I will too
llvm-svn: 22634
2005-08-03 22:33:21 +00:00
Chris Lattner
430d0022df Rename IVUse to IVUsersOfOneStride, use a struct instead of a pair to
unify some parallel vectors and get field names more descriptive than
"first" and "second".  This isn't lisp afterall :)

llvm-svn: 22633
2005-08-03 22:21:05 +00:00
Chris Lattner
84e9baa925 Fix a nasty dangling pointer issue. The ScalarEvolution pass would keep a
map from instruction* to SCEVHandles.  When we delete instructions, we have
to tell it about it.  We would run into nasty cases where new instructions
were reallocated at old instruction addresses and get the old map values.
Bad bad bad :(

llvm-svn: 22632
2005-08-03 21:36:09 +00:00
Chris Lattner
938ebaa2b0 Fix this to test the BE we care about
llvm-svn: 22631
2005-08-03 21:01:46 +00:00
Chris Lattner
1d465e8925 Fix an obvious bug in the Log2 stuff that broke SingleSource/UnitTests/2005-05-12-Int64ToFP
last night.

llvm-svn: 22630
2005-08-03 20:53:19 +00:00
Chris Lattner
8191442548 Fix PR611, codegen'ing SREM of FP operands to fmod or fmodf instead of
the sequence used for integer ops

llvm-svn: 22629
2005-08-03 20:31:37 +00:00
Chris Lattner
3de05cc930 The correct fix for PR612, which also fixes
Transforms/LowerInvoke/2005-08-03-InvokeWithPHIUse.ll

llvm-svn: 22628
2005-08-03 18:51:44 +00:00
Chris Lattner
c519a7e06e new testcase for PR612
llvm-svn: 22627
2005-08-03 18:51:15 +00:00
Chris Lattner
f8a81a9886 When inserting code, make sure not to insert it before PHI nodes. This
fixes PR612 and Transforms/LowerInvoke/2005-08-03-InvokeWithPHI.ll

llvm-svn: 22626
2005-08-03 18:34:29 +00:00
Chris Lattner
89ba7922f4 new testcase for PR612
llvm-svn: 22625
2005-08-03 18:33:48 +00:00
Nate Begeman
b3b86d5692 Add a couple rlwinm tests for bitfield clears
llvm-svn: 22624
2005-08-03 18:27:17 +00:00
Nate Begeman
134628b4fb Update rlwimi tests to catch all the cases we care about
llvm-svn: 22623
2005-08-03 18:11:23 +00:00
Chris Lattner
0ca5d9cb12 Testcase that used to crash simplifycfg
llvm-svn: 22622
2005-08-03 18:01:07 +00:00
Chris Lattner
d683bdd0f8 Fix Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll, a problem that
occurred while bugpointing another testcase

llvm-svn: 22621
2005-08-03 17:59:45 +00:00
Chris Lattner
590642eb91 add support for Graphviz when viewing CFGs
llvm-svn: 22620
2005-08-03 17:55:05 +00:00
Misha Brukman
fce3285891 Fix grammar: apostrophe-s ('s) is possessive, not plural; also iff vs. if.
llvm-svn: 22619
2005-08-03 17:29:52 +00:00
Chris Lattner
8aa621c4b1 Wrap comments to 80 cols, fix code sequence for CountLeadingZeros_64 on
non-ppc GCC 4.0 machines.  Patch by Jim Laskey!

llvm-svn: 22618
2005-08-03 16:53:58 +00:00
Chris Lattner
8dc82b7909 minor capitalization thing, patch by Jim Laskey
llvm-svn: 22617
2005-08-03 16:52:22 +00:00
Chris Lattner
dfc20bf2dd Fix another bug in the clz patch that caused miscompilations when !gcc4
llvm-svn: 22616
2005-08-03 01:04:40 +00:00
Chris Lattner
2dbf1960ff Finally, add the required constraint checks to fix Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll
the right way

llvm-svn: 22615
2005-08-03 00:59:12 +00:00
Chris Lattner
42b635c70c un-xfail this
llvm-svn: 22614
2005-08-03 00:58:44 +00:00
Chris Lattner
908036942c Simplify some code, add the correct pred checks
llvm-svn: 22613
2005-08-03 00:38:27 +00:00
Chris Lattner
982b75c061 Refactor code out of PropagatePredecessorsForPHIs, turning it into a pure function with no side-effects
llvm-svn: 22612
2005-08-03 00:29:26 +00:00
Chris Lattner
1f047fd513 use splice instead of remove/insert to avoid some symtab operations
llvm-svn: 22611
2005-08-03 00:23:42 +00:00
Chris Lattner
76dc204488 move two functions up in the file, use SafeToMergeTerminators to eliminate
some duplicated code

llvm-svn: 22610
2005-08-03 00:19:45 +00:00
Chris Lattner
733d6704ce Rip some code out of the main SimplifyCFG function into a subfunction and
call it from the only place it is live.  No functionality changes.

llvm-svn: 22609
2005-08-03 00:11:16 +00:00
Chris Lattner
e972403215 This fails for now
llvm-svn: 22608
2005-08-03 00:10:28 +00:00
Chris Lattner
ac594de8dc Disable this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050801/027345.html

This breaks real programs and only fixes an obscure regression testcase.  A
real fix is in development.

llvm-svn: 22606
2005-08-02 23:31:38 +00:00
Chris Lattner
eee90f7eb4 Change a place to use an arbitrary value instead of null, when possible
llvm-svn: 22605
2005-08-02 23:29:23 +00:00
Chris Lattner
bd615f518c If the user interrupts bugpoint, don't extract loops
llvm-svn: 22603
2005-08-02 23:25:56 +00:00
Chris Lattner
68095d7722 Add a note, people are responsible for requesting that they be added to the
file.

llvm-svn: 22602
2005-08-02 22:10:21 +00:00
Chris Lattner
ab08df9699 Pass -export-dynamic to gcc when compiling with -native and the link is
performed with -export-dynamic (aka. -disable-internalize).

Patch by Nicholas Riley!

llvm-svn: 22601
2005-08-02 22:07:38 +00:00
Chris Lattner
0caa43492f Fix the non-gcc 4.0 paths for countleadingzeros
Patch fixed by Jim Laskey

llvm-svn: 22598
2005-08-02 20:21:33 +00:00
Chris Lattner
fba2e9c8f9 Fix inverted conditionals
llvm-svn: 22597
2005-08-02 20:06:18 +00:00
Chris Lattner
80e038c148 one more hunk that got dropped
llvm-svn: 22596
2005-08-02 19:35:29 +00:00
Chris Lattner
989d8bbda9 This hunk accidentally got dropped. Patch by Jim Laskey
llvm-svn: 22595
2005-08-02 19:30:55 +00:00
Chris Lattner
6667bdbaca Update to use the new MathExtras.h support for log2 computation.
Patch contributed by Jim Laskey!

llvm-svn: 22594
2005-08-02 19:26:06 +00:00
Chris Lattner
44060e0871 Fix the non-gcc 4.0 path to compile
llvm-svn: 22593
2005-08-02 19:21:51 +00:00
Chris Lattner
22d00a8e90 Update to use the new MathExtras.h support for log2 computation.
Patch contributed by Jim Laskey!

llvm-svn: 22592
2005-08-02 19:16:58 +00:00
Chris Lattner
e1d60c39aa Consolidate all of the various log2 computing functions into MathExtras.h.
Also, provide accelerated implementations when building with GCC.
Patch contributed by Jim Laskey!

llvm-svn: 22591
2005-08-02 19:15:30 +00:00
Chris Lattner
25865406f0 Update a doc, patch contributed by Jim Laskey!
llvm-svn: 22590
2005-08-02 19:14:25 +00:00
Chris Lattner
c98d48fabe add a pass name to make debugging dumps nicer
llvm-svn: 22588
2005-08-02 19:07:49 +00:00
Misha Brukman
c9076e0acf Fix grammar: it's == "it is".
llvm-svn: 22587
2005-08-02 16:04:59 +00:00
Chris Lattner
351b891cbc Like the comment says, do not insert cast instructions before phi nodes
llvm-svn: 22586
2005-08-02 03:31:14 +00:00
Jeff Cohen
9aafa06bef It's dangerous coding on Mondays.
llvm-svn: 22585
2005-08-02 03:26:32 +00:00
Chris Lattner
4fd3e16cbd This code was very close, but not quite right. It did not take into
consideration the case where a reference in an unreachable block could
occur.  This fixes Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll,
something I ran into while bugpoint'ing another pass.

llvm-svn: 22584
2005-08-02 03:24:05 +00:00
Chris Lattner
8530d6d0af New testcase that caused simplifycfg to crash
llvm-svn: 22583
2005-08-02 03:23:03 +00:00
Jeff Cohen
ba7cc68594 Implement SetInterruptFunction for Windows.
llvm-svn: 22582
2005-08-02 03:04:47 +00:00
Chris Lattner
75a44e154e add a comment, make a check more lenient
llvm-svn: 22581
2005-08-02 02:52:02 +00:00
Chris Lattner
dcce49e006 Simplify for loop, clear a per-loop map after processing each loop
llvm-svn: 22580
2005-08-02 02:44:31 +00:00
Chris Lattner
beb01faea3 When the user hits ctrl-c, bugpoint should attempt to stop reduction as
quickly as possible and output what it has so far.  If they hit it twice,
bugpoint is killed.

llvm-svn: 22579
2005-08-02 02:16:17 +00:00
Chris Lattner
6a5d6ecd09 Implement sys::SetInterruptFunction on Unix, stub it on win32 so that the
build will not fail

llvm-svn: 22578
2005-08-02 02:14:22 +00:00
Chris Lattner
a429d00757 add a new function proto
llvm-svn: 22577
2005-08-02 02:13:42 +00:00
Chris Lattner
9ef1294210 Add a comment
Make LSR ignore GEP's that have loop variant base values, as we currently
cannot codegen them

llvm-svn: 22576
2005-08-02 01:32:29 +00:00
Chris Lattner
564900e5e5 Fix an iterator invalidation problem
llvm-svn: 22575
2005-08-02 00:41:11 +00:00
Chris Lattner
fca31aee4f 200.sixtrack prints FP numbers with a very strange notation that uses D
instead of E for exponentials (e.g. 1.234D-43).  Add support for this
notation.

llvm-svn: 22574
2005-08-02 00:11:53 +00:00
Chris Lattner
b30c947ceb make is the standard name, not gmake
llvm-svn: 22573
2005-08-02 00:10:52 +00:00
Chris Lattner
0545ae9ca4 Mark these as V9 specific
llvm-svn: 22572
2005-08-01 20:38:31 +00:00
Andrew Lenharth
ae97fff758 update function codes to reflect /su flags that have been added since this was written
llvm-svn: 22571
2005-08-01 20:06:01 +00:00
Chris Lattner
4398daf069 Fix casts from long to sbyte on ppc
llvm-svn: 22570
2005-08-01 18:16:37 +00:00
Andrew Lenharth
33bbf15147 use llabs not abs
llvm-svn: 22569
2005-08-01 17:47:28 +00:00
Andrew Lenharth
27f1e26db7 one cannot allocate a global, until one is done initializing the global pointers
llvm-svn: 22568
2005-08-01 17:35:40 +00:00
Chris Lattner
8a3d007d75 temporarily fail these two tests until LSR evolves to support them
llvm-svn: 22567
2005-08-01 17:10:50 +00:00
Chris Lattner
e17c5d0e59 ConstantInt::get only works for arguments < 128.
SimplifyLibCalls probably has to be audited to make sure it does not make
this mistake elsewhere.  Also, if this code knows that the type will be
unsigned, obviously one arm of this is dead.

Reid, can you take a look into this further?

llvm-svn: 22566
2005-08-01 16:52:50 +00:00
Jeff Cohen
546fd5944e Keep tabs and trailing spaces out.
llvm-svn: 22565
2005-07-30 18:33:25 +00:00
Jeff Cohen
c500991055 Fix VC++ build problems.
llvm-svn: 22564
2005-07-30 18:22:27 +00:00
Chris Lattner
941d84a34d fix float->long conversions on x86
llvm-svn: 22563
2005-07-30 01:40:57 +00:00
Chris Lattner
4c0f43edf6 this tests every fp-to-integer conversion
llvm-svn: 22562
2005-07-30 01:33:38 +00:00
Chris Lattner
4913457573 fix a typeo
llvm-svn: 22561
2005-07-30 00:43:00 +00:00
Nate Begeman
17a0e2afea Ack, typo
llvm-svn: 22560
2005-07-30 00:21:31 +00:00
Chris Lattner
aeef51b6b7 Change the fp to integer code to not perform 2-byte stores followed by
1 byte loads and other operations.  This is bad for store-forwarding on
common CPUs.  We now do this:

fnstcw WORD PTR [%ESP]
mov %AX, WORD PTR [%ESP]

instead of:

fnstcw WORD PTR [%ESP]
mov %AL, BYTE PTR [%ESP + 1]

llvm-svn: 22559
2005-07-30 00:17:52 +00:00
Nate Begeman
e68bcd1946 Commit a new LoopStrengthReduce pass that can use scalar evolutions and
target data to decide which loop induction variables to strength reduce
and how to do so.  This work is mostly by Chris Lattner, with tweaks by
me to get it working on some of MultiSource.

llvm-svn: 22558
2005-07-30 00:15:07 +00:00
Nate Begeman
2bca4d9b7b Break SCEVExpander out of IndVarSimplify into its own .h/.cpp file so that
other passes may use it.

llvm-svn: 22557
2005-07-30 00:12:19 +00:00
Chris Lattner
4738d1b5cd Use a custom expander for all FP to int conversions, as the X86 only has
FP-to-int-in-memory: this exposes the load from the stored slot to the
selection dag, allowing it to be folded into other operaions.

llvm-svn: 22556
2005-07-30 00:05:54 +00:00
Chris Lattner
f59b2daddb Allow targets to have custom expanders for FP_TO_*INT conversions where
both the src and dest values are legal

llvm-svn: 22555
2005-07-30 00:04:12 +00:00
Andrew Lenharth
0940218cca support near allocations for the JIT
llvm-svn: 22554
2005-07-29 23:40:16 +00:00
Andrew Lenharth
2f9c52e194 turn off GOT on archs that didn't use it (not that it appeard to harm them much with it on)
llvm-svn: 22553
2005-07-29 23:32:02 +00:00
Chris Lattner
bc85c32c73 Implement a FIXME: move a bunch of cruft for handling FP_TO_*INT operations
that the X86 does not support to the legalizer.  This allows it to be better
optimized, etc, and will help with SSE support.

llvm-svn: 22551
2005-07-29 01:00:29 +00:00
Chris Lattner
6dc60e859b Don't forget to diddle with the control word when performing an FISTP64.
llvm-svn: 22550
2005-07-29 00:54:34 +00:00
Chris Lattner
67756e2e22 Use a custom expander to compile this:
long %test4(double %X) {
        %tmp.1 = cast double %X to long         ; <long> [#uses=1]
        ret long %tmp.1
}

to this:

_test4:
        sub %ESP, 12
        fld QWORD PTR [%ESP + 16]
        fistp QWORD PTR [%ESP]
        mov %EDX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%ESP]
        add %ESP, 12
        ret

instead of this:

_test4:
        sub %ESP, 28
        fld QWORD PTR [%ESP + 32]
        fstp QWORD PTR [%ESP]
        call ___fixdfdi
        add %ESP, 28
        ret

llvm-svn: 22549
2005-07-29 00:40:01 +00:00
Chris Lattner
fe68d75aad Allow targets to define custom expanders for FP_TO_*INT
llvm-svn: 22548
2005-07-29 00:33:32 +00:00
Chris Lattner
44fe26ff07 allow a target to request that unknown FP_TO_*INT conversion be promoted to
a larger integer destination.

llvm-svn: 22547
2005-07-29 00:11:56 +00:00
Chris Lattner
f99f8f9081 instead of having all conversions be handled by one case value, and then have
subcases inside, break things out earlier.

llvm-svn: 22546
2005-07-28 23:31:12 +00:00
Chris Lattner
7727bbfb06 New testcase for PR610
llvm-svn: 22545
2005-07-28 20:18:33 +00:00
Andrew Lenharth
1ec48e8683 support bsr, and more .td simplification
llvm-svn: 22543
2005-07-28 18:14:47 +00:00
Andrew Lenharth
3faa82219a new is not a valid default anywhere, so make this pure virtual
llvm-svn: 22542
2005-07-28 18:13:59 +00:00
Reid Spencer
29f83e0997 Fix a problem in getDirectoryContents where sub-directory names were
appended to a path string that didn't end in a slash, yielding invalid
path names.

Path contribute by Nicholas Riley.

llvm-svn: 22539
2005-07-28 16:25:57 +00:00
Andrew Lenharth
b57b0baac0 get lazy JITing working. Some of shootout runs now
llvm-svn: 22538
2005-07-28 12:45:20 +00:00
Andrew Lenharth
3444cf5128 Like constants, globals on some platforms are GOT relative. This means they have to be allocated
near the GOT, which new doesn't do.  So break out the allocate into a new function.

Also move GOT index handling into JITResolver.  This lets it update the mapping when a Lazy
function is JITed.  It doesn't managed the table, just the mapping.  Note that this is
still non-ideal, as any function that takes a function address should also take a GOT
index, but that is a lot of changes.  The relocation resolve process updates any GOT entry
it sees is out of date.

llvm-svn: 22537
2005-07-28 12:44:13 +00:00
Chris Lattner
a8195603e4 Eliminate an extra copy from R1 that Nate noticed on function calls that
have to write arguments to the stack

llvm-svn: 22536
2005-07-28 05:23:43 +00:00
Chris Lattner
7c38bd14ef Specify the correct number of operands
llvm-svn: 22535
2005-07-28 04:42:11 +00:00
Reid Spencer
87c5a8a48a Run the verifier pass after all the other passes rather than before them.
This catches mistakes in the passes rather than just verifying the bytecode
input to llc.

llvm-svn: 22534
2005-07-28 04:00:49 +00:00
Nate Begeman
c5b6bd9a8e Fold constant adds into loads and stores to frame indices.
For the following code:
double %ext(int %A.0__, long %A.1__) {
        %A_addr = alloca %typedef.DComplex              ; <%typedef.DComplex*> [#uses=2]
        %tmp.1 = cast %typedef.DComplex* %A_addr to int*                ; <int*> [#uses=1]
        store int %A.0__, int* %tmp.1
        %tmp.2 = getelementptr %typedef.DComplex* %A_addr, int 0, uint 1                ; <double*> [#uses=2]
        %tmp.3 = cast double* %tmp.2 to long*           ; <long*> [#uses=1]
        store long %A.1__, long* %tmp.3
        %tmp.5 = load double* %tmp.2            ; <double> [#uses=1]
        ret double %tmp.5
}

We now generate:
_ext:
.LBB_ext_0:     ;
        stw r3, -12(r1)
        stw r4, -8(r1)
        stw r5, -4(r1)
        lfd f1, -8(r1)
        blr

Instead of:
_ext:
.LBB_ext_0:     ;
        stw r3, -12(r1)
        addi r2, r1, -12
        stw r4, 4(r2)
        stw r5, 8(r2)
        lfd f1, 4(r2)
        blr

This also fires hundreds of times on MultiSource.

llvm-svn: 22533
2005-07-28 03:02:05 +00:00
Reid Spencer
8e3830dae7 Make the verifier pass run (in debug mode) in llc. This adds a sanity check
to llc when debugging. Also allow other passes to be run from llc.
Patch contributed by Michael McCracken.

llvm-svn: 22532
2005-07-28 02:25:30 +00:00
Jeff Cohen
8c6de7781a Please do not reintroduce tabs.
llvm-svn: 22531
2005-07-28 02:04:44 +00:00
Nate Begeman
594a3ba40e Fix some comments
llvm-svn: 22530
2005-07-27 23:11:27 +00:00
Chris Lattner
96cbfbbeaf Fix debug info to not print out recently freed memory.
llvm-svn: 22529
2005-07-27 23:11:25 +00:00
Chris Lattner
9937713252 Print symbolic register names in debug dumps
llvm-svn: 22528
2005-07-27 23:03:38 +00:00
Reid Spencer
2b381e0c1e Fix PR608:
Previously the script assumed the version number was the last field, now
it assumes it is the first sequence of digits.

llvm-svn: 22527
2005-07-27 21:58:38 +00:00
Jeff Cohen
5f4ef3c5a8 Eliminate all remaining tabs and trailing spaces.
llvm-svn: 22523
2005-07-27 06:12:32 +00:00
Nate Begeman
8e2411334c Implement the optimization for the Red Zone on Darwin. This removes the
unnecessary SP manipulation in leaf routines that don't need it.

llvm-svn: 22522
2005-07-27 06:06:29 +00:00
Chris Lattner
a5ec193118 fix some warnings when compiled with 32-bit hosts
llvm-svn: 22521
2005-07-27 05:58:01 +00:00
Jeff Cohen
33a030e36c Eliminate tabs and trailing spaces.
llvm-svn: 22520
2005-07-27 05:53:44 +00:00
Chris Lattner
f7100ad225 Testcase for PR607
llvm-svn: 22519
2005-07-26 22:08:53 +00:00
Chris Lattner
1defb7fe80 add a note about the red zone
llvm-svn: 22518
2005-07-26 19:07:51 +00:00
Chris Lattner
06721f50b0 Wrap some long lines, fix emission of weak global variables
llvm-svn: 22517
2005-07-26 19:03:27 +00:00
Nate Begeman
7b8733571e Update the PPC readme
llvm-svn: 22516
2005-07-26 18:59:06 +00:00
Chris Lattner
31d0ac2414 ConvertibleToGEP always returns 0, remove some old crufty code which
is actually dead because of this!

llvm-svn: 22515
2005-07-26 16:38:28 +00:00
Chris Lattner
54d27a49da fix a warning on 32-bit systems
llvm-svn: 22513
2005-07-25 23:42:58 +00:00
Nate Begeman
b9ce12b4bb Fix an optimization put in for accessing static globals. This obviates
the need to build PIC.

llvm-svn: 22512
2005-07-25 21:15:28 +00:00
Reid Spencer
dfa35465dd Get rid of bash specific syntax for variable dereferencing, replacing it
with the more crufty (but more widely available) "eval" command.

llvm-svn: 22509
2005-07-25 20:25:08 +00:00
Andrew Lenharth
54b0b62ff0 fix compile error
llvm-svn: 22508
2005-07-23 07:46:48 +00:00
Chris Lattner
12f5d12b21 PowerPC no-pic code is not quite ready for prime-time
llvm-svn: 22507
2005-07-22 22:58:34 +00:00
Misha Brukman
08c3645d3a No, really, it's an Alpha! And you probably thought it was a PowerPC.
llvm-svn: 22506
2005-07-22 22:43:40 +00:00
Andrew Lenharth
7dec1f3aa6 Handle more imm forms, and load small negative i32 constants without hitting memory (should do the same for arbitrary zero extended small negative constants)
llvm-svn: 22505
2005-07-22 22:24:01 +00:00
Andrew Lenharth
9900701f19 I know PowerPC wishes it could be alpha, but it cannot. so there
llvm-svn: 22504
2005-07-22 22:00:24 +00:00
Andrew Lenharth
3fe8a6b104 make sure we always handle small negatives well
llvm-svn: 22503
2005-07-22 21:53:35 +00:00
Andrew Lenharth
c32843ed2b finally found the gcc defined constants
llvm-svn: 22502
2005-07-22 21:00:30 +00:00
Andrew Lenharth
c7fe0f510f Alpha has JIT
llvm-svn: 22501
2005-07-22 20:54:01 +00:00
Andrew Lenharth
55d045190e Alpha JIT (beta)
llvm-svn: 22500
2005-07-22 20:52:16 +00:00
Andrew Lenharth
02daecc7c6 simpilfy instruction encoding (and make the lines way shorter, aka Misha happification)
llvm-svn: 22499
2005-07-22 20:50:29 +00:00
Andrew Lenharth
111e5e6490 update interface
llvm-svn: 22498
2005-07-22 20:49:37 +00:00
Andrew Lenharth
940b07c7fa the JIT memory manager will construct a GOT if you want it too. Also, it places the constants in the allocated memory, rather than a malloc area
llvm-svn: 22497
2005-07-22 20:48:12 +00:00
Andrew Lenharth
cf5cf4dfcd allow constants to be relocated like GV (necessary for alpha, as constants are relocated with globals, not with .text), and allow targets to have a GOT managed for them
llvm-svn: 22496
2005-07-22 20:46:42 +00:00
Chris Lattner
9762834a7f new testcase for PR602
llvm-svn: 22495
2005-07-21 21:55:08 +00:00
Nate Begeman
a9443f29b0 Support building non-PIC
Remove the LoadHiAddr pseudo-instruction.
Optimization of stores to and loads from statics.
Force JIT to use new non-PIC codepaths.

llvm-svn: 22494
2005-07-21 20:44:43 +00:00
Chris Lattner
53208ecf34 revert to using 4-byte alignment for doubles, as specified by the ABI
llvm-svn: 22493
2005-07-21 19:17:18 +00:00
Chris Lattner
8a8f2e5a01 llvm.sqrt somehow escaped documentation.
llvm-svn: 22490
2005-07-21 01:29:16 +00:00
Nate Begeman
15527113ab Support assembling fsqrt on darwin. This will be implemented better when
PowerPC gets subtarget support up.

llvm-svn: 22489
2005-07-21 01:25:49 +00:00
Chris Lattner
4e6c118b4d If errno doesn't matter (e.g. in -ffast-math scenarios), sqrt* should be
compiled to llvm.sqrt.

llvm-svn: 22488
2005-07-21 01:09:27 +00:00
Nate Begeman
8465fe8b4b Generate mfocrf when targeting g5. Generate fsqrt/fsqrts when targetin g5.
8-byte align doubles.

llvm-svn: 22486
2005-07-20 22:42:00 +00:00
Misha Brukman
5379a5b571 * "GNU Compiler Collection's gcc tool" is redundant
* Made bullet points start with a verb and lowercase, since they are not
  complete sentences
* Cleaned up grammar, removed extraneous verbosity

llvm-svn: 22485
2005-07-20 21:06:37 +00:00
Chris Lattner
24b350039b Allow this to pass on non-linux systems as well, such as darwin
llvm-svn: 22484
2005-07-20 19:12:00 +00:00
Chris Lattner
18aa4d8196 Do not let MaskedValueIsZero consider undef to be zero, for reasons
explained in the comment.

This fixes UnitTests/2003-09-18-BitFieldTest on darwin

llvm-svn: 22483
2005-07-20 18:49:28 +00:00
Chris Lattner
05732c86d4 count the number of relocations performed.
llvm-svn: 22480
2005-07-20 16:29:20 +00:00
Chris Lattner
14568496c0 set the target triple so that we don't fail due to X86 abi issues
llvm-svn: 22479
2005-07-20 03:56:48 +00:00
Nate Begeman
0851f1aaa1 Integrate SelectFPExpr into SelectExpr. This gets PPC32 closer to being
automatically generated from a target description.

llvm-svn: 22470
2005-07-19 16:51:05 +00:00
Nate Begeman
1ac40a1245 Remove unnecessary FP_EXTEND. This causes worse codegen for SSE.
llvm-svn: 22469
2005-07-19 16:50:03 +00:00
Reid Spencer
d37d854cb2 For: memory operations -> stores
This is the first incremental patch to implement this feature. It adds no
functionality to LLVM but setup up the information needed from targets in
order to implement the optimization correctly. Each target needs to specify
the maximum number of store operations for conversion of the llvm.memset,
llvm.memcpy, and llvm.memmove intrinsics into a sequence of store operations.
The limit needs to be chosen at the threshold of performance for such an
optimization (generally smallish). The target also needs to specify whether
the target can support unaligned stores for multi-byte store operations.
This helps ensure the optimization doesn't generate code that will trap on
an alignment errors.
More patches to follow.

llvm-svn: 22468
2005-07-19 04:52:44 +00:00
Chris Lattner
fb6343984a remove some sparc-v9-specific information
llvm-svn: 22467
2005-07-19 03:37:48 +00:00
Reid Spencer
e5dc84b73c Provide descriptions for the TargetInstrInfo and TargetFrameInfo classes.
llvm-svn: 22466
2005-07-19 01:36:35 +00:00
Chris Lattner
247aef884c When transforming &A[i] < &A[j] -> i < j, make sure to perform the comparison
as a signed compare.  This patch may fix PR597, but is correct in any case.

llvm-svn: 22465
2005-07-18 23:07:33 +00:00
Chris Lattner
b35912e421 The assertion was wrong: the code only worked for i64. While we're at it,
expand the code to work for all integer datatypes.  This should unbreak
alpha.

llvm-svn: 22464
2005-07-18 04:31:14 +00:00
Reid Spencer
012d35ae17 Add a parameter to the FIND_STD_PROGRAM macro that allows an alternate name
for the command line options. This helps with situations where the executable
name sought is too generic and a more meaningful name needs to be used for
the command line options. It also helps satisfy picky project leaders.

llvm-svn: 22461
2005-07-17 05:30:33 +00:00
Reid Spencer
e7e3c214cf Add two new checks for use in LLVM configuration files:
* FIND_STD_PROGRAM will find a program in the path or using --with options
  and verify that the path/bin/program is executable. Also allows checking
  for include files and libraries. If found, USE_PROGRAM is set, otherwise
  its not set. Also sets PROGRAM_BIN (bin directory), and PROGRAM_DIR (top
  level directory). If headers are found, sets PROGRAM_INC. If libraries
  are found, sets PROGRAM_LIB.
* CHECK_PROGRAM_SANITY can be used to run a program with some option that
  only produces information output and requires no input. If the output
  matches a regular expression, the program passes the sanity check.
  Otherwise, an error occurs.

llvm-svn: 22458
2005-07-17 00:50:40 +00:00
Chris Lattner
a5998ce94f Only get the .bss and .data sections when needed instead of unconditionally.
This allows is to not emit empty sections when .data or .bss is not used.

llvm-svn: 22457
2005-07-16 17:41:06 +00:00
Chris Lattner
2148cffae7 Add two helper methods, adjust a prototype
llvm-svn: 22456
2005-07-16 17:40:34 +00:00
Chris Lattner
363964e53d Refactor getSection() method to make it easier to use.
llvm-svn: 22455
2005-07-16 17:36:04 +00:00
Chris Lattner
2b3380b44e Add ability to set TYPE and FLAGS field for section trivially
llvm-svn: 22454
2005-07-16 17:35:26 +00:00
Chris Lattner
fd44500427 Major refactor of the ELFWriter code. Instead of building up one big
vector that represents the .o file at once, build up a vector for each
section of the .o file.  This is needed because the .o file writer needs
to be able to switch between sections as it emits them (e.g. switch
between the .text section and the .rel section when emitting code).

This patch has no functionality change.

llvm-svn: 22453
2005-07-16 08:01:13 +00:00
Nate Begeman
7e74c834c1 Teach the legalizer how to promote SINT_TO_FP to a wider SINT_TO_FP that
the target natively supports.  This eliminates some special-case code from
the x86 backend and generates better code as well.

For an i8 to f64 conversion, before & after:

_x87 before:
        subl $2, %esp
        movb 6(%esp), %al
        movsbw %al, %ax
        movw %ax, (%esp)
        filds (%esp)
        addl $2, %esp
        ret

_x87 after:
        subl $2, %esp
        movsbw 6(%esp), %ax
        movw %ax, (%esp)
        filds (%esp)
        addl $2, %esp
        ret

_sse before:
        subl $12, %esp
        movb 16(%esp), %al
        movsbl %al, %eax
        cvtsi2sd %eax, %xmm0
        addl $12, %esp
        ret

_sse after:
        subl $12, %esp
        movsbl 16(%esp), %eax
        cvtsi2sd %eax, %xmm0
        addl $12, %esp
        ret

llvm-svn: 22452
2005-07-16 02:02:34 +00:00
Nate Begeman
8293d0e232 Teach the register allocator that movaps is also a move instruction
llvm-svn: 22451
2005-07-16 02:00:20 +00:00
Nate Begeman
57b9ed522d A couple more darwinisms
llvm-svn: 22450
2005-07-16 01:59:47 +00:00
Chris Lattner
507a27592f Remove all knowledge of UINT_TO_FP from the X86 backend, relying on the
legalizer to eliminate them.  With this comes the expected code quality
improvements, such as, for this:

double foo(unsigned short X) { return X; }

we now generate this:

_foo:
        subl $4, %esp
        movzwl 8(%esp), %eax
        movl %eax, (%esp)
        fildl (%esp)
        addl $4, %esp
        ret

instead of this:

_foo:
        subl $4, %esp
        movw 8(%esp), %ax
        movzwl %ax, %eax   ;; Load not folded into this.
        movl %eax, (%esp)
        fildl (%esp)
        addl $4, %esp
        ret

-Chris

llvm-svn: 22449
2005-07-16 00:28:20 +00:00
Chris Lattner
e3e847bfd7 Break the code for expanding UINT_TO_FP operations out into its own
SelectionDAGLegalize::ExpandLegalUINT_TO_FP method.

Add a new method, PromoteLegalUINT_TO_FP, which allows targets to request
that UINT_TO_FP operations be promoted to a larger input type.  This is
useful for targets that have some UINT_TO_FP or SINT_TO_FP operations but
not all of them (like X86).

The same should be done with SINT_TO_FP, but this patch does not do that
yet.

llvm-svn: 22447
2005-07-16 00:19:57 +00:00
Chris Lattner
b47f5e6d54 You can't use config options without config.h
llvm-svn: 22446
2005-07-15 22:48:31 +00:00
Chris Lattner
3a6a4d3707 Fix PR595: These error messages should not be looking at CGI.Name, they
should be looking at CGI.TheDef->getName().

llvm-svn: 22445
2005-07-15 22:43:04 +00:00
John Criswell
a3f5110d5e Fixed some punctuation.
llvm-svn: 22443
2005-07-15 19:25:12 +00:00
Nate Begeman
a0b5e035ea Get closer to fully working scalar FP in SSE regs. This gets singlesource
working, and Olden/power.

llvm-svn: 22441
2005-07-15 00:38:55 +00:00
Nate Begeman
0f38dc4970 Add support for printing the sse scalar comparison instruction mnemonics.
llvm-svn: 22440
2005-07-14 22:52:25 +00:00
Nate Begeman
4f229d5197 Add support for a TODO; instructions in .td files can now have arguments
printed as part of the opcode.  This allows something like
cmp${cc}ss in the x86 backed to be printed as cmpltss, cmpless, etc.
depending on what the value of $cc is.

llvm-svn: 22439
2005-07-14 22:50:30 +00:00
John Criswell
b249d409be Regression test for PR#596: Make sure that negation of a minus doesn't
turn into a C predecrement operator.

llvm-svn: 22438
2005-07-14 19:56:03 +00:00
John Criswell
3870f9d31a Fixed PR#596:
Add parenthesis around the value being negated; that way, if the value
begins with a minus sign (e.g. negative integer), we won't generate a
C predecrement operator by mistake.

llvm-svn: 22437
2005-07-14 19:41:16 +00:00
Chris Lattner
46524e2573 Make this use the new autoconf support for finding the executables for
gv and Graphviz.

llvm-svn: 22434
2005-07-14 05:33:13 +00:00
Reid Spencer
f284268ba5 * Correct the AC_DEFINE for LLVM_PATH_GRAPHVIZ to use AC_DEFINE_UNQUOTED so
we actually get the path and not $GRAPHVIZ as the value.
* Add a #define for the gv program (HAVE_GV) and its value LLVM_PATH_GV.

llvm-svn: 22433
2005-07-14 05:19:12 +00:00
Chris Lattner
fcc53ad625 As discussed on IRC, this stuff is just for debugging.
llvm-svn: 22432
2005-07-14 05:17:43 +00:00
Reid Spencer
0ac41946e1 Put the path to the Graphviz program in the #defines so it can be used.
llvm-svn: 22430
2005-07-14 02:25:12 +00:00
Chris Lattner
51ded0e1ee If the Graphviz program is available, use it to visualize dot graphs.
llvm-svn: 22429
2005-07-14 01:10:55 +00:00
Reid Spencer
8640f2bdc1 Get rid of warnings on Alpha
llvm-svn: 22428
2005-07-13 23:20:24 +00:00
Reid Spencer
f17006fdda Implement a test for the Graphviz program for Chris Lattner. The symbol
GRAPHVIZ will contain the path to the program if its found (or "echo Graphviz"
if not) and the #define HAVE_GRAPHVIZ will be defined if its found.

llvm-svn: 22424
2005-07-13 03:20:14 +00:00
Reid Spencer
86df93a216 Don't call pthread_mutexattr_setpshared on FreeBSD because its implementation
of pthreads is missing that call (despite it violating the spec).

llvm-svn: 22423
2005-07-13 03:02:06 +00:00
Jeff Cohen
65806e62b1 Note to self: don't introduce memory leaks.
llvm-svn: 22422
2005-07-13 02:58:04 +00:00
Jeff Cohen
014dd48fbc Eliminate tabs
llvm-svn: 22421
2005-07-13 02:19:59 +00:00
Jeff Cohen
3800a28d46 Win32 support for Mutex class.
llvm-svn: 22420
2005-07-13 02:15:18 +00:00
Chris Lattner
f9ddfef872 Fix Alpha/2005-07-12-TwoMallocCalls.ll and PR593.
It is not safe to call LegalizeOp on something that has already been legalized.
Instead, just force another iteration of legalization.

This could affect all platforms but X86, as this codepath is dynamically
dead on X86 (ISD::MEMSET and friends are legal).

llvm-svn: 22419
2005-07-13 02:00:04 +00:00
Chris Lattner
330d3acee8 new testcase for PR593
llvm-svn: 22418
2005-07-13 01:57:39 +00:00
Chris Lattner
ba08a336f0 Fix test/Regression/CodeGen/Generic/2005-07-12-memcpy-i64-length.ll
llvm-svn: 22417
2005-07-13 01:42:45 +00:00
Chris Lattner
27e4e8e1b8 new testcase that crashes llc on x86/ppc. Not generated by C/C++ or LLVM
though.

llvm-svn: 22416
2005-07-13 01:42:03 +00:00
Reid Spencer
4f61c64639 Add a test that runs the ParallelJIT example program to ensure that the
JIT can run against a multi-threaded program without getting its data
structures messed up. Also had to add the examples directory to the path
for the tests so that ParallelJIT can be found.

llvm-svn: 22415
2005-07-13 00:35:12 +00:00
Reid Spencer
06a1da3efb Correct the file title.
llvm-svn: 22414
2005-07-12 22:00:29 +00:00
Reid Spencer
6855097c0d For PR418:
Add an example program that utilizes multiple threads in the JIT to process
work. This was used by Evan Jones as the original test case for ensuring
that the ExecutionEngine was thread safe.

Original source by Evan Jones (adapted from other LLVM JIT examples) and
made LLVM style compliant by Reid Spencer.

llvm-svn: 22411
2005-07-12 21:51:33 +00:00
Nate Begeman
8dd96ec769 Check in the last of the darwin-specific code necessary to get shootout
working before modifying the asm printer to use the subtarget info.

llvm-svn: 22408
2005-07-12 18:34:58 +00:00
Nate Begeman
5fc86e8314 Remove some code that moved to the generic asm printer a long time ago.
llvm-svn: 22407
2005-07-12 18:34:15 +00:00
Reid Spencer
4386e4a826 Update release notes regarding thread-safe JIT.
llvm-svn: 22405
2005-07-12 16:36:24 +00:00
Reid Spencer
79876f52aa For PR540:
This patch completes the changes for making lli thread-safe. Here's the list
of changes:
* The Support/ThreadSupport* files were removed and replaced with the
  MutexGuard.h file since all ThreadSupport* declared was a Mutex Guard.
  The implementation of MutexGuard.h is now based on sys::Mutex which hides
  its implementation and makes it unnecessary to have the -NoSupport.h and
  -PThreads.h versions of ThreadSupport.

* All places in ExecutionEngine that previously referred to "Mutex" now
  refer to sys::Mutex

* All places in ExecutionEngine that previously referred to "MutexLocker"
  now refer to MutexGuard (this is frivolous but I believe the technically
  correct name for such a class is "Guard" not a "Locker").

These changes passed all of llvm-test. All we need now are some test cases
that actually use multiple threads.

llvm-svn: 22404
2005-07-12 15:51:55 +00:00
Reid Spencer
f404981bf2 For PR540:
Add a Mutex class for thread synchronization in a platform-independent way.
The current implementation only supports pthreads. Win32 use of Critical
Sections will be added later. The design permits other threading models to
be used if (and only if) pthreads is not available.

llvm-svn: 22403
2005-07-12 15:37:43 +00:00
Reid Spencer
1aa7d05f3c For PR540:
* Add check for pthread.h
* Make sure -lpthread gets added to LIBS if its available

llvm-svn: 22402
2005-07-12 15:24:20 +00:00
Reid Spencer
cd59fb7a1b In support of PR418:
Make sure that -lpthread gets added to LIBS variable which puts it at the
end of the tools' link commands, if libpthread.a is found.

Add a test for pthread.h so we can use #ifdef HAVE_PTHREAD_H

llvm-svn: 22401
2005-07-12 07:19:13 +00:00
Chris Lattner
298ac69934 Add support for 64-bit elf files
llvm-svn: 22400
2005-07-12 06:57:52 +00:00
Chris Lattner
c292519a20 Add support for emitting 64-bit integers
llvm-svn: 22399
2005-07-12 06:57:26 +00:00
Chris Lattner
b9e53d892b Add some apparently undocumented ELF section header flags
llvm-svn: 22398
2005-07-12 06:40:29 +00:00
Andrew Lenharth
20b534a4fd Fix povray and minor cleanups
llvm-svn: 22397
2005-07-12 04:20:52 +00:00
Nate Begeman
b6daad1f4d Clean up and add comments to the newly implemented subtarget code.
llvm-svn: 22396
2005-07-12 03:04:49 +00:00
Jeff Cohen
8161bc5d35 Add new files to Visual Studio projects.
llvm-svn: 22395
2005-07-12 03:00:20 +00:00
Jeff Cohen
ddc8b78cda I don't know how this ever compiled with gcc, but VC++ correctly rejects it.
llvm-svn: 22394
2005-07-12 02:59:38 +00:00
Jeff Cohen
33b8232ce0 VC++ demands that the function returns a value
llvm-svn: 22393
2005-07-12 02:53:33 +00:00
Nate Begeman
df8946dede Clean up the TargetSubtarget class a bit, removing an unnecessary argument
to the constructor.

llvm-svn: 22392
2005-07-12 02:41:19 +00:00
Chris Lattner
351817b1f9 Minor changes to improve comments and fix the build on _WIN32 systems.
llvm-svn: 22391
2005-07-12 02:36:10 +00:00
Chris Lattner
f873f4d504 Add a note
llvm-svn: 22390
2005-07-12 02:35:36 +00:00
Nate Begeman
f26625e1de Implement Subtarget support
Implement the X86 Subtarget.

This consolidates the checks for target triple, and setting options based
on target triple into one place.  This allows us to convert the asm printer
and isel over from being littered with "forDarwin", "forCygwin", etc. into
just having the appropriate flags for each subtarget feature controlling
the code for that feature.

This patch also implements indirect external and weak references in the
X86 pattern isel, for darwin.  Next up is to convert over the asm printers
to use this new interface.

llvm-svn: 22389
2005-07-12 01:41:54 +00:00
Nate Begeman
83b492b83c Commit some pending darwin changes before subtarget support.
llvm-svn: 22388
2005-07-12 01:37:28 +00:00
Chris Lattner
986675cb75 Fix PR576.
Instead of emitting a JIT stub that looks like this:

internal void %l1_main_entry_2E_ce_wrapper(int) {
header:
        %resolver = call sbyte* %getPointerToNamedFunction( sbyte* getelementptr ([20 x sbyte]* %l1_main_entry_2E_ce_name, int 0, int 0) )           ; <sbyte*> [#uses=1]
        %resolverCast = cast sbyte* %resolver to void (int)*            ; <void (int)*> [#uses=1]
        call void %resolverCast( int %0 )
        ret void
}

Emit one that looks like this:

internal void %l1_main_entry_2E_ce_wrapper(int) {
Entry:
	%fpcache = load void (int)** %l1_main_entry_2E_ce.fpcache               ; <void (int)*> [#uses=2]
        %isNull = seteq void (int)* %fpcache, null              ; <bool> [#uses=1]
        br bool %isNull, label %lookupfp, label %usecache

usecache:               ; preds = %lookupfp, %Entry
        %fp = phi void (int)* [ %resolverCast, %lookupfp ], [ %fpcache, %Entry ]            ; <void (int)*> [#uses=1]
        call void %fp( int %0 )
        ret void

lookupfp:               ; preds = %Entry
        %resolver = call sbyte* %getPointerToNamedFunction( sbyte* getelementptr ([20 x sbyte]* %l1_main_entry_2E_ce_name, int 0, int 0) )           ; <sbyte*> [#uses=1]
        %resolverCast = cast sbyte* %resolver to void (int)*            ; <void (int)*> [#uses=2]
        store void (int)* %resolverCast, void (int)** %l1_main_entry_2E_ce.fpcache
        br label %usecache
}


This makes the JIT debugger *MUCH* faster on large programs, as
getPointerToNamedFunction takes time linear with the size of the program, and
before we would call it every time a function in the text module was called from
the safe module (ouch!).

llvm-svn: 22387
2005-07-12 01:00:32 +00:00
Chris Lattner
de69bf9972 add a note so I can remember the common t-t's
llvm-svn: 22386
2005-07-12 00:20:49 +00:00
Chris Lattner
fd564c6bc9 fix a warning
llvm-svn: 22385
2005-07-11 22:46:18 +00:00
Andrew Lenharth
23167c3be9 Remove glibc specific functions, and mark a couple as C99
llvm-svn: 22384
2005-07-11 20:35:20 +00:00
Andrew Lenharth
c51a74cc02 because on alpha:
#   define errno (*__errno_location ())

*shakes head

llvm-svn: 22383
2005-07-11 17:41:12 +00:00
Chris Lattner
449e07f390 Clean up code, no functionality changes.
llvm-svn: 22382
2005-07-11 06:34:30 +00:00
Chris Lattner
9bdb1c3818 Output .size directives to tell the assembler the size of each function.
llvm-svn: 22381
2005-07-11 06:29:14 +00:00
Chris Lattner
0d2f043c41 Fix crazy indentation
llvm-svn: 22380
2005-07-11 06:25:47 +00:00
Chris Lattner
3cad7bedc9 convert dos newlines to unix. No other changes.
llvm-svn: 22379
2005-07-11 06:25:34 +00:00
Chris Lattner
5bacb00452 Emit a symbol table entry for each function we output to the ELF file. This
allows objdump to know which function we are emitting to:

00000000 <foo>:     <----
   0:   b8 01 00 00 00          mov    $0x1,%eax
   5:   03 44 24 04             add    0x4(%esp,1),%eax
   9:   c3                      ret

... and allows .o files to be useful for linking :)

llvm-svn: 22378
2005-07-11 06:17:35 +00:00
Chris Lattner
c1b8551e3a The symbol table just needs a const GlobalValue*, not a non-const one.
llvm-svn: 22377
2005-07-11 06:16:24 +00:00
Chris Lattner
d831209c34 Refactor things a bit to allow the ELF code emitter to run the X86 machine code emitter
after itself.

llvm-svn: 22376
2005-07-11 05:17:48 +00:00
Chris Lattner
2244f73437 add code to emit the .text section to the section header.
Add a *VERY INITIAL* machine code emitter class.  This is enough to take
this C function:
int foo(int X) { return X +1; }

and make objdump produce the following:

$ objdump -d t-llvm.o

t-llvm.o:     file format elf32-i386

Disassembly of section .text:

00000000 <.text>:
   0:   b8 01 00 00 00          mov    $0x1,%eax
   5:   03 44 24 04             add    0x4(%esp,1),%eax
   9:   c3                      ret


Anything using branches or refering to the constant pool or requiring
relocations will not work yet.

llvm-svn: 22375
2005-07-11 05:17:18 +00:00
Chris Lattner
6801f4f291 expose a new code emitter object
llvm-svn: 22374
2005-07-11 05:15:32 +00:00
Chris Lattner
3bdfd6fcd1 add a helper method
llvm-svn: 22373
2005-07-11 04:49:33 +00:00
Chris Lattner
c3e38f7943 Remove prototype for non-existant function
llvm-svn: 22372
2005-07-11 04:20:55 +00:00
Chris Lattner
dfe33bc837 Use a name mangler object to uniquify names and remove nonstandard
characters from them.

llvm-svn: 22371
2005-07-11 03:11:47 +00:00
Chris Lattner
93bf2de35b add a name mangler object
llvm-svn: 22370
2005-07-11 03:11:10 +00:00
Chris Lattner
8ffb66111c fix long lines
llvm-svn: 22369
2005-07-11 02:49:16 +00:00
Chris Lattner
53676dfd33 Change *EXTLOAD to use an VTSDNode operand instead of being an MVTSDNode.
This is the last MVTSDNode.

This allows us to eliminate a bunch of special case code for handling
MVTSDNodes.

Also, remove some uses of dyn_cast that should really be cast (which is
cheaper in a release build).

llvm-svn: 22368
2005-07-10 01:56:13 +00:00
Chris Lattner
de0a4b1987 Change *EXTLOAD to use an VTSDNode operand instead of being an MVTSDNode.
This is the last MVTSDNode.

This allows us to eliminate a bunch of special case code for handling
MVTSDNodes.

llvm-svn: 22367
2005-07-10 01:55:33 +00:00
Chris Lattner
36db1ed06f Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode
llvm-svn: 22366
2005-07-10 00:29:18 +00:00
Chris Lattner
9bfa5495dd Move TRUNCSTORE to using a VTSDNode operand instead of being a MVTSDNode.
Also update some comments that Andrew forgot to update when he changed
loads/stores.

llvm-svn: 22365
2005-07-10 00:28:25 +00:00
Chris Lattner
0b6ba90a72 Introduce a new VTSDNode class with the ultimate goal of eliminating the
MVTSDNode class.  This class is used to provide an operand to operators
that require an extra type.  We start by converting FP_ROUND_INREG and
SIGN_EXTEND_INREG over to using it.

llvm-svn: 22364
2005-07-10 00:07:11 +00:00
Jeff Cohen
0aad91acfe Fix bugs also fixed in Unix version, plus other general cleanup.
llvm-svn: 22363
2005-07-09 18:42:49 +00:00
Jeff Cohen
5b106d0fed 1. Fix bug in getBaseName where it mishandles suffixes
2. Fix bug in eraseSuffix where it allows /path/.suffix to become /path/

llvm-svn: 22362
2005-07-09 18:42:02 +00:00
Reid Spencer
2d85f5697d Ensure that functions like isDirectory don't fail if the file doesn't
exist but just return false instead.

llvm-svn: 22361
2005-07-08 17:46:10 +00:00
Reid Spencer
03f6f7a537 Make sure we don't error out if an invalid path is used, just simply
exit from isBytecodeLPath with "false".

llvm-svn: 22360
2005-07-08 16:48:52 +00:00
Reid Spencer
d28e432c36 Two changes:
1. Use isValid() to check validity of the resulting path name in the
   eraseSuffix even though we can't think of a case where eraseSuffix could
   possibly cause an invalid path name.
2. Rewrite isValid() to not use the deprecated realpath function any more.
   It now just uses isascii to make sure all the characters are legit.

llvm-svn: 22359
2005-07-08 06:53:26 +00:00
Chris Lattner
748de6e248 Add support for emitting a .data section and .bss section.
Add support for emitting external and .bss symbols.

llvm-svn: 22358
2005-07-08 05:47:00 +00:00
Jeff Cohen
f50677610f Stamp out tabs
llvm-svn: 22357
2005-07-08 05:02:13 +00:00
Jeff Cohen
0e1d7354b7 Make Win32 implementation conform to new paradigm
llvm-svn: 22356
2005-07-08 04:50:08 +00:00
Jeff Cohen
4c24144ddf Fix eraseSuffix()
llvm-svn: 22355
2005-07-08 04:49:16 +00:00
Reid Spencer
af48d8643d Final Changes For PR495:
This chagne just renames some sys::Path methods to ensure they are not
misused. The Path documentation now divides methods into two dimensions:
Path/Disk and accessor/mutator. Path accessors and mutators only operate
on the Path object itself without making any disk accesses. Disk accessors
and mutators will also access or modify the file system. Because of the
potentially destructive nature of disk mutators, it was decided that all
such methods should end in the work "Disk" to ensure the user recognizes
that the change will occur on the file system. This patch makes that
change. The method name changes are:

makeReadable        -> makeReadableOnDisk
makeWriteable       -> makeWriteableOnDisk
makeExecutable      -> makeExecutableOnDisk
setStatusInfo       -> setStatusInfoOnDisk
createDirectory     -> createDirectoryOnDisk
createFile          -> createFileOnDisk
createTemporaryFile -> createTemporaryFileOnDisk
destroy             -> eraseFromDisk
rename              -> renamePathOnDisk

These changes pass the Linux Deja Gnu tests.

llvm-svn: 22354
2005-07-08 03:08:58 +00:00
Jeff Cohen
215db9041b Fix VC++ breakage
llvm-svn: 22353
2005-07-08 02:48:42 +00:00
Jeff Cohen
941500dcd1 fix typo
llvm-svn: 22352
2005-07-08 02:48:04 +00:00
Nate Begeman
b62a4c8da6 Add support for assembling .s files on mac os x for intel
Add support for running bugpoint on mac os x for intel

llvm-svn: 22351
2005-07-08 00:23:26 +00:00
Reid Spencer
17c1bd372a Changes to mimic those in Unix/Path.inc in support of PR495. This hasn't
been compiled or tested.

llvm-svn: 22350
2005-07-07 23:35:23 +00:00
Reid Spencer
c9c0473fa5 For PR495:
Get rid of the difference between file paths and directory paths. The Path
class now simply stores a path that can refer to either a file or a
directory. This required various changes in the implementation and interface
of the class with the corresponding impact to its users. Doxygen comments were
also updated to reflect these changes. Interface changes are:

appendDirectory -> appendComponent
appendFile -> appendComponent
elideDirectory -> eraseComponent
elideFile -> eraseComponent
elideSuffix -> eraseSuffix
renameFile -> rename
setDirectory -> set
setFile -> set

Changes pass Dejagnu and llvm-test/SingleSource tests.

llvm-svn: 22349
2005-07-07 23:21:43 +00:00
Chris Lattner
4ed40f7c6f Fix a problem that instcombine would hit when dealing with unreachable code.
Because the instcombine has to scan the entire function when it starts up
to begin with, we might as well do it in DFO so we can nuke unreachable code.

This fixes: Transforms/InstCombine/2005-07-07-DeadPHILoop.ll

llvm-svn: 22348
2005-07-07 20:40:38 +00:00
Chris Lattner
2d0f468cd2 New testcase distilled from a large chunk of code Misha sent me.
llvm-svn: 22347
2005-07-07 20:39:45 +00:00
Andrew Lenharth
8d40dcbd18 clean up prolouge and epilouge
llvm-svn: 22346
2005-07-07 19:52:58 +00:00
Reid Spencer
5b891e9847 For PR495:
Change interface to Path class:
readable -> canRead
writable -> canWrite
executable -> canExecute

More (incremental) changes coming to close 495.

llvm-svn: 22345
2005-07-07 18:21:42 +00:00
Chris Lattner
2e81f65eb8 Restore some code that was accidentally removed by Nate's patch yesterday.
This fixes the regressions from last night.

llvm-svn: 22344
2005-07-07 17:12:53 +00:00
Chris Lattner
1932f5c9be Add support for emitting the symbol table (and its string table) of the
module to the ELF file.  Test it by adding support for emitting common
symbols.  This allows us to compile this:

%X = weak global int 0
%Y = weak global int 0
%Z = weak global int 0

to an elf file that 'readelf's this:

Symbol table '.symtab' contains 4 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000004     4 OBJECT  GLOBAL DEFAULT  COM X
     2: 00000004     4 OBJECT  GLOBAL DEFAULT  COM Y
     3: 00000004     4 OBJECT  GLOBAL DEFAULT  COM Z

llvm-svn: 22343
2005-07-07 07:02:20 +00:00
Chris Lattner
92a139dd0b Add support for building/representing the symbol table, add some enum constants
llvm-svn: 22342
2005-07-07 07:00:37 +00:00
Nate Begeman
fcd2f76cb6 Fix a typo in my checkin today that caused regressions. Oops!
llvm-svn: 22341
2005-07-07 06:32:01 +00:00
Nate Begeman
8a0933608a First round of support for doing scalar FP using the SSE2 ISA extension and
XMM registers.  There are many known deficiencies and fixmes, which will be
addressed ASAP.  The major benefit of this work is that it will allow the
LLVM register allocator to allocate FP registers across basic blocks.

The x86 backend will still default to x87 style FP.  To enable this work,
you must pass -enable-sse-scalar-fp and either -sse2 or -sse3 to llc.

An example before and after would be for:
double foo(double *P) { double Sum = 0; int i; for (i = 0; i < 1000; ++i)
                        Sum += P[i]; return Sum; }

The inner loop looks like the following:
x87:
.LBB_foo_1:     # no_exit
        fldl (%esp)
        faddl (%eax,%ecx,8)
        fstpl (%esp)
        incl %ecx
        cmpl $1000, %ecx
        #FP_REG_KILL
        jne .LBB_foo_1  # no_exit

SSE2:
        addsd (%eax,%ecx,8), %xmm0
        incl %ecx
        cmpl $1000, %ecx
        #FP_REG_KILL
        jne .LBB_foo_1  # no_exit

llvm-svn: 22340
2005-07-06 18:59:04 +00:00
Chris Lattner
a7220851c0 Make several cleanups to Andrews varargs change:
1. Pass Value*'s into lowering methods so that the proper pointers can be
   added to load/stores from the valist
2. Intrinsics that return void should only return a token chain, not a token
   chain/retval pair.
3. Rename LowerVAArgNext -> LowerVAArg, because VANext is long gone.
4. Now that we have Value*'s available in the lowering methods, pass them
   into any load/stores from the valist that are emitted

llvm-svn: 22339
2005-07-05 19:58:54 +00:00
Chris Lattner
f5473e44a9 Make several cleanups to Andrews varargs change:
1. Pass Value*'s into lowering methods so that the proper pointers can be
   added to load/stores from the valist
2. Intrinsics that return void should only return a token chain, not a token
   chain/retval pair.
3. Rename LowerVAArgNext -> LowerVAArg, because VANext is long gone.

llvm-svn: 22338
2005-07-05 19:57:53 +00:00
Andrew Lenharth
80fe411662 2 fixes:
1: Legalize operand in UINT_TO_FP expanision

2: SRA x, const i8 was not promoting the constant to shift amount type.
llvm-svn: 22337
2005-07-05 19:52:39 +00:00
Chris Lattner
91ae129b90 Fit to 80 columns
llvm-svn: 22336
2005-07-05 17:50:16 +00:00
Chris Lattner
1239d2d7ff Fix PowerPC varargs
llvm-svn: 22335
2005-07-05 17:48:31 +00:00
Andrew Lenharth
8c220defa8 oops
llvm-svn: 22334
2005-07-05 16:36:18 +00:00
Andrew Lenharth
a1f37d616e updates
llvm-svn: 22333
2005-07-05 15:18:33 +00:00
Andrew Lenharth
26fa89e0a7 check the correct VT
llvm-svn: 22332
2005-07-04 20:07:21 +00:00
Andrew Lenharth
da852d51df fix loading address of fp symbols
llvm-svn: 22331
2005-07-03 20:06:13 +00:00
Chris Lattner
9f6ce0ebb3 Percolate the call up to the right superclass
llvm-svn: 22330
2005-07-03 17:34:39 +00:00
Andrew Lenharth
be3a74ca3e I really didn't think this was necessary. But, Legalize wasn't running again
and legalizing the extload.  Strange.  Should fix most alpha regressions.

llvm-svn: 22329
2005-07-02 20:58:53 +00:00
Jeff Cohen
64869f5d20 Adding new files to Visual Studio projects.
llvm-svn: 22328
2005-07-02 02:04:26 +00:00
Nate Begeman
9a1dc72729 The statistic needs to be in the correct namespace.
llvm-svn: 22327
2005-07-01 23:56:38 +00:00
Chris Lattner
d313b92b66 Varargs is apparently currently broken on PPC. This hacks it so that it
is at least overloading the right virtual methods.  The implementations
are currently wrong though.  This fixes Ptrdist/bc, but not other programs
(e.g. siod).

llvm-svn: 22326
2005-07-01 23:11:56 +00:00
Chris Lattner
b97404687a Refactor X86AsmPrinter.cpp into multiple files. Patch contributed
by Aaron Gray, cleaned up by me.

llvm-svn: 22324
2005-07-01 22:44:09 +00:00
Andrew Lenharth
21da9b669e simplify call code, remove pseudo ops for div and rem, track more loads and stores
llvm-svn: 22323
2005-07-01 19:14:02 +00:00
Andrew Lenharth
dd55b1566b simplify call code, remove pseudo ops for div and rem, track more loads and stores
llvm-svn: 22322
2005-07-01 19:12:13 +00:00
Chris Lattner
e8ab64b5c3 remove some debugging code
llvm-svn: 22321
2005-07-01 06:40:58 +00:00
Andrew Lenharth
0a370f4de5 oops
llvm-svn: 22320
2005-06-30 19:32:57 +00:00
Andrew Lenharth
b5597e38f6 FP EXTLOAD is not support on all archs, expand to LOAD and FP_EXTEND
llvm-svn: 22319
2005-06-30 19:22:37 +00:00
Chris Lattner
937c71f2b3 Fix PR590 and Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll.
The optimization for locally used allocas was not safe for allocas that
were read before they were written.  This change disables that optimization
in that case.

llvm-svn: 22318
2005-06-30 07:29:44 +00:00
Chris Lattner
ba613f478a new testcase for PR590
llvm-svn: 22317
2005-06-30 07:28:54 +00:00
Nate Begeman
718387e491 Make the x86 asm printer darwin-aware. This mostly entails doing the same
thing as cygwin most of the time, and printing our alignments in log2
rather than number of bytes.

llvm-svn: 22316
2005-06-30 00:53:20 +00:00
Andrew Lenharth
2edc1881ac restore old srcValueNode behavior and try to to work around it
llvm-svn: 22315
2005-06-29 18:54:02 +00:00
Chris Lattner
f550554c02 Don't crash on a query where the block is not in any loop. Thanks to
Sameer D. Sahasrabuddhe for pointing this out!

llvm-svn: 22314
2005-06-29 17:41:25 +00:00
John Criswell
51e2a48b35 Bug fixed.
llvm-svn: 22313
2005-06-29 16:22:34 +00:00
John Criswell
810b4f8d55 Doh! Forgot to LLVMify the style.
llvm-svn: 22312
2005-06-29 15:57:50 +00:00
Andrew Lenharth
8192568fbc tracking the instructions causing loads and stores provides more information than just the pointer being loaded or stored
llvm-svn: 22311
2005-06-29 15:57:19 +00:00
John Criswell
4642afdcc1 Basic fix for PR#591; don't convert an fprintf() to an fwrite() if there
is a mismatch in their character type pointers (i.e. fprintf() prints an
array of ubytes while fwrite() takes an array of sbytes).
We can probably do better than this (such as casting the ubyte to an
sbyte).

llvm-svn: 22310
2005-06-29 15:03:18 +00:00
Andrew Lenharth
4401049f05 thinko
llvm-svn: 22309
2005-06-29 13:35:05 +00:00
Andrew Lenharth
d0a2f0f95a unify SelectExpr and SelectFP
llvm-svn: 22308
2005-06-29 12:49:51 +00:00
Andrew Lenharth
d0f59dedf8 fix most regressions
llvm-svn: 22307
2005-06-29 12:23:34 +00:00
Andrew Lenharth
47a9c4715a support more relocations for stores also
llvm-svn: 22306
2005-06-29 00:39:17 +00:00
Andrew Lenharth
1ef3c0c798 Get rid of all symbolic loads. I now do gernate all relocations sequences
rather than relying on the assembler.  Only a few more pseudo instructions
left.  Also merge load code paths.

llvm-svn: 22305
2005-06-29 00:31:08 +00:00
Jeff Cohen
8d9d9d7af0 Add ElfWriter stuff to Visual Studio
llvm-svn: 22304
2005-06-28 02:43:03 +00:00
Andrew Lenharth
93bf000891 some call work
llvm-svn: 22303
2005-06-27 23:59:51 +00:00
Andrew Lenharth
d74877a46d Adapt the code for handling uint -> fp conversion for the 32 bit case to
handling it in the 64 bit case.  The two code paths should probably be merged.

llvm-svn: 22302
2005-06-27 23:28:32 +00:00
Andrew Lenharth
a50adcf57d So, it turns out I forgot that one valid way of restoring GP after a call
is to use RA, which assumes the called function uses RA for the register
holding the return address when it issues a ret.

llvm-svn: 22301
2005-06-27 23:24:11 +00:00
Nate Begeman
db32921535 Initial set of .td file changes necessary to get scalar fp in xmm registers
working.  The instruction selector changes will hopefully be coming later
this week once they are debugged.  This is necessary to support the darwin
x86 FP model, and is recommended by intel as the replacement for x87.  As
a bonus, the register allocator knows how to deal with these registers
across basic blocks, unliky the FP stackifier.  This leads to significantly
better codegen in several cases.

llvm-svn: 22300
2005-06-27 21:20:31 +00:00
Andrew Lenharth
595646f934 get rid of another pseudo op
llvm-svn: 22299
2005-06-27 21:11:40 +00:00
Andrew Lenharth
1291a85883 generate address of constant pool entries
llvm-svn: 22298
2005-06-27 21:02:56 +00:00
Andrew Lenharth
02ffa5a7ed Misha happification patch
llvm-svn: 22297
2005-06-27 17:39:17 +00:00
Andrew Lenharth
7aba58ab89 Reduce use of pseudo ops
Namely, output the rellocation flags explicitly when loading constants.
Added benifit: save a load when loading from the constant pool.

llvm-svn: 22296
2005-06-27 17:15:36 +00:00
Andrew Lenharth
fcb112eb7a missed a load
llvm-svn: 22295
2005-06-27 16:40:26 +00:00
Andrew Lenharth
96db51a3b6 make constant pool labels local
llvm-svn: 22294
2005-06-27 16:29:54 +00:00
Andrew Lenharth
53bb83bc43 who said we had to use the return address in the return address register. Might save a move in many cases
llvm-svn: 22293
2005-06-27 15:36:48 +00:00
Chris Lattner
10594206f4 Add support to the X86 backend for emitting ELF files. To use this, we
currently use: llc t.bc --filetype=obj

This will produce a t.o file which is dumpable with readelf.  Currently
the file produced is empty, but the scaffolding to do more is now in place.

llvm-svn: 22292
2005-06-27 06:30:12 +00:00
Chris Lattner
386b151ce6 iniital checkin of ELFWriter implementation
For now, the elf writer is only capable of emitting an empty elf file, with
a section table and a section table string table.  This will be enhanced
in the future :)

llvm-svn: 22291
2005-06-27 06:29:00 +00:00
Chris Lattner
a1debbc634 iniital checkin of ELFWriter header.
For now, the elf writer is only capable of emitting an empty elf file, with
a section table and a section table string table.  This will be enhanced
in the future :)

llvm-svn: 22290
2005-06-27 06:28:45 +00:00
Andrew Lenharth
dac0b3cb8a depend more on legalize putting constants on the RHS
llvm-svn: 22289
2005-06-26 23:01:11 +00:00
Andrew Lenharth
331380b2e2 With setOperationAction(ISD::UINT_TO_FP, MVT::i64, Expand), Legalize
should be able to handle this case.  The code is there, so let's see
if it works.

llvm-svn: 22288
2005-06-26 22:23:06 +00:00
Chris Lattner
06fcc4cb75 add a new -filetype argument to llc.
llvm-svn: 22287
2005-06-25 03:32:05 +00:00
Chris Lattner
4c661789c1 add some new file types
llvm-svn: 22286
2005-06-25 03:31:43 +00:00
Chris Lattner
09b0eb387a minor cleanups, use copy ctor instead of manually doing it.
llvm-svn: 22285
2005-06-25 03:00:34 +00:00
Chris Lattner
6a7b48e747 refactor this interface
llvm-svn: 22284
2005-06-25 02:50:35 +00:00
Chris Lattner
f11f48ba61 Refactor the addPassesToEmitAssembly interface into a addPassesToEmitFile
interface.

llvm-svn: 22282
2005-06-25 02:48:37 +00:00
Chris Lattner
f96366550c refactor these interfaces a bit
llvm-svn: 22281
2005-06-25 02:47:50 +00:00
Chris Lattner
aad30b0dc9 improve comments
llvm-svn: 22280
2005-06-24 18:17:33 +00:00
Chris Lattner
805ecf0c79 Fix grammar
llvm-svn: 22279
2005-06-24 18:00:40 +00:00
Chris Lattner
c0ad71edd4 add a note about variable length array
llvm-svn: 22278
2005-06-24 17:22:57 +00:00
Chris Lattner
9610c6f287 add a debug type
llvm-svn: 22277
2005-06-24 16:00:46 +00:00
Andrew Lenharth
af1e825112 remove a pseudo instruction, make ret always right, and fix vararg chains
llvm-svn: 22276
2005-06-23 23:42:05 +00:00
Andrew Lenharth
01cebcc131 finally, Working varargs
llvm-svn: 22275
2005-06-23 16:48:51 +00:00
Andrew Lenharth
a4a12983cc more complete Lowering for vacopy and vaarg
llvm-svn: 22274
2005-06-22 23:04:28 +00:00
Andrew Lenharth
253145299b If we support structs as va_list, we must pass pointers to them to va_copy
See last commit for LangRef, this implements it on all targets.

llvm-svn: 22273
2005-06-22 21:04:42 +00:00
Andrew Lenharth
5305ea5c86 SelectionDAG is very unhappy when the argument to an intrinsic is a struct
llvm-svn: 22272
2005-06-22 20:38:11 +00:00
Andrew Lenharth
cf9008afea Make it easier to find alpha stuff in doxygen, and fixup labeling
of memory instructions in the assembly, to allow later linking
of traces with LLVM Value*s.

llvm-svn: 22271
2005-06-22 17:19:45 +00:00
John Criswell
9cb5a82cdc Fixed indentation.
llvm-svn: 22270
2005-06-20 19:59:22 +00:00
Andrew Lenharth
d6bee05fc4 because some functions just use va_start and pass things to vfprintf
llvm-svn: 22269
2005-06-20 15:41:37 +00:00
Andrew Lenharth
5488847304 the correct fix was to fix AliasAnalysis.getModRefInfo
llvm-svn: 22268
2005-06-20 15:25:22 +00:00
Andrew Lenharth
f42d7b54c0 make AliasAnalysis know that VAArg writes memory. This is extremely conservative and should be fixed
llvm-svn: 22267
2005-06-20 15:24:23 +00:00
Andrew Lenharth
805d84a077 prevent GCSE from forwarding stores to loads around vaarg. This is uggly, and I am trying to fix the AliasInfo, as it should catch the problem instead.
llvm-svn: 22266
2005-06-20 15:02:05 +00:00
Andrew Lenharth
cf52eb2b99 prevent va_arg from being hoisted from a loop
llvm-svn: 22265
2005-06-20 13:36:33 +00:00
Andrew Lenharth
2929266127 fix DCE + va_arg problem
llvm-svn: 22264
2005-06-19 14:46:20 +00:00
Andrew Lenharth
d4b103107e prevent DCE of vaarg intrinsics. This should take care of most regressions
llvm-svn: 22263
2005-06-19 14:41:20 +00:00
Andrew Lenharth
717f1610f0 va_end fix
llvm-svn: 22262
2005-06-19 14:04:55 +00:00
Andrew Lenharth
237e6afde7 so this doesn't crash when run. It is hard to tell if things are right enough to work correctly with all the TmpInstructions running around
llvm-svn: 22261
2005-06-19 05:45:00 +00:00
Andrew Lenharth
aa1d999682 add a check for the mixing of vaarg and vanext with va_arg
llvm-svn: 22260
2005-06-19 03:53:56 +00:00
Reid Spencer
da180831e4 Ignore the configure.out file generated by "make reconfigure"
llvm-svn: 22259
2005-06-18 23:01:25 +00:00
Reid Spencer
5503ee7d88 Ignore some generated files.
llvm-svn: 22258
2005-06-18 23:00:34 +00:00
Reid Spencer
ce3f35a84f Ignore generated files.
llvm-svn: 22257
2005-06-18 22:59:31 +00:00
Reid Spencer
ef0d7c6af6 Fix this test case to actually test the new va_arg instruction not the
old vaarg instruction.

llvm-svn: 22256
2005-06-18 20:27:32 +00:00
Andrew Lenharth
a4c10cd6f2 OK, at least get rid of old stuff, and mark what needs to be fixed for V9
llvm-svn: 22255
2005-06-18 18:46:40 +00:00
Andrew Lenharth
9144ec4764 core changes for varargs
llvm-svn: 22254
2005-06-18 18:34:52 +00:00
Andrew Lenharth
4549a86233 header file changes for varargs
llvm-svn: 22253
2005-06-18 18:31:30 +00:00
Andrew Lenharth
435054cd1b new vararg test
llvm-svn: 22252
2005-06-18 18:30:37 +00:00
Andrew Lenharth
5fb787c619 OK, after checking the backwards compatibility code on X86 and the new code
path on alpha, now has come the time for new vararg support.  So, with out
further ado, I revert behavior back a couple of years!

Well, ok, I lied.  A few more notes.

First, the Simple ISels cannot be expected to work any longer, but they
should still compile

Second, there are likely some bugs to track down once the nightly testers
start with this.

Third, the initial patch doesn't include sparcv9, but I'll do that today.

Forth, subsequent patches won't bother being long winded.

llvm-svn: 22251
2005-06-18 18:28:17 +00:00
Reid Spencer
a7828baa3c Fix a problem with the strcmp optimization checking the wrong string and
not casting to the correct type.

llvm-svn: 22250
2005-06-18 17:46:28 +00:00
Reid Spencer
4fdd96c4e0 Clean up some uninitialized variables and missing return statements that
GCC 4.0.0 compiler (sometimes incorrectly) warns about under release build.

llvm-svn: 22249
2005-06-18 17:37:34 +00:00
Reid Spencer
1fb9d01919 Make sure a variable is initialized before use to clean up a warning from
GCC 4.0.0 in release build.

llvm-svn: 22248
2005-06-18 16:53:27 +00:00
Andrew Lenharth
26fc33fd2a A start at a Sparc V8 Pattern ISel. Anyone want to implement the calling
convention? ;)

llvm-svn: 22247
2005-06-17 16:52:12 +00:00
Chris Lattner
3d57b4c75f silence incredibly braindead GCC 4 warning
llvm-svn: 22246
2005-06-17 13:44:07 +00:00
Chris Lattner
459a9cbe1e silence a bogus warning
llvm-svn: 22245
2005-06-17 13:23:32 +00:00
Chris Lattner
8f7da41021 silence a huge number of bogus warnings with GCC 4 on Reid's tester.
llvm-svn: 22244
2005-06-17 13:20:15 +00:00
Tanya Lattner
8a78658cc0 Removed IIIi specific changes. This should be fixed to add floating point deps for the IIi.
llvm-svn: 22243
2005-06-17 04:21:09 +00:00
Tanya Lattner
123d238dc6 Special dep graph for SMS for superblocks.
llvm-svn: 22242
2005-06-17 04:16:14 +00:00
Tanya Lattner
64a1a12dd0 Special versions of the dep graph and scheduled for SMS for superblocks.
llvm-svn: 22241
2005-06-17 04:15:43 +00:00
Tanya Lattner
d092f6a71a Added statistic to count number of spills.
llvm-svn: 22240
2005-06-17 04:01:34 +00:00
Tanya Lattner
8bf6374d90 Numerous bug fixes and the completed modschedSB algorithm (minor bugs still exist for course).
llvm-svn: 22239
2005-06-17 04:00:57 +00:00
Tanya Lattner
b1ba8df090 Added SMS for superblocks as an option (experimental)
llvm-svn: 22238
2005-06-17 04:00:22 +00:00
Tanya Lattner
dba361d134 Added ModuloSchedSB as a friend class.
llvm-svn: 22237
2005-06-17 03:59:51 +00:00
Chris Lattner
2ceb6ee576 This is not true: (X != 13 | X < 15) -> X < 15
It is actually always true.  This fixes PR586 and
Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll

llvm-svn: 22236
2005-06-17 03:59:17 +00:00
Chris Lattner
e708353d04 new testcase for PR586
llvm-svn: 22235
2005-06-17 03:58:30 +00:00
Chris Lattner
73bcba5f61 Don't crash when dealing with INTMIN. This fixes PR585 and
Transforms/InstCombine/2005-06-16-RangeCrash.ll

llvm-svn: 22234
2005-06-17 02:05:55 +00:00
Chris Lattner
d230aee4be new testcase for PR585
llvm-svn: 22233
2005-06-17 02:04:47 +00:00
Chris Lattner
5e735294bf Don't crash on: X = phi (X, X).
This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll

llvm-svn: 22232
2005-06-17 01:45:53 +00:00
Chris Lattner
29ae6f6ed9 new testcase for PR584
llvm-svn: 22231
2005-06-17 01:45:03 +00:00
Chris Lattner
c53cb9d3ff avoid constructing out of range shift amounts.
llvm-svn: 22230
2005-06-17 01:29:28 +00:00
Nate Begeman
a2e8779b0d Fix bug 537 test 2, which checks to make sure that we fold A+(B-A) -> B for
integer types.  Add a couple checks to not perform these kinds of transform
on floating point values.

llvm-svn: 22228
2005-06-16 07:06:03 +00:00
Chris Lattner
89dc4f16f5 Fix PR583 and testcase Transforms/InstCombine/2005-06-15-DivSelectCrash.ll
llvm-svn: 22227
2005-06-16 04:55:52 +00:00
Chris Lattner
69d21ed707 new testcase for PR583
llvm-svn: 22226
2005-06-16 04:55:29 +00:00
Chris Lattner
252a845e30 Fix PR571, removing code that does just the WRONG thing :)
llvm-svn: 22225
2005-06-16 03:00:08 +00:00
Chris Lattner
104002bee3 Fix a bug in my previous patch. Do not get the shift amount type (which
is always ubyte, get the type being shifted).  This unbreaks espresso

llvm-svn: 22224
2005-06-16 01:52:07 +00:00
Chris Lattner
d48b127aea Fix PR575, patch provided by John Mellor-Crummey. Thanks!
llvm-svn: 22223
2005-06-15 22:49:30 +00:00
Chris Lattner
0c2be5094c new testcase for PR580
llvm-svn: 22222
2005-06-15 22:42:53 +00:00
Chris Lattner
df81539278 Fix PR582. The rewriter can move casts around, which invalidated the
BB iterator.  This fixes Transforms/IndVarsSimplify/2005-06-15-InstMoveCrash.ll

llvm-svn: 22221
2005-06-15 21:29:31 +00:00
Chris Lattner
478158a4c5 new testcase for PR582
llvm-svn: 22220
2005-06-15 21:28:55 +00:00
Chris Lattner
50bdfcb045 Do not promote globals only used by main to locals if there are constantexprs
or other uses hanging off of them.

llvm-svn: 22219
2005-06-15 21:11:48 +00:00
Chris Lattner
11b4d966b7 new testcase for PR579
llvm-svn: 22218
2005-06-15 21:11:18 +00:00
Chris Lattner
19b57f55aa Fix PR577 and testcase InstCombine/2005-06-15-ShiftSetCCCrash.ll.
Do not perform undefined out of range shifts.

llvm-svn: 22217
2005-06-15 20:53:31 +00:00
Chris Lattner
b28f0ef40a new testcase for PR577
llvm-svn: 22216
2005-06-15 20:52:39 +00:00
Reid Spencer
95eda5aafc Don't lie to the casual reader about Value subclassing from Annotable.
llvm-svn: 22215
2005-06-15 18:40:45 +00:00
Nate Begeman
aaaebbed19 Add some operators the PowerPC backend needs to efficiently and correctly
generate conditional branches.

llvm-svn: 22214
2005-06-15 18:28:44 +00:00
Reid Spencer
a299d6f701 Put the hack back in that removes features, causes regressions to fail, but
allows test programs to succeed. Actual fix for this is forthcoming.

llvm-svn: 22213
2005-06-15 18:25:30 +00:00
Nate Begeman
1bf8927518 Commit fix for generating conditional branch pseudo instructions that
avoids dereferencing the end() iterator when selecting the fallthrough
block.  This requires an ilist change.

llvm-svn: 22212
2005-06-15 18:22:43 +00:00
Duraid Madina
31e5579fbf nothing funny about building the CFE on Linux/Itanium
llvm-svn: 22211
2005-06-14 07:29:50 +00:00
Nate Begeman
54c022156d Commit a small improvement that is already in the x86 and ia64 backends to
not generate unnecessary register copies.  This improves compile time by
2-5% depending on the test.

llvm-svn: 22210
2005-06-14 03:55:23 +00:00
Reid Spencer
6d231e55fa Unbreak several InstCombine regression checks introduced by a hack to
fix the bzip2 test. A better hack is needed.

llvm-svn: 22209
2005-06-13 06:41:26 +00:00
Nate Begeman
2829f330a3 When compiled with GCC 4.0, a latent bug was exposed where both SparcV9
and the target independant register allocator were both using a class named
'LiveRange'.  This lead to the target independant code calling code in the
SparcV9 backend, which crashed.  Fixed by renaming SparcV9's LiveRange to
V9LiveRange.

llvm-svn: 22208
2005-06-12 23:52:58 +00:00
Nate Begeman
02e33b70b1 Fix a memory smasher caught by Mac OS X's debug malloc library. We were
incorrectly using an iterator after it was invalid.

llvm-svn: 22207
2005-06-12 23:50:33 +00:00
Chris Lattner
1609a541cd Fix a 64-bit problem, passing (int)0 through ... instead of (void*)0
llvm-svn: 22206
2005-06-09 03:32:54 +00:00
Chris Lattner
fbc45f10d0 Fix a problem on 64-bit targets where we passed (int)0 through ... instead of
(void*)0.

llvm-svn: 22205
2005-06-09 02:59:00 +00:00
Andrew Lenharth
ea9af931b8 make SparcV8 and V9 seperately configurable
llvm-svn: 22204
2005-06-08 22:32:51 +00:00
Andrew Lenharth
c504a3db60 fix BranchCC with a setCC with an arg of 0
llvm-svn: 22203
2005-06-08 18:02:21 +00:00
Reid Spencer
8086cfaa6a For PR572:
Undefine the PPC symbol which is defined by Linux/PPC (erroneously) so it
doesn't pollute the user namespace and clash with our namespace declarations.

llvm-svn: 22202
2005-06-08 17:44:48 +00:00
Nate Begeman
60cf00c982 Handle some more real world cases of rlwimi. These don't come up that
regularly in "normal" code, but for things like software graphics, they
make a big difference.

For the following code:
unsigned short Trans16Bit(unsigned srcA,unsigned srcB,unsigned alpha)
{
	unsigned tmpA,tmpB,mixed;
	tmpA = ((srcA & 0x03E0) << 15) | (srcA & 0x7C1F);
	tmpB = ((srcB & 0x03E0) << 15) | (srcB & 0x7C1F);
	mixed = (tmpA * alpha) + (tmpB * (32 - alpha));
	return ((mixed >> 5) & 0x7C1F) | ((mixed >> 20) & 0x03E0);
}

We now generate:
_Trans16Bit:
.LBB_Trans16Bit_0:      ; entry
        andi. r2, r4, 31775
        rlwimi r2, r4, 15, 7, 11
        subfic r4, r5, 32
        mullw r2, r2, r4
        andi. r4, r3, 31775
        rlwimi r4, r3, 15, 7, 11
        mullw r3, r4, r5
        add r2, r2, r3
        srwi r3, r2, 5
        andi. r3, r3, 31775
        rlwimi r3, r2, 12, 22, 26
        blr

Instead of:
_Trans16Bit:
.LBB_Trans16Bit_0:      ; entry
        slwi r2, r4, 15
        rlwinm r2, r2, 0, 7, 11
        andi. r4, r4, 31775
        or r2, r2, r4
        subfic r4, r5, 32
        mullw r2, r2, r4
        slwi r4, r3, 15
        rlwinm r4, r4, 0, 7, 11
        andi. r3, r3, 31775
        or r3, r4, r3
        mullw r3, r3, r5
        add r2, r2, r3
        srwi r3, r2, 5
        andi. r3, r3, 31775
        srwi r2, r2, 20
        rlwimi r3, r2, 0, 22, 26
        blr

llvm-svn: 22201
2005-06-08 04:14:27 +00:00
Nate Begeman
85c7d546fe Fix lli linking on Mac OS X 10.4.1 for Intel.
llvm-svn: 22200
2005-06-08 01:02:38 +00:00
Andrew Lenharth
c3f68473a5 Remove code for conversion from old style va_args. Preparing the way for
returning to the old style :)

llvm-svn: 22199
2005-06-08 00:49:08 +00:00
Misha Brukman
ee14fc41f1 We also have V8, so do not force every Sparc to be treated like a V9. It is
still possible to force V9 (even if configure doesn't think it's one) via
``./configure --target=sparcv9-sun-solaris2.8'' so nothing is lost.

llvm-svn: 22198
2005-06-06 19:29:36 +00:00
Misha Brukman
ee811dcd12 * Add ability to specify the target LLVM will compile for via configure
* Minor whitespace cleanups

llvm-svn: 22197
2005-06-06 19:17:05 +00:00
Misha Brukman
ddb94f4169 Fix spelling of `correlate'
llvm-svn: 22196
2005-06-06 19:08:04 +00:00
Andrew Lenharth
c74fe84456 allow marking of loads and stores in the instruction stream with enough information to reconstruct the Value* if it existed
llvm-svn: 22195
2005-06-06 19:03:55 +00:00
Andrew Lenharth
b07a3d7138 hide basic block labels. The utility of these for debuging is long since passed
llvm-svn: 22194
2005-06-06 19:03:09 +00:00
Misha Brukman
175df27466 * Replace block of commented-out lines with #if 0
* Remove warning "control reaches end of non-void function"

llvm-svn: 22193
2005-06-06 17:39:46 +00:00
Andrew Lenharth
ffe65458e7 hack to fix bzip2 (bug 571)
llvm-svn: 22192
2005-06-04 12:43:56 +00:00
Reid Spencer
2a43ec334a Fix the definitions of LLVMGCC and LLVMGXX to include the EXEEXT (the
.exe extension) on Cygwin. This fixes the last few remaining Cygwin
issues. Thanks to Aaron Gray for tracking this down.

llvm-svn: 22191
2005-06-02 22:34:49 +00:00
Reid Spencer
4c07caf9d4 Make sure that Cygwin assembly includes _ as part of function names.
llvm-svn: 22190
2005-06-02 21:33:19 +00:00
Reid Spencer
d1ef1df103 Put in a hack for Cygwin that prevents mkdtemp from being used since
configure seems to find it on Cygwin but linking against it fails.

llvm-svn: 22189
2005-06-02 05:38:20 +00:00
Andrew Lenharth
7c0e9285ce try custom expanders, doesn't seem to expand yet, so disabled
llvm-svn: 22188
2005-05-31 19:49:34 +00:00
Andrew Lenharth
41e2981e0a switch to the new live in thing. Really, this time it works
llvm-svn: 22187
2005-05-31 18:42:18 +00:00
Andrew Lenharth
676e4db6dc switch to the new live in thing
llvm-svn: 22186
2005-05-31 18:37:16 +00:00
Andrew Lenharth
973d85e660 switch to the new live in thing
llvm-svn: 22185
2005-05-31 18:35:43 +00:00
Reid Spencer
d85c00251e Make sure the tools get built if no build target is specified.
llvm-svn: 22184
2005-05-29 00:49:24 +00:00
Andrew Lenharth
86f856f19c match gcc, makes diff easier
llvm-svn: 22179
2005-05-27 03:39:30 +00:00
Andrew Lenharth
39edea8306 Fix 2005-05-12-Int64ToFP
The issue is there is no unsigned -> double conversion, only signed.  So I
need to test the sign and do a different thing depending on it.  Ideally
this should be in a different BB, but in the mean time, I use a branch
free method.

llvm-svn: 22177
2005-05-26 18:18:34 +00:00
Misha Brukman
6f78543a86 Add a -cvstag option for testing specific branches, such as release candidates
llvm-svn: 22176
2005-05-26 16:28:55 +00:00
Reid Spencer
fec4f805d6 Add a "libs-only" target for avoiding construction of the tools and
runtime libraries.

llvm-svn: 22169
2005-05-25 21:03:17 +00:00
Reid Spencer
13f5193ff7 Two dist-check related changes:
1. Allow DIST_CHECK_CONFIG_OPTION to specify a set of options to be passed
   to the configure script during the dist-check target. This allows things
   to be passed down on a project basis so the configure doesn't fail.

2. Use the tar | (cd ; tar ) idiom to copy files which is more flexible
   than using the cp command. THis allows us to exclude CVS .svn
   directories at source rather than stripping them out of the tar ball.

llvm-svn: 22166
2005-05-24 02:33:20 +00:00
Reid Spencer
9c636a3b9b Remove trailing blank line, just to test whether the new commit script
is going to credit the commit correctly or not.

llvm-svn: 22165
2005-05-21 01:29:30 +00:00
Reid Spencer
9fbad13dd7 Make the registration hash_map static. No other module needs it. Also,
document what its for a little better.

llvm-svn: 22164
2005-05-21 01:27:04 +00:00
Reid Spencer
0b13cdabae Adjust the file comment to read a little easier.
llvm-svn: 22163
2005-05-21 00:57:44 +00:00
Reid Spencer
45bb4afc79 Make sure ... arguments are casted to sbyte* where needed.
llvm-svn: 22162
2005-05-21 00:39:30 +00:00
Reid Spencer
895af9ef24 Add a "brief" comment for CastToCStr
llvm-svn: 22161
2005-05-21 00:23:23 +00:00
Chris Lattner
bb09f861cd new testcase
llvm-svn: 22160
2005-05-20 22:25:44 +00:00
Chris Lattner
f8053cee7c Fix mismatched type problem that crashed on cases like this:
sprintf(P, "%s", X);

Where X is not an sbyte*.  This fixes the bug JohnMC reported on llvm-bugs.

llvm-svn: 22159
2005-05-20 22:22:25 +00:00
Chris Lattner
19f9f32a5c Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
llvm-svn: 22158
2005-05-20 22:19:54 +00:00
Chris Lattner
7e9e2e0ea9 New testcase that crashes simplifycfg, identified accidentally by JohnMC
llvm-svn: 22157
2005-05-20 22:19:34 +00:00
Nate Begeman
38724d33c1 C'mon everybody, let's modify X86JITInfo.cpp. This time, we add <iostream>
so that the shiny new use of std::cerr is defined.

llvm-svn: 22156
2005-05-20 21:29:24 +00:00
Reid Spencer
43a0f5bc54 Finally get the quoting right for both Unix and Windows for the llvmgcc and
llvmgxx programs. dejagnu doesn't understand single quote and we need to
pass double quotes through to the shell in order to escape blanks in the
paths. This patch uses \" to escape the quotes passed through to the shell.
Thanks to Aaron Gray for testing this out on cygwin.

llvm-svn: 22155
2005-05-20 20:13:41 +00:00
Misha Brukman
eba2471fa3 Since everyone else has "fixed" this file, might as well join in the fun.
* Change assert() to std::cerr printout, as it will not appear in opt builds
* Add comments to clarify what #ifdef/#else/#endif match what condition(s)

llvm-svn: 22154
2005-05-20 19:46:50 +00:00
Andrew Lenharth
0abbc1336d now with a legend, and multiple lines work.
llvm-svn: 22153
2005-05-20 17:50:51 +00:00
Andrew Lenharth
e5dc5c9c74 OK, the simple scheme for the db plus a couple of cgi scripts that
do the dynamic plotting of stuff.  Still being tested, but makes graphs

llvm-svn: 22152
2005-05-20 17:33:42 +00:00
Chris Lattner
8deafa3378 Fix this a 3rd time :)
llvm-svn: 22151
2005-05-20 17:00:21 +00:00
Andrew Lenharth
5d37a3abae fix compilation error due to no abort being defined. There is probably a better way to do this
llvm-svn: 22150
2005-05-20 16:34:44 +00:00
Duraid Madina
3a5eb61899 re-enable direct calls, this should just be a performance boost
llvm-svn: 22148
2005-05-20 11:39:17 +00:00
Duraid Madina
6e7355e6c1 this seems dead (and broke the ia64 build, so..)
llvm-svn: 22147
2005-05-20 06:21:59 +00:00
Chris Lattner
416a0d4c18 Give the asmparser the ability to parse strings. Patch contributed by
Alexander Friedman

llvm-svn: 22146
2005-05-20 03:25:47 +00:00
Chris Lattner
086f56c7f9 Give the asmparser the ability to parse strings, patch contributed by
Alexander Friedman!

llvm-svn: 22145
2005-05-20 03:25:29 +00:00
Jeff Cohen
e3948c433c Fix tail call support in VC++ builds
llvm-svn: 22143
2005-05-20 01:35:39 +00:00
Reid Spencer
b19f7a3c22 Make sure that tool names don't have any leading or trailing spaces in them.
If they do, it screws up the concatenation of the .exe suffix on cygwin.

llvm-svn: 22142
2005-05-19 21:10:31 +00:00
Reid Spencer
98a2d980ee Make sure that tool names don't have any leading or trailing spaces in them.
If they do, it screws up the concatenation of the .exe suffix on cygwin.

llvm-svn: 22141
2005-05-19 21:03:11 +00:00
Reid Spencer
90b689d943 Build the install directories just exactly as any others. Hopefully this
helps out cygwin build.

llvm-svn: 22140
2005-05-19 20:26:14 +00:00
Reid Spencer
e63f99c871 For PR514: Do not configure removed files
llvm-svn: 22139
2005-05-19 08:37:50 +00:00
Reid Spencer
8a4aa631fa For PR514: Do not configure removed files
llvm-svn: 22138
2005-05-19 08:31:55 +00:00
Chris Lattner
83a6f107fb Fastcc passes arguments in EAX and EDX, make sure the JIT doesn't clobber them
llvm-svn: 22137
2005-05-19 06:49:17 +00:00
Chris Lattner
57279597ab Tailcalls require stubs to be emitted. Otherwise, the compilation callback
doesn't know who 'called' it.

llvm-svn: 22136
2005-05-19 05:54:33 +00:00
Reid Spencer
e4925ca229 For PR514:
* Make sure the "etcdir" gets checked for configuration files so that
  the installed location for config files is checked.
* Remove the st.in file (moved to projects/Stacker/tools/stkrc)

llvm-svn: 22135
2005-05-19 01:06:46 +00:00
Reid Spencer
ba1e216183 Make the value to -s not be interpreted as a file name
llvm-svn: 22134
2005-05-19 01:05:02 +00:00
Reid Spencer
33d07dc48f Add an llvmc specification file for the "st" suffix. This allows Stacker
programs to benefit from the optimization capabilities of the llvmc.

llvm-svn: 22133
2005-05-19 00:54:10 +00:00
Reid Spencer
e9bee08f1d For PR514:
* language specification files are no longer configured with "configure"
* add substitutions for %bindir%, %libdir%, and various llvmgcc related
  variables needed in the c and cpp spec files.
* Implement the stubstituions in the Compiler Driver.
* Move st.in to projects/Stacker/tools/stkrc where it belongs.

llvm-svn: 22128
2005-05-19 00:52:28 +00:00
Reid Spencer
a80f16710f Two changes to support building shared libraries that contain multiple
llvm archive or re-linked libraries:
1. Permit the "JIT" special keyword on LLVMLIBS to be recognized when
   building a library, not just for building tools
2. If LINK_LIBS_IN_SHARED is set, the LLVMLIBS and USEDLIBS can be specified
   when linking a shared library and the libraries listed will be
   incorported into the shared library. THis is only used when the
   SHARED_LIBRARY variable is set.

llvm-svn: 22127
2005-05-19 00:37:31 +00:00
Chris Lattner
f30c73c7aa Reid linked to the CVS release notes on newsforge :(
llvm-svn: 22126
2005-05-18 22:23:56 +00:00
Misha Brukman
d5f457c47b Wrap long lines
llvm-svn: 22125
2005-05-18 20:37:33 +00:00
John Criswell
fee5f11463 New Release Notes for LLVM 1.6.
llvm-svn: 22124
2005-05-18 20:28:46 +00:00
Misha Brukman
713b3c691c Onward to LLVM-1.6 and beyond!
llvm-svn: 22123
2005-05-18 20:23:20 +00:00
John Criswell
ac87c14e2e Updated version to LLVM 1.6 CVS.
llvm-svn: 22122
2005-05-18 20:18:40 +00:00
John Criswell
e1a8120f52 Merged in release_15.
llvm-svn: 22120
2005-05-18 19:43:33 +00:00
Chris Lattner
05deb04cb0 teach the inliner about coldcc and noreturn functions
llvm-svn: 22113
2005-05-18 04:30:33 +00:00
Misha Brukman
add85fc7f8 Remove extra header in the SPARC section
llvm-svn: 22101
2005-05-17 15:15:19 +00:00
Reid Spencer
9803b40764 Fix a few grammaros.
llvm-svn: 22100
2005-05-17 02:47:27 +00:00
Misha Brukman
b6d38fc0f6 * Add a link to the pattern-matching codegen docs
* Tersify wording

llvm-svn: 22099
2005-05-17 02:33:03 +00:00
Misha Brukman
e62ec45887 Recommend writing new instruction selectors using pattern-based mechanisms
llvm-svn: 22098
2005-05-17 02:27:30 +00:00
Misha Brukman
3dcba5cd4a Add link to debugging code generators with bugpoint
llvm-svn: 22097
2005-05-17 02:12:32 +00:00
Reid Spencer
1e68384501 It would help if the headings were sorted properly.
llvm-svn: 22096
2005-05-16 19:33:21 +00:00
Reid Spencer
5a68566566 Fix a brain blunder in the HTML output.
llvm-svn: 22094
2005-05-16 18:52:57 +00:00
Reid Spencer
8dd9127970 Sometimes tab completion is *not* your friend. Added the wrong file, by
accident so now I'm correcting it. The script is userloc.pl not userloc.html

llvm-svn: 22093
2005-05-16 18:30:38 +00:00
Reid Spencer
84f479aa7f Adjust the dependencies and generate the output to docs/userloc.html so
that it can properly link to the CSS stylesheet and images.

llvm-svn: 22092
2005-05-16 18:29:13 +00:00
Reid Spencer
ad966163dd Add a script to generate information about the number of lines of code a
user has checked in (not necessarily authored) based on cvs annotate.

llvm-svn: 22091
2005-05-16 18:26:47 +00:00
Reid Spencer
5c2e03d65b Add the ability to generate the User LOC page via the userloc.pl script.
llvm-svn: 22090
2005-05-16 18:12:58 +00:00
714 changed files with 70033 additions and 35030 deletions

View File

@@ -4,3 +4,4 @@ config.log
config.status
cvs.out
autom4te.cache
configure.out

View File

@@ -1,6 +1,7 @@
Inspired by the CREDITS file from the Linux source tree, this file is,
likewise, at least a partial list of people who have contributed to the LLVM
project. The format and the next paragraph are stolen directly from that file.
This file is a partial list of people who have contributed to the LLVM
project. If you have contributed a patch or made some other contribution to
LLVM, please submit a patch to this file to add yourself, and it will be
done!
The list is sorted by name and formatted to allow easy grepping and
beautification by scripts. The fields are: name (N), email (E), web-address

View File

@@ -7,17 +7,25 @@
#
#===------------------------------------------------------------------------===#
LEVEL = .
DIRS = lib/System lib/Support utils lib tools
DIRS = lib/System lib/Support utils lib
ifneq ($(MAKECMDGOALS),tools-only)
DIRS += runtime docs
OPTIONAL_DIRS = examples projects
ifeq ($(MAKECMDGOALS),tools-only)
DIRS += tools
else
ifneq ($(MAKECMDGOALS),libs-only)
DIRS += tools runtime docs
OPTIONAL_DIRS = examples projects
endif
endif
EXTRA_DIST := test llvm.spec include
include $(LEVEL)/Makefile.common
# Specify options to pass to configure script when we're
# running the dist-check target
DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
.PHONY: debug-opt-prof
debug-opt-prof:
$(Echo) Building Debug Version
@@ -42,3 +50,22 @@ dist-hook::
$(TopDistDir)/include/llvm/Support/ThreadSupport.h
tools-only: all
libs-only: all
#------------------------------------------------------------------------
# Make sure the generated headers are up-to-date. This must be kept in
# sync with the AC_CONFIG_HEADER invocations in autoconf/configure.ac
#------------------------------------------------------------------------
FilesToConfig := \
include/llvm/Config/config.h \
include/llvm/Support/DataTypes.h \
include/llvm/ADT/hash_map \
include/llvm/ADT/hash_set \
include/llvm/ADT/iterator
FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
all-local:: $(FilesToConfigPATH)
$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
$(Echo) Regenerating $*
$(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
.PRECIOUS: $(FilesToConfigPATH)

View File

@@ -77,7 +77,7 @@ ifneq ($(MakefileConfigIn),)
PreConditions += $(MakefileConfig)
endif
preconditions : $(PreConditions)
preconditions: $(PreConditions)
#------------------------------------------------------------------------
# Make sure the BUILT_SOURCES are built first
@@ -359,10 +359,13 @@ Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
$(C.Flags) -c
Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
$(CXX.Flags) -c
Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
$(CompileCommonOpts) $(LD.Flags) $(Strip)
Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
@@ -423,17 +426,10 @@ endif
# in the file so they get built before dependencies
#---------------------------------------------------------
$(PROJ_bindir):
$(Verb) $(MKDIR) $(PROJ_bindir)
$(PROJ_libdir):
$(Verb) $(MKDIR) $(PROJ_libdir)
$(PROJ_includedir):
$(Verb) $(MKDIR) $(PROJ_includedir)
$(PROJ_etcdir):
$(Verb) $(MKDIR) $(PROJ_etcdir)
$(PROJ_bindir): $(PROJ_bindir)/.dir
$(PROJ_libdir): $(PROJ_libdir)/.dir
$(PROJ_includedir): $(PROJ_includedir)/.dir
$(PROJ_etcdir): $(PROJ_etcdir)/.dir
# To create other directories, as needed, and timestamp their creation
%/.dir:
@@ -553,6 +549,100 @@ uninstall-local::
endif
###############################################################################
# Set up variables for building libararies
###############################################################################
#---------------------------------------------------------
# Handle the special "JIT" value for LLVM_LIBS which is a
# shorthand for a bunch of libraries that get the correct
# JIT support for a library or a tool that runs JIT.
#---------------------------------------------------------
ifeq ($(LLVMLIBS),JIT)
# Make sure we can get our own symbols in the tool
Link += -dlopen self
# Generic JIT libraries
JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
# You can enable the X86 JIT on a non-X86 host by setting the flag
# ENABLE_X86_JIT on the make command line. If not, it will still be
# enabled automagically on an X86 host.
ifeq ($(ARCH), x86)
ENABLE_X86_JIT = 1
endif
# What the X86 JIT requires
ifdef ENABLE_X86_JIT
JIT_LIBS += LLVMX86 LLVMSelectionDAG
endif
# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
# enabled automagically on an SparcV9 host.
ifeq ($(ARCH), Sparc)
ENABLE_SPARCV9_JIT = 1
endif
# What the Sparc JIT requires
ifdef ENABLE_SPARCV9_JIT
JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
LLVMSparcV9LiveVar LLVMInstrumentation.a \
LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
LLVMDataStructure LLVMSparcV9RegAlloc
endif
# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
# ENABLE_PPC_JIT on the make command line. If not, it will still be
# enabled automagically on an PowerPC host.
ifeq ($(ARCH), PowerPC)
ENABLE_PPC_JIT = 1
endif
# What the PowerPC JIT requires
ifdef ENABLE_PPC_JIT
JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
endif
# You can enable the Alpha JIT on a non-Alpha host by setting the flag
# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
# enabled automagically on an Alpha host.
ifeq ($(ARCH), Alpha)
ENABLE_ALPHA_JIT = 1
endif
# What the Alpha JIT requires
ifdef ENABLE_ALPHA_JIT
JIT_LIBS += LLVMAlpha LLVMSelectionDAG
endif
LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
LLVMSystem.a $(PLATFORMLIBDL)
endif
#---------------------------------------------------------
# Define various command line options pertaining to the
# libraries needed when linking. There are "Proj" libs
# (defined by the user's project) and "LLVM" libs (defined
# by the # LLVM project).
#---------------------------------------------------------
# Some versions of gcc on Alpha produce too many symbols, so use a .a file
ifeq ($(ARCH),Alpha)
USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
endif
ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
###############################################################################
# Library Build Rules: Four ways to build a library
###############################################################################
@@ -634,10 +724,18 @@ ifdef SHARED_LIBRARY
all-local:: $(LibName.LA)
ifdef LINK_LIBS_IN_SHARED
$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
$(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
$(Verb) $(Link) -o $@ $(ObjectsLO) \
$(ProjLibsOptions) $(LLVMLibsOptions)
$(Verb) $(LTInstall) $@ $(LibDir)
else
$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
$(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
$(Verb) $(Link) -o $@ $(ObjectsLO)
$(Verb) $(LTInstall) $@ $(LibDir)
endif
clean-local::
ifneq ($(strip $(LibName.LA)),)
@@ -726,10 +824,18 @@ endif
#---------------------------------------------------------
# ReLinked Library Targets:
# If the user didn't explicitly forbid building a
# relinked then we provide targets for building them.
# If the user explicitly requests a relinked library with
# BUILD_RELINKED, provide it. Otherwise, if they specify
# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
# them one.
#---------------------------------------------------------
ifndef BUILD_ARCHIVE
ifndef DONT_BUILD_RELINKED
BUILD_RELINKED = 1
endif
endif
ifdef BUILD_RELINKED
all-local:: $(LibName.O)
@@ -800,79 +906,14 @@ endif
ifdef TOOLNAME
#---------------------------------------------------------
# Handle the special "JIT" value for LLVM_LIBS which is a
# shorthand for a bunch of libraries that get the correct
# JIT support for a tool that runs JIT.
#---------------------------------------------------------
ifeq ($(LLVMLIBS),JIT)
# Make sure we can get our own symbols in the tool
Link += -dlopen self
# Generic JIT libraries
JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
# You can enable the X86 JIT on a non-X86 host by setting the flag
# ENABLE_X86_JIT on the make command line. If not, it will still be
# enabled automagically on an X86 host.
ifeq ($(ARCH), x86)
ENABLE_X86_JIT = 1
endif
# What the X86 JIT requires
ifdef ENABLE_X86_JIT
JIT_LIBS += LLVMX86 LLVMSelectionDAG
endif
# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
# enabled automagically on an SparcV9 host.
ifeq ($(ARCH), Sparc)
ENABLE_SPARCV9_JIT = 1
endif
# What the Sparc JIT requires
ifdef ENABLE_SPARCV9_JIT
JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
LLVMDataStructure.a LLVMSparcV9RegAlloc
endif
# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
# ENABLE_PPC_JIT on the make command line. If not, it will still be
# enabled automagically on an PowerPC host.
ifeq ($(ARCH), PowerPC)
ENABLE_PPC_JIT = 1
endif
# What the PowerPC JIT requires
ifdef ENABLE_PPC_JIT
JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
endif
LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
LLVMSystem.a $(PLATFORMLIBDL)
endif
#---------------------------------------------------------
# Set up variables for building a tool.
#---------------------------------------------------------
ifdef EXAMPLE_TOOL
ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
else
ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
endif
ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
#---------------------------------------------------------
# Tell make that we need to rebuild subdirectories before
@@ -972,6 +1013,20 @@ $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
endif
## Rules for building preprocessed (.i/.ii) outputs.
$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
$(Verb) $(Preprocess.C) $< -o $@
#---------------------------------------------------------
# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
#---------------------------------------------------------
@@ -1053,7 +1108,7 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
ifdef TARGET
TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td)
INCFiles := $(filter %.inc,$(BUILT_SOURCES))
INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
.PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1110,6 +1165,16 @@ $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) code emitter with tblgen"
$(Verb) $(TableGen) -gen-emitter -o $@ $<
$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) instruction selector implementation with tblgen"
$(Verb) $(TableGen) -gen-dag-isel -o $@ $<
$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) subtarget information with tblgen"
$(Verb) $(TableGen) -gen-subtarget -o $@ $<
clean-local::
-$(Verb) $(RM) -f $(INCFiles)
@@ -1128,9 +1193,9 @@ LexFiles := $(filter %.l,$(Sources))
ifneq ($(LexFiles),)
LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
.PRECIOUS: $(LexOutput)
# Cancel built-in rules for lex
%.c: %.l
%.cpp: %.l
# Note the extra sed filtering here, used to cut down on the warnings emited
# by GCC. The last line is a gross hack to work around flex aparently not
@@ -1138,13 +1203,17 @@ LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
# uninitialized string buffers in LLVM we can generate very long tokens, so
# this is a hack around it.
# FIXME. (f.e. char Buffer[10000] )
%.cpp: %.l
$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
$(Echo) Flexing $*.l
$(Verb) $(FLEX) -t $< | \
$(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
$(SED) 's/void yyunput/inline void yyunput/' | \
$(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
$(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
> $@
> $(PROJ_SRC_DIR)/$*.cpp
$(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp (generated file)"
LexObjs := $(patsubst %.l,$(ObjDir)/%.o,$(LexFiles))
$(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
clean-local::
-$(Verb) $(RM) -f $(LexOutput)
@@ -1159,7 +1228,7 @@ endif
YaccFiles := $(filter %.y,$(Sources))
ifneq ($(YaccFiles),)
YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
.PRECIOUS: $(YaccOutput)
@@ -1169,14 +1238,14 @@ YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
%.h: %.y
# Rule for building the bison parsers...
%.cpp %.h : %.y
$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
$(Echo) "Bisoning $*.y"
$(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
$(Verb) $(MV) -f $*.tab.c $*.cpp
$(Verb) $(MV) -f $*.tab.h $*.h
$(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
$(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
$(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
$(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
clean-local::
-$(Verb) $(RM) -f $(YaccOutput)
$(Verb) $(RM) -f $(YaccOutput)
endif
@@ -1354,7 +1423,7 @@ dist-check:: $(DistTarGZip)
gunzip -c $(DistTarGZip) | $(TAR) xf - && \
cd build && \
../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
--srcdir=../$(DistName) && \
--srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
$(MAKE) all && \
$(MAKE) check && \
$(MAKE) install && \
@@ -1420,9 +1489,16 @@ $(DistDir)/.makedistdir: $(DistSources)
if test -d "$$from_dir/$$file"; then \
if test -d "$(PROJ_SRC_DIR)/$$file" && \
test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
$(CP) -pR "$(PROJ_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
cd $(PROJ_SRC_DIR) ; \
$(TAR) cf - $$file --exclude .svn --exclude CVS | \
( cd $$to_dir ; $(TAR) xf - ) ; \
cd $(PROJ_OBJ_DIR) ; \
else \
cd $$from_dir ; \
$(TAR) cf - $$file --exclude .svn --exclude CVS | \
( cd $$to_dir ; $(TAR) xf - ) ; \
cd $(PROJ_OBJ_DIR) ; \
fi; \
$(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
elif test -f "$$from_dir/$$file" ; then \
$(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
elif test -L "$$from_dir/$$file" ; then \
@@ -1443,8 +1519,8 @@ $(DistDir)/.makedistdir: $(DistSources)
fi; \
done
$(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
$(EchoCmd) Eliminating CVS directories from distribution ; \
$(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
$(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
$(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
$(MAKE) dist-hook ; \
$(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
-o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
@@ -1539,3 +1615,4 @@ printvars::
$(Echo) "YaccFiles : " '$(YaccFiles)'
$(Echo) "LexFiles : " '$(LexFiles)'
$(Echo) "Module : " '$(Module)'
$(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'

File diff suppressed because it is too large Load Diff

1
llvm/Xcode/README.txt Normal file
View File

@@ -0,0 +1 @@
Xcode project files for LLVM, for Xcode 2.1

View File

@@ -31,12 +31,12 @@ dnl===
dnl===-----------------------------------------------------------------------===
dnl Initialize autoconf and define the package name, version number and
dnl email address for reporting bugs.
AC_INIT([[llvm]],[[1.5cvs]],[llvmbugs@cs.uiuc.edu])
AC_INIT([[llvm]],[[1.6]],[llvmbugs@cs.uiuc.edu])
dnl Provide a copyright substitution and ensure the copyright notice is included
dnl in the output of --version option of the generated configure script.
AC_SUBST(LLVM_COPYRIGHT,["Copyright (c) 2003-2005 University of Illinois at Urbana-Champaign."])
AC_COPYRIGHT($LLVM_COPYRIGHT)
AC_COPYRIGHT([Copyright (c) 2003-2005 University of Illinois at Urbana-Champaign.])
dnl Indicate that we require autoconf 2.59 or later. Ths is needed because we
dnl use some autoconf macros only available in 2.59.
@@ -159,14 +159,6 @@ case $llvm_cv_platform_type in
;;
esac
dnl If we are targetting a Sparc machine running Solaris, pretend that it is
dnl V9, since that is all that we support at the moment, and autoconf will only
dnl tell us we're a sparc.
case $target in
sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
;;
esac
dnl Determine what our target architecture is and configure accordingly.
dnl This will allow Makefiles to make a distinction between the hardware and
dnl the OS.
@@ -220,7 +212,7 @@ else
Sparc) AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]) ;;
PowerPC) AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]) ;;
x86_64) AC_SUBST(JIT,[[]]) ;;
Alpha) AC_SUBST(JIT,[[]]) ;;
Alpha) AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]) ;;
IA64) AC_SUBST(JIT,[[]]) ;;
*) AC_SUBST(JIT,[[]]) ;;
esac
@@ -238,6 +230,18 @@ case "$enableval" in
*) AC_MSG_ERROR([Invalid setting for --enable-doxygen. Use "yes" or "no"]) ;;
esac
dnl Allow disablement of threads
AC_ARG_ENABLE(threads,
AS_HELP_STRING([--enable-threads],
[Use threads if available (default is YES)]),,
enableval=yes)
case "$enableval" in
yes) AC_SUBST(ENABLE_THREADS,[1]) ;;
no) AC_SUBST(ENABLE_THREADS,[0]) ;;
*) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
esac
AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
dnl Allow specific targets to be specified for building (or not)
TARGETS_TO_BUILD=""
AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-target],
@@ -312,6 +316,18 @@ AC_PROG_RANLIB
AC_PATH_PROG(RM, [rm], [rm])
AC_PATH_PROG(SED, [sed], [sed])
AC_PATH_PROG(TAR, [tar], [gtar])
AC_PATH_PROG(GRAPHVIZ, [Graphviz], [echo Graphviz])
if test "$GRAPHVIZ" != "echo Graphviz" ; then
AC_DEFINE([HAVE_GRAPHVIZ],[1],[Define if the Graphviz program is available])
AC_DEFINE_UNQUOTED([LLVM_PATH_GRAPHVIZ],"$GRAPHVIZ",
[Define to path to Graphviz program if found or 'echo Graphviz' otherwise])
fi
AC_PATH_PROG(GV, [gv], [echo gv])
if test "$GRAPHVIZ" != "echo gv" ; then
AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available])
AC_DEFINE_UNQUOTED([LLVM_PATH_GV],"$GV",
[Define to path to gv program if found or 'echo gv' otherwise])
fi
dnl Find the install program
AC_PROG_INSTALL
@@ -357,11 +373,13 @@ esac
AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
if test "$WITH_LLVMGCCDIR" = "default" ; then
AC_PATH_PROG(LLVMGCC, [llvm-gcc], [])
AC_PATH_PROG(LLVMGXX, [llvm-g++], [])
LLVMGCC="llvm-gcc${EXEEXT}"
LLVMGXX="llvm-g++${EXEEXT}"
AC_PATH_PROG(LLVMGCC, $LLVMGCC, [])
AC_PATH_PROG(LLVMGXX, $LLVMGXX, [])
else
LLVMGCC=$WITH_LLVMGCCDIR/bin/llvm-gcc
LLVMGXX=$WITH_LLVMGCCDIR/bin/llvm-g++
LLVMGCC="$WITH_LLVMGCCDIR/bin/llvm-gcc${EXEEXT}"
LLVMGXX="$WITH_LLVMGCCDIR/bin/llvm-g++${EXEEXT}"
AC_SUBST(LLVMGCC,$LLVMGCC)
AC_SUBST(LLVMGXX,$LLVMGXX)
fi
@@ -398,7 +416,7 @@ fi
dnl Verify that GCC is version 3.0 or higher
if test "$GCC" = "yes"
then
gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
gccmajor=`$CC --version | head -n 1 | sed 's/[[^0-9]]*\([[0-9.]]\).*/\1/'`
if test "$gccmajor" -lt "3"
then
AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
@@ -423,6 +441,7 @@ dnl===-----------------------------------------------------------------------===
dnl libelf is for sparc only; we can ignore it if we don't have it
AC_CHECK_LIB(elf, elf_begin)
dnl lt_dlopen may be required for plugin support.
AC_SEARCH_LIBS(lt_dlopen,ltdl,AC_DEFINE([HAVE_LT_DLOPEN],[1],
[Define if lt_dlopen() is available on this platform]),
@@ -440,9 +459,12 @@ AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
dnl pthread locking functions are optional - but llvm will not be thread-safe
dnl without locks.
AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],
[Have pthread_mutex_lock]))
if test "$ENABLE_THREADS" -eq 1 ; then
AC_CHECK_LIB(pthread,pthread_mutex_init)
AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],
[Have pthread_mutex_lock]))
fi
dnl===-----------------------------------------------------------------------===
dnl===
@@ -465,6 +487,9 @@ AC_CHECK_HEADERS([dlfcn.h execinfo.h fcntl.h inttypes.h limits.h link.h])
AC_CHECK_HEADERS([malloc.h signal.h stdint.h unistd.h utime.h windows.h])
AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h sys/types.h])
AC_CHECK_HEADERS([rw/stdex/hash_map.h rw/stdex/hash_set.h])
if test "$ENABLE_THREADS" -eq 1 ; then
AC_CHECK_HEADERS(pthread.h)
fi
dnl===-----------------------------------------------------------------------===
dnl===
@@ -609,20 +634,19 @@ dnl===
dnl===-----------------------------------------------------------------------===
dnl Configure header files
AC_CONFIG_HEADERS(include/llvm/Config/config.h)
dnl WARNING: dnl If you add or remove any of the following config headers, then
dnl you MUST also update Makefile.rules so that the variable FilesToConfig
dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the
dnl files can be updated automatically when their *.in sources change.
AC_CONFIG_HEADERS([include/llvm/Config/config.h])
AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
AC_CONFIG_HEADERS([include/llvm/ADT/hash_map])
AC_CONFIG_HEADERS([include/llvm/ADT/hash_set])
AC_CONFIG_HEADERS([include/llvm/Support/ThreadSupport.h])
AC_CONFIG_HEADERS([include/llvm/ADT/iterator])
dnl Configure the makefile's configuration data
AC_CONFIG_FILES([Makefile.config])
dnl Configure llvmc's configuration files
AC_CONFIG_FILES([tools/llvmc/st tools/llvmc/cpp tools/llvmc/ll tools/llvmc/c])
dnl Configure doxygen's configuration file
AC_CONFIG_FILES([docs/doxygen.cfg])

View File

@@ -0,0 +1,118 @@
dnl Check for a standard program that has a bin, include and lib directory
dnl
dnl Parameters:
dnl $1 - prefix directory to check
dnl $2 - program name to check
dnl $3 - header file to check
dnl $4 - library file to check
AC_DEFUN([CHECK_STD_PROGRAM],
[m4_define([allcapsname],translit($2,a-z,A-Z))
if test -n "$1" -a -d "$1" -a -n "$2" -a -d "$1/bin" -a -x "$1/bin/$2" ; then
AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"])
AC_SUBST(allcapsname(),[$1/bin/$2])
AC_SUBST(allcapsname()[_BIN],[$1/bin])
AC_SUBST(allcapsname()[_DIR],[$1])
if test -n "$3" -a -d "$1/include" -a -f "$1/include/$3" ; then
AC_SUBST(allcapsname()[_INC],[$1/include])
fi
if test -n "$4" -a -d "$1/lib" -a -f "$1/lib/$4" ; then
AC_SUBST(allcapsname()[_LIB],[$1/lib])
fi
fi
])
dnl Find a program via --with options, in the path, or well known places
dnl
dnl Parameters:
dnl $1 - program's executable name
dnl $2 - header file name to check (optional)
dnl $3 - library file name to check (optional)
dnl $4 - alternate (long) name for the program
AC_DEFUN([FIND_STD_PROGRAM],
[m4_define([allcapsname],translit($1,a-z,A-Z))
m4_define([stdprog_long_name],ifelse($4,,translit($1,[ !@#$%^&*()-+={}[]:;"',./?],[-]),translit($4,[ !@#$%^&*()-+={}[]:;"',./?],[-])))
AC_MSG_CHECKING([for ]stdprog_long_name()[ bin/lib/include locations])
AC_ARG_WITH($1,
AS_HELP_STRING([--with-]stdprog_long_name()[=DIR],
[Specify that the ]stdprog_long_name()[ install prefix is DIR]),
$1[pfxdir=$withval],$1[pfxdir=nada])
AC_ARG_WITH($1[-bin],
AS_HELP_STRING([--with-]stdprog_long_name()[-bin=DIR],
[Specify that the ]stdprog_long_name()[ binary is in DIR]),
$1[bindir=$withval],$1[bindir=nada])
AC_ARG_WITH($1[-lib],
AS_HELP_STRING([--with-]stdprog_long_name()[-lib=DIR],
[Specify that ]stdprog_long_name()[ libraries are in DIR]),
$1[libdir=$withval],$1[libdir=nada])
AC_ARG_WITH($1[-inc],
AS_HELP_STRING([--with-]stdprog_long_name()[-inc=DIR],
[Specify that the ]stdprog_long_name()[ includes are in DIR]),
$1[incdir=$withval],$1[incdir=nada])
eval pfxval=\$\{$1pfxdir\}
eval binval=\$\{$1bindir\}
eval incval=\$\{$1incdir\}
eval libvar=\$\{$1libdir\}
if test "${pfxval}" != "nada" ; then
CHECK_STD_PROGRAM(${pfxval},$1,$2,$3)
elif test "${binval}" != "nada" ; then
if test "${libval}" != "nada" ; then
if test "${incval}" != "nada" ; then
if test -d "${binval}" ; then
if test -d "${incval}" ; then
if test -d "${libval}" ; then
AC_SUBST(allcapsname(),${binval}/$1)
AC_SUBST(allcapsname()[_BIN],${binval})
AC_SUBST(allcapsname()[_INC],${incval})
AC_SUBST(allcapsname()[_LIB],${libval})
AC_SUBST([USE_]allcapsname(),[1])
AC_MSG_RESULT([found via --with options])
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-libdir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-incdir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-bindir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-incdir option must be specified])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-libdir option must be specified])
fi
else
tmppfxdir=`which $1 2>&1`
if test -n "$tmppfxdir" -a -d "${tmppfxdir%*$1}" -a \
-d "${tmppfxdir%*$1}/.." ; then
tmppfxdir=`cd "${tmppfxdir%*$1}/.." ; pwd`
CHECK_STD_PROGRAM($tmppfxdir,$1,$2,$3)
AC_MSG_RESULT([found in PATH at ]$tmppfxdir)
else
checkresult="yes"
eval checkval=\$\{"USE_"allcapsname()\}
CHECK_STD_PROGRAM([/usr],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/usr/local],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/sw],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/opt],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/],$1,$2,$3)
if test -z "${checkval}" ; then
checkresult="no"
fi
fi
fi
fi
fi
AC_MSG_RESULT($checkresult)
fi
fi
])

View File

@@ -0,0 +1,22 @@
dnl Check a program for version sanity. The test runs a program, passes it an
dnl argument to make it print out some identification string, and filters that
dnl output with a regular expression. If the output is non-empty, the program
dnl passes the sanity check.
dnl $1 - Name or full path of the program to run
dnl $2 - Argument to pass to print out identification string
dnl $3 - grep RE to match identification string
AC_DEFUN([CHECK_PROGRAM_SANITY],
[
AC_MSG_CHECKING([sanity for program ]$1)
sanity_path=`which $1 2>/dev/null`
if test "$?" -eq 0 -a -x "$sanity_path" ; then
sanity=`$1 $2 2>&1 | grep "$3"`
if test -z "$sanity" ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
fi
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([not found])
fi
])

478
llvm/configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for llvm 1.5cvs.
# Generated by GNU Autoconf 2.59 for llvm 1.6.
#
# Report bugs to <llvmbugs@cs.uiuc.edu>.
#
@@ -8,7 +8,7 @@
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
#
# $LLVM_COPYRIGHT
# Copyright (c) 2003-2005 University of Illinois at Urbana-Champaign.
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
@@ -425,8 +425,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='llvm'
PACKAGE_TARNAME='-llvm-'
PACKAGE_VERSION='1.5cvs'
PACKAGE_STRING='llvm 1.5cvs'
PACKAGE_VERSION='1.6'
PACKAGE_STRING='llvm 1.6'
PACKAGE_BUGREPORT='llvmbugs@cs.uiuc.edu'
ac_unique_file="lib/VMCore/Module.cpp"
@@ -475,7 +475,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS LLVM_COPYRIGHT subdirs build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVM_ON_UNIX LLVM_ON_WIN32 ARCH ENDIAN CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT ENABLE_OPTIMIZED JIT ENABLE_DOXYGEN TARGETS_TO_BUILD CPP CXX CXXFLAGS ac_ct_CXX LEX LEXLIB LEX_OUTPUT_ROOT FLEX YACC BISON ifGNUmake LN_S CMP CP DATE FIND GREP MKDIR MV RANLIB ac_ct_RANLIB RM SED TAR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA BZIP2 DOT DOXYGEN ETAGS GROFF GZIP POD2HTML POD2MAN RUNTEST TCLSH ZIP EGREP INSTALL_LTDL_TRUE INSTALL_LTDL_FALSE CONVENIENCE_LTDL_TRUE CONVENIENCE_LTDL_FALSE LIBADD_DL ECHO AR ac_ct_AR STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL ETAGSFLAGS LLVMGCC LLVMGXX ALLOCA MMAP_FILE LLVMCC1 LLVMCC1PLUS LLVMGCCDIR SHLIBEXT LLVM_PREFIX LLVM_BINDIR LLVM_LIBDIR LLVM_DATADIR LLVM_DOCSDIR LLVM_ETCDIR LLVM_INCLUDEDIR LLVM_INFODIR LLVM_MANDIR LLVM_CONFIGTIME LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS LLVM_COPYRIGHT subdirs build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVM_ON_UNIX LLVM_ON_WIN32 ARCH ENDIAN CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT ENABLE_OPTIMIZED JIT ENABLE_DOXYGEN ENABLE_THREADS TARGETS_TO_BUILD CPP CXX CXXFLAGS ac_ct_CXX LEX LEXLIB LEX_OUTPUT_ROOT FLEX YACC BISON ifGNUmake LN_S CMP CP DATE FIND GREP MKDIR MV RANLIB ac_ct_RANLIB RM SED TAR GRAPHVIZ GV INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA BZIP2 DOT DOXYGEN ETAGS GROFF GZIP POD2HTML POD2MAN RUNTEST TCLSH ZIP EGREP INSTALL_LTDL_TRUE INSTALL_LTDL_FALSE CONVENIENCE_LTDL_TRUE CONVENIENCE_LTDL_FALSE LIBADD_DL ECHO AR ac_ct_AR STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL ETAGSFLAGS LLVMGCC LLVMGXX ALLOCA MMAP_FILE LLVMCC1 LLVMCC1PLUS LLVMGCCDIR SHLIBEXT LLVM_PREFIX LLVM_BINDIR LLVM_LIBDIR LLVM_DATADIR LLVM_DOCSDIR LLVM_ETCDIR LLVM_INCLUDEDIR LLVM_INFODIR LLVM_MANDIR LLVM_CONFIGTIME LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -964,7 +964,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures llvm 1.5cvs to adapt to many kinds of systems.
\`configure' configures llvm 1.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1026,7 +1026,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of llvm 1.5cvs:";;
short | recursive ) echo "Configuration of llvm 1.6:";;
esac
cat <<\_ACEOF
@@ -1036,6 +1036,7 @@ Optional Features:
--enable-optimized
--enable-jit Enable Just In Time Compiling (default is YES)
--enable-doxygen Build doxygen documentation (default is NO)
--enable-threads Use threads if available (default is YES)
--enable-target Build specific host targets:
all,host-only,{target-name} (default=all)
--enable-ltdl-install install libltdl
@@ -1172,14 +1173,14 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
llvm configure 1.5cvs
llvm configure 1.6
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
$LLVM_COPYRIGHT
Copyright (c) 2003-2005 University of Illinois at Urbana-Champaign.
_ACEOF
exit 0
fi
@@ -1188,7 +1189,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by llvm $as_me 1.5cvs, which was
It was created by llvm $as_me 1.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1774,12 +1775,6 @@ _ACEOF
;;
esac
case $target in
sparc*-*-solaris*) target=sparcv9-sun-solaris2.8
;;
esac
echo "$as_me:$LINENO: checking target architecture" >&5
echo $ECHO_N "checking target architecture... $ECHO_C" >&6
if test "${llvm_cv_target_arch+set}" = set; then
@@ -3003,7 +2998,7 @@ else
;;
x86_64) JIT=
;;
Alpha) JIT=
Alpha) JIT=TARGET_HAS_JIT=1
;;
IA64) JIT=
;;
@@ -3031,6 +3026,28 @@ echo "$as_me: error: Invalid setting for --enable-doxygen. Use \"yes\" or \"no\"
{ (exit 1); exit 1; }; } ;;
esac
# Check whether --enable-threads or --disable-threads was given.
if test "${enable_threads+set}" = set; then
enableval="$enable_threads"
else
enableval=yes
fi;
case "$enableval" in
yes) ENABLE_THREADS=1
;;
no) ENABLE_THREADS=0
;;
*) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-threads. Use \"yes\" or \"no\"" >&5
echo "$as_me: error: Invalid setting for --enable-threads. Use \"yes\" or \"no\"" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
cat >>confdefs.h <<_ACEOF
#define ENABLE_THREADS $ENABLE_THREADS
_ACEOF
TARGETS_TO_BUILD=""
# Check whether --enable-targets or --disable-targets was given.
if test "${enable_targets+set}" = set; then
@@ -5060,6 +5077,110 @@ else
echo "${ECHO_T}no" >&6
fi
# Extract the first word of "Graphviz", so it can be a program name with args.
set dummy Graphviz; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_GRAPHVIZ+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $GRAPHVIZ in
[\\/]* | ?:[\\/]*)
ac_cv_path_GRAPHVIZ="$GRAPHVIZ" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_GRAPHVIZ="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
test -z "$ac_cv_path_GRAPHVIZ" && ac_cv_path_GRAPHVIZ="echo Graphviz"
;;
esac
fi
GRAPHVIZ=$ac_cv_path_GRAPHVIZ
if test -n "$GRAPHVIZ"; then
echo "$as_me:$LINENO: result: $GRAPHVIZ" >&5
echo "${ECHO_T}$GRAPHVIZ" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test "$GRAPHVIZ" != "echo Graphviz" ; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GRAPHVIZ 1
_ACEOF
cat >>confdefs.h <<_ACEOF
#define LLVM_PATH_GRAPHVIZ "$GRAPHVIZ"
_ACEOF
fi
# Extract the first word of "gv", so it can be a program name with args.
set dummy gv; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_GV+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $GV in
[\\/]* | ?:[\\/]*)
ac_cv_path_GV="$GV" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_GV="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
test -z "$ac_cv_path_GV" && ac_cv_path_GV="echo gv"
;;
esac
fi
GV=$ac_cv_path_GV
if test -n "$GV"; then
echo "$as_me:$LINENO: result: $GV" >&5
echo "${ECHO_T}$GV" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test "$GRAPHVIZ" != "echo gv" ; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GV 1
_ACEOF
cat >>confdefs.h <<_ACEOF
#define LLVM_PATH_GV "$GV"
_ACEOF
fi
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
@@ -8235,7 +8356,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 8238 "configure"
#line 8359 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10226,7 +10347,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 10229 "configure"' > conftest.$ac_ext
echo '#line 10350 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -10711,7 +10832,7 @@ fi
# Provide some information about the compiler.
echo "$as_me:10714:" \
echo "$as_me:10835:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -11768,11 +11889,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11771: $lt_compile\"" >&5)
(eval echo "\"\$as_me:11892: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:11775: \$? = $ac_status" >&5
echo "$as_me:11896: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -12011,11 +12132,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:12014: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12135: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:12018: \$? = $ac_status" >&5
echo "$as_me:12139: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -12071,11 +12192,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:12074: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12195: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:12078: \$? = $ac_status" >&5
echo "$as_me:12199: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14256,7 +14377,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 14259 "configure"
#line 14380 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -14354,7 +14475,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 14357 "configure"
#line 14478 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16547,11 +16668,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16550: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16671: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16554: \$? = $ac_status" >&5
echo "$as_me:16675: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -16607,11 +16728,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16610: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16731: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:16614: \$? = $ac_status" >&5
echo "$as_me:16735: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17968,7 +18089,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 17971 "configure"
#line 18092 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -18066,7 +18187,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 18069 "configure"
#line 18190 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -18903,11 +19024,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:18906: $lt_compile\"" >&5)
(eval echo "\"\$as_me:19027: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:18910: \$? = $ac_status" >&5
echo "$as_me:19031: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -18963,11 +19084,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:18966: $lt_compile\"" >&5)
(eval echo "\"\$as_me:19087: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:18970: \$? = $ac_status" >&5
echo "$as_me:19091: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -21002,11 +21123,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:21005: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21126: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:21009: \$? = $ac_status" >&5
echo "$as_me:21130: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -21245,11 +21366,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:21248: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21369: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:21252: \$? = $ac_status" >&5
echo "$as_me:21373: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -21305,11 +21426,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:21308: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21429: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:21312: \$? = $ac_status" >&5
echo "$as_me:21433: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -23490,7 +23611,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 23493 "configure"
#line 23614 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -23588,7 +23709,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 23591 "configure"
#line 23712 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -24625,8 +24746,10 @@ ETAGSFLAGS=$ETAGSFLAGS
if test "$WITH_LLVMGCCDIR" = "default" ; then
# Extract the first word of "llvm-gcc", so it can be a program name with args.
set dummy llvm-gcc; ac_word=$2
LLVMGCC="llvm-gcc${EXEEXT}"
LLVMGXX="llvm-g++${EXEEXT}"
# Extract the first word of "$LLVMGCC", so it can be a program name with args.
set dummy $LLVMGCC; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_LLVMGCC+set}" = set; then
@@ -24664,8 +24787,8 @@ else
echo "${ECHO_T}no" >&6
fi
# Extract the first word of "llvm-g++", so it can be a program name with args.
set dummy llvm-g++; ac_word=$2
# Extract the first word of "$LLVMGXX", so it can be a program name with args.
set dummy $LLVMGXX; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_LLVMGXX+set}" = set; then
@@ -24704,8 +24827,8 @@ echo "${ECHO_T}no" >&6
fi
else
LLVMGCC=$WITH_LLVMGCCDIR/bin/llvm-gcc
LLVMGXX=$WITH_LLVMGCCDIR/bin/llvm-g++
LLVMGCC="$WITH_LLVMGCCDIR/bin/llvm-gcc${EXEEXT}"
LLVMGXX="$WITH_LLVMGCCDIR/bin/llvm-g++${EXEEXT}"
LLVMGCC=$LLVMGCC
LLVMGXX=$LLVMGXX
@@ -24742,7 +24865,7 @@ fi
if test "$GCC" = "yes"
then
gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
gccmajor=`$CC --version | head -n 1 | sed 's/[^0-9]*\([0-9.]\).*/\1/'`
if test "$gccmajor" -lt "3"
then
{ { echo "$as_me:$LINENO: error: gcc 3.x required, but you have a lower version" >&5
@@ -24837,6 +24960,7 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for library containing lt_dlopen" >&5
echo $ECHO_N "checking for library containing lt_dlopen... $ECHO_C" >&6
if test "${ac_cv_search_lt_dlopen+set}" = set; then
@@ -25238,7 +25362,82 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for library containing pthread_mutex_lock" >&5
if test "$ENABLE_THREADS" -eq 1 ; then
echo "$as_me:$LINENO: checking for pthread_mutex_init in -lpthread" >&5
echo $ECHO_N "checking for pthread_mutex_init in -lpthread... $ECHO_C" >&6
if test "${ac_cv_lib_pthread_pthread_mutex_init+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char pthread_mutex_init ();
int
main ()
{
pthread_mutex_init ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_pthread_pthread_mutex_init=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pthread_pthread_mutex_init=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5
echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_init" >&6
if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPTHREAD 1
_ACEOF
LIBS="-lpthread $LIBS"
fi
echo "$as_me:$LINENO: checking for library containing pthread_mutex_lock" >&5
echo $ECHO_N "checking for library containing pthread_mutex_lock... $ECHO_C" >&6
if test "${ac_cv_search_pthread_mutex_lock+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25368,6 +25567,7 @@ _ACEOF
fi
fi
@@ -26752,6 +26952,158 @@ fi
done
if test "$ENABLE_THREADS" -eq 1 ; then
for ac_header in pthread.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
## ----------------------------------- ##
## Report this to llvmbugs@cs.uiuc.edu ##
## ----------------------------------- ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
fi
echo "$as_me:$LINENO: checking for pid_t" >&5
@@ -30268,24 +30620,18 @@ _ACEOF
ac_config_headers="$ac_config_headers include/llvm/Config/config.h"
ac_config_headers="$ac_config_headers include/llvm/Support/DataTypes.h"
ac_config_headers="$ac_config_headers include/llvm/ADT/hash_map"
ac_config_headers="$ac_config_headers include/llvm/ADT/hash_set"
ac_config_headers="$ac_config_headers include/llvm/Support/ThreadSupport.h"
ac_config_headers="$ac_config_headers include/llvm/ADT/iterator"
ac_config_files="$ac_config_files Makefile.config"
ac_config_files="$ac_config_files tools/llvmc/st tools/llvmc/cpp tools/llvmc/ll tools/llvmc/c"
ac_config_files="$ac_config_files docs/doxygen.cfg"
@@ -30698,7 +31044,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by llvm $as_me 1.5cvs, which was
This file was extended by llvm $as_me 1.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -30761,7 +31107,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
llvm config.status 1.5cvs
llvm config.status 1.6
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -30872,10 +31218,6 @@ do
case "$ac_config_target" in
# Handling of arguments.
"Makefile.config" ) CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
"tools/llvmc/st" ) CONFIG_FILES="$CONFIG_FILES tools/llvmc/st" ;;
"tools/llvmc/cpp" ) CONFIG_FILES="$CONFIG_FILES tools/llvmc/cpp" ;;
"tools/llvmc/ll" ) CONFIG_FILES="$CONFIG_FILES tools/llvmc/ll" ;;
"tools/llvmc/c" ) CONFIG_FILES="$CONFIG_FILES tools/llvmc/c" ;;
"docs/doxygen.cfg" ) CONFIG_FILES="$CONFIG_FILES docs/doxygen.cfg" ;;
"setup" ) CONFIG_COMMANDS="$CONFIG_COMMANDS setup" ;;
"Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
@@ -30892,7 +31234,6 @@ do
"include/llvm/Support/DataTypes.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Support/DataTypes.h" ;;
"include/llvm/ADT/hash_map" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/ADT/hash_map" ;;
"include/llvm/ADT/hash_set" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/ADT/hash_set" ;;
"include/llvm/Support/ThreadSupport.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Support/ThreadSupport.h" ;;
"include/llvm/ADT/iterator" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/ADT/iterator" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -31008,6 +31349,7 @@ s,@OBJEXT@,$OBJEXT,;t t
s,@ENABLE_OPTIMIZED@,$ENABLE_OPTIMIZED,;t t
s,@JIT@,$JIT,;t t
s,@ENABLE_DOXYGEN@,$ENABLE_DOXYGEN,;t t
s,@ENABLE_THREADS@,$ENABLE_THREADS,;t t
s,@TARGETS_TO_BUILD@,$TARGETS_TO_BUILD,;t t
s,@CPP@,$CPP,;t t
s,@CXX@,$CXX,;t t
@@ -31033,6 +31375,8 @@ s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@RM@,$RM,;t t
s,@SED@,$SED,;t t
s,@TAR@,$TAR,;t t
s,@GRAPHVIZ@,$GRAPHVIZ,;t t
s,@GV@,$GV,;t t
s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
s,@INSTALL_DATA@,$INSTALL_DATA,;t t

View File

@@ -1,2 +1,4 @@
doxygen.cfg
doxygen
doxygen.out
*.tar.gz

View File

@@ -732,7 +732,7 @@ as shown in the following table.</p>
</table>
<p>
Of particular note, the bytecode format number is simply a 28-bit
monotonically increase integer that identifies the version of the bytecode
monotonically increasing integer that identifies the version of the bytecode
format (which is not directly related to the LLVM release number). The
bytecode versions defined so far are (note that this document only
describes the latest version, 1.3):</p>
@@ -740,7 +740,9 @@ describes the latest version, 1.3):</p>
<li>#0: LLVM 1.0 &amp; 1.1</li>
<li>#1: LLVM 1.2</li>
<li>#2: LLVM 1.2.5 (not released)</li>
<li>#3: LLVM 1.3<br>
<li>#3: LLVM 1.3</li>
<li>#4: LLVM 1.3.x (not released)</li>
<li>#5: LLVM 1.4, 1.5, 1.6</li>
</li>
</ul>
<p>Note that we plan to eventually expand the target description

View File

@@ -68,9 +68,10 @@ located in a top-level directory (like <tt>/cygdrive/c/llvm</tt> and
and Settings" directory). We welcome patches to fix this issue.
</p>
<p>It has been found that the GCC 3.3.3 compiler provided with recent Cygwin
versions is incapable of compiling the LLVM CFE correctly. If your Cygwin
versions is incapable of compiling the LLVM GCC front-end correctly. If your
Cygwin
installation includes GCC 3.3.3, we <i>strongly</i> recommend that you download
GCC 3.4.3, build it separately, and use it for compiling LLVM CFE. This has been
GCC 3.4.3, build it separately, and use it for compiling the LLVM GCC front-end. This has been
shown to work correctly.</p>
<p>Some versions of Cygwin utilize an experimental version of GNU binutils that
will cause the GNU <tt>ld</tt> linker to fail an assertion when linking
@@ -103,7 +104,8 @@ invalid code. Instead, use the system assembler and linker.
<li><p>Configure and build the LLVM libraries and tools. There are two ways to
do this: either with <i>objdir</i> == <i>srcdir</i> or
<i>objdir</i> != <i>srcdir</i>. It is recommended
that <i>srcdir</i> not be the same as <i>objdir</i>:</p>
that <i>srcdir</i> be the same as <i>objdir</i> for your LLVM tree (but note
that you should always use <i>srcdir</i> != <i>objdir</i> for llvm-gcc):</p>
<ul>
<li>With <i>objdir</i> != <i>srcdir</i>:<pre>
% cd <i>objdir</i>
@@ -129,7 +131,7 @@ of permissions. Specify a path into which LLVM can be installed (e.g.
</pre></li>
<li><p>Unpack the C/C++ front-end source into cfrontend/src, either by
untar'ing an llvm-gcc.tar.gz file or checking out CVS into this
untar'ing a cfrontend.source.tar.gz file or checking out CVS into this
directory.</p></li>
<li><p>Make "build" and "install" directories as siblings of the "src" tree:</p>
@@ -146,6 +148,7 @@ of permissions. Specify a path into which LLVM can be installed (e.g.
<p>
<b>Linux/x86:</b><br>
<b>Linux/IA-64:</b><br>
<b>MacOS X/PowerPC</b> (requires dlcompat library):<br>
<b>AIX/PowerPC:</b>
</p>

View File

@@ -15,7 +15,8 @@
<li><a href="#introduction">Introduction</a>
<ul>
<li><a href="#required">Required components in the code generator</a></li>
<li><a href="#high-level-design">The high-level design of the code generator</a></li>
<li><a href="#high-level-design">The high-level design of the code
generator</a></li>
<li><a href="#tablegen">Using TableGen for target description</a></li>
</ul>
</li>
@@ -27,12 +28,16 @@
<li><a href="#mregisterinfo">The <tt>MRegisterInfo</tt> class</a></li>
<li><a href="#targetinstrinfo">The <tt>TargetInstrInfo</tt> class</a></li>
<li><a href="#targetframeinfo">The <tt>TargetFrameInfo</tt> class</a></li>
<li><a href="#targetsubtarget">The <tt>TargetSubtarget</tt> class</a></li>
<li><a href="#targetjitinfo">The <tt>TargetJITInfo</tt> class</a></li>
</ul>
</li>
<li><a href="#codegendesc">Machine code description classes</a>
<ul>
<li><a href="#machineinstr">The <tt>MachineInstr</tt> class</a></li>
<li><a href="#machinebasicblock">The <tt>MachineBasicBlock</tt>
class</a></li>
<li><a href="#machinefunction">The <tt>MachineFunction</tt> class</a></li>
</ul>
</li>
<li><a href="#codegenalgs">Target-independent code generation algorithms</a>
@@ -46,14 +51,21 @@
Construction</a></li>
<li><a href="#selectiondag_legalize">SelectionDAG Legalize Phase</a></li>
<li><a href="#selectiondag_optimize">SelectionDAG Optimization
Phase</a></li>
Phase: the DAG Combiner</a></li>
<li><a href="#selectiondag_select">SelectionDAG Select Phase</a></li>
<li><a href="#selectiondag_sched">SelectionDAG Scheduling and Formation
Phase</a></li>
<li><a href="#selectiondag_future">Future directions for the
SelectionDAG</a></li>
</ul></li>
<li><a href="#codeemit">Code Emission</a>
<ul>
<li><a href="#codeemit_asm">Generating Assembly Code</a></li>
<li><a href="#codeemit_bin">Generating Binary Machine Code</a></li>
</ul></li>
</ul>
</li>
<li><a href="#targetimpls">Target description implementations</a>
<li><a href="#targetimpls">Target-specific Implementation Notes</a>
<ul>
<li><a href="#x86">The X86 backend</a></li>
</ul>
@@ -159,7 +171,7 @@ LLVM machine description model: programmable FPGAs for example.</p>
<p><b>Important Note:</b> For historical reasons, the LLVM SparcV9 code
generator uses almost entirely different code paths than described in this
document. For this reason, there are some deprecated interfaces (such as
<tt>TargetRegInfo</tt> and <tt>TargetSchedInfo</tt>), which are only used by the
<tt>TargetSchedInfo</tt>), which are only used by the
V9 backend and should not be used by any other targets. Also, all code in the
<tt>lib/Target/SparcV9</tt> directory and subdirectories should be considered
deprecated, and should not be used as the basis for future code generator work.
@@ -181,36 +193,47 @@ quality code generation for standard register-based microprocessors. Code
generation in this model is divided into the following stages:</p>
<ol>
<li><b><a href="#instselect">Instruction Selection</a></b> - Determining an
efficient implementation of the input LLVM code in the target instruction set.
<li><b><a href="#instselect">Instruction Selection</a></b> - This phase
determines an efficient way to express the input LLVM code in the target
instruction set.
This stage produces the initial code for the program in the target instruction
set, then makes use of virtual registers in SSA form and physical registers that
represent any required register assignments due to target constraints or calling
conventions.</li>
conventions. This step turns the LLVM code into a DAG of target
instructions.</li>
<li><b><a href="#selectiondag_sched">Scheduling and Formation</a></b> - This
phase takes the DAG of target instructions produced by the instruction selection
phase, determines an ordering of the instructions, then emits the instructions
as <tt><a href="#machineinstr">MachineInstr</a></tt>s with that ordering. Note
that we describe this in the <a href="#instselect">instruction selection
section</a> because it operates on a <a
href="#selectiondag_intro">SelectionDAG</a>.
</li>
<li><b><a href="#ssamco">SSA-based Machine Code Optimizations</a></b> - This
optional stage consists of a series of machine-code optimizations that
operate on the SSA-form produced by the instruction selector. Optimizations
like modulo-scheduling, normal scheduling, or peephole optimization work here.
like modulo-scheduling or peephole optimization work here.
</li>
<li><b><a name="#regalloc">Register Allocation</a></b> - The
<li><b><a href="#regalloc">Register Allocation</a></b> - The
target code is transformed from an infinite virtual register file in SSA form
to the concrete register file used by the target. This phase introduces spill
code and eliminates all virtual register references from the program.</li>
<li><b><a name="#proepicode">Prolog/Epilog Code Insertion</a></b> - Once the
<li><b><a href="#proepicode">Prolog/Epilog Code Insertion</a></b> - Once the
machine code has been generated for the function and the amount of stack space
required is known (used for LLVM alloca's and spill slots), the prolog and
epilog code for the function can be inserted and "abstract stack location
references" can be eliminated. This stage is responsible for implementing
optimizations like frame-pointer elimination and stack packing.</li>
<li><b><a name="latemco">Late Machine Code Optimizations</a></b> - Optimizations
<li><b><a href="#latemco">Late Machine Code Optimizations</a></b> - Optimizations
that operate on "final" machine code can go here, such as spill code scheduling
and peephole optimizations.</li>
<li><b><a name="codemission">Code Emission</a></b> - The final stage actually
<li><b><a href="#codeemit">Code Emission</a></b> - The final stage actually
puts out the code for the current function, either in the target assembler
format or in machine code.</li>
@@ -255,6 +278,16 @@ domain-specific and target-specific abstractions to reduce the amount of
repetition.
</p>
<p>As LLVM continues to be developed and refined, we plan to move more and more
of the target description to be in <tt>.td</tt> form. Doing so gives us a
number of advantages. The most important is that it makes it easier to port
LLVM, because it reduces the amount of C++ code that has to be written and the
surface area of the code generator that needs to be understood before someone
can get in an get something working. Second, it is also important to us because
it makes it easier to change things: in particular, if tables and other things
are all emitted by tblgen, we only need to change one place (tblgen) to update
all of the targets to a new interface.</p>
</div>
<!-- *********************************************************************** -->
@@ -270,8 +303,7 @@ repetition.
target machine; independent of any particular client. These classes are
designed to capture the <i>abstract</i> properties of the target (such as the
instructions and registers it has), and do not incorporate any particular pieces
of code generation algorithms. These interfaces do not take interference graphs
as inputs or other algorithm-specific data structures.</p>
of code generation algorithms.</p>
<p>All of the target description classes (except the <tt><a
href="#targetdata">TargetData</a></tt> class) are designed to be subclassed by
@@ -311,8 +343,8 @@ implemented as well.</p>
<div class="doc_text">
<p>The <tt>TargetData</tt> class is the only required target description class,
and it is the only class that is not extensible. You cannot derived a new
class from it. <tt>TargetData</tt> specifies information about how the target
and it is the only class that is not extensible (you cannot derived a new
class from it). <tt>TargetData</tt> specifies information about how the target
lays out memory for structures, the alignment requirements for various data
types, the size of pointers in the target, and whether the target is
little-endian or big-endian.</p>
@@ -329,18 +361,16 @@ little-endian or big-endian.</p>
<p>The <tt>TargetLowering</tt> class is used by SelectionDAG based instruction
selectors primarily to describe how LLVM code should be lowered to SelectionDAG
operations. Among other things, this class indicates:
<ul><li>an initial register class to use for various ValueTypes,</li>
<li>which operations are natively supported by the target machine,</li>
<li>the return type of setcc operations, and</li>
<li>the type to use for shift amounts, etc</li>.
<ul><li>an initial register class to use for various ValueTypes</li>
<li>which operations are natively supported by the target machine</li>
<li>the return type of setcc operations</li>
<li>the type to use for shift amounts</li>
<li>various high-level characteristics, like whether it is profitable to turn
division by a constant into a multiplication sequence</li>
</ol></p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="mregisterinfo">The <tt>MRegisterInfo</tt> class</a>
@@ -355,12 +385,12 @@ target and any interactions between the registers.</p>
<p>Registers in the code generator are represented in the code generator by
unsigned numbers. Physical registers (those that actually exist in the target
description) are unique small numbers, and virtual registers are generally
large.</p>
large. Note that register #0 is reserved as a flag value.</p>
<p>Each register in the processor description has an associated
<tt>MRegisterDesc</tt> entry, which provides a textual name for the register
(used for assembly output and debugging dumps), a set of aliases (used to
indicate that one register overlaps with another), and some flag bits.
<tt>TargetRegisterDesc</tt> entry, which provides a textual name for the register
(used for assembly output and debugging dumps) and a set of aliases (used to
indicate that one register overlaps with another).
</p>
<p>In addition to the per-register description, the <tt>MRegisterInfo</tt> class
@@ -383,11 +413,46 @@ href="TableGenFundamentals.html">TableGen</a> description of the register file.
<a name="targetinstrinfo">The <tt>TargetInstrInfo</tt> class</a>
</div>
<div class="doc_text">
<p>The <tt>TargetInstrInfo</tt> class is used to describe the machine
instructions supported by the target. It is essentially an array of
<tt>TargetInstrDescriptor</tt> objects, each of which describes one
instruction the target supports. Descriptors define things like the mnemonic
for the opcode, the number of operands, the list of implicit register uses
and defs, whether the instruction has certain target-independent properties
(accesses memory, is commutable, etc), and holds any target-specific flags.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="targetframeinfo">The <tt>TargetFrameInfo</tt> class</a>
</div>
<div class="doc_text">
<p>The <tt>TargetFrameInfo</tt> class is used to provide information about the
stack frame layout of the target. It holds the direction of stack growth,
the known stack alignment on entry to each function, and the offset to the
locals area. The offset to the local area is the offset from the stack
pointer on function entry to the first location where function data (local
variables, spill locations) can be stored.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="targetsubtarget">The <tt>TargetSubtarget</tt> class</a>
</div>
<div class="doc_text">
<p>
<p>The <tt>TargetSubtarget</tt> class is used to provide information about the
specific chip set being targeted. A sub-target informs code generation of
which instructions are supported, instruction latencies and instruction
execution itinerary; i.e., which processing units are used, in what order, and
for how long.
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="targetjitinfo">The <tt>TargetJITInfo</tt> class</a>
@@ -403,7 +468,8 @@ href="TableGenFundamentals.html">TableGen</a> description of the register file.
<p>
At the high-level, LLVM code is translated to a machine specific representation
formed out of MachineFunction, MachineBasicBlock, and <a
formed out of <a href="#machinefunction">MachineFunction</a>,
<a href="#machinebasicblock">MachineBasicBlock</a>, and <a
href="#machineinstr"><tt>MachineInstr</tt></a> instances
(defined in include/llvm/CodeGen). This representation is completely target
agnostic, representing instructions in their most abstract form: an opcode and a
@@ -589,6 +655,43 @@ are no virtual registers left in the code.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="machinebasicblock">The <tt>MachineBasicBlock</tt> class</a>
</div>
<div class="doc_text">
<p>The <tt>MachineBasicBlock</tt> class contains a list of machine instructions
(<a href="#machineinstr">MachineInstr</a> instances). It roughly corresponds to
the LLVM code input to the instruction selector, but there can be a one-to-many
mapping (i.e. one LLVM basic block can map to multiple machine basic blocks).
The MachineBasicBlock class has a "<tt>getBasicBlock</tt>" method, which returns
the LLVM basic block that it comes from.
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="machinefunction">The <tt>MachineFunction</tt> class</a>
</div>
<div class="doc_text">
<p>The <tt>MachineFunction</tt> class contains a list of machine basic blocks
(<a href="#machinebasicblock">MachineBasicBlock</a> instances). It corresponds
one-to-one with the LLVM function input to the instruction selector. In
addition to a list of basic blocks, the <tt>MachineFunction</tt> contains a
the MachineConstantPool, MachineFrameInfo, MachineFunctionInfo,
SSARegMap, and a set of live in and live out registers for the function. See
<tt>MachineFunction.h</tt> for more information.
</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section">
<a name="codegenalgs">Target-independent code generation algorithms</a>
@@ -598,7 +701,7 @@ are no virtual registers left in the code.</p>
<div class="doc_text">
<p>This section documents the phases described in the <a
href="high-level-design">high-level design of the code generator</a>. It
href="#high-level-design">high-level design of the code generator</a>. It
explains how they work and some of the rationale behind their design.</p>
</div>
@@ -613,23 +716,15 @@ explains how they work and some of the rationale behind their design.</p>
Instruction Selection is the process of translating LLVM code presented to the
code generator into target-specific machine instructions. There are several
well-known ways to do this in the literature. In LLVM there are two main forms:
the old-style 'simple' instruction selector (which effectively peephole selects
each LLVM instruction into a series of machine instructions), and the new
SelectionDAG based instruction selector.
the SelectionDAG based instruction selector framework and an old-style 'simple'
instruction selector (which effectively peephole selects each LLVM instruction
into a series of machine instructions). We recommend that all targets use the
SelectionDAG infrastructure.
</p>
<p>The 'simple' instruction selectors are tedious to write, require a lot of
boiler plate code, and are difficult to get correct. Additionally, any
optimizations written for a simple instruction selector cannot be used by other
targets. For this reason, LLVM is moving to a new SelectionDAG based
instruction selector, which is described in this section. If you are starting a
new port, we recommend that you write the instruction selector using the
SelectionDAG infrastructure.</p>
<p>In time, most of the target-specific code for instruction selection will be
auto-generated from the target description (<tt>*.td</tt>) files. For now,
however, the <a href="#selectiondag_select">Select Phase</a> must still be
written by hand.</p>
<p>Portions of the DAG instruction selector are generated from the target
description files (<tt>*.td</tt>) files. Eventually, we aim for the entire
instruction selector to be generated from these <tt>.td</tt> files.</p>
</div>
<!-- _______________________________________________________________________ -->
@@ -643,8 +738,10 @@ written by hand.</p>
The SelectionDAG provides an abstraction for code representation in a way that
is amenable to instruction selection using automatic techniques
(e.g. dynamic-programming based optimal pattern matching selectors), It is also
well suited to other phases of code generation; in particular, instruction scheduling. Additionally, the SelectionDAG provides a host representation where a
large variety of very-low-level (but target-independent)
well suited to other phases of code generation; in particular,
instruction scheduling (SelectionDAG's are very close to scheduling DAGs
post-selection). Additionally, the SelectionDAG provides a host representation
where a large variety of very-low-level (but target-independent)
<a href="#selectiondag_optimize">optimizations</a> may be
performed: ones which require extensive information about the instructions
efficiently supported by the target.
@@ -653,11 +750,10 @@ efficiently supported by the target.
<p>
The SelectionDAG is a Directed-Acyclic-Graph whose nodes are instances of the
<tt>SDNode</tt> class. The primary payload of the <tt>SDNode</tt> is its
operation code (Opcode) that indicates what operation the node performs.
operation code (Opcode) that indicates what operation the node performs and
the operands to the operation.
The various operation node types are described at the top of the
<tt>include/llvm/CodeGen/SelectionDAGNodes.h</tt> file. Depending on the
operation, nodes may contain additional information (e.g. the condition code
for a SETCC node) contained in a derived class.</p>
<tt>include/llvm/CodeGen/SelectionDAGNodes.h</tt> file.</p>
<p>Although most operations define a single value, each node in the graph may
define multiple values. For example, a combined div/rem operation will define
@@ -691,8 +787,10 @@ block function, this would be the return node.
<p>
One important concept for SelectionDAGs is the notion of a "legal" vs. "illegal"
DAG. A legal DAG for a target is one that only uses supported operations and
supported types. On PowerPC, for example, a DAG with any values of i1, i8, i16,
or i64 type would be illegal. The <a href="#selectiondag_legalize">legalize</a>
supported types. On a 32-bit PowerPC, for example, a DAG with any values of i1,
i8, i16,
or i64 type would be illegal, as would a DAG that uses a SREM or UREM operation.
The <a href="#selectiondag_legalize">legalize</a>
phase is responsible for turning an illegal DAG into a legal DAG.
</p>
</div>
@@ -726,13 +824,26 @@ SelectionDAG-based instruction selection consists of the following steps:
eliminate inefficiencies introduced by legalization.</li>
<li><a href="#selectiondag_select">Select instructions from DAG</a> - Finally,
the target instruction selector matches the DAG operations to target
instructions, emitting them and building the MachineFunction being
compiled.</li>
instructions. This process translates the target-independent input DAG into
another DAG of target instructions.</li>
<li><a href="#selectiondag_sched">SelectionDAG Scheduling and Formation</a>
- The last phase assigns a linear order to the instructions in the
target-instruction DAG and emits them into the MachineFunction being
compiled. This step uses traditional prepass scheduling techniques.</li>
</ol>
<p>After all of these steps are complete, the SelectionDAG is destroyed and the
rest of the code generation passes are run.</p>
<p>One great way to visualize what is going on here is to take advantage of a
few LLC command line options. In particular, the <tt>-view-isel-dags</tt>
option pops up a window with the SelectionDAG input to the Select phase for all
of the code compiled (if you only get errors printed to the console while using
this, you probably <a href="ProgrammersManual.html#ViewGraph">need to configure
your system</a> to add support for it). The <tt>-view-sched-dags</tt> option
views the SelectionDAG output from the Select phase and input to the Scheduler
phase.
</p>
</div>
<!-- _______________________________________________________________________ -->
@@ -749,7 +860,8 @@ intent of this pass is to expose as much low-level, target-specific details
to the SelectionDAG as possible. This pass is mostly hard-coded (e.g. an LLVM
add turns into an SDNode add while a geteelementptr is expanded into the obvious
arithmetic). This pass requires target-specific hooks to lower calls and
returns, varargs, etc. For these features, the TargetLowering interface is
returns, varargs, etc. For these features, the <a
href="#targetlowering">TargetLowering</a> interface is
used.
</p>
@@ -768,34 +880,41 @@ tasks:</p>
<ol>
<li><p>Convert values of unsupported types to values of supported types.</p>
<p>There are two main ways of doing this: promoting a small type to a larger
type (e.g. f32 -&gt; f64, or i16 -&gt; i32), and breaking up large
integer types
to smaller ones (e.g. implementing i64 with i32 operations where
possible). Type conversions can insert sign and zero extensions as
<p>There are two main ways of doing this: converting small types to
larger types ("promoting"), and breaking up large integer types
into smaller ones ("expanding"). For example, a target might require
that all f32 values are promoted to f64 and that all i1/i8/i16 values
are promoted to i32. The same target might require that all i64 values
be expanded into i32 values. These changes can insert sign and zero
extensions as
needed to make sure that the final code has the same behavior as the
input.</p>
<p>A target implementation tells the legalizer which types are supported
(and which register class to use for them) by calling the
"addRegisterClass" method in its TargetLowering constructor.</p>
</li>
<li><p>Eliminate operations that are not supported by the target in a supported
type.</p>
<p>Targets often have wierd constraints, such as not supporting every
<li><p>Eliminate operations that are not supported by the target.</p>
<p>Targets often have weird constraints, such as not supporting every
operation on every supported datatype (e.g. X86 does not support byte
conditional moves). Legalize takes care of either open-coding another
sequence of operations to emulate the operation (this is known as
expansion), promoting to a larger type that supports the operation
conditional moves and PowerPC does not support sign-extending loads from
a 16-bit memory location). Legalize takes care by open-coding
another sequence of operations to emulate the operation ("expansion"), by
promoting to a larger type that supports the operation
(promotion), or using a target-specific hook to implement the
legalization.</p>
legalization (custom).</p>
<p>A target implementation tells the legalizer which operations are not
supported (and which of the above three actions to take) by calling the
"setOperationAction" method in its TargetLowering constructor.</p>
</li>
</ol>
<p>
Instead of using a Legalize pass, we could require that every target-specific
<a href="#selectiondag_optimize">selector</a> supports and expands every
operator and type even if they are not supported and may require many
instructions to implement (in fact, this is the approach taken by the
"simple" selectors). However, using a Legalize pass allows all of the
cannonicalization patterns to be shared across targets which makes it very
Prior to the existance of the Legalize pass, we required that every
target <a href="#selectiondag_optimize">selector</a> supported and handled every
operator and type even if they are not natively supported. The introduction of
the Legalize phase allows all of the
cannonicalization patterns to be shared across targets, and makes it very
easy to optimize the cannonicalized code because it is still in the form of
a DAG.
</p>
@@ -804,7 +923,8 @@ a DAG.
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="selectiondag_optimize">SelectionDAG Optimization Phase</a>
<a name="selectiondag_optimize">SelectionDAG Optimization Phase: the DAG
Combiner</a>
</div>
<div class="doc_text">
@@ -815,13 +935,14 @@ immediately after the DAG is built and once after legalization. The first run
of the pass allows the initial code to be cleaned up (e.g. performing
optimizations that depend on knowing that the operators have restricted type
inputs). The second run of the pass cleans up the messy code generated by the
Legalize pass, allowing Legalize to be very simple since it can ignore many
special cases.
Legalize pass, which allows Legalize to be very simple (it can focus on making
code legal instead of focusing on generating <i>good</i> and legal code).
</p>
<p>
One important class of optimizations that this pass will do in the future is
optimizing inserted sign and zero extension instructions. Here are some good
One important class of optimizations performed is optimizing inserted sign and
zero extension instructions. We currently use ad-hoc techniques, but could move
to more rigorous techniques in the future. Here are some good
papers on the subject:</p>
<p>
@@ -850,10 +971,155 @@ International Conference on Compiler Construction (CC) 2004
<div class="doc_text">
<p>The Select phase is the bulk of the target-specific code for instruction
selection. This phase takes a legal SelectionDAG as input, and does simple
pattern matching on the DAG to generate code. In time, the Select phase will
be automatically generated from the target's InstrInfo.td file, which is why we
want to make the Select phase as simple and mechanical as possible.</p>
selection. This phase takes a legal SelectionDAG as input,
pattern matches the instructions supported by the target to this DAG, and
produces a new DAG of target code. For example, consider the following LLVM
fragment:</p>
<pre>
%t1 = add float %W, %X
%t2 = mul float %t1, %Y
%t3 = add float %t2, %Z
</pre>
<p>This LLVM code corresponds to a SelectionDAG that looks basically like this:
</p>
<pre>
(fadd:f32 (fmul:f32 (fadd:f32 W, X), Y), Z)
</pre>
<p>If a target supports floating point multiply-and-add (FMA) operations, one
of the adds can be merged with the multiply. On the PowerPC, for example, the
output of the instruction selector might look like this DAG:</p>
<pre>
(FMADDS (FADDS W, X), Y, Z)
</pre>
<p>
The FMADDS instruction is a ternary instruction that multiplies its first two
operands and adds the third (as single-precision floating-point numbers). The
FADDS instruction is a simple binary single-precision add instruction. To
perform this pattern match, the PowerPC backend includes the following
instruction definitions:
</p>
<pre>
def FMADDS : AForm_1&lt;59, 29,
(ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
"fmadds $FRT, $FRA, $FRC, $FRB",
[<b>(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC),
F4RC:$FRB))</b>]&gt;;
def FADDS : AForm_2&lt;59, 21,
(ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
"fadds $FRT, $FRA, $FRB",
[<b>(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))</b>]&gt;;
</pre>
<p>The portion of the instruction definition in bold indicates the pattern used
to match the instruction. The DAG operators (like <tt>fmul</tt>/<tt>fadd</tt>)
are defined in the <tt>lib/Target/TargetSelectionDAG.td</tt> file.
"<tt>F4RC</tt>" is the register class of the input and result values.<p>
<p>The TableGen DAG instruction selector generator reads the instruction
patterns in the .td and automatically builds parts of the pattern matching code
for your target. It has the following strengths:</p>
<ul>
<li>At compiler-compiler time, it analyzes your instruction patterns and tells
you if your patterns make sense or not.</li>
<li>It can handle arbitrary constraints on operands for the pattern match. In
particular, it is straight-forward to say things like "match any immediate
that is a 13-bit sign-extended value". For examples, see the
<tt>immSExt16</tt> and related tblgen classes in the PowerPC backend.</li>
<li>It knows several important identities for the patterns defined. For
example, it knows that addition is commutative, so it allows the
<tt>FMADDS</tt> pattern above to match "<tt>(fadd X, (fmul Y, Z))</tt>" as
well as "<tt>(fadd (fmul X, Y), Z)</tt>", without the target author having
to specially handle this case.</li>
<li>It has a full-featured type-inferencing system. In particular, you should
rarely have to explicitly tell the system what type parts of your patterns
are. In the FMADDS case above, we didn't have to tell tblgen that all of
the nodes in the pattern are of type 'f32'. It was able to infer and
propagate this knowledge from the fact that F4RC has type 'f32'.</li>
<li>Targets can define their own (and rely on built-in) "pattern fragments".
Pattern fragments are chunks of reusable patterns that get inlined into your
patterns during compiler-compiler time. For example, the integer "(not x)"
operation is actually defined as a pattern fragment that expands as
"(xor x, -1)", since the SelectionDAG does not have a native 'not'
operation. Targets can define their own short-hand fragments as they see
fit. See the definition of 'not' and 'ineg' for examples.</li>
<li>In addition to instructions, targets can specify arbitrary patterns that
map to one or more instructions, using the 'Pat' class. For example,
the PowerPC has no way to load an arbitrary integer immediate into a
register in one instruction. To tell tblgen how to do this, it defines:
<pre>
// Arbitrary immediate support. Implement in terms of LIS/ORI.
def : Pat&lt;(i32 imm:$imm),
(ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))&gt;;
</pre>
If none of the single-instruction patterns for loading an immediate into a
register match, this will be used. This rule says "match an arbitrary i32
immediate, turning it into an ORI ('or a 16-bit immediate') and an LIS
('load 16-bit immediate, where the immediate is shifted to the left 16
bits') instruction". To make this work, the LO16/HI16 node transformations
are used to manipulate the input immediate (in this case, take the high or
low 16-bits of the immediate).
</li>
<li>While the system does automate a lot, it still allows you to write custom
C++ code to match special cases, in case there is something that is hard
to express.</li>
</ul>
<p>
While it has many strengths, the system currently has some limitations,
primarily because it is a work in progress and is not yet finished:
</p>
<ul>
<li>Overall, there is no way to define or match SelectionDAG nodes that define
multiple values (e.g. ADD_PARTS, LOAD, CALL, etc). This is the biggest
reason that you currently still <i>have to</i> write custom C++ code for
your instruction selector.</li>
<li>There is no great way to support match complex addressing modes yet. In the
future, we will extend pattern fragments to allow them to define multiple
values (e.g. the four operands of the <a href="#x86_memory">X86 addressing
mode</a>). In addition, we'll extend fragments so that a fragment can match
multiple different patterns.</li>
<li>We don't automatically infer flags like isStore/isLoad yet.</li>
<li>We don't automatically generate the set of supported registers and
operations for the <a href="#"selectiondag_legalize>Legalizer</a> yet.</li>
<li>We don't have a way of tying in custom legalized nodes yet.</li>
</ul>
<p>Despite these limitations, the instruction selector generator is still quite
useful for most of the binary and logical operations in typical instruction
sets. If you run into any problems or can't figure out how to do something,
please let Chris know!</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="selectiondag_sched">SelectionDAG Scheduling and Formation Phase</a>
</div>
<div class="doc_text">
<p>The scheduling phase takes the DAG of target instructions from the selection
phase and assigns an order. The scheduler can pick an order depending on
various constraints of the machines (i.e. order for minimal register pressure or
try to cover instruction latencies). Once an order is established, the DAG is
converted to a list of <a href="#machineinstr">MachineInstr</a>s and the
Selection DAG is destroyed.
</p>
<p>Note that this phase is logically separate from the instruction selection
phase, but is tied to it closely in the code because it operates on
SelectionDAGs.</p>
</div>
@@ -865,12 +1131,8 @@ want to make the Select phase as simple and mechanical as possible.</p>
<div class="doc_text">
<ol>
<li>Optional whole-function selection.</li>
<li>Select is a graph translation phase.</li>
<li>Place the machine instructions resulting from Select according to register
pressure or a schedule.</li>
<li>DAG Scheduling.</li>
<li>Auto-generate the Select phase from the target description (*.td) files.
<li>Optional function-at-a-time selection.</li>
<li>Auto-generate entire selector from .td file.</li>
</li>
</ol>
@@ -898,12 +1160,33 @@ pressure or a schedule.</li>
<div class="doc_text"><p>To Be Written</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="codemission">Code Emission</a>
<a name="codeemit">Code Emission</a>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="codeemit_asm">Generating Assembly Code</a>
</div>
<div class="doc_text">
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="codeemit_bin">Generating Binary Machine Code</a>
</div>
<div class="doc_text">
<p>For the JIT or .o file writer</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section">
<a name="targetimpls">Target description implementations</a>
<a name="targetimpls">Target-specific Implementation Notes</a>
</div>
<!-- *********************************************************************** -->
@@ -932,6 +1215,28 @@ implementations.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="x86_tt">X86 Target Triples Supported</a>
</div>
<div class="doc_text">
<p>
The following are the known target triples that are supported by the X86
backend. This is not an exhaustive list, but it would be useful to add those
that people test.
</p>
<ul>
<li><b>i686-pc-linux-gnu</b> - Linux</li>
<li><b>i386-unknown-freebsd5.3</b> - FreeBSD 5.3</li>
<li><b>i686-pc-cygwin</b> - Cygwin on Win32</li>
<li><b>i686-pc-mingw32</b> - MingW on Win32</li>
<li><b>i686-apple-darwin*</b> - Apple Darwin on X86</li>
</ul>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="x86_memory">Representing X86 addressing modes in MachineInstrs</a>

View File

@@ -1 +1,4 @@
pod2htm?.tmp
*.html
*.1
*.ps

View File

@@ -30,7 +30,7 @@ html/%.html: %.pod
--podpath=. --noindex --infile=$< --outfile=$@ --title=$*
man/man1/%.1: %.pod
pod2man --release=1.4 --center="LLVM Command Guide" $< $@
pod2man --release=1.5 --center="LLVM Command Guide" $< $@
ps/%.ps: man/man1/%.1
groff -Tps -man $< > $@

View File

@@ -10,23 +10,22 @@ B<llvmc> [I<options>] [I<filenames>...]
=head1 DESCRIPTION
The B<llvmc> command is a configurable driver for invoking other
LLVM (and non-LLVM) tools in order to compile, optimize and link software
for multiple languages. For those familiar with the GNU Compiler
Collection's B<gcc> tool, it is very similar. This tool has the
following main goals or purposes:
B<llvmc> is a configurable driver for invoking other LLVM (and non-LLVM) tools
in order to compile, optimize and link software for multiple languages. For
those familiar with FSF's B<gcc> tool, it is very similar. B<llvmc> has the
following goals:
=over
=item * A Single point of access to the LLVM tool set.
=item * provide a single point of access to the LLVM tool set,
=item * Hide the complexities of the LLVM tools through a single interface.
=item * hide the complexities of the LLVM tools through a single interface,
=item * Make integration of existing non-LLVM tools simple.
=item * make integration of existing non-LLVM tools simple,
=item * Extend the capabilities of minimal front ends.
=item * extend the capabilities of minimal front ends, and
=item * Make the interface for compiling consistent for all languages.
=item * make the interface for compiling consistent for all languages.
=back

View File

@@ -23,6 +23,7 @@
set of possibilities</a></li>
<li><a href="#namedalternatives">Named alternatives</a></li>
<li><a href="#list">Parsing a list of options</a></li>
<li><a href="#bits">Collecting options as a set of flags</a></li>
<li><a href="#description">Adding freeform text to help output</a></li>
</ol></li>
@@ -61,6 +62,7 @@
<tt>cl::ParseEnvironmentOptions</tt> function</a></li>
<li><a href="#cl::opt">The <tt>cl::opt</tt> class</a></li>
<li><a href="#cl::list">The <tt>cl::list</tt> class</a></li>
<li><a href="#cl::bits">The <tt>cl::bits</tt> class</a></li>
<li><a href="#cl::alias">The <tt>cl::alias</tt> class</a></li>
<li><a href="#cl::extrahelp">The <tt>cl::extrahelp</tt> class</a></li>
</ul></li>
@@ -691,6 +693,65 @@ checking we have to do.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="bits">Collecting options as a set of flags</a>
</div>
<div class="doc_text">
<p>Instead of collecting sets of options in a list, it is also possible to
gather information for enum values in a <b>bit vector</b>. The represention used by
the <a href="#bits"><tt>cl::bits</tt></a> class is an <tt>unsigned</tt>
integer. An enum value is represented by a 0/1 in the enum's ordinal value bit
position. 1 indicating that the enum was specified, 0 otherwise. As each
specified value is parsed, the resulting enum's bit is set in the option's bit
vector:</p>
<div class="doc_code"><pre>
<i>bits</i> |= 1 << (unsigned)<i>enum</i>;
</pre></div>
<p>Options that are specified multiple times are redundant. Any instances after
the first are discarded.</p>
<p>Reworking the above list example, we could replace <a href="#list">
<tt>cl::list</tt></a> with <a href="#bits"><tt>cl::bits</tt></a>:</p>
<div class="doc_code"><pre>
<a href="#cl::bits">cl::bits</a>&lt;Opts&gt; OptimizationBits(<a href="#cl::desc">cl::desc</a>("<i>Available Optimizations:</i>"),
<a href="#cl::values">cl::values</a>(
clEnumVal(dce , "<i>Dead Code Elimination</i>"),
clEnumVal(constprop , "<i>Constant Propagation</i>"),
clEnumValN(inlining, "<i>inline</i>", "<i>Procedure Integration</i>"),
clEnumVal(strip , "<i>Strip Symbols</i>"),
clEnumValEnd));
</pre></div>
<p>To test to see if <tt>constprop</tt> was specified, we can use the
<tt>cl:bits::isSet</tt> function:</p>
<div class="doc_code"><pre>
if (OptimizationBits.isSet(constprop)) {
...
}
</pre></div>
<p>It's also possible to get the raw bit vector using the
<tt>cl::bits::getBits</tt> function:</p>
<div class="doc_code"><pre>
unsigned bits = OptimizationBits.getBits();
</pre></div>
<p>Finally, if external storage is used, then the location specified must be of
<b>type</b> <tt>unsigned</tt>. In all other ways a <a
href="#bits"><tt>cl::bits</tt></a> option is morally equivalent to a <a
href="#list"> <tt>cl::list</tt></a> option.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="description">Adding freeform text to help output</a>
@@ -1506,6 +1567,31 @@ be used.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="cl::bits">The <tt>cl::bits</tt> class</a>
</div>
<div class="doc_text">
<p>The <tt>cl::bits</tt> class is the class used to represent a list of command
line options in the form of a bit vector. It is also a templated class which
can take up to three arguments:</p>
<div class="doc_code"><pre>
<b>namespace</b> cl {
<b>template</b> &lt;<b>class</b> DataType, <b>class</b> Storage = <b>bool</b>,
<b>class</b> ParserClass = parser&lt;DataType&gt; &gt;
<b>class</b> bits;
}
</pre></div>
<p>This class works the exact same as the <a
href="#cl::opt"><tt>cl::lists</tt></a> class, except that the second argument
must be of <b>type</b> <tt>unsigned</tt> if external storage is used.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="cl::alias">The <tt>cl::alias</tt> class</a>

View File

@@ -143,9 +143,6 @@ branch stubs for powerpc64-linux (from binutils)</a></li>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="sparc">SPARC</a></div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">Official manuals and docs</div>
<div class="doc_text">
<ul>

View File

@@ -307,9 +307,9 @@ if necessary.</li>
</div>
<p>Note that you will need about 1-3 GB of space for a full LLVM build in Debug
mode, depending on the system (because of all the debug info), and the libraries
appear in more than one of the tools that get linked, so there is some
duplication. If you do not need many of the tools and you are space-conscious,
mode, depending on the system (it is so large because of all the debugging
information and the fact that the libraries are statically linked into multiple
tools). If you do not need many of the tools and you are space-conscious,
you can disable them individually in <tt>llvm/tools/Makefile</tt>. The Release
build requires considerably less space.</p>
@@ -348,6 +348,12 @@ href="CFEBuildInstrs.html">try to compile it</a> on your platform.</p>
<td>C/C++ compiler<sup><a href="#sf1">1</a></sup></td>
</tr>
<tr>
<td><a href="http://www.gnu.org/software/texinfo">TeXinfo</a></td>
<td>4.5</td>
<td>For building the CFE</td>
</tr>
<tr>
<td><a href="http://www.gnu.org/software/flex">Flex</a></td>
<td>2.5.4</td>
@@ -576,9 +582,10 @@ variables.
<dl>
<dt><tt>LLVM_LIB_SEARCH_PATH</tt>=<tt>/path/to/your/bytecode/libs</tt></dt>
<dd>[Optional] This environment variable helps LLVM linking tools find the
locations of your bytecode libraries. It is provided only a
locations of your bytecode libraries. It is provided only as a
convenience since you can specify the paths using the -L options of the
tools and the C/C++ front-end will use the bytecode files installed in its
tools and the C/C++ front-end will automatically use the bytecode files
installed in its
<tt>lib</tt> directory.</dd>
</dl>
@@ -620,7 +627,7 @@ compressed with the gzip program.
<dt><tt>cfrontend-x.y.i386-unknown-freebsd5.1.tar.gz</tt></dt>
<dd>Binary release of the GCC front end for FreeBSD/x86.<br/></dd>
<dt><tt>cfrontend-x.y.powerpc-apple-darwin7.6.0.tar.gz</tt></dt>
<dt><tt>cfrontend-x.y.powerpc-apple-darwin7.8.0.tar.gz</tt></dt>
<dd>Binary release of the GCC front end for MacOS X/PPC.<br/></dd>
</dl>
@@ -654,6 +661,7 @@ revision), you can specify a label. The following releases have the following
labels:</p>
<ul>
<li>Release 1.6: <b>RELEASE_16</b></li>
<li>Release 1.5: <b>RELEASE_15</b></li>
<li>Release 1.4: <b>RELEASE_14</b></li>
<li>Release 1.3: <b>RELEASE_13</b></li>
@@ -788,11 +796,12 @@ script to configure the build system:</p>
<a href="CFEBuildInstrs.html">Bootstrapping the LLVM C/C++ Front-End</a>
for details on building the C/C++ Front End.</dd>
<dt><i>--with-tclinclude</i></dt>
<dd>Path to the tcl include directory under which the <tt>tclsh</tt> can be
<dd>Path to the tcl include directory under which <tt>tclsh</tt> can be
found. Use this if you have multiple tcl installations on your machine and you
want to use a specific one (8.x) for LLVM. LLVM only uses tcl for running the
dejagnu based test suite in <tt>llvm/test</tt>. If you don't specify this
option, the LLVM configure script will search for tcl 8.4 and 8.3 releases.
option, the LLVM configure script will search for the tcl 8.4 and 8.3
releases.
<p></p>
</dd>
<dt><i>--enable-optimized</i></dt>
@@ -817,7 +826,7 @@ script to configure the build system:</p>
native compiler (no cross-compiler targets available). The "native" target is
selected as the target of the build host. You can also specify a comma
separated list of target names that you want available in llc. The target
names use all lower case. The current set is of targets is: <br/>
names use all lower case. The current set of targets is: <br/>
<tt>alpha, ia64, powerpc, skeleton, sparc, x86</tt>.
<p></p></dd>
<dt><i>--enable-doxygen</i></dt>
@@ -1148,7 +1157,7 @@ different <a href="#tools">tools</a>.</p>
<dd> This directory contains files that describe various target architectures
for code generation. For example, the <tt>llvm/lib/Target/SparcV9</tt>
directory holds the Sparc machine description while
<tt>llvm/lib/Target/CBackend</tt> implements the LLVM-to-C converter</dd>
<tt>llvm/lib/Target/CBackend</tt> implements the LLVM-to-C converter.</dd>
<dt><tt><b>llvm/lib/CodeGen/</b></tt></dt>
<dd> This directory contains the major parts of the code generator: Instruction
@@ -1251,8 +1260,8 @@ information is in the <a href="CommandGuide/index.html">Command Guide</a>.</p>
all from one command line. <tt>llvmc</tt> also takes care of processing the
dependent libraries found in bytecode. This reduces the need to get the
traditional <tt>-l&lt;name&gt;</tt> options right on the command line. Please
note that this tool is new in 1.4 and considered experimental. It will be
fully supported in 1.5.</dd>
note that this tool, while functional, is still experimental and not feature
complete.</dd>
<dt><tt><b>llvm-ar</b></tt></dt>
<dd>The archiver produces an archive containing
@@ -1271,9 +1280,8 @@ information is in the <a href="CommandGuide/index.html">Command Guide</a>.</p>
<dd><tt>llvm-ld</tt> is very similar to gccld and provides a general purpose
and extensible linker for LLVM. This is the linker invoked by <tt>llvmc</tt>.
It allows optimization modules to be loaded so that language specific
optimizations can be applied at link time. Please note that this tool is new
in LLVM 1.4 and still considered experimental. It will be fully supported in
LLVM 1.5.</dd>
optimizations can be applied at link time. This tool is considered
experimental.</dd>
<dt><tt><b>llvm-link</b></tt></dt>
<dd><tt>llvm-link</tt>, not surprisingly, links multiple LLVM modules into
@@ -1291,7 +1299,7 @@ information is in the <a href="CommandGuide/index.html">Command Guide</a>.</p>
<dt><tt><b>llc</b></tt></dt>
<dd> <tt>llc</tt> is the LLVM backend compiler, which
translates LLVM bytecode to a SPARC or x86 assembly file, or to C code (with
translates LLVM bytecode to a native code assembly file or to C code (with
the -march=c option).</dd>
<dt><tt><b>llvm-gcc</b></tt></dt>
@@ -1299,8 +1307,7 @@ information is in the <a href="CommandGuide/index.html">Command Guide</a>.</p>
that has been retargeted to emit LLVM code as the machine code output. It
works just like any other GCC compiler, taking the typical <tt>-c, -S, -E,
-o</tt> options that are typically used. The source code for the
<tt>llvm-gcc</tt> tool is currently not included in the LLVM CVS tree
because it is quite large and not very interesting.
<tt>llvm-gcc</tt> tool is available as a separate CVS module.
<blockquote>
<dl>
<dt><tt><b>gccas</b></tt></dt>

View File

@@ -170,15 +170,10 @@ progress has been made since the 1.4 release.</p>
beta, there are no guarantees and there is no support for it at this time.
It has been reported that VC++ Express also works.</p>
<p>You will also need several open source packages: bison, flex, and sed.
These must be installed in <tt>llvm/win32/tools</tt>. These can be found at
<a href="http://gnuwin32.sourceforge.net">http://gnuwin32.sourceforge.net</a>
or
<a href="http://unxutils.sourceforge.net">http://unxutils.sourceforge.net</a>.
Bison prefers that m4 be in the path. You must add it to the Visual Studio
configuration under the menu Options -&gt; Projects -&gt; VC++ Directories.
Alternatively, you can set the environment variable <tt>M4</tt> to point to
<tt>m4</tt> executable.</p>
<p>If you plan to modify any .y or .l files, you will need to have bison
and/or flex installed where Visual Studio can find them. Otherwise, you do
not need them and the pre-generated files that come with the source tree
will be used.</p>
</div>
@@ -279,28 +274,26 @@ All these paths are absolute:</p>
<p><b>Note: while you cannot do this step on Windows, you can do it on a
Unix system and transfer <tt>hello.bc</tt> to Windows.</b></p></li>
<li><p>Run the program. To make sure the program ran, execute the
following command:</p>
<li><p>Run the program using the just-in-time compiler:</p>
<p><tt>% lli hello.bc</tt></p></li>
<li><p>Use the <tt>llvm-dis</tt> utility to take a look at the LLVM assembly
code:</p>
<p><tt>% llvm-dis &lt; hello.bc | less</tt><p></li>
<p><tt>% llvm-dis &lt; hello.bc | more</tt><p></li>
<li><p>Compile the program to native assembly using the LLC code
generator:</p>
<li><p>Compile the program to C using the LLC code generator:</p>
<p><tt>% llc hello.bc -o hello.s</tt></p>
<p><tt>% llc -march=c hello.bc</tt></p></li>
<li><p>Assemble the native assembly language file into a program:</p>
<li><p>Compile to binary using Microsoft C:</p>
<p><b>Not currently possible, but eventually will use <tt>NASMW</tt>.</b></p>
<p><tt>% cl hello.cbe.c</tt></p></li>
<li><p>Execute the native code program:</p>
<p><tt>% ./hello.native</tt></p></li>
<p><tt>% hello.cbe.exe</tt></p></li>
</ol>

View File

@@ -17,15 +17,12 @@ under Cygwin and/or Mingw.
DONT_BUILD_RELINKED. This breaks all the tools makefiles; you just need to
change them to have .a's.
5. Cygwin's math.h defines log2(); it needs to be #undefed if already defined
in MathExtras.h.
5. There isn't a <values.h>.
6. There isn't a <values.h>.
7. There isn't a mallinfo() (or, at least, it's documented, but it doesn't seem
6. There isn't a mallinfo() (or, at least, it's documented, but it doesn't seem
to link).
8. The version of Bison that cygwin (and newer Linux versions) comes with
7. The version of Bison that cygwin (and newer Linux versions) comes with
does not like = signs in rules. Burg's gram.yc source file uses them. I think
you can just take them out.

View File

@@ -101,7 +101,6 @@
<li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
<li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
<li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
<li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
<li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
</ol>
</li>
@@ -144,6 +143,8 @@
<li><a href="#i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a></li>
<li><a href="#i_memset">'<tt>llvm.memset</tt>' Intrinsic</a></li>
<li><a href="#i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a></li>
<li><a href="#i_sqrt">'<tt>llvm.sqrt</tt>' Intrinsic</a></li>
</ol>
</li>
<li><a href="#int_count">Bit counting Intrinsics</a>
@@ -494,11 +495,11 @@ convention.</p>
<p>Global variables define regions of memory allocated at compilation time
instead of run-time. Global variables may optionally be initialized. A
variable may be defined as a global "constant", which indicates that the
variable may be defined as a global "constant," which indicates that the
contents of the variable will <b>never</b> be modified (enabling better
optimization, allowing the global data to be placed in the read-only section of
an executable, etc). Note that variables that need runtime initialization
cannot be marked "constant", as there is a store to the variable.</p>
cannot be marked "constant" as there is a store to the variable.</p>
<p>
LLVM explicitly allows <em>declarations</em> of global variables to be marked
@@ -718,6 +719,14 @@ be any type with a size.</p>
</td>
</tr>
</table>
<p>Note that 'variable sized arrays' can be implemented in LLVM with a zero
length array. Normally, accesses past the end of an array are undefined in
LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
As a special case, however, zero length arrays are recognized to be variable
length. This allows implementation of 'pascal style arrays' with the LLVM
type "{ int, [0 x float]}", for example.</p>
</div>
<!-- _______________________________________________________________________ -->
@@ -734,7 +743,7 @@ The return type of a function type cannot be an aggregate type.
</p>
<h5>Syntax:</h5>
<pre> &lt;returntype&gt; (&lt;parameter list&gt;)<br></pre>
<p>Where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
<p>...where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
which indicates that the function takes a variable number of arguments.
Variable argument functions can access their arguments with the <a
@@ -988,7 +997,7 @@ and smaller aggregate constants.</p>
<dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a
value to zero of <em>any</em> type, including scalar and aggregate types.
This is often used to avoid having to print large zero initializers (e.g. for
large arrays), and is always exactly equivalent to using explicit zero
large arrays) and is always exactly equivalent to using explicit zero
initializers.
</dd>
</dl>
@@ -1477,7 +1486,7 @@ Both arguments must have identical types.</p>
<p>This returns the <i>remainder</i> of a division (where the result
has the same sign as the divisor), not the <i>modulus</i> (where the
result has the same sign as the dividend) of a value. For more
information about the difference, see: <a
information about the difference, see <a
href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
Math Forum</a>.</p>
<h5>Example:</h5>
@@ -1854,9 +1863,9 @@ Instruction</a> </div>
<p>The '<tt>load</tt>' instruction is used to read from memory.</p>
<h5>Arguments:</h5>
<p>The argument to the '<tt>load</tt>' instruction specifies the memory
address to load from. The pointer must point to a <a
address from which to load. The pointer must point to a <a
href="#t_firstclass">first class</a> type. If the <tt>load</tt> is
marked as <tt>volatile</tt> then the optimizer is not allowed to modify
marked as <tt>volatile</tt>, then the optimizer is not allowed to modify
the number or order of execution of this <tt>load</tt> with other
volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
instructions. </p>
@@ -1880,7 +1889,7 @@ Instruction</a> </div>
<p>The '<tt>store</tt>' instruction is used to write to memory.</p>
<h5>Arguments:</h5>
<p>There are two arguments to the '<tt>store</tt>' instruction: a value
to store and an address to store it into. The type of the '<tt>&lt;pointer&gt;</tt>'
to store and an address in which to store it. The type of the '<tt>&lt;pointer&gt;</tt>'
operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
operand. If the <tt>store</tt> is marked as <tt>volatile</tt>, then the
optimizer is not allowed to modify the number or order of execution of
@@ -1990,7 +1999,15 @@ the LLVM code for the given testcase is equivalent to:</p>
ret int* %t5
}
</pre>
<p>Note that it is undefined to access an array out of bounds: array and
pointer indexes must always be within the defined bounds of the array type.
The one exception for this rules is zero length arrays. These arrays are
defined to be accessible as variable length arrays, which requires access
beyond the zero'th element.</p>
<h5>Example:</h5>
<pre>
<i>; yields [12 x ubyte]*:aptr</i>
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
@@ -2209,58 +2226,6 @@ the <a href="#i_invoke">invoke</a> instruction.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vanext">'<tt>vanext</tt>' Instruction</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
&lt;resultarglist&gt; = vanext &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
</pre>
<h5>Overview:</h5>
<p>The '<tt>vanext</tt>' instruction is used to access arguments passed
through the "variable argument" area of a function call. It is used to
implement the <tt>va_arg</tt> macro in C.</p>
<h5>Arguments:</h5>
<p>This instruction takes a <tt>va_list</tt> value and the type of the
argument. It returns another <tt>va_list</tt>. The actual type of
<tt>va_list</tt> may be defined differently for different targets. Most targets
use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p>
<h5>Semantics:</h5>
<p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt>
past an argument of the specified type. In conjunction with the <a
href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
the <tt>va_arg</tt> macro available in C. For more information, see
the variable argument handling <a href="#int_varargs">Intrinsic
Functions</a>.</p>
<p>It is legal for this instruction to be called in a function which
does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
function.</p>
<p><tt>vanext</tt> is an LLVM instruction instead of an <a
href="#intrinsics">intrinsic function</a> because it takes a type as an
argument. The type refers to the current argument in the <tt>va_list</tt>; it
tells the compiler how far on the stack it needs to advance to find the next
argument.</p>
<h5>Example:</h5>
<p>See the <a href="#int_varargs">variable argument processing</a>
section.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
@@ -2271,34 +2236,35 @@ section.</p>
<h5>Syntax:</h5>
<pre>
&lt;resultval&gt; = vaarg &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
&lt;resultval&gt; = va_arg &lt;va_list*&gt; &lt;arglist&gt;, &lt;argty&gt;
</pre>
<h5>Overview:</h5>
<p>The '<tt>vaarg</tt>' instruction is used to access arguments passed through
<p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through
the "variable argument" area of a function call. It is used to implement the
<tt>va_arg</tt> macro in C.</p>
<h5>Arguments:</h5>
<p>This instruction takes a <tt>va_list</tt> value and the type of the
argument. It returns a value of the specified argument type. Again, the actual
type of <tt>va_list</tt> is target specific.</p>
<p>This instruction takes a <tt>va_list*</tt> value and the type of
the argument. It returns a value of the specified argument type and
increments the <tt>va_list</tt> to poin to the next argument. Again, the
actual type of <tt>va_list</tt> is target specific.</p>
<h5>Semantics:</h5>
<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from
the specified <tt>va_list</tt>. In conjunction with the <a
href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the
<tt>va_arg</tt> macro available in C. For more information, see the variable
argument handling <a href="#int_varargs">Intrinsic Functions</a>.</p>
<p>The '<tt>va_arg</tt>' instruction loads an argument of the specified
type from the specified <tt>va_list</tt> and causes the
<tt>va_list</tt> to point to the next argument. For more information,
see the variable argument handling <a href="#int_varargs">Intrinsic
Functions</a>.</p>
<p>It is legal for this instruction to be called in a function which does not
take a variable number of arguments, for example, the <tt>vfprintf</tt>
function.</p>
<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
<p><tt>va_arg</tt> is an LLVM instruction instead of an <a
href="#intrinsics">intrinsic function</a> because it takes a type as an
argument.</p>
@@ -2361,20 +2327,19 @@ used.</p>
<pre>
int %test(int %X, ...) {
; Initialize variable argument processing
%ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
%ap = alloca sbyte*
call void %<a href="#i_va_start">llvm.va_start</a>(sbyte** %ap)
; Read a single integer argument
%tmp = vaarg sbyte* %ap, int
; Advance to the next argument
%ap2 = vanext sbyte* %ap, int
%tmp = va_arg sbyte** %ap, int
; Demonstrate usage of llvm.va_copy and llvm.va_end
%aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
%aq = alloca sbyte*
call void %<a href="#i_va_copy">llvm.va_copy</a>(sbyte** %aq, sbyte** %ap)
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %aq)
; Stop processing of arguments.
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %ap)
ret int %tmp
}
</pre>
@@ -2388,19 +2353,25 @@ int %test(int %X, ...) {
<div class="doc_text">
<h5>Syntax:</h5>
<pre> declare &lt;va_list&gt; %llvm.va_start()<br></pre>
<pre> declare void %llvm.va_start(&lt;va_list&gt;* &lt;arglist&gt;)<br></pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt>&lt;arglist&gt;</tt>
for subsequent use by the variable argument intrinsics.</p>
<P>The '<tt>llvm.va_start</tt>' intrinsic initializes
<tt>*&lt;arglist&gt;</tt> for subsequent use by <tt><a
href="#i_va_arg">va_arg</a></tt>.</p>
<h5>Arguments:</h5>
<P>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p>
<h5>Semantics:</h5>
<p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
macro available in C. In a target-dependent way, it initializes and
returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt>
will produce the first variable argument passed to the function. Unlike
the C <tt>va_start</tt> macro, this intrinsic does not need to know the
last argument of the function; the compiler can figure that out.</p>
<p>Note that this intrinsic function is only legal to be called from
within the body of a variable argument function.</p>
<P>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
macro available in C. In a target-dependent way, it initializes the
<tt>va_list</tt> element the argument points to, so that the next call to
<tt>va_arg</tt> will produce the first variable argument passed to the function.
Unlike the C <tt>va_start</tt> macro, this intrinsic does not need to know the
last argument of the function, the compiler can figure that out.</p>
</div>
<!-- _______________________________________________________________________ -->
@@ -2410,7 +2381,7 @@ within the body of a variable argument function.</p>
<div class="doc_text">
<h5>Syntax:</h5>
<pre> declare void %llvm.va_end(&lt;va_list&gt; &lt;arglist&gt;)<br></pre>
<pre> declare void %llvm.va_end(&lt;va_list*&gt; &lt;arglist&gt;)<br></pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>&lt;arglist&gt;</tt>
which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
@@ -2435,24 +2406,27 @@ with calls to <tt>llvm.va_end</tt>.</p>
<h5>Syntax:</h5>
<pre>
declare &lt;va_list&gt; %llvm.va_copy(&lt;va_list&gt; &lt;destarglist&gt;)
declare void %llvm.va_copy(&lt;va_list&gt;* &lt;destarglist&gt;,
&lt;va_list&gt;* &lt;srcarglist&gt;)
</pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
from the source argument list to the destination argument list.</p>
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position from
the source argument list to the destination argument list.</p>
<h5>Arguments:</h5>
<p>The argument is the <tt>va_list</tt> to copy.</p>
<p>The first argument is a pointer to a <tt>va_list</tt> element to initialize.
The second argument is a pointer to a <tt>va_list</tt> element to copy from.</p>
<h5>Semantics:</h5>
<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
macro available in C. In a target-dependent way, it copies the source
<tt>va_list</tt> element into the returned list. This intrinsic is necessary
because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be
<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> macro
available in C. In a target-dependent way, it copies the source
<tt>va_list</tt> element into the destination list. This intrinsic is necessary
because the <tt><a href="i_va_begin">llvm.va_begin</a></tt> intrinsic may be
arbitrarily complex and require memory allocation, for example.</p>
</div>
@@ -3161,6 +3135,41 @@ false.
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_sqrt">'<tt>llvm.sqrt</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare &lt;float or double&gt; %llvm.sqrt(&lt;float or double&gt; Val)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.sqrt</tt>' intrinsic returns the sqrt of the specified operand,
returning the same value as the libm '<tt>sqrt</tt>' function would. Unlike
<tt>sqrt</tt> in libm, however, <tt>llvm.sqrt</tt> has undefined behavior for
negative numbers (which allows for better optimization).
</p>
<h5>Arguments:</h5>
<p>
The argument and return value are floating point numbers of the same type.
</p>
<h5>Semantics:</h5>
<p>
This function returns the sqrt of the specified operand if it is a positive
floating point number.
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_count">Bit Counting Intrinsics</a>

View File

@@ -64,3 +64,10 @@ $(PROJ_OBJ_DIR)/doxygen.tar.gz: $(DOXYFILES) $(PROJ_OBJ_DIR)/doxygen.cfg
$(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/doxygen.tar doxygen
$(Verb) $(GZIP) $(PROJ_OBJ_DIR)/doxygen.tar
userloc: $(LLVM_SRC_ROOT)/docs/userloc.html
$(LLVM_SRC_ROOT)/docs/userloc.html:
$(Echo) Making User LOC Table
$(Verb) cd $(LLVM_SRC_ROOT) ; ./utils/userloc.pl -details -recurse \
-html lib include tools runtime utils examples autoconf test > docs/userloc.html

View File

@@ -552,7 +552,7 @@
<div class="doc_text">
<p>This utility target, only available when <tt>$(PROJ_OBJ_ROOT)</tt> is not
the same as <tt>$(PROJ_SRC_ROOT)</tt>, will completely clean the
<tt>$(PROJ_OBJ_ROOT)</tt> directoy by removing its content entirely and
<tt>$(PROJ_OBJ_ROOT)</tt> directory by removing its content entirely and
reconfiguring the directory. This returns the <tt>$(PROJ_OBJ_ROOT)</tt>
directory to a completely fresh state. All content in the directory except
configured files and top-level makefiles will be lost.</p>

View File

@@ -41,6 +41,7 @@ option</a></li>
<li>The <tt>InstVisitor</tt> template
<li>The general graph API
-->
<li><a href="#ViewGraph">Viewing graphs while debugging code</a></li>
</ul>
</li>
<li><a href="#common">Helpful Hints for Common Operations</a>
@@ -491,6 +492,44 @@ maintainable and useful.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="ViewGraph">Viewing graphs while debugging code</a>
</div>
<div class="doc_text">
<p>Several of the important data structures in LLVM are graphs: for example
CFGs made out of LLVM <a href="#BasicBlock">BasicBlock</a>s, CFGs made out of
LLVM <a href="CodeGenerator.html#machinebasicblock">MachineBasicBlock</a>s, and
<a href="CodeGenerator.html#selectiondag_intro">Instruction Selection
DAGs</a>. In many cases, while debugging various parts of the compiler, it is
nice to instantly visualize these graphs.</p>
<p>LLVM provides several callbacks that are available in a debug build to do
exactly that. If you call the <tt>Function::viewCFG()</tt> method, for example,
the current LLVM tool will pop up a window containing the CFG for the function
where each basic block is a node in the graph, and each node contains the
instructions in the block. Similarly, there also exists
<tt>Function::viewCFGOnly()</tt> (does not include the instructions), the
<tt>MachineFunction::viewCFG()</tt> and <tt>MachineFunction::viewCFGOnly()</tt>,
and the <tt>SelectionDAG::viewGraph()</tt> methods. Within GDB, for example,
you can usually use something like "<tt>call DAG.viewGraph()</tt>" to pop
up a window. Alternatively, you can sprinkle calls to these functions in your
code in places you want to debug.</p>
<p>Getting this to work requires a small amount of configuration. On Unix
systems with X11, install the <a href="http://www.graphviz.org">graphviz</a>
toolkit, and make sure 'dot' and 'gv' are in your path. If you are running on
Mac OS/X, download and install the Mac OS/X <a
href="http://www.pixelglow.com/graphviz/">Graphviz program</a>, and add
<tt>/Applications/Graphviz.app/Contents/MacOS/</tt> (or whereever you install
it) to your path. Once in your system and path are set up, rerun the LLVM
configure script and rebuild LLVM to enable this functionality.</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section">
<a name="common">Helpful Hints for Common Operations</a>

View File

@@ -87,6 +87,12 @@ provide enough information on how to write your own Makefiles.</p>
choosing. You can place it anywhere you like. Rename the directory to match
the name of your project.</li>
<li>
If you downloaded LLVM using CVS, remove all the directories named CVS (and all
the files therein) from your project's new source tree. This will keep CVS
from thinking that your project is inside <tt>llvm/projects/sample</tt>.
</li>
<li>Add your source code and Makefiles to your source tree.</li>
<li>If you want your project to be configured with the <tt>configure</tt> script

View File

@@ -4,11 +4,11 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="llvm.css" type="text/css">
<title>LLVM 1.5 Release Notes</title>
<title>LLVM 1.6 Release Notes</title>
</head>
<body>
<div class="doc_title">LLVM 1.5 Release Notes</div>
<div class="doc_title">LLVM 1.6 Release Notes</div>
<ol>
<li><a href="#intro">Introduction</a></li>
@@ -20,7 +20,7 @@
</ol>
<div class="doc_author">
<p>Written by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a><p>
<p>Written by the <a href="http://llvm.org">LLVM Team</a><p>
</div>
<!-- *********************************************************************** -->
@@ -32,15 +32,15 @@
<div class="doc_text">
<p>This document contains the release notes for the LLVM compiler
infrastructure, release 1.5. Here we describe the status of LLVM, including any
infrastructure, release 1.6. Here we describe the status of LLVM, including any
known problems and major improvements from the previous release. The most
up-to-date version of this document can be found on the <a
href="http://llvm.cs.uiuc.edu/releases/1.5/">LLVM 1.5 web site</a>. If you are
href="http://llvm.org/releases/1.6/">LLVM 1.6 web site</a>. If you are
not reading this on the LLVM web pages, you should probably go there because
this document may be updated after the release.</p>
<p>For more information about LLVM, including information about the latest
release, please check out the <a href="http://llvm.cs.uiuc.edu">main LLVM
release, please check out the <a href="http://llvm.org/">main LLVM
web site</a>. If you have questions or comments, the <a
href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM developer's mailing
list</a> is a good place to send them.</p>
@@ -48,7 +48,7 @@ list</a> is a good place to send them.</p>
<p>Note that if you are reading this file from CVS or the main LLVM web page,
this document applies to the <i>next</i> release, not the current one. To see
the release notes for the current or previous releases, see the <a
href="http://llvm.cs.uiuc.edu/releases/">releases page</a>.</p>
href="http://llvm.org/releases/">releases page</a>.</p>
</div>
@@ -60,286 +60,191 @@ href="http://llvm.cs.uiuc.edu/releases/">releases page</a>.</p>
<div class="doc_text">
<p>This is the sixth public release of the LLVM Compiler Infrastructure.</p>
<p>LLVM 1.5 is known to correctly compile a wide range of C and C++ programs,
includes bug fixes for those problems found since the 1.4 release, and includes
a large number of new features and enhancements, described below.</p>
<p>This is the seventh public release of the LLVM Compiler Infrastructure. This
release incorporates a large number of enhancements and additions (primarily in
the code generator), which combine to improve the quality of the code generated
by LLVM by up to 30% in some cases. This release is also the first release to
have first-class support for Mac OS/X: all of the major bugs have been shaken
out and it is now as well supported as Linux on X86.</p>
</div>
<!--=========================================================================-->
<div class="doc_subsection">
<a name="newfeatures">New Features in LLVM 1.5</a>
<a name="newfeatures">New Features in LLVM 1.6</a>
</div>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="newcg">New Native Code
Generators</a></div>
<div class="doc_subsubsection"><a name="iselgen">Instruction Selector
Generation from Target Description</a></div>
<div class="doc_text">
<p>
This release includes new native code generators for <a
href="#alpha-be">Alpha</a>, <a href="#ia64-be">IA-64</a>, and <a
href="#sparcv8">SPARC-V8</a> (32-bit SPARC). These code generators are still
beta quality, but are progressing rapidly. The Alpha backend is implemented
with an eye towards being compatible with the widely used SimpleScalar
simulator.
</p>
</div>
<p>LLVM now includes support for auto-generating large portions of the
instruction selectors from target descriptions. This allows us to
write patterns in the target .td file, instead of writing lots of
nasty C++ code. Most of the PowerPC instruction selector is now
generated from the PowerPC target description files and other targets
are adding support that will be live for LLVM 1.7.</p>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="selectiondag">New Instruction
Selector Framework</a></div>
<p>For example, here are some patterns used by the PowerPC backend. A
floating-point multiply then subtract instruction (FMSUBS):</p>
<div class="doc_text">
<p>This release includes a <a href="CodeGenerator.html#instselect">new framework
for building instruction selectors</a>, which has long been the hardest part of
building a new LLVM target. This framework handles a lot of the mundane (but
easy to get wrong) details of writing the instruction selector, such as
generating efficient code for <a
href="LangRef.html#i_getelementptr">getelementptr</a> instructions, promoting
small integer types to larger types (e.g. for RISC targets with one size of
integer registers), expanding 64-bit integer operations for 32-bit targets, etc.
Currently, the X86, PowerPC, Alpha, and IA-64 backends use this framework. The
SPARC backends will be migrated when time permits.
</p>
</div>
<div class="doc_code"><p>
<tt>(set F4RC:$FRT, (fsub (fmul F4RC:$FRA, F4RC:$FRC), F4RC:$FRB))</tt>
</p></div>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="customccs">New Support for Per-Function
Calling Conventions</a></div>
<p>Exclusive-or by 16-bit immediate (XORI):</p>
<div class="doc_text">
<p>LLVM 1.5 adds supports for <a href="LangRef.html#callingconv">per-function
calling conventions</a>. Traditionally, the LLVM code generators match the
native C calling conventions for a target. This is important for compatibility,
but is not very flexible. This release allows custom calling conventions to be
established for functions, and defines three target-independent conventions (<a
href="LangRef.html#callingconv">C call, fast call, and cold call</a>) which may
be supported by code generators. When possible, the LLVM optimizer promotes C
functions to use the "fastcc" convention, allowing the use of more efficient
calling sequences (e.g., parameters are passed in registers in the X86 target).
</p>
<div class="doc_code"><p>
<tt>(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))</tt>
</p></div>
<p>Targets may now also define target-specific calling conventions, allowing
LLVM to fully support calling convention altering options (e.g. GCC's
<tt>-mregparm</tt> flag) and well-defined target conventions (e.g. stdcall and
fastcall on X86).</p>
</div>
<p>Exclusive-or by 16-bit immediate shifted right 16-bits (XORIS):</p>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="tailcalls">New Support for
Proper Tail Calls</a></div>
<div class="doc_code"><p>
<tt>(set GPRC:$dst, (xor GPRC:$src1, imm16Shifted:$src2))</tt>
</p></div>
<div class="doc_text">
<p>The release now includes support for <a
href="http://doi.acm.org/10.1145/277650.277719">proper tail calls</a>, as
required to implement languages like Scheme. Tail calls make use of two
features: custom calling conventions (described above), which allow the code
generator to use a convention where the caller deallocates its stack before it
returns. The second feature is a flag on the <a href="LangRef.html#i_call">call
instruction</a>, which indicates that the callee does not access the caller's
stack frame (indicating that it is acceptable to deallocate the caller stack
before invoking the callee). LLVM proper tail calls run on the system stack (as
do normal calls), supports indirect tail calls, tail calls with arbitrary
numbers of arguments, tail calls where the callee requires more argument space
than the caller, etc. The only case not supported are varargs calls, but that
could be added if desired.
</p>
<p>With these definitions, we teach the code generator how to combine these two
instructions to xor an abitrary 32-bit immediate with the following
definition. The first line specifies what to match (a xor with an arbitrary
immediate) the second line specifies what to produce:</p>
<p>In order for a front-end to get a guaranteed tail call, it must mark
functions as "fastcc", mark calls with the 'tail' marker, and follow the call
with a return of the called value (or void). The optimizer and code generator
attempt to handle more general cases, but the simple case will always work if
the code generator supports tail calls. Here is an example:</p>
<pre>
fastcc int %bar(int %X, int(double, int)* %FP) { ;<i> fastcc</i>
%Y = tail call fastcc int %FP(double 0.0, int %X) ;<i> tail, fastcc</i>
ret int %Y
}
<div class="doc_code"><p>
<pre>def : Pat&lt;(xor GPRC:$in, imm:$imm),
(XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))&gt;;
</pre>
<p>In LLVM 1.5, the X86 code generator is the only target that has been enhanced
to support proper tail calls (other targets will be enhanced in future).
Further, because this support was added very close to the release, it is
disabled by default. Pass <tt>-enable-x86-fastcc</tt> to llc to enable it (this
will be enabled by default in the next release). The example above compiles to:
</p>
<pre>
bar:
sub ESP, 8 # Callee uses more space than the caller
mov ECX, DWORD PTR [ESP + 8] # Get the old return address
mov DWORD PTR [ESP + 4], 0 # First half of 0.0
mov DWORD PTR [ESP + 8], 0 # Second half of 0.0
mov DWORD PTR [ESP], ECX # Put the return address where it belongs
jmp EDX # Tail call "FP"
</pre>
<p>
With fastcc on X86, the first two integer arguments are passed in EAX/EDX, the
callee pops its arguments off the stack, and the argument area is always a
multiple of 8 bytes in size.
</p>
</p></div>
</div>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection">Other New Features</div>
<div class="doc_subsubsection"><a name="sched">Instruction Scheduling
Support</a></div>
<div class="doc_text">
<p>Instruction selectors using the refined <a
href="CodeGenerator.html#instselect">instruction selection framework</a> can now
use a simple pre-pass scheduler included with LLVM 1.6. This scheduler is
currently simple (cannot be configured much by the targets), but will be
extended in the future.</p>
</div>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="subtarget">Code Generator Subtarget
Support</a></div>
<div class="doc_text">
<p>It is now straight-forward to parameterize a target implementation, and
provide a mapping from CPU names to sets of target parameters. LLC now supports
a <tt>-mcpu=cpu</tt> option that lets you choose a subtarget by CPU name: use
"<tt>llvm-as &lt; /dev/null | llc -march=XXX -mcpu=help</tt>" to get a list of
supported CPUs for target "XXX". It also provides a
<tt>-mattr=+attr1,-attr2</tt> option that can be used to control individual
features of a target (the previous command will list available features as
well).</p>
<p>This functionality is nice when you want tell LLC something like "compile to
code that is specialized for the PowerPC G5, but doesn't use altivec code. In
this case, using "<tt>llc -march=ppc32 -mcpu=g5 -mattr=-altivec</tt>".</p>
</div>
<!--_________________________________________________________________________-->
<div class="doc_subsubsection"><a name="jitlock">Other New Features</a></div>
<div class="doc_text">
<ol>
<li>LLVM now includes an <a href="http://llvm.cs.uiuc.edu/PR415">
Interprocedural Sparse Conditional Constant Propagation</a> pass, named
-ipsccp, which is run by default at link-time.</li>
<li>LLVM 1.5 is now about 15% faster than LLVM 1.4 and its core data
structures use about 30% less memory.</li>
<li>Support for Microsoft Visual Studio is improved, and <a
href="GettingStartedVS.html">now documented</a>. Most LLVM tools build
natively with Visual C++ now.</li>
<li><a href="GettingStarted.html#config">Configuring LLVM to build a subset
of the available targets</a> is now implemented, via the
<tt>--enable-targets=</tt> option.</li>
<li>LLVM can now create native shared libraries with '<tt>llvm-gcc ...
-shared -Wl,-native</tt>' (or with <tt>-Wl,-native-cbe</tt>).</li>
<li>LLVM now supports a new "<a href="LangRef.html#i_prefetch">llvm.prefetch
</a>" intrinsic, and llvm-gcc now supports __builtin_prefetch.
<li>LLVM now supports intrinsics for <a href="LangRef.html#int_count">bit
counting</a> and llvm-gcc now implements the GCC
<tt>__builtin_popcount</tt>, <tt>__builtin_ctz</tt>, and
<tt>__builtin_clz</tt> builtins.</li>
<li>LLVM now mostly builds on HP-UX with the HP aCC Compiler.</li>
<li>The LLVM X86 backend can now emit Cygwin-compatible .s files.</li>
<li>LLVM now includes workarounds in the code generator generator which
reduces the likelyhood of <a href="http://llvm.cs.uiuc.edu/PR448">GCC
hitting swap during optimized builds</a>.</li>
<li>The <a href="http://llvm.cs.uiuc.edu/ProjectsWithLLVM/#llvmtv">LLVM
Transformation Visualizer</a> (llvm-tv) project has been updated to
work with LLVM CVS.</li>
<li>Nightly tester output is now archived on the <a
href="http://mail.cs.uiuc.edu/pipermail/llvm-testresults/">
llvm-testresults</a> mailing list.</li>
<li>The JIT now uses mutexes to protect its internal data structures. This
allows multi-threaded programs to be run from the JIT or interpreter without
corruption of the internal data structures. See
<a href="http://llvm.org/PR418">PR418</a> and
<a href="http://llvm.org/PR540">PR540</a> for the details.
</li>
<li>LLVM on Win32 <a href="http://llvm.org/PR614">no longer requires sed,
flex, or bison when compiling with Visual C++</a>.</li>
<li>The llvm-test suite can now use the NAG Fortran to C compiler to compile
SPEC FP programs if available (allowing us to test all of SPEC'95 &amp;
2000).</li>
<li>When bugpoint is grinding away and the user hits ctrl-C, it now
gracefully stops and gives what it has reduced so far, instead of
giving up completely. In addition, <a href="http://llvm.org/PR576">the JIT
debugging mode of bugpoint is much faster</a>.</li>
<li>LLVM now includes Xcode project files in the llvm/Xcode directory.</li>
<li>LLVM now supports Mac OS/X on Intel.</li>
<li>LLVM now builds cleanly with GCC 4.1.</li>
</ol>
</div>
<!--=========================================================================-->
<div class="doc_subsection">
<a name="codequality">Code Quality Improvements in LLVM 1.5</a>
<a name="codequality">Code Quality Improvements in LLVM 1.6</a>
</div>
<div class="doc_text">
<ol>
<li>The new -simplify-libcalls pass improves code generated for well-known
library calls. The pass optimizes calls to many of the string, memory, and
standard I/O functions (e.g. replace the calls with simpler/faster calls) when
possible, given information known statically about the arguments to the call.
</li>
<li>The -globalopt pass now promotes non-address-taken static globals that are
only accessed in main to SSA registers.</li>
<li>Loops with trip counts based on array pointer comparisons (e.g. "<tt>for (i
= 0; &amp;A[i] != &amp;A[n]; ++i) ...</tt>") are optimized better than before,
which primarily helps iterator-intensive C++ codes.</li>
<li>The optimizer now eliminates simple cases where redundant conditions exist
between neighboring blocks.</li>
<li>The reassociation pass (which turns (1+X+3) into (X+1+3) among other
things), is more aggressive and intelligent.</li>
<li>The -prune-eh pass now detects no-return functions in addition to the
no-unwind functions it did before.</li>
<li>The -globalsmodref alias analysis generates more precise results in some
cases.</li>
<li>The <tt>-globalopt</tt> pass can now statically evaluate C++ static
constructors when they are simple enough. For example, it can
now statically initialize "<tt>struct X { int a; X() : a(4) {} } g;</tt>".
</li>
<li>The Loop Strength Reduction pass has been completely rewritten, is far
more aggressive, and is turned on by default in the RISC targets. On PPC,
we find that it often speeds up programs from 10-40% depending on the
program.</li>
<li>The code produced when exception handling is enabled is far more
efficient in some cases, particularly on Mac OS/X.</li>
</ol>
</div>
<!--=========================================================================-->
<div class="doc_subsection">
<a name="codequality">Code Generator Improvements in LLVM 1.5</a>
<a name="codequality">Code Generator Improvements in LLVM 1.6</a>
</div>
<div class="doc_text">
<ol>
<li>The code generator now can provide and use information about commutative
two-address instructions when performing register allocation.</li>
<li>The code generator now tracks function live-in registers explicitly,
instead of requiring the target to generate 'implicit defs' at the
entry to a function.</li>
<li>The code generator can lower integer division by a constant to
multiplication by a magic constant and multiplication by a constant into
shift/add sequences.</li>
<li>The code generator compiles fabs/fneg/sin/cos/sqrt to assembly instructions
when possible.</li>
<li>The PowerPC backend generates better code in many cases, making use of
FMA instructions and the recording ("dot") forms of various PowerPC
instructions.</li>
<li>The Alpha backend is substantially more stable and robust than in LLVM 1.5.
For example, it now fully supports varargs functions. The Alpha backend
also now features beta JIT support.</li>
<li>The code generator contains a new component, the DAG Combiner. This allows
us to optimize lowered code (e.g. after 64-bit operations have been lowered
to use 32-bit registers on 32-bit targets) and do fine-grained bit-twiddling
optimizations for the backend.</li>
<li>The SelectionDAG infrastructure is far more capable and mature, able to
handle many new target peculiarities in a target-independent way.</li>
<li>The default <a href="http://llvm.org/PR547">register allocator is now far
faster on some testcases</a>,
particularly on targets with a large number of registers (e.g. IA64
and PPC).</li>
</ol>
</div>
<!--=========================================================================-->
<div class="doc_subsection">
<a name="bugfix">Significant Bugs Fixed in LLVM 1.5</a>
<a name="bugfix">Significant Bugs Fixed in LLVM 1.6</a>
</div>
<div class="doc_text">
<p>Bugs fixed in the LLVM Core:</p>
<ol>
<li><a href="http://llvm.cs.uiuc.edu/PR491">[dse] DSE deletes stores that
are partially overwritten by smaller stores</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR548">[instcombine] miscompilation of
setcc or setcc in one case</a></li>
<li>Transition code for LLVM 1.0 style varargs was removed from the .ll file
parser. LLVM 1.0 bytecode files are still supported. </li>
<li>A vast number of bugs have been fixed in the PowerPC backend and in
llvm-gcc when configured for Mac OS/X (particularly relating to ABI
issues). For example:
<a href="http://llvm.org/PR603">PR449</a>,
<a href="http://llvm.org/PR594">PR594</a>,
<a href="http://llvm.org/PR603">PR603</a>,
<a href="http://llvm.org/PR609">PR609</a>,
<a href="http://llvm.org/PR630">PR630</a>,
<a href="http://llvm.org/PR643">PR643</a>,
and several others without bugzilla bugs.</li>
<li>Several bugs in tail call support have been fixed.</li>
<li><a href="http://llvm.org/PR608">configure does not correctly detect gcc
version on cygwin</a>.</li>
<li>Many many other random bugs have been fixed. Query <a
href="http://llvm.org/bugs">our bugzilla</a> with a target of 1.6 for more
information.</li>
</ol>
<p>Code Generator Bugs:</p>
<ol>
<li><a href="http://llvm.cs.uiuc.edu/PR490">[cbackend] Logical constant
expressions (and/or/xor) not implemented</a>.</li>
<li><a href="http://llvm.cs.uiuc.edu/PR511">[cbackend] C backend does not
respect 'volatile'</a>.</li>
<li>The JIT sometimes miscompiled globals and constant pool entries for
64-bit integer constants on 32-bit hosts.</li>
<li>The C backend should no longer produce code that crashes ICC 8.1.</li>
</ol>
<p>Bugs in the C/C++ front-end:</p>
<ol>
<li><a href="http://llvm.cs.uiuc.edu/PR487">[llvmgcc] llvm-gcc incorrectly
rejects some constant initializers involving the addresses of array
elements</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR501">[llvm-g++] Crash compiling
anonymous union</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR509">[llvm-g++] Do not use dynamic
initialization where static init will do</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR510">[llvmgcc] Field offset
miscalculated for some structure fields following bit fields</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR513">[llvm-g++] Temporary lifetimes
incorrect for short circuit logical operations</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR517">[llvm-gcc] Crash compiling
bitfield &lt;-&gt; aggregate assignment</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR520">[llvm-g++] Error compiling
virtual function thunk with an unnamed argument</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR522">[llvm-gcc] Crash on certain
C99 complex number routines</a></li>
<li><a href="http://llvm.cs.uiuc.edu/PR529">[llvm-g++] Crash using placement
new on an array type</a></li>
</ol>
</div>
<!-- *********************************************************************** -->
@@ -353,12 +258,12 @@ things), is more aggressive and intelligent.</li>
<p>LLVM is known to work on the following platforms:</p>
<ul>
<li>Intel and AMD machines running Red Hat Linux and FreeBSD (and probably
other unix-like systems).</li>
<li>Intel and AMD machines running Red Hat Linux, Fedora Core and FreeBSD
(and probably other unix-like systems).</li>
<li>Sun UltraSPARC workstations running Solaris 8.</li>
<li>Intel and AMD machines running on Win32 with the Cygwin libraries (limited
support is available for native builds with Visual C++).</li>
<li>PowerPC-based Mac OS X systems, running 10.2 and above.</li>
<li>PowerPC and X86-based Mac OS X systems, running 10.2 and above.</li>
<li>Alpha-based machines running Debian GNU/Linux.</li>
<li>Itanium-based machines running Linux and HP-UX.</li>
</ul>
@@ -382,7 +287,7 @@ portability patches and reports of successful builds or error messages.</p>
<p>This section contains all known problems with the LLVM system, listed by
component. As new problems are discovered, they will be added to these
sections. If you run into a problem, please check the <a
href="http://llvm.cs.uiuc.edu/bugs/">LLVM bug database</a> and submit a bug if
href="http://llvm.org/bugs/">LLVM bug database</a> and submit a bug if
there isn't already one.</p>
</div>
@@ -402,16 +307,28 @@ components, please contact us on the llvmdev list.</p>
<ul>
<li>The following passes are incomplete or buggy, and may be removed in future
releases: <tt>-cee, -branch-combine, -instloops, -paths, -pre</tt></li>
releases: <tt>-cee, -pre</tt></li>
<li>The <tt>llvm-db</tt> tool is in a very early stage of development, but can
be used to step through programs and inspect the stack.</li>
<li>The "iterative scan" register allocator (enabled with
<tt>-regalloc=iterativescan</tt>) is not stable.</li>
<li>The SparcV8, Alpha, and IA64 code generators are experimental.</li>
<li>The SparcV8 and IA64 code generators are experimental.</li>
<li>The Alpha JIT is experimental.</li>
</ul>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="build">Known problems with the Build System</a>
</div>
<div class="doc_text">
<ul>
<li>The <a href="http://llvm.org/PR656">configure script sometimes fails on Solaris/Sparc</a>. A work around is documented in <a href="http://llvm.org/PR656">PR656.</a></li>
</ul>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="core">Known problems with the LLVM Core</a>
@@ -422,14 +339,6 @@ components, please contact us on the llvmdev list.</p>
<ul>
<li>In the JIT, <tt>dlsym()</tt> on a symbol compiled by the JIT will not
work.</li>
<li>The JIT does not use mutexes to protect its internal data structures. As
such, execution of a threaded program could cause these data structures to be
corrupted.
</li>
<li><a href="http://llvm.cs.uiuc.edu/PR240">The lower-invoke pass does not
mark values live across a setjmp as volatile</a>. This missing feature
only affects targets whose setjmp/longjmp libraries do not save and restore
the entire register file.</li>
</ul>
</div>
@@ -453,7 +362,7 @@ components, please contact us on the llvmdev list.</p>
</pre></li>
<li>Initialization of global union variables can only be done <a
href="http://llvm.cs.uiuc.edu/PR162">with the largest union member</a>.</li>
href="http://llvm.org/PR162">with the largest union member</a>.</li>
</ul>
</div>
@@ -678,7 +587,7 @@ Analysis rules. As such, special options may be necessary to compile the code
(for example, GCC requires the <tt>-fno-strict-aliasing</tt> option). This
problem probably cannot be fixed.</li>
<li><a href="http://llvm.cs.uiuc.edu/PR56">Zero arg vararg functions are not
<li><a href="http://llvm.org/PR56">Zero arg vararg functions are not
supported</a>. This should not affect LLVM produced by the C or C++
frontends.</li>
@@ -694,7 +603,8 @@ frontends.</li>
<div class="doc_text">
<ul>
<li>None yet</li>
<li><a href="http://llvm.org/PR566">Memory Mapped I/O Intrinsics do not fence
memory</a></li>
</ul>
</div>
@@ -720,7 +630,7 @@ frontends.</li>
<div class="doc_text">
<ul>
<li><a href="http://llvm.cs.uiuc.edu/PR60">[sparcv9] SparcV9 backend miscompiles
<li><a href="http://llvm.org/PR60">[sparcv9] SparcV9 backend miscompiles
several programs in the LLVM test suite</a></li>
</ul>
@@ -738,10 +648,6 @@ several programs in the LLVM test suite</a></li>
<li>On 21164s, some rare FP arithmetic sequences which may trap do not have the
appropriate nops inserted to ensure restartability.</li>
<li>Defining vararg functions is not supported (but calling them is ok).</li>
<li>Due to the vararg problems, C++ exceptions do not work. Small changes are required to the CFE (which break correctness in the exception handler) to compile the exception handling library (and thus the C++ standard library).</li>
</ul>
</div>
@@ -760,7 +666,7 @@ made where the argument is not 16-byte aligned, as required on IA64. (Strictly
speaking this is not a bug in the IA64 back-end; it will also be encountered
when building C++ programs using the C back-end.)</li>
<li>The C++ front-end does not use <a href="http://llvm.cs.uiuc.edu/PR406">IA64
<li>The C++ front-end does not use <a href="http://llvm.org/PR406">IA64
ABI compliant layout of v-tables</a>. In particular, it just stores function
pointers instead of function descriptors in the vtable. This bug prevents
mixing C++ code compiled with LLVM with C++ objects compiled by other C++
@@ -785,12 +691,8 @@ programs.</li>
<ul>
<li>Many features are still missing (e.g. support for 64-bit integer
arithmetic).</li>
<li>This backend needs to be updated to use the SelectionDAG instruction
selection framework.</li>
arithmetic). This back-end is in pre-beta state.</li>
</ul>
</div>
<!-- *********************************************************************** -->
@@ -802,16 +704,16 @@ selection framework.</li>
<div class="doc_text">
<p>A wide variety of additional information is available on the <a
href="http://llvm.cs.uiuc.edu">LLVM web page</a>, including <a
href="http://llvm.cs.uiuc.edu/docs/">documentation</a> and <a
href="http://llvm.cs.uiuc.edu/pubs/">publications describing algorithms and
href="http://llvm.org">LLVM web page</a>, including <a
href="http://llvm.org/docs/">documentation</a> and <a
href="http://llvm.org/pubs/">publications describing algorithms and
components implemented in LLVM</a>. The web page also contains versions of the
API documentation which is up-to-date with the CVS version of the source code.
You can access versions of these documents specific to this release by going
into the "<tt>llvm/doc/</tt>" directory in the LLVM tree.</p>
<p>If you have any questions or comments about LLVM, please feel free to contact
us via the <a href="http://llvm.cs.uiuc.edu/docs/#maillist"> mailing
us via the <a href="http://llvm.org/docs/#maillist"> mailing
lists</a>.</p>
</div>
@@ -825,7 +727,7 @@ lists</a>.</p>
<a href="http://validator.w3.org/check/referer"><img
src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
<a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
<a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br>
Last modified: $Date$
</address>

View File

@@ -309,6 +309,8 @@ supported include:</p>
<li><tt>value{17}</tt> - access to one bit of a value</li>
<li><tt>value{15-17}</tt> - access to multiple bits of a value</li>
<li><tt>DEF</tt> - reference to a record definition</li>
<li><tt>CLASS&lt;val list&gt;</tt> - reference to a new anonymous definition of
CLASS with the specified template arguments.</li>
<li><tt>X.Y</tt> - reference to the subfield of a value</li>
<li><tt>list[4-7,17,2-3]</tt> - A slice of the 'list' list, including elements
4,5,6,7,17,2, and 3 from it. Elements may be included multiple times.</li>
@@ -335,7 +337,7 @@ for different types. These rules allow you to assign a value like "7" to a
information that TableGen collects. Records are defined with a <tt>def</tt> or
<tt>class</tt> keyword, the record name, and an optional list of "<a
href="#templateargs">template arguments</a>". If the record has superclasses,
they are specified as a comma seperated list that starts with a colon character
they are specified as a comma separated list that starts with a colon character
(":"). If <a href="#valuedef">value definitions</a> or <a href="#recordlet">let
expressions</a> are needed for the class, they are enclosed in curly braces
("{}"); otherwise, the record ends with a semicolon. Here is a simple TableGen
@@ -515,7 +517,7 @@ multiple records at a time, and may be useful in certain other cases.
File-scope let expressions are really just another way that TableGen allows the
end-user to factor out commonality from the records.</p>
<p>File-scope "let" expressions take a comma-seperated list of bindings to
<p>File-scope "let" expressions take a comma-separated list of bindings to
apply, and one of more records to bind the values in. Here are some
examples:</p>

View File

@@ -68,21 +68,21 @@ convert the LLVM representation to machine assembly code or other languages.</p>
implement the following:</p>
<ul>
<li>Describe the register set
<li>Describe the register set.
<ul>
<li>Create a <a href="TableGenFundamentals.html">TableGen</a> description of
the register set and register classes</li>
<li>Implement a subclass of <tt><a
href="CodeGenerator.html#mregisterinfo">MRegisterInfo</a></tt></li>
</ul></li>
<li>Describe the instruction set
<li>Describe the instruction set.
<ul>
<li>Create a <a href="TableGenFundamentals.html">TableGen</a> description of
the instruction set</li>
<li>Implement a subclass of <tt><a
href="CodeGenerator.html#targetinstrinfo">TargetInstrInfo</a></tt></li>
</ul></li>
<li>Describe the target machine
<li>Describe the target machine.
<ul>
<li>Create a <a href="TableGenFundamentals.html">TableGen</a> description of
the target that describes the pointer size and references the instruction
@@ -104,37 +104,37 @@ RegisterTarget&lt;<em>MyTargetMachine</em>&gt; M("short_name", " Target name");
is the description of your target to appear in <tt>-help</tt>
listing.</li>
</ul></li>
<li>Implement the assembly printer for the architecture. Usually, if you have
described the instruction set with the assembly printer generator in mind, that
step can be almost automated.</li>
</ul>
<p>Now, for static code generation you also need to write an instruction
selector for your platform: see <tt>lib/Target/*/*ISelSimple.cpp</tt> which
is no longer "simple" but it gives you the idea: you have to be able to create
MachineInstrs for any given LLVM instruction using the <tt>InstVisitor</tt>
pattern, and produce a <tt>MachineFunction</tt> with
<tt>MachineBasicBlock</tt>s full of <tt><a
href="CodeGenerator.html#machineinstr">MachineInstr</a></tt>s for a
corresponding LLVM Function. Creating an instruction selector is perhaps the
most time-consuming part of creating a back-end.</p>
<p>To create a JIT for your platform:</p>
<li>Implement the assembly printer for the architecture.
<ul>
<li>Define all of the assembly strings for your target, adding them to the
instructions in your *InstrInfo.td file.</li>
<li>Implement the <tt>llvm::AsmPrinter</tt> interface.</li>
</ul>
</li>
<li>Implement an instruction selector for the architecture.
<ul>
<li>The recommended method is the <a href="CodeGenerator.html#instselect">
pattern-matching DAG-to-DAG instruction selector</a> (for example, see
the PowerPC backend in PPCISelDAGtoDAG.cpp). Parts of instruction
selector creation can be performed by adding patterns to the instructions
in your <tt>.td</tt> file.</li>
</ul>
</li>
<li>Optionally, add subtarget support.
<ul>
<li>Create a subclass of <tt><a
href="CodeGenerator.html#targetjitinfo">TargetJITInfo</a></tt></li>
<li>Create a machine code emitter that will be used to emit binary code
directly into memory, given <tt>MachineInstr</tt>s</li>
<li>If your target has multiple subtargets (e.g. variants with different
capabilities), implement the <tt>llvm::TargetSubtarget</tt> interface
for your architecture. This allows you to add <tt>-mcpu=</tt> and
<tt>-mattr=</tt> options.</li>
</ul>
<li>Optionally, add JIT support.
<ul>
<li>Create a subclass of <tt><a
href="CodeGenerator.html#targetjitinfo">TargetJITInfo</a></tt></li>
<li>Create a machine code emitter that will be used to emit binary code
directly into memory, given <tt>MachineInstr</tt>s</li>
</ul>
</ul>
<p>Note that <tt>lib/target/Skeleton</tt> is a clean skeleton for a new target,
so you might want to start with that and adapt it for your target, and if you
are wondering how things are done, peek in the X86 or PowerPC target.</p>
<p>The Skeleton target is non-functional but provides the basic building blocks
you will need for your endeavor.</p>
</div>
<!-- _______________________________________________________________________ -->
@@ -229,10 +229,13 @@ how the C backend is written.</p>
<ul>
<li><a href="CodeGenerator.html">Code generator</a> -
describes some of the classes in code generation at a high level, but
it is not (yet) complete.</li>
it is not (yet) complete</li>
<li><a href="TableGenFundamentals.html">TableGen fundamentals</a> -
describes how to use TableGen to describe your target information succinctly
</li>
describes how to use TableGen to describe your target information
succinctly</li>
<li><a href="HowToSubmitABug.html#codegen">Debugging code generation with
bugpoint</a> - shows bugpoint usage scenarios to simplify backend
development</li>
</ul>
</div>

View File

@@ -471,9 +471,9 @@ following signature:</p>
<b>virtual bool</b> runOnModule(Module &amp;M) = 0;
</pre>
<p>The <tt>runOnModule</tt> method performs the interesting work of the pass,
and should return true if the module was modified by the transformation, false
otherwise.</p>
<p>The <tt>runOnModule</tt> method performs the interesting work of the pass.
It should return true if the module was modified by the transformation and
false otherwise.</p>
</div>

View File

@@ -37,7 +37,8 @@ using namespace llvm;
static Function *CreateFibFunction(Module *M) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::IntTy, Type::IntTy, 0);
Function *FibF = M->getOrInsertFunction("fib", Type::IntTy, Type::IntTy,
(Type *)0);
// Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);

View File

@@ -51,7 +51,8 @@ int main() {
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy, 0);
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy,
(Type *)0);
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
@@ -76,7 +77,7 @@ int main() {
// Now we going to create function `foo', which returns an int and takes no
// arguments.
Function *FooF = M->getOrInsertFunction("foo", Type::IntTy, 0);
Function *FooF = M->getOrInsertFunction("foo", Type::IntTy, (Type *)0);
// Add a basic block to the FooF function.
BB = new BasicBlock("EntryBlock", FooF);

View File

@@ -11,6 +11,6 @@ LEVEL=..
include $(LEVEL)/Makefile.config
#PARALLEL_DIRS:= $(patsubst %/Makefile,%,$(wildcard $(SourceDir)/*/Makefile))
PARALLEL_DIRS:= Fibonacci HowToUseJIT ModuleMaker BFtoLLVM
PARALLEL_DIRS:= ParallelJIT Fibonacci HowToUseJIT ModuleMaker BFtoLLVM
include $(LEVEL)/Makefile.common

View File

@@ -0,0 +1,18 @@
##===- examples/ParallelJIT/Makefile -----------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Reid A. Spencer and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../..
TOOLNAME = ParallelJIT
EXAMPLE_TOOL = 1
# Enable JIT support
LLVMLIBS := JIT
include $(LEVEL)/Makefile.common
LIBS += -lpthread

View File

@@ -0,0 +1,297 @@
//===-- examples/ParallelJIT/ParallelJIT.cpp - Exercise threaded-safe JIT -===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Evan Jones and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Parallel JIT
//
// This test program creates two LLVM functions then calls them from three
// separate threads. It requires the pthreads library.
// The three threads are created and then block waiting on a condition variable.
// Once all threads are blocked on the conditional variable, the main thread
// wakes them up. This complicated work is performed so that all three threads
// call into the JIT at the same time (or the best possible approximation of the
// same time). This test had assertion errors until I got the locking right.
#include <pthread.h>
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/Type.h"
#include "llvm/Instructions.h"
#include "llvm/ModuleProvider.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include <iostream>
using namespace llvm;
static Function* createAdd1(Module* M)
{
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy,
(Type *)0);
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
// Get pointers to the constant `1'.
Value *One = ConstantSInt::get(Type::IntTy, 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
Argument *ArgX = Add1F->arg_begin(); // Get the arg
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the add instruction, inserting it into the end of BB.
Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB);
// Create the return instruction and add it to the basic block
new ReturnInst(Add, BB);
// Now, function add1 is ready.
return Add1F;
}
static Function *CreateFibFunction(Module *M)
{
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::IntTy, Type::IntTy,
(Type *)0);
// Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
// Get pointers to the constants.
Value *One = ConstantSInt::get(Type::IntTy, 1);
Value *Two = ConstantSInt::get(Type::IntTy, 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the true_block.
BasicBlock *RetBB = new BasicBlock("return", FibF);
// Create an exit block.
BasicBlock* RecurseBB = new BasicBlock("recurse", FibF);
// Create the "if (arg < 2) goto exitbb"
Value *CondInst = BinaryOperator::createSetLE(ArgX, Two, "cond", BB);
new BranchInst(RetBB, RecurseBB, CondInst, BB);
// Create: ret int 1
new ReturnInst(One, RetBB);
// create fib(x-1)
Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB);
Value *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB);
// create fib(x-2)
Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB);
Value *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB);
// fib(x-1)+fib(x-2)
Value *Sum =
BinaryOperator::createAdd(CallFibX1, CallFibX2, "addresult", RecurseBB);
// Create the return instruction and add it to the basic block
new ReturnInst(Sum, RecurseBB);
return FibF;
}
struct threadParams {
ExecutionEngine* EE;
Function* F;
int value;
};
// We block the subthreads just before they begin to execute:
// we want all of them to call into the JIT at the same time,
// to verify that the locking is working correctly.
class WaitForThreads
{
public:
WaitForThreads()
{
n = 0;
waitFor = 0;
int result = pthread_cond_init( &condition, NULL );
assert( result == 0 );
result = pthread_mutex_init( &mutex, NULL );
assert( result == 0 );
}
~WaitForThreads()
{
int result = pthread_cond_destroy( &condition );
assert( result == 0 );
result = pthread_mutex_destroy( &mutex );
assert( result == 0 );
}
// All threads will stop here until another thread calls releaseThreads
void block()
{
int result = pthread_mutex_lock( &mutex );
assert( result == 0 );
n ++;
//~ std::cout << "block() n " << n << " waitFor " << waitFor << std::endl;
assert( waitFor == 0 || n <= waitFor );
if ( waitFor > 0 && n == waitFor )
{
// There are enough threads blocked that we can release all of them
std::cout << "Unblocking threads from block()" << std::endl;
unblockThreads();
}
else
{
// We just need to wait until someone unblocks us
result = pthread_cond_wait( &condition, &mutex );
assert( result == 0 );
}
// unlock the mutex before returning
result = pthread_mutex_unlock( &mutex );
assert( result == 0 );
}
// If there are num or more threads blocked, it will signal them all
// Otherwise, this thread blocks until there are enough OTHER threads
// blocked
void releaseThreads( size_t num )
{
int result = pthread_mutex_lock( &mutex );
assert( result == 0 );
if ( n >= num ) {
std::cout << "Unblocking threads from releaseThreads()" << std::endl;
unblockThreads();
}
else
{
waitFor = num;
pthread_cond_wait( &condition, &mutex );
}
// unlock the mutex before returning
result = pthread_mutex_unlock( &mutex );
assert( result == 0 );
}
private:
void unblockThreads()
{
// Reset the counters to zero: this way, if any new threads
// enter while threads are exiting, they will block instead
// of triggering a new release of threads
n = 0;
// Reset waitFor to zero: this way, if waitFor threads enter
// while threads are exiting, they will block instead of
// triggering a new release of threads
waitFor = 0;
int result = pthread_cond_broadcast( &condition );
assert( result == 0 );
}
size_t n;
size_t waitFor;
pthread_cond_t condition;
pthread_mutex_t mutex;
};
static WaitForThreads synchronize;
void* callFunc( void* param )
{
struct threadParams* p = (struct threadParams*) param;
// Call the `foo' function with no arguments:
std::vector<GenericValue> Args(1);
Args[0].IntVal = p->value;
synchronize.block(); // wait until other threads are at this point
GenericValue gv = p->EE->runFunction(p->F, Args);
return (void*) intptr_t(gv.IntVal);
}
int main()
{
// Create some module to put our function into it.
Module *M = new Module("test");
Function* add1F = createAdd1( M );
Function* fibF = CreateFibFunction( M );
// Now we create the JIT.
ExistingModuleProvider* MP = new ExistingModuleProvider(M);
ExecutionEngine* EE = ExecutionEngine::create(MP, false);
//~ std::cout << "We just constructed this LLVM module:\n\n" << *M;
//~ std::cout << "\n\nRunning foo: " << std::flush;
// Create one thread for add1 and two threads for fib
struct threadParams add1 = { EE, add1F, 1000 };
struct threadParams fib1 = { EE, fibF, 39 };
struct threadParams fib2 = { EE, fibF, 42 };
pthread_t add1Thread;
int result = pthread_create( &add1Thread, NULL, callFunc, &add1 );
if ( result != 0 ) {
std::cerr << "Could not create thread" << std::endl;
return 1;
}
pthread_t fibThread1;
result = pthread_create( &fibThread1, NULL, callFunc, &fib1 );
if ( result != 0 ) {
std::cerr << "Could not create thread" << std::endl;
return 1;
}
pthread_t fibThread2;
result = pthread_create( &fibThread2, NULL, callFunc, &fib2 );
if ( result != 0 ) {
std::cerr << "Could not create thread" << std::endl;
return 1;
}
synchronize.releaseThreads(3); // wait until other threads are at this point
void* returnValue;
result = pthread_join( add1Thread, &returnValue );
if ( result != 0 ) {
std::cerr << "Could not join thread" << std::endl;
return 1;
}
std::cout << "Add1 returned " << intptr_t(returnValue) << std::endl;
result = pthread_join( fibThread1, &returnValue );
if ( result != 0 ) {
std::cerr << "Could not join thread" << std::endl;
return 1;
}
std::cout << "Fib1 returned " << intptr_t(returnValue) << std::endl;
result = pthread_join( fibThread2, &returnValue );
if ( result != 0 ) {
std::cerr << "Could not join thread" << std::endl;
return 1;
}
std::cout << "Fib2 returned " << intptr_t(returnValue) << std::endl;
return 0;
}

View File

@@ -138,6 +138,8 @@ public:
iterator begin() const { return TheMapping.begin(); }
iterator end() const { return TheMapping.end(); }
bool empty() const { return TheMapping.empty(); }
/// member_* Iterate over the members of an equivalence class.
///
class member_iterator;

View File

@@ -24,7 +24,7 @@
// 3.0.4 std ext/hash_map
// 3.1 __gnu_cxx ext/hash_map
// HP aCC6 std stdex/rw/hashm*ap.h
//
// MS VC++ stdext hash_map
#undef HAVE_GNU_EXT_HASH_MAP
#undef HAVE_STD_EXT_HASH_MAP
@@ -63,6 +63,14 @@
# define HASH_NAMESPACE std
# endif
// Support Microsoft VC++.
#elif defined(_MSC_VER)
# include <hash_map>
# ifndef HASH_NAMESPACE
# define HASH_NAMESPACE stdext
using std::_Distance;
# endif
// Give a warning if we couldn't find it, instead of (or in addition to)
// randomly doing something dumb.
#else
@@ -84,7 +92,8 @@ template <typename KeyType,
class _HashFcn = hash<KeyType>,
class _EqualKey = equal_to<KeyType>,
class _A = allocator <ValueType> >
class hash_map : public rw_hashmap<KeyType, ValueType, class _HashFcn, class _EqualKey, class _A> {
class hash_map : public rw_hashmap<KeyType, ValueType, class _HashFcn,
class _EqualKey, class _A> {
};
template <typename KeyType,
@@ -92,16 +101,13 @@ template <typename KeyType,
class _HashFcn = hash<KeyType>,
class _EqualKey = equal_to<KeyType>,
class _A = allocator <ValueType> >
class hash_multimap : public rw_hashmultimap<KeyType, ValueType, class _HashFcn, class _EqualKey, class _A> {
class hash_multimap : public rw_hashmultimap<KeyType, ValueType, class _HashFcn,
class _EqualKey, class _A> {
};
} // end HASH_NAMESPACE;
#endif
using HASH_NAMESPACE::hash_map;
using HASH_NAMESPACE::hash_multimap;
using HASH_NAMESPACE::hash;
// Include vector because ext/hash_map includes stl_vector.h and leaves
// out specializations like stl_bvector.h, causing link conflicts.
#include <vector>
@@ -135,6 +141,10 @@ namespace stdext {
#endif
using HASH_NAMESPACE::hash_map;
using HASH_NAMESPACE::hash_multimap;
using HASH_NAMESPACE::hash;
#include "llvm/ADT/HashExtras.h"
#endif

View File

@@ -25,7 +25,7 @@
// 3.0.4 std ext/hash_set
// 3.1 __gnu_cxx ext/hash_set
// HP aCC6 std stdex/rw/hashset.h
//
// MS VC++ stdext hash_set
#undef HAVE_GNU_EXT_HASH_SET
#undef HAVE_STD_EXT_HASH_SET
@@ -64,6 +64,13 @@
# define HASH_NAMESPACE std
# endif
// Support Microsoft VC++.
#elif defined(_MSC_VER)
# include <hash_set>
# ifndef HASH_NAMESPACE
# define HASH_NAMESPACE stdext
# endif
// Give a warning if we couldn't find it, instead of (or in addition to)
// randomly doing something dumb.
#else
@@ -83,17 +90,17 @@ template <class DataType> struct hash {
*/
template <typename ValueType,
class _HashFcn = hash<ValueType>,
class _EqualKey = equal_to<ValueType>,
class _A = allocator <ValueType> >
class hash_set : public rw_hashset<ValueType, class _HashFcn, class _EqualKey, class _A> {
class _HashFcn = hash<ValueType>,
class _EqualKey = equal_to<ValueType>,
class _A = allocator <ValueType> >
class hash_set :
public rw_hashset<ValueType, class _HashFcn, class _EqualKey, class _A> {
};
} // end HASH_NAMESPACE;
#endif
using HASH_NAMESPACE::hash_set;
using HASH_NAMESPACE::hash;
// Include vector because ext/hash_set includes stl_vector.h and leaves
// out specializations like stl_bvector.h, causing link conflicts.

View File

@@ -169,6 +169,26 @@ void operator+(int, ilist_iterator<T>);
template<typename T>
void operator+(ilist_iterator<T>,int);
// operator!=/operator== - Allow mixed comparisons without dereferencing
// the iterator, which could very likely be pointing to end().
template<typename T>
bool operator!=(const T* LHS, const ilist_iterator<const T> &RHS) {
return LHS != RHS.getNodePtrUnchecked();
}
template<typename T>
bool operator==(const T* LHS, const ilist_iterator<const T> &RHS) {
return LHS == RHS.getNodePtrUnchecked();
}
template<typename T>
bool operator!=(T* LHS, const ilist_iterator<T> &RHS) {
return LHS != RHS.getNodePtrUnchecked();
}
template<typename T>
bool operator==(T* LHS, const ilist_iterator<T> &RHS) {
return LHS == RHS.getNodePtrUnchecked();
}
// Allow ilist_iterators to convert into pointers to a node automatically when
// used by the dyn_cast, cast, isa mechanisms...

View File

@@ -34,6 +34,12 @@
#undef HAVE_STD_ITERATOR
#undef HAVE_FWD_ITERATOR
#ifdef _MSC_VER
# define HAVE_BI_ITERATOR 0
# define HAVE_STD_ITERATOR 1
# define HAVE_FWD_ITERATOR 0
#endif
#if !HAVE_BI_ITERATOR
# if HAVE_STD_ITERATOR
/// If the bidirectional iterator is not defined, we attempt to define it in

View File

@@ -37,6 +37,7 @@ namespace llvm {
class LoadInst;
class StoreInst;
class VAArgInst;
class TargetData;
class AliasAnalysis {
@@ -254,8 +255,12 @@ public:
ModRefResult getModRefInfo(InvokeInst *I, Value *P, unsigned Size) {
return getModRefInfo(CallSite(I), P, Size);
}
ModRefResult getModRefInfo(VAArgInst* I, Value* P, unsigned Size) {
return AliasAnalysis::Mod;
}
ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) {
switch (I->getOpcode()) {
case Instruction::VAArg: return getModRefInfo((VAArgInst*)I, P, Size);
case Instruction::Load: return getModRefInfo((LoadInst*)I, P, Size);
case Instruction::Store: return getModRefInfo((StoreInst*)I, P, Size);
case Instruction::Call: return getModRefInfo((CallInst*)I, P, Size);

View File

@@ -0,0 +1,36 @@
//===-- ConstantFolding.h - Analyze constant folding possibilities --------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This family of functions determines the possibility of performing constant
// folding.
//
//===----------------------------------------------------------------------===//
#include "llvm/Constants.h"
#include "llvm/Function.h"
using namespace llvm;
namespace llvm {
/// canConstantFoldCallTo - Return true if its even possible to fold a call to
/// the specified function.
extern
bool canConstantFoldCallTo(Function *F);
/// ConstantFoldFP - Given a function that evaluates the constant, return an
/// LLVM Constant that represents the evaluated constant
extern Constant *
ConstantFoldFP(double (*NativeFP)(double), double V, const Type *Ty);
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
/// with the specified arguments, returning null if unsuccessful.
extern Constant *
ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands);
}

View File

@@ -31,6 +31,10 @@ class DSCallSite;
class DSNode;
class DSNodeHandle;
FunctionPass *createDataStructureStatsPass();
FunctionPass *createDataStructureGraphCheckerPass();
// FIXME: move this stuff to a private header
namespace DataStructureAnalysis {
/// isPointerType - Return true if this first class type is big enough to hold

View File

@@ -1,63 +0,0 @@
//===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a package of expression analysis utilties:
//
// ClassifyExpr: Analyze an expression to determine the complexity of the
// expression, and which other variables it depends on.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_EXPRESSIONS_H
#define LLVM_ANALYSIS_EXPRESSIONS_H
namespace llvm {
class Type;
class Value;
class ConstantInt;
struct ExprType;
/// ClassifyExpr - Analyze an expression to determine the complexity of the
/// expression, and which other values it depends on.
///
ExprType ClassifyExpr(Value *Expr);
/// ExprType Class - Represent an expression of the form CONST*VAR+CONST
/// or simpler. The expression form that yields the least information about the
/// expression is just the Linear form with no offset.
///
struct ExprType {
enum ExpressionType {
Constant, // Expr is a simple constant, Offset is value
Linear, // Expr is linear expr, Value is Var+Offset
ScaledLinear, // Expr is scaled linear exp, Value is Scale*Var+Offset
} ExprTy;
const ConstantInt *Offset; // Offset of expr, or null if 0
Value *Var; // Var referenced, if Linear or above (null if 0)
const ConstantInt *Scale; // Scale of var if ScaledLinear expr (null if 1)
inline ExprType(const ConstantInt *CPV = 0) {
Offset = CPV; Var = 0; Scale = 0;
ExprTy = Constant;
}
ExprType(Value *Val); // Create a linear or constant expression
ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
/// If this expression has an intrinsic type, return it. If it is zero,
/// return the specified type.
///
const Type *getExprType(const Type *Default) const;
};
} // End llvm namespace
#endif

View File

@@ -1,62 +0,0 @@
//===- llvm/Analysis/FindUnsafePointerTypes.h - Unsafe pointers -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a pass that can be used to determine, interprocedurally,
// which pointer types are accessed unsafely in a program. If there is an
// "unsafe" access to a specific pointer type, transformations that depend on
// type safety cannot be permitted.
//
// The result of running this analysis over a program is a set of unsafe pointer
// types that cannot be transformed. Safe pointer types are not tracked.
//
// Additionally, this analysis exports a hidden command line argument that (when
// enabled) prints out the reasons a type was determined to be unsafe. Just add
// -printunsafeptrinst to the command line of the tool you want to get it.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
#define LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
#include "llvm/Pass.h"
#include <set>
namespace llvm {
class PointerType;
struct FindUnsafePointerTypes : public ModulePass {
// UnsafeTypes - Set of types that are not safe to transform.
std::set<PointerType*> UnsafeTypes;
public:
// Accessor for underlying type set...
inline const std::set<PointerType*> &getUnsafeTypes() const {
return UnsafeTypes;
}
/// run - Inspect the operations that the specified module does on
/// values of various types. If they are deemed to be 'unsafe' note that the
/// type is not safe to transform.
///
virtual bool runOnModule(Module &M);
/// print - Loop over the results of the analysis, printing out unsafe types.
///
void print(std::ostream &o, const Module *Mod) const;
/// getAnalysisUsage - Of course, we provide ourself...
///
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
};
} // End llvm namespace
#endif

View File

@@ -110,7 +110,7 @@ inline Interval::succ_iterator succ_begin(Interval *I) {
inline Interval::succ_iterator succ_end(Interval *I) {
return I->Successors.end();
}
/// pred_begin/pred_end - define methods so that Intervals may be used
/// just like BasicBlocks can with the pred_* functions, and *::pred_iterator.
///
@@ -128,7 +128,7 @@ template <> struct GraphTraits<Interval*> {
static NodeType *getEntryNode(Interval *I) { return I; }
/// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
static inline ChildIteratorType child_begin(NodeType *N) {
static inline ChildIteratorType child_begin(NodeType *N) {
return succ_begin(N);
}
static inline ChildIteratorType child_end(NodeType *N) {

View File

@@ -0,0 +1,62 @@
//===- LinkAllAnalyses.h - Reference All Analysis Passes --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This header file pulls in all analysis passes for tools like analyze and
// bugpoint that need this functionality.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_LINKALLANALYSES_H
#define LLVM_ANALYSIS_LINKALLANALYSES_H
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/IntervalPartition.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/DataStructure/DataStructure.h"
#include "llvm/Function.h"
#include <cstdlib>
namespace {
struct ForceAnalysisPassLinking {
ForceAnalysisPassLinking() {
// We must reference the passes in such a way that compilers will not
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
if (std::getenv("bar") != (char*) -1)
return;
(void)new llvm::LocalDataStructures();
(void)new llvm::BUDataStructures();
(void)new llvm::TDDataStructures();
(void)new llvm::CompleteBUDataStructures();
(void)new llvm::EquivClassGraphs();
(void)llvm::createDataStructureStatsPass();
(void)llvm::createDataStructureGraphCheckerPass();
(void)llvm::createProfileLoaderPass();
(void)llvm::createNoProfileInfoPass();
(void)llvm::createInstCountPass();
(void)new llvm::IntervalPartition();
(void)new llvm::ImmediateDominators();
(void)new llvm::PostDominatorSet();
(void)new llvm::CallGraph();
(void)new llvm::FindUsedTypes();
(void)new llvm::ScalarEvolution();
((llvm::Function*)0)->viewCFGOnly();
llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)0);
X.add((llvm::Value*)0, 0); // for -print-alias-sets
}
} ForceAnalysisPassLinking;
};
#endif

View File

@@ -121,6 +121,12 @@ public:
///
BasicBlock *getLoopPreheader() const;
/// getLoopLatch - If there is a latch block for this loop, return it. A
/// latch block is the canonical backedge for a loop. A loop header in normal
/// form has two edges into it: one from a preheader and one from a latch
/// block.
BasicBlock *getLoopLatch() const;
/// getCanonicalInductionVariable - Check to see if the loop has a canonical
/// induction variable: an integer recurrence that starts at 0 and increments
/// by one each time through the loop. If so, return the phi node that
@@ -250,7 +256,8 @@ public:
// isLoopHeader - True if the block is a loop header node
bool isLoopHeader(BasicBlock *BB) const {
return getLoopFor(BB)->getHeader() == BB;
const Loop *L = getLoopFor(BB);
return L && L->getHeader() == BB;
}
/// runOnFunction - Calculate the natural loop information.

View File

@@ -102,6 +102,10 @@ namespace llvm {
// simple context insensitive alias analysis.
//
ModulePass *createSteensgaardPass();
// Minor pass prototypes, allowing us to expose them through bugpoint and
// analyze.
FunctionPass *createInstCountPass();
}
#endif

View File

@@ -195,6 +195,14 @@ namespace llvm {
/// specified expression.
SCEVHandle getSCEV(Value *V) const;
/// hasSCEV - Return true if the SCEV for this value has already been
/// computed.
bool hasSCEV(Value *V) const;
/// setSCEV - Insert the specified SCEV into the map of current SCEVs for
/// the specified value.
void setSCEV(Value *V, const SCEVHandle &H);
/// getSCEVAtScope - Return a SCEV expression handle for the specified value
/// at the specified scope in the program. The L value specifies a loop
/// nest to evaluate the expression at, where null is the top-level or a

View File

@@ -0,0 +1,180 @@
//===---- llvm/Analysis/ScalarEvolutionExpander.h - SCEV Exprs --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the classes used to generate code from scalar expressions.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_SCALAREVOLUTION_EXPANDER_H
#define LLVM_ANALYSIS_SCALAREVOLUTION_EXPANDER_H
#include "llvm/BasicBlock.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Type.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Support/CFG.h"
namespace llvm {
/// SCEVExpander - This class uses information about analyze scalars to
/// rewrite expressions in canonical form.
///
/// Clients should create an instance of this class when rewriting is needed,
/// and destroying it when finished to allow the release of the associated
/// memory.
struct SCEVExpander : public SCEVVisitor<SCEVExpander, Value*> {
ScalarEvolution &SE;
LoopInfo &LI;
std::map<SCEVHandle, Value*> InsertedExpressions;
std::set<Instruction*> InsertedInstructions;
Instruction *InsertPt;
friend struct SCEVVisitor<SCEVExpander, Value*>;
public:
SCEVExpander(ScalarEvolution &se, LoopInfo &li) : SE(se), LI(li) {}
/// clear - Erase the contents of the InsertedExpressions map so that users
/// trying to expand the same expression into multiple BasicBlocks or
/// different places within the same BasicBlock can do so.
void clear() { InsertedExpressions.clear(); }
/// isInsertedInstruction - Return true if the specified instruction was
/// inserted by the code rewriter. If so, the client should not modify the
/// instruction.
bool isInsertedInstruction(Instruction *I) const {
return InsertedInstructions.count(I);
}
/// getOrInsertCanonicalInductionVariable - This method returns the
/// canonical induction variable of the specified type for the specified
/// loop (inserting one if there is none). A canonical induction variable
/// starts at zero and steps by one on each iteration.
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){
assert((Ty->isInteger() || Ty->isFloatingPoint()) &&
"Can only insert integer or floating point induction variables!");
SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty),
SCEVUnknown::getIntegerSCEV(1, Ty), L);
return expand(H);
}
/// addInsertedValue - Remember the specified instruction as being the
/// canonical form for the specified SCEV.
void addInsertedValue(Instruction *I, SCEV *S) {
InsertedExpressions[S] = (Value*)I;
InsertedInstructions.insert(I);
}
/// expandCodeFor - Insert code to directly compute the specified SCEV
/// expression into the program. The inserted code is inserted into the
/// specified block.
///
/// If a particular value sign is required, a type may be specified for the
/// result.
Value *expandCodeFor(SCEVHandle SH, Instruction *IP, const Type *Ty = 0) {
// Expand the code for this SCEV.
this->InsertPt = IP;
return expandInTy(SH, Ty);
}
protected:
Value *expand(SCEV *S) {
// Check to see if we already expanded this.
std::map<SCEVHandle, Value*>::iterator I = InsertedExpressions.find(S);
if (I != InsertedExpressions.end())
return I->second;
Value *V = visit(S);
InsertedExpressions[S] = V;
return V;
}
Value *expandInTy(SCEV *S, const Type *Ty) {
Value *V = expand(S);
if (Ty && V->getType() != Ty) {
// FIXME: keep track of the cast instruction.
if (Constant *C = dyn_cast<Constant>(V))
return ConstantExpr::getCast(C, Ty);
else if (Instruction *I = dyn_cast<Instruction>(V)) {
// Check to see if there is already a cast. If there is, use it.
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI) {
if ((*UI)->getType() == Ty)
if (CastInst *CI = dyn_cast<CastInst>(cast<Instruction>(*UI))) {
BasicBlock::iterator It = I; ++It;
if (isa<InvokeInst>(I))
It = cast<InvokeInst>(I)->getNormalDest()->begin();
while (isa<PHINode>(It)) ++It;
if (It != BasicBlock::iterator(CI)) {
// Splice the cast immediately after the operand in question.
BasicBlock::InstListType &InstList =
It->getParent()->getInstList();
InstList.splice(It, CI->getParent()->getInstList(), CI);
}
return CI;
}
}
BasicBlock::iterator IP = I; ++IP;
if (InvokeInst *II = dyn_cast<InvokeInst>(I))
IP = II->getNormalDest()->begin();
while (isa<PHINode>(IP)) ++IP;
return new CastInst(V, Ty, V->getName(), IP);
} else {
// FIXME: check to see if there is already a cast!
return new CastInst(V, Ty, V->getName(), InsertPt);
}
}
return V;
}
Value *visitConstant(SCEVConstant *S) {
return S->getValue();
}
Value *visitTruncateExpr(SCEVTruncateExpr *S) {
Value *V = expand(S->getOperand());
return new CastInst(V, S->getType(), "tmp.", InsertPt);
}
Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
Value *V = expandInTy(S->getOperand(),S->getType()->getUnsignedVersion());
return new CastInst(V, S->getType(), "tmp.", InsertPt);
}
Value *visitAddExpr(SCEVAddExpr *S) {
const Type *Ty = S->getType();
Value *V = expandInTy(S->getOperand(S->getNumOperands()-1), Ty);
// Emit a bunch of add instructions
for (int i = S->getNumOperands()-2; i >= 0; --i)
V = BinaryOperator::createAdd(V, expandInTy(S->getOperand(i), Ty),
"tmp.", InsertPt);
return V;
}
Value *visitMulExpr(SCEVMulExpr *S);
Value *visitUDivExpr(SCEVUDivExpr *S) {
const Type *Ty = S->getType();
Value *LHS = expandInTy(S->getLHS(), Ty);
Value *RHS = expandInTy(S->getRHS(), Ty);
return BinaryOperator::createDiv(LHS, RHS, "tmp.", InsertPt);
}
Value *visitAddRecExpr(SCEVAddRecExpr *S);
Value *visitUnknown(SCEVUnknown *S) {
return S->getValue();
}
};
}
#endif

View File

@@ -28,6 +28,7 @@ class ParseException;
// the verifier after parsing the file to check that it's ok.
//
Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
Module *ParseAssemblyString(const char * AsmString, Module * M);// throw (ParseException)
//===------------------------------------------------------------------------===
// Helper Classes

View File

@@ -101,6 +101,11 @@ public:
/// and deletes it.
///
void eraseFromParent();
/// moveBefore - Unlink this instruction from its current function and
/// insert it into the function that MovePos lives in, right before
/// MovePos.
void moveBefore(BasicBlock *MovePos);
/// getSinglePredecessor - If this basic block has a single predecessor block,
/// return the block, otherwise return a null pointer.
@@ -134,7 +139,7 @@ public:
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BasicBlock *BB) { return true; }
static inline bool classof(const BasicBlock *) { return true; }
static inline bool classof(const Value *V) {
return V->getValueType() == Value::BasicBlockVal;
}
@@ -160,7 +165,7 @@ public:
/// splitBasicBlock - This splits a basic block into two at the specified
/// instruction. Note that all instructions BEFORE the specified iterator
/// stay as part of the original basic block, an unconditional branch is added
/// to the original BB, and the rest of the instructions in the BB are moved
/// to the original BB, and the rest of the instructions in the BB are moved
/// to the new BB, including the old terminator. The newly formed BasicBlock
/// is returned. This function invalidates the specified iterator.
///

View File

@@ -0,0 +1,323 @@
//===-- ELFWriter.h - Target-independent ELF writer support -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the ELFWriter class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_ELFWRITER_H
#define LLVM_CODEGEN_ELFWRITER_H
#include "llvm/CodeGen/MachineFunctionPass.h"
#include <list>
namespace llvm {
class GlobalVariable;
class Mangler;
class MachineCodeEmitter;
class ELFCodeEmitter;
/// ELFWriter - This class implements the common target-independent code for
/// writing ELF files. Targets should derive a class from this to
/// parameterize the output format.
///
class ELFWriter : public MachineFunctionPass {
friend class ELFCodeEmitter;
public:
MachineCodeEmitter &getMachineCodeEmitter() const {
return *(MachineCodeEmitter*)MCE;
}
~ELFWriter();
typedef std::vector<unsigned char> DataBuffer;
protected:
ELFWriter(std::ostream &O, TargetMachine &TM);
/// Output stream to send the resultant object file to.
///
std::ostream &O;
/// Target machine description.
///
TargetMachine &TM;
/// Mang - The object used to perform name mangling for this module.
///
Mangler *Mang;
/// MCE - The MachineCodeEmitter object that we are exposing to emit machine
/// code for functions to the .o file.
ELFCodeEmitter *MCE;
//===------------------------------------------------------------------===//
// Properties to be set by the derived class ctor, used to configure the
// ELFWriter.
// e_machine - This field is the target specific value to emit as the
// e_machine member of the ELF header.
unsigned short e_machine;
// e_flags - The machine flags for the target. This defaults to zero.
unsigned e_flags;
//===------------------------------------------------------------------===//
// Properties inferred automatically from the target machine.
//
/// is64Bit/isLittleEndian - This information is inferred from the target
/// machine directly, indicating whether to emit a 32- or 64-bit ELF file.
bool is64Bit, isLittleEndian;
/// doInitialization - Emit the file header and all of the global variables
/// for the module to the ELF file.
bool doInitialization(Module &M);
bool runOnMachineFunction(MachineFunction &MF);
/// doFinalization - Now that the module has been completely processed, emit
/// the ELF file to 'O'.
bool doFinalization(Module &M);
private:
// The buffer we accumulate the file header into. Note that this should be
// changed into something much more efficient later (and the bytecode writer
// as well!).
DataBuffer FileHeader;
/// ELFSection - This struct contains information about each section that is
/// emitted to the file. This is eventually turned into the section header
/// table at the end of the file.
struct ELFSection {
std::string Name; // Name of the section.
unsigned NameIdx; // Index in .shstrtab of name, once emitted.
unsigned Type;
unsigned Flags;
uint64_t Addr;
unsigned Offset;
unsigned Size;
unsigned Link;
unsigned Info;
unsigned Align;
unsigned EntSize;
/// SectionIdx - The number of the section in the Section Table.
///
unsigned short SectionIdx;
/// SectionData - The actual data for this section which we are building
/// up for emission to the file.
DataBuffer SectionData;
enum { SHT_NULL = 0, SHT_PROGBITS = 1, SHT_SYMTAB = 2, SHT_STRTAB = 3,
SHT_RELA = 4, SHT_HASH = 5, SHT_DYNAMIC = 6, SHT_NOTE = 7,
SHT_NOBITS = 8, SHT_REL = 9, SHT_SHLIB = 10, SHT_DYNSYM = 11 };
enum { SHN_UNDEF = 0, SHN_ABS = 0xFFF1, SHN_COMMON = 0xFFF2 };
enum { // SHF - ELF Section Header Flags
SHF_WRITE = 1 << 0, // Writable
SHF_ALLOC = 1 << 1, // Mapped into the process addr space
SHF_EXECINSTR = 1 << 2, // Executable
SHF_MERGE = 1 << 4, // Might be merged if equal
SHF_STRINGS = 1 << 5, // Contains null-terminated strings
SHF_INFO_LINK = 1 << 6, // 'sh_info' contains SHT index
SHF_LINK_ORDER = 1 << 7, // Preserve order after combining
SHF_OS_NONCONFORMING = 1 << 8, // nonstandard OS support required
SHF_GROUP = 1 << 9, // Section is a member of a group
SHF_TLS = 1 << 10,// Section holds thread-local data
};
ELFSection(const std::string &name)
: Name(name), Type(0), Flags(0), Addr(0), Offset(0), Size(0),
Link(0), Info(0), Align(0), EntSize(0) {
}
};
/// SectionList - This is the list of sections that we have emitted to the
/// file. Once the file has been completely built, the section header table
/// is constructed from this info.
std::list<ELFSection> SectionList;
unsigned NumSections; // Always = SectionList.size()
/// SectionLookup - This is a mapping from section name to section number in
/// the SectionList.
std::map<std::string, ELFSection*> SectionLookup;
/// getSection - Return the section with the specified name, creating a new
/// section if one does not already exist.
ELFSection &getSection(const std::string &Name,
unsigned Type, unsigned Flags = 0) {
ELFSection *&SN = SectionLookup[Name];
if (SN) return *SN;
SectionList.push_back(Name);
SN = &SectionList.back();
SN->SectionIdx = NumSections++;
SN->Type = Type;
SN->Flags = Flags;
return *SN;
}
ELFSection &getDataSection() {
return getSection(".data", ELFSection::SHT_PROGBITS,
ELFSection::SHF_WRITE | ELFSection::SHF_ALLOC);
}
ELFSection &getBSSSection() {
return getSection(".bss", ELFSection::SHT_NOBITS,
ELFSection::SHF_WRITE | ELFSection::SHF_ALLOC);
}
/// ELFSym - This struct contains information about each symbol that is
/// added to logical symbol table for the module. This is eventually
/// turned into a real symbol table in the file.
struct ELFSym {
const GlobalValue *GV; // The global value this corresponds to.
unsigned NameIdx; // Index in .strtab of name, once emitted.
uint64_t Value;
unsigned Size;
unsigned char Info;
unsigned char Other;
unsigned short SectionIdx;
enum { STB_LOCAL = 0, STB_GLOBAL = 1, STB_WEAK = 2 };
enum { STT_NOTYPE = 0, STT_OBJECT = 1, STT_FUNC = 2, STT_SECTION = 3,
STT_FILE = 4 };
ELFSym(const GlobalValue *gv) : GV(gv), Value(0), Size(0), Info(0),
Other(0), SectionIdx(0) {}
void SetBind(unsigned X) {
assert(X == (X & 0xF) && "Bind value out of range!");
Info = (Info & 0x0F) | (X << 4);
}
void SetType(unsigned X) {
assert(X == (X & 0xF) && "Type value out of range!");
Info = (Info & 0xF0) | X;
}
};
/// SymbolTable - This is the list of symbols we have emitted to the file.
/// This actually gets rearranged before emission to the file (to put the
/// local symbols first in the list).
std::vector<ELFSym> SymbolTable;
// As we complete the ELF file, we need to update fields in the ELF header
// (e.g. the location of the section table). These members keep track of
// the offset in ELFHeader of these various pieces to update and other
// locations in the file.
unsigned ELFHeader_e_shoff_Offset; // e_shoff in ELF header.
unsigned ELFHeader_e_shstrndx_Offset; // e_shstrndx in ELF header.
unsigned ELFHeader_e_shnum_Offset; // e_shnum in ELF header.
// align - Emit padding into the file until the current output position is
// aligned to the specified power of two boundary.
static void align(DataBuffer &Output, unsigned Boundary) {
assert(Boundary && (Boundary & (Boundary-1)) == 0 &&
"Must align to 2^k boundary");
size_t Size = Output.size();
if (Size & (Boundary-1)) {
// Add padding to get alignment to the correct place.
size_t Pad = Boundary-(Size & (Boundary-1));
Output.resize(Size+Pad);
}
}
static void outbyte(DataBuffer &Output, unsigned char X) {
Output.push_back(X);
}
void outhalf(DataBuffer &Output, unsigned short X) {
if (isLittleEndian) {
Output.push_back(X&255);
Output.push_back(X >> 8);
} else {
Output.push_back(X >> 8);
Output.push_back(X&255);
}
}
void outword(DataBuffer &Output, unsigned X) {
if (isLittleEndian) {
Output.push_back((X >> 0) & 255);
Output.push_back((X >> 8) & 255);
Output.push_back((X >> 16) & 255);
Output.push_back((X >> 24) & 255);
} else {
Output.push_back((X >> 24) & 255);
Output.push_back((X >> 16) & 255);
Output.push_back((X >> 8) & 255);
Output.push_back((X >> 0) & 255);
}
}
void outxword(DataBuffer &Output, uint64_t X) {
if (isLittleEndian) {
Output.push_back((X >> 0) & 255);
Output.push_back((X >> 8) & 255);
Output.push_back((X >> 16) & 255);
Output.push_back((X >> 24) & 255);
Output.push_back((X >> 32) & 255);
Output.push_back((X >> 40) & 255);
Output.push_back((X >> 48) & 255);
Output.push_back((X >> 56) & 255);
} else {
Output.push_back((X >> 56) & 255);
Output.push_back((X >> 48) & 255);
Output.push_back((X >> 40) & 255);
Output.push_back((X >> 32) & 255);
Output.push_back((X >> 24) & 255);
Output.push_back((X >> 16) & 255);
Output.push_back((X >> 8) & 255);
Output.push_back((X >> 0) & 255);
}
}
void outaddr32(DataBuffer &Output, unsigned X) {
outword(Output, X);
}
void outaddr64(DataBuffer &Output, uint64_t X) {
outxword(Output, X);
}
void outaddr(DataBuffer &Output, uint64_t X) {
if (!is64Bit)
outword(Output, (unsigned)X);
else
outxword(Output, X);
}
// fix functions - Replace an existing entry at an offset.
void fixhalf(DataBuffer &Output, unsigned short X, unsigned Offset) {
unsigned char *P = &Output[Offset];
P[0] = (X >> (isLittleEndian ? 0 : 8)) & 255;
P[1] = (X >> (isLittleEndian ? 8 : 0)) & 255;
}
void fixword(DataBuffer &Output, unsigned X, unsigned Offset) {
unsigned char *P = &Output[Offset];
P[0] = (X >> (isLittleEndian ? 0 : 24)) & 255;
P[1] = (X >> (isLittleEndian ? 8 : 16)) & 255;
P[2] = (X >> (isLittleEndian ? 16 : 8)) & 255;
P[3] = (X >> (isLittleEndian ? 24 : 0)) & 255;
}
void fixaddr(DataBuffer &Output, uint64_t X, unsigned Offset) {
if (!is64Bit)
fixword(Output, (unsigned)X, Offset);
else
assert(0 && "Emission of 64-bit data not implemented yet!");
}
private:
void EmitGlobal(GlobalVariable *GV);
void EmitSymbolTable();
void EmitSectionTableStringTable();
void OutputSectionsAndSectionTable();
};
}
#endif

View File

@@ -143,6 +143,11 @@ namespace llvm {
/// only overlaps with one value in the source interval.
bool joinable(const LiveInterval& other, unsigned CopyIdx) const;
/// getOverlapingRanges - Given another live interval which is defined as a
/// copy from this one, return a list of all of the live ranges where the
/// two overlap and have different value numbers.
void getOverlapingRanges(const LiveInterval &Other, unsigned CopyIdx,
std::vector<LiveRange*> &Ranges);
/// overlaps - Return true if the intersection of the two live intervals is
/// not empty.

View File

@@ -22,7 +22,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "LiveInterval.h"
#include "llvm/CodeGen/LiveInterval.h"
namespace llvm {
@@ -164,12 +164,17 @@ namespace llvm {
void handlePhysicalRegisterDef(MachineBasicBlock* mbb,
MachineBasicBlock::iterator mi,
LiveInterval& interval,
unsigned SrcReg, unsigned DestReg);
unsigned SrcReg, unsigned DestReg,
bool isLiveIn = false);
/// Return true if the two specified registers belong to different
/// register classes. The registers may be either phys or virt regs.
bool differingRegisterClasses(unsigned RegA, unsigned RegB) const;
bool AdjustIfAllOverlappingRangesAreCopiesFrom(LiveInterval &IntA,
LiveInterval &IntB,
unsigned CopyIdx);
bool overlapsAliases(const LiveInterval *lhs,
const LiveInterval *rhs) const;

View File

@@ -40,7 +40,8 @@ class LiveVariables : public MachineFunctionPass {
public:
struct VarInfo {
/// DefInst - The machine instruction that defines this register.
MachineInstr *DefInst;
///
MachineInstr *DefInst;
/// AliveBlocks - Set of blocks of which this value is alive completely
/// through. This is a bit set which uses the basic block number as an
@@ -76,18 +77,22 @@ private:
///
std::vector<VarInfo> VirtRegInfo;
/// RegistersKilled - This multimap keeps track of all of the registers that
/// RegistersKilled - This map keeps track of all of the registers that
/// are dead immediately after an instruction reads its operands. If an
/// instruction does not have an entry in this map, it kills no registers.
///
std::multimap<MachineInstr*, unsigned> RegistersKilled;
std::map<MachineInstr*, std::vector<unsigned> > RegistersKilled;
/// RegistersDead - This multimap keeps track of all of the registers that are
/// RegistersDead - This map keeps track of all of the registers that are
/// dead immediately after an instruction executes, which are not dead after
/// the operands are evaluated. In practice, this only contains registers
/// which are defined by an instruction, but never used.
///
std::multimap<MachineInstr*, unsigned> RegistersDead;
std::map<MachineInstr*, std::vector<unsigned> > RegistersDead;
/// Dummy - An always empty vector used for instructions without dead or
/// killed operands.
std::vector<unsigned> Dummy;
/// AllocatablePhysicalRegisters - This vector keeps track of which registers
/// are actually register allocatable by the target machine. We can not track
@@ -110,42 +115,54 @@ public:
/// killed_iterator - Iterate over registers killed by a machine instruction
///
typedef std::multimap<MachineInstr*, unsigned>::iterator killed_iterator;
typedef std::vector<unsigned>::iterator killed_iterator;
std::vector<unsigned> &getKillsVector(MachineInstr *MI) {
std::map<MachineInstr*, std::vector<unsigned> >::iterator I =
RegistersKilled.find(MI);
return I != RegistersKilled.end() ? I->second : Dummy;
}
std::vector<unsigned> &getDeadDefsVector(MachineInstr *MI) {
std::map<MachineInstr*, std::vector<unsigned> >::iterator I =
RegistersDead.find(MI);
return I != RegistersDead.end() ? I->second : Dummy;
}
/// killed_begin/end - Get access to the range of registers killed by a
/// machine instruction.
killed_iterator killed_begin(MachineInstr *MI) {
return RegistersKilled.lower_bound(MI);
return getKillsVector(MI).begin();
}
killed_iterator killed_end(MachineInstr *MI) {
return RegistersKilled.upper_bound(MI);
return getKillsVector(MI).end();
}
std::pair<killed_iterator, killed_iterator>
killed_range(MachineInstr *MI) {
return RegistersKilled.equal_range(MI);
std::vector<unsigned> &V = getKillsVector(MI);
return std::make_pair(V.begin(), V.end());
}
/// KillsRegister - Return true if the specified instruction kills the
/// specified register.
bool KillsRegister(MachineInstr *MI, unsigned Reg) {
std::pair<killed_iterator, killed_iterator> KIP = killed_range(MI);
for (; KIP.first != KIP.second; ++KIP.first)
if (KIP.first->second == Reg)
return true;
return false;
}
bool KillsRegister(MachineInstr *MI, unsigned Reg) const;
killed_iterator dead_begin(MachineInstr *MI) {
return RegistersDead.lower_bound(MI);
return getDeadDefsVector(MI).begin();
}
killed_iterator dead_end(MachineInstr *MI) {
return RegistersDead.upper_bound(MI);
return getDeadDefsVector(MI).end();
}
std::pair<killed_iterator, killed_iterator>
dead_range(MachineInstr *MI) {
return RegistersDead.equal_range(MI);
std::vector<unsigned> &V = getDeadDefsVector(MI);
return std::make_pair(V.begin(), V.end());
}
/// RegisterDefIsDead - Return true if the specified instruction defines the
/// specified register, but that definition is dead.
bool RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const;
//===--------------------------------------------------------------------===//
// API to update live variable information
@@ -160,7 +177,17 @@ public:
/// instruction.
///
void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) {
RegistersKilled.insert(std::make_pair(MI, IncomingReg));
std::vector<unsigned> &V = RegistersKilled[MI];
// Insert in a sorted order.
if (V.empty() || IncomingReg > V.back()) {
V.push_back(IncomingReg);
} else {
std::vector<unsigned>::iterator I = V.begin();
for (; *I < IncomingReg; ++I)
/*empty*/;
if (*I != IncomingReg) // Don't insert duplicates.
V.insert(I, IncomingReg);
}
getVarInfo(IncomingReg).Kills.push_back(MI);
}
@@ -173,30 +200,46 @@ public:
MachineInstr *MI) {
if (!getVarInfo(reg).removeKill(MI))
return false;
for (killed_iterator i = killed_begin(MI), e = killed_end(MI); i != e; ) {
if (i->second == reg)
RegistersKilled.erase(i++);
else
++i;
}
std::vector<unsigned> &V = getKillsVector(MI);
for (unsigned i = 0, e = V.size(); i != e; ++i)
if (V[i] == reg) {
V.erase(V.begin()+i);
return true;
}
return true;
}
/// removeVirtualRegistersKilled - Remove all of the specified killed
/// registers from the live variable information.
void removeVirtualRegistersKilled(killed_iterator B, killed_iterator E) {
for (killed_iterator I = B; I != E; ++I) { // Remove VarInfo entries...
bool removed = getVarInfo(I->second).removeKill(I->first);
assert(removed && "kill not in register's VarInfo?");
/// removeVirtualRegistersKilled - Remove all killed info for the specified
/// instruction.
void removeVirtualRegistersKilled(MachineInstr *MI) {
std::map<MachineInstr*, std::vector<unsigned> >::iterator I =
RegistersKilled.find(MI);
if (I != RegistersKilled.end()) {
std::vector<unsigned> &Regs = I->second;
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
bool removed = getVarInfo(Regs[i]).removeKill(MI);
assert(removed && "kill not in register's VarInfo?");
}
RegistersKilled.erase(I);
}
RegistersKilled.erase(B, E);
}
/// addVirtualRegisterDead - Add information about the fact that the specified
/// register is dead after being used by the specified instruction.
///
void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) {
RegistersDead.insert(std::make_pair(MI, IncomingReg));
std::vector<unsigned> &V = RegistersDead[MI];
// Insert in a sorted order.
if (V.empty() || IncomingReg > V.back()) {
V.push_back(IncomingReg);
} else {
std::vector<unsigned>::iterator I = V.begin();
for (; *I < IncomingReg; ++I)
/*empty*/;
if (*I != IncomingReg) // Don't insert duplicates.
V.insert(I, IncomingReg);
}
getVarInfo(IncomingReg).Kills.push_back(MI);
}
@@ -210,21 +253,28 @@ public:
if (!getVarInfo(reg).removeKill(MI))
return false;
for (killed_iterator i = killed_begin(MI), e = killed_end(MI); i != e; ) {
if (i->second == reg)
RegistersKilled.erase(i++);
else
++i;
}
std::vector<unsigned> &V = getDeadDefsVector(MI);
for (unsigned i = 0, e = V.size(); i != e; ++i)
if (V[i] == reg) {
V.erase(V.begin()+i);
return true;
}
return true;
}
/// removeVirtualRegistersDead - Remove all of the specified dead
/// registers from the live variable information.
void removeVirtualRegistersDead(killed_iterator B, killed_iterator E) {
for (killed_iterator I = B; I != E; ++I) // Remove VarInfo entries...
getVarInfo(I->second).removeKill(I->first);
RegistersDead.erase(B, E);
void removeVirtualRegistersDead(MachineInstr *MI) {
std::map<MachineInstr*, std::vector<unsigned> >::iterator I =
RegistersDead.find(MI);
if (I != RegistersDead.end()) {
std::vector<unsigned> &Regs = I->second;
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
bool removed = getVarInfo(Regs[i]).removeKill(MI);
assert(removed && "kill not in register's VarInfo?");
}
RegistersDead.erase(I);
}
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {

View File

@@ -94,6 +94,9 @@ public:
//
virtual uint64_t getConstantPoolEntryAddress(unsigned Index) = 0;
// allocateGlobal - Allocate some space for a global variable.
virtual unsigned char* allocateGlobal(unsigned size, unsigned alignment) = 0;
/// createDebugEmitter - Return a dynamically allocated machine
/// code emitter, which just prints the opcodes and fields out the cout. This
/// can be used for debugging users of the MachineCodeEmitter interface.

View File

@@ -46,6 +46,10 @@ public:
return Constants.size()-1;
}
/// isEmpty - Return true if this constant pool contains no constants.
///
bool isEmpty() const { return Constants.empty(); }
const std::vector<Constant*> &getConstants() const { return Constants; }
/// print - Used by the MachineFunction printer to print information about

View File

@@ -143,8 +143,7 @@ public:
MachineConstantPool *getConstantPool() const { return ConstantPool; }
/// MachineFunctionInfo - Keep track of various per-function pieces of
/// information for backends that would like to do so. (Currently,
/// SPARC and IA64.)
/// information for backends that would like to do so.
///
template<typename Ty>
Ty *getInfo() {

View File

@@ -503,10 +503,10 @@ public:
void dump() const;
friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
//
// Define iterators to access the Value operands of the Machine Instruction.
// Note that these iterators only enumerate the explicit operands.
// begin() and end() are defined to produce these iterators...
// begin() and end() are defined to produce these iterators. NOTE, these are
// SparcV9 specific!
//
template<class _MI, class _V> class ValOpIterator;
typedef ValOpIterator<const MachineInstr*,const Value*> const_val_op_iterator;
@@ -711,7 +711,7 @@ public:
void SetRegForImplicitRef(unsigned i, int regNum);
//
// Iterator to enumerate machine operands.
// Iterator to enumerate machine operands. NOTE, this is SPARCV9 specific!
//
template<class MITy, class VTy>
class ValOpIterator : public forward_iterator<VTy, ptrdiff_t> {
@@ -763,10 +763,9 @@ public:
}
};
// define begin() and end()
// Note: These are Sparc-V9 specific!
val_op_iterator begin() { return val_op_iterator::begin(this); }
val_op_iterator end() { return val_op_iterator::end(this); }
const_val_op_iterator begin() const {
return const_val_op_iterator::begin(this);
}

View File

@@ -32,23 +32,33 @@ class GlobalValue;
/// 4. An optional constant value to be added to the reference.
/// 5. A bit, CanRewrite, which indicates to the JIT that a function stub is
/// not needed for the relocation.
/// 6. An index into the GOT, if the target uses a GOT
///
class MachineRelocation {
/// OffsetTypeExternal - The low 24-bits of this value is the offset from the
/// start of the code buffer of the relocation to perform. Bit 24 of this is
/// set if Target should use ExtSym instead of GV, Bit 25 is the CanRewrite
/// bit, and the high 6 bits hold the relocation type.
// FIXME: with the additional types of relocatable things, rearrange the
// storage of things to be a bit more effiecient
unsigned OffsetTypeExternal;
union {
GlobalValue *GV; // If this is a pointer to an LLVM global
const char *ExtSym; // If this is a pointer to a named symbol
void *Result; // If this has been resolved to a resolved pointer
unsigned GOTIndex; // Index in the GOT of this symbol/global
unsigned CPool; // Index in the Constant Pool
} Target;
intptr_t ConstantVal;
bool GOTRelative; //out of bits in OffsetTypeExternal
bool isConstPool;
public:
MachineRelocation(unsigned Offset, unsigned RelocationType, GlobalValue *GV,
intptr_t cst = 0, bool DoesntNeedFunctionStub = 0)
: OffsetTypeExternal(Offset + (RelocationType << 26)), ConstantVal(cst) {
intptr_t cst = 0, bool DoesntNeedFunctionStub = 0,
bool GOTrelative = 0)
: OffsetTypeExternal(Offset + (RelocationType << 26)), ConstantVal(cst),
GOTRelative(GOTrelative), isConstPool(0) {
assert((Offset & ~((1 << 24)-1)) == 0 && "Code offset too large!");
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
Target.GV = GV;
@@ -57,14 +67,23 @@ public:
}
MachineRelocation(unsigned Offset, unsigned RelocationType, const char *ES,
intptr_t cst = 0)
intptr_t cst = 0, bool GOTrelative = 0)
: OffsetTypeExternal(Offset + (1 << 24) + (RelocationType << 26)),
ConstantVal(cst) {
ConstantVal(cst), GOTRelative(GOTrelative), isConstPool(0) {
assert((Offset & ~((1 << 24)-1)) == 0 && "Code offset too large!");
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
Target.ExtSym = ES;
}
MachineRelocation(unsigned Offset, unsigned RelocationType, unsigned CPI,
intptr_t cst = 0)
: OffsetTypeExternal(Offset + (RelocationType << 26)),
ConstantVal(cst), GOTRelative(0), isConstPool(1) {
assert((Offset & ~((1 << 24)-1)) == 0 && "Code offset too large!");
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
Target.CPool = CPI;
}
/// getMachineCodeOffset - Return the offset into the code buffer that the
/// relocation should be performed.
unsigned getMachineCodeOffset() const {
@@ -87,13 +106,25 @@ public:
/// isGlobalValue - Return true if this relocation is a GlobalValue, as
/// opposed to a constant string.
bool isGlobalValue() const {
return (OffsetTypeExternal & (1 << 24)) == 0;
return (OffsetTypeExternal & (1 << 24)) == 0 && !isConstantPoolIndex();
}
/// isString - Return true if this is a constant string.
///
bool isString() const {
return !isGlobalValue();
return !isGlobalValue() && !isConstantPoolIndex();
}
/// isConstantPoolIndex - Return true if this is a constant pool reference.
///
bool isConstantPoolIndex() const {
return isConstPool;
}
/// isGOTRelative - Return true the target wants the index into the GOT of
/// the symbol rather than the address of the symbol.
bool isGOTRelative() const {
return GOTRelative;
}
/// doesntNeedFunctionStub - This function returns true if the JIT for this
@@ -119,6 +150,13 @@ public:
return Target.ExtSym;
}
/// getConstantPoolIndex - If this is a const pool reference, return
/// the index into the constant pool.
unsigned getConstantPoolIndex() const {
assert(isConstantPoolIndex() && "This is not a constant pool reference!");
return Target.CPool;
}
/// getResultPointer - Once this has been resolved to point to an actual
/// address, this returns the pointer.
void *getResultPointer() const {
@@ -130,6 +168,19 @@ public:
void setResultPointer(void *Ptr) {
Target.Result = Ptr;
}
/// setGOTIndex - Set the GOT index to a specific value.
void setGOTIndex(unsigned idx) {
Target.GOTIndex = idx;
}
/// getGOTIndex - Once this has been resolved to an entry in the GOT,
/// this returns that index. The index is from the lowest address entry
/// in the GOT.
unsigned getGOTIndex() const {
return Target.GOTIndex;
}
};
}

View File

@@ -70,11 +70,6 @@ namespace llvm {
///
FunctionPass *createLinearScanRegisterAllocator();
/// IterativeScanRegisterAllocation Pass - This pass implements the iterative
/// scan register allocation algorithm, a global register allocator.
///
FunctionPass *createIterativeScanRegisterAllocator();
/// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
/// and eliminates abstract frame references.
///

View File

@@ -66,6 +66,7 @@ public:
typedef std::vector<SDNode*>::const_iterator allnodes_iterator;
allnodes_iterator allnodes_begin() const { return AllNodes.begin(); }
allnodes_iterator allnodes_end() const { return AllNodes.end(); }
unsigned allnodes_size() const { return AllNodes.size(); }
/// getRoot - Return the root tag of the SelectionDAG.
///
@@ -79,6 +80,12 @@ public:
///
const SDOperand &setRoot(SDOperand N) { return Root = N; }
/// Combine - This iterates over the nodes in the SelectionDAG, folding
/// certain types of nodes together, or eliminating superfluous nodes. When
/// the AfterLegalize argument is set to 'true', Combine takes care not to
/// generate any nodes that will be illegal on the target.
void Combine(bool AfterLegalize);
/// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
/// compatible with the target instruction selector, as indicated by the
/// TargetLowering object.
@@ -94,36 +101,69 @@ public:
void RemoveDeadNodes(SDNode *N = 0);
SDOperand getConstant(uint64_t Val, MVT::ValueType VT);
SDOperand getTargetConstant(uint64_t Val, MVT::ValueType VT);
SDOperand getConstantFP(double Val, MVT::ValueType VT);
SDOperand getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT);
SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT);
SDOperand getFrameIndex(int FI, MVT::ValueType VT);
SDOperand getConstantPool(unsigned CPIdx, MVT::ValueType VT);
SDOperand getTargetFrameIndex(int FI, MVT::ValueType VT);
SDOperand getConstantPool(Constant *C, MVT::ValueType VT);
SDOperand getTargetConstantPool(Constant *C, MVT::ValueType VT);
SDOperand getBasicBlock(MachineBasicBlock *MBB);
SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT);
SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT);
SDOperand getValueType(MVT::ValueType);
SDOperand getRegister(unsigned Reg, MVT::ValueType VT);
SDOperand getCopyToReg(SDOperand Chain, SDOperand N, unsigned Reg) {
// Note: these are auto-CSE'd because the caller doesn't make requests that
// could cause duplicates to occur.
SDNode *NN = new RegSDNode(ISD::CopyToReg, Chain, N, Reg);
NN->setValueTypes(MVT::Other);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N) {
return getNode(ISD::CopyToReg, MVT::Other, Chain,
getRegister(Reg, N.getValueType()), N);
}
SDOperand getCopyFromReg(unsigned Reg, MVT::ValueType VT, SDOperand Chain) {
// Note: These nodes are auto-CSE'd by the caller of this method.
SDNode *NN = new RegSDNode(ISD::CopyFromReg, Chain, Reg);
NN->setValueTypes(VT, MVT::Other);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
// This version of the getCopyToReg method takes an extra operand, which
// indicates that there is potentially an incoming flag value (if Flag is not
// null) and that there should be a flag result.
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N,
SDOperand Flag) {
std::vector<MVT::ValueType> VTs;
VTs.push_back(MVT::Other);
VTs.push_back(MVT::Flag);
std::vector<SDOperand> Ops;
Ops.push_back(Chain);
Ops.push_back(getRegister(Reg, N.getValueType()));
Ops.push_back(N);
if (Flag.Val) Ops.push_back(Flag);
return getNode(ISD::CopyToReg, VTs, Ops);
}
SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
std::vector<MVT::ValueType> ResultTys;
ResultTys.push_back(VT);
ResultTys.push_back(MVT::Other);
std::vector<SDOperand> Ops;
Ops.push_back(Chain);
Ops.push_back(getRegister(Reg, VT));
return getNode(ISD::CopyFromReg, ResultTys, Ops);
}
// This version of the getCopyFromReg method takes an extra operand, which
// indicates that there is potentially an incoming flag value (if Flag is not
// null) and that there should be a flag result.
SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT,
SDOperand Flag) {
std::vector<MVT::ValueType> ResultTys;
ResultTys.push_back(VT);
ResultTys.push_back(MVT::Other);
ResultTys.push_back(MVT::Flag);
std::vector<SDOperand> Ops;
Ops.push_back(Chain);
Ops.push_back(getRegister(Reg, VT));
if (Flag.Val) Ops.push_back(Flag);
return getNode(ISD::CopyFromReg, ResultTys, Ops);
}
SDOperand getImplicitDef(SDOperand Chain, unsigned Reg) {
// Note: These nodes are auto-CSE'd by the caller of this method.
SDNode *NN = new RegSDNode(ISD::ImplicitDef, Chain, Reg);
NN->setValueTypes(MVT::Other);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
SDOperand getImplicitDef(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
return getNode(ISD::ImplicitDef, MVT::Other, Chain, getRegister(Reg, VT));
}
/// getCall - Note that this destroys the vector of RetVals passed in.
@@ -151,9 +191,7 @@ public:
return NN;
}
SDOperand getSetCC(ISD::CondCode, MVT::ValueType VT,
SDOperand LHS, SDOperand RHS);
SDOperand getCondCode(ISD::CondCode Cond);
/// getZeroExtendInReg - Return the expression required to zero extend the Op
/// value assuming it was the smaller SrcTy value.
@@ -169,62 +207,186 @@ public:
SDOperand N1, SDOperand N2, SDOperand N3);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
std::vector<SDOperand> &Children);
SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
std::vector<SDOperand> &Ops);
// getNode - These versions take an extra value type for extending and
// truncating loads, stores, rounds, extends etc.
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
SDOperand N2, MVT::ValueType EVT);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand N, MVT::ValueType EVT);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
SDOperand N2, SDOperand N3, MVT::ValueType EVT);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
SDOperand N2, SDOperand N3, SDOperand N4,
MVT::ValueType EVT);
/// getSetCC - Helper function to make it easier to build SetCC's if you just
/// have an ISD::CondCode instead of an SDOperand.
///
SDOperand getSetCC(MVT::ValueType VT, SDOperand LHS, SDOperand RHS,
ISD::CondCode Cond) {
return getNode(ISD::SETCC, VT, LHS, RHS, getCondCode(Cond));
}
/// getSelectCC - Helper function to make it easier to build SelectCC's if you
/// just have an ISD::CondCode instead of an SDOperand.
///
SDOperand getSelectCC(SDOperand LHS, SDOperand RHS,
SDOperand True, SDOperand False, ISD::CondCode Cond) {
MVT::ValueType VT = True.getValueType();
return getNode(ISD::SELECT_CC, VT, LHS, RHS, True, False,getCondCode(Cond));
}
/// getBR2Way_CC - Helper function to make it easier to build BRTWOWAY_CC
/// nodes.
///
SDOperand getBR2Way_CC(SDOperand Chain, SDOperand CCNode, SDOperand LHS,
SDOperand RHS, SDOperand True, SDOperand False) {
std::vector<SDOperand> Ops;
Ops.push_back(Chain);
Ops.push_back(CCNode);
Ops.push_back(LHS);
Ops.push_back(RHS);
Ops.push_back(True);
Ops.push_back(False);
return getNode(ISD::BRTWOWAY_CC, MVT::Other, Ops);
}
/// getLoad - Loads are not normal binary operators: their result type is not
/// determined by their operands, and they produce a value AND a token chain.
///
SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
SDOperand SV);
SDOperand getExtLoad(unsigned Opcode, MVT::ValueType VT, SDOperand Chain,
SDOperand Ptr, SDOperand SV, MVT::ValueType EVT);
// getSrcValue - construct a node to track a Value* through the backend
SDOperand getSrcValue(const Value* I, int offset = 0);
void replaceAllUsesWith(SDOperand Old, SDOperand New) {
assert(Old != New && "RAUW self!");
assert(0 && "Unimplemented!");
}
/// SelectNodeTo - These are used for target selectors to *mutate* the
/// specified node to have the specified return type, Target opcode, and
/// operands. Note that target opcodes are stored as
/// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field.
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3, SDOperand Op4);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3, SDOperand Op4,
SDOperand Op5);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
void SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
SDOperand Op3);
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2) {
std::vector<MVT::ValueType> ResultTys;
ResultTys.push_back(VT1);
ResultTys.push_back(VT2);
std::vector<SDOperand> Ops;
Ops.push_back(Op1);
Ops.push_back(Op2);
return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3,
SDOperand Op4) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3, Op4);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3,
SDOperand Op4, SDOperand Op5) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3, Op4, Op5);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
std::vector<SDOperand> &Ops) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops);
}
SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, std::vector<SDOperand> &Ops) {
std::vector<MVT::ValueType> ResultTys;
ResultTys.push_back(VT1);
ResultTys.push_back(VT2);
return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
}
/// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
/// This can cause recursive merging of nodes in the DAG. Use the first
/// version if 'From' is known to have a single result, use the second
/// if you have two nodes with identical results, use the third otherwise.
///
/// These methods all take an optional vector, which (if not null) is
/// populated with any nodes that are deleted from the SelectionDAG, due to
/// new equivalences that are discovered.
///
void ReplaceAllUsesWith(SDOperand From, SDOperand Op,
std::vector<SDNode*> *Deleted = 0);
void ReplaceAllUsesWith(SDNode *From, SDNode *To,
std::vector<SDNode*> *Deleted = 0);
void ReplaceAllUsesWith(SDNode *From, const std::vector<SDOperand> &To,
std::vector<SDNode*> *Deleted = 0);
/// DeleteNode - Remove the specified node from the system. This node must
/// have no referrers.
void DeleteNode(SDNode *N);
void dump() const;
private:
void RemoveNodeFromCSEMaps(SDNode *N);
SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
void DeleteNodeIfDead(SDNode *N, void *NodeSet);
void DeleteNodeNotInCSEMaps(SDNode *N);
/// SimplifySetCC - Try to simplify a setcc built with the specified operands
/// and cc. If unable to simplify it, return a null SDOperand.
SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N1,
SDOperand N2, ISD::CondCode Cond);
// Maps to auto-CSE operations.
std::map<std::pair<unsigned, MVT::ValueType>, SDNode *> NullaryOps;
std::map<std::pair<unsigned, std::pair<SDOperand, MVT::ValueType> >,
SDNode *> UnaryOps;
std::map<std::pair<unsigned, std::pair<SDOperand, SDOperand> >,
SDNode *> BinaryOps;
std::map<std::pair<std::pair<SDOperand, SDOperand>,
std::pair<ISD::CondCode, MVT::ValueType> >,
SetCCSDNode*> SetCCs;
std::map<std::pair<unsigned, MVT::ValueType>, RegisterSDNode*> RegNodes;
std::vector<CondCodeSDNode*> CondCodeNodes;
std::map<std::pair<SDOperand, std::pair<SDOperand, MVT::ValueType> >,
SDNode *> Loads;
std::map<const GlobalValue*, SDNode*> GlobalValues;
std::map<const GlobalValue*, SDNode*> TargetGlobalValues;
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> Constants;
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> TargetConstants;
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> ConstantFPs;
std::map<int, SDNode*> FrameIndices;
std::map<unsigned, SDNode*> ConstantPoolIndices;
std::map<int, SDNode*> FrameIndices, TargetFrameIndices;
std::map<Constant *, SDNode*> ConstantPoolIndices;
std::map<Constant *, SDNode*> TargetConstantPoolIndices;
std::map<MachineBasicBlock *, SDNode*> BBNodes;
std::vector<SDNode*> ValueTypeNodes;
std::map<std::string, SDNode*> ExternalSymbols;
std::map<std::string, SDNode*> TargetExternalSymbols;
std::map<std::pair<unsigned,
std::pair<MVT::ValueType, std::vector<SDOperand> > >,
SDNode*> OneResultNodes;
@@ -232,23 +394,6 @@ private:
std::pair<std::vector<MVT::ValueType>,
std::vector<SDOperand> > >,
SDNode*> ArbitraryNodes;
std::map<std::string, SDNode*> ExternalSymbols;
struct EVTStruct {
unsigned Opcode;
MVT::ValueType VT, EVT;
std::vector<SDOperand> Ops;
bool operator<(const EVTStruct &RHS) const {
if (Opcode < RHS.Opcode) return true;
if (Opcode > RHS.Opcode) return false;
if (VT < RHS.VT) return true;
if (VT > RHS.VT) return false;
if (EVT < RHS.EVT) return true;
if (EVT > RHS.EVT) return false;
return Ops < RHS.Ops;
}
};
std::map<EVTStruct, SDNode*> MVTSDNodes;
};
template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {

View File

@@ -40,9 +40,7 @@ public:
SelectionDAGISel(TargetLowering &tli) : TLI(tli) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual bool runOnFunction(Function &Fn);
@@ -51,6 +49,11 @@ public:
virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
virtual void InstructionSelectBasicBlock(SelectionDAG &SD) = 0;
protected:
/// Pick a safe ordering and emit instructions for each target node in the
/// graph.
void ScheduleAndEmitDAG(SelectionDAG &SD);
private:
SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
Value *V, unsigned Reg);

View File

@@ -48,19 +48,36 @@ namespace ISD {
// EntryToken - This is the marker used to indicate the start of the region.
EntryToken,
// Token factor - This node is takes multiple tokens as input and produces a
// Token factor - This node takes multiple tokens as input and produces a
// single token result. This is used to represent the fact that the operand
// operators are independent of each other.
TokenFactor,
// AssertSext, AssertZext - These nodes record if a register contains a
// value that has already been zero or sign extended from a narrower type.
// These nodes take two operands. The first is the node that has already
// been extended, and the second is a value type node indicating the width
// of the extension
AssertSext, AssertZext,
// Various leaf nodes.
Constant, ConstantFP, GlobalAddress, FrameIndex, ConstantPool,
BasicBlock, ExternalSymbol,
BasicBlock, ExternalSymbol, VALUETYPE, CONDCODE, Register,
// TargetConstant - Like Constant, but the DAG does not do any folding or
// simplification of the constant. This is used by the DAG->DAG selector.
TargetConstant,
// TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
// anything else with this node, and this is valid in the target-specific
// dag, turning into a GlobalAddress operand.
TargetGlobalAddress,
TargetFrameIndex,
TargetConstantPool,
TargetExternalSymbol,
// CopyToReg - This node has chain and child nodes, and an associated
// register number. The instruction selector must guarantee that the value
// of the value node is available in the register stored in the RegSDNode
// object.
// CopyToReg - This node has three operands: a chain, a register number to
// set to this value, and a value.
CopyToReg,
// CopyFromReg - This node indicates that the input value is a virtual or
@@ -69,10 +86,9 @@ namespace ISD {
CopyFromReg,
// ImplicitDef - This node indicates that the specified register is
// implicitly defined by some operation (e.g. its a live-in argument). This
// register is indicated in the RegSDNode object. The only operand to this
// is the token chain coming in, the only result is the token chain going
// out.
// implicitly defined by some operation (e.g. its a live-in argument). The
// two operands to this are the token chain coming in and the register.
// The only result is the token chain going out.
ImplicitDef,
// UNDEF - An undefined node
@@ -90,8 +106,11 @@ namespace ISD {
BUILD_PAIR,
// Simple binary arithmetic operators.
// Simple integer binary arithmetic operators.
ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
// Simple binary floating point operators.
FADD, FSUB, FMUL, FDIV, FREM,
// MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
// an unsigned/signed value of type i[2*n], then return the top part.
@@ -103,13 +122,19 @@ namespace ISD {
// Counting operators
CTTZ, CTLZ, CTPOP,
// Select operator.
SELECT,
// Select
SELECT,
// Select with condition operator - This selects between a true value and
// a false value (ops #2 and #3) based on the boolean result of comparing
// the lhs and rhs (ops #0 and #1) of a conditional expression with the
// condition code in op #4, a CondCodeSDNode.
SELECT_CC,
// SetCC operator - This evaluates to a boolean (i1) true value if the
// condition is true. These nodes are instances of the
// SetCCSDNode class, which contains the condition code as extra
// state.
// condition is true. The operands to this are the left and right operands
// to compare (ops #0, and #1) and the condition code to compare them with
// (op #2) as a CondCodeSDNode.
SETCC,
// ADD_PARTS/SUB_PARTS - These operators take two logical operands which are
@@ -137,6 +162,9 @@ namespace ISD {
// ZERO_EXTEND - Used for integer types, zeroing the new bits.
ZERO_EXTEND,
// ANY_EXTEND - Used for integer types. The high bits are undefined.
ANY_EXTEND,
// TRUNCATE - Completely drop the high bits.
TRUNCATE,
@@ -148,8 +176,8 @@ namespace ISD {
// SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
// sign extend a small value in a large integer register (e.g. sign
// extending the low 8 bits of a 32-bit register to fill the top 24 bits
// with the 7th bit). The size of the smaller type is indicated by the
// ExtraValueType in the MVTSDNode for the operator.
// with the 7th bit). The size of the smaller type is indicated by the 1th
// operand, a ValueType node.
SIGN_EXTEND_INREG,
// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
@@ -164,8 +192,8 @@ namespace ISD {
// FP_ROUND_INREG - This operator takes a floating point register, and
// rounds it to a floating point value. It then promotes it and returns it
// in a register of the same size. This operation effectively just discards
// excess precision. The type to round down to is specified by the
// ExtraValueType in the MVTSDNode (currently always 64->32->64).
// excess precision. The type to round down to is specified by the 1th
// operation, a VTSDNode (currently always 64->32->64).
FP_ROUND_INREG,
// FP_EXTEND - Extend a smaller FP type into a larger FP type.
@@ -176,14 +204,15 @@ namespace ISD {
FNEG, FABS, FSQRT, FSIN, FCOS,
// Other operators. LOAD and STORE have token chains as their first
// operand, then the same operands as an LLVM load/store instruction.
// operand, then the same operands as an LLVM load/store instruction, then a
// SRCVALUE node that provides alias analysis information.
LOAD, STORE,
// EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators are instances of the
// MVTSDNode. All of these load a value from memory and extend them to a
// larger value (e.g. load a byte into a word register). All three of these
// have two operands, a chain and a pointer to load from. The extra value
// type is the source type being loaded.
// EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators all load a value from
// memory and extend them to a larger value (e.g. load a byte into a word
// register). All three of these have four operands, a token chain, a
// pointer to load from, a SRCVALUE for alias analysis, and a VALUETYPE node
// indicating the type to load.
//
// SEXTLOAD loads the integer operand and sign extends it to a larger
// integer result type.
@@ -197,15 +226,17 @@ namespace ISD {
// TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
// value and stores it to memory in one operation. This can be used for
// either integer or floating point operands, and the stored type
// represented as the 'extra' value type in the MVTSDNode representing the
// operator. This node has the same three operands as a standard store.
// either integer or floating point operands. The first four operands of
// this are the same as a standard store. The fifth is the ValueType to
// store it as (which will be smaller than the source value).
TRUNCSTORE,
// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
// to a specified boundary. The first operand is the token chain, the
// second is the number of bytes to allocate, and the third is the alignment
// boundary.
// boundary. The size is guaranteed to be a multiple of the stack
// alignment, and the alignment is guaranteed to be bigger than the stack
// alignment (if required) or 0 to get standard stack alignment.
DYNAMIC_STACKALLOC,
// Control flow instructions. These all have token chains.
@@ -226,6 +257,18 @@ namespace ISD {
// operation to BRCOND/BR pairs when necessary.
BRCONDTWOWAY,
// BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in
// that the condition is represented as condition code, and two nodes to
// compare, rather than as a combined SetCC node. The operands in order are
// chain, cc, lhs, rhs, block to branch to if condition is true.
BR_CC,
// BRTWOWAY_CC - Two-way conditional branch. The operands in order are
// chain, cc, lhs, rhs, block to branch to if condition is true, block to
// branch to if condition is false. Targets usually do not implement this,
// preferring to have legalize demote the operation to BRCOND/BR pairs.
BRTWOWAY_CC,
// RET - Return from function. The first operand is the chain,
// and any subsequent operands are the return values for the
// function. This operation can have variable number of operands.
@@ -267,6 +310,9 @@ namespace ISD {
// other operands match the intrinsic. These produce a token chain in
// addition to a value (if any).
READPORT, WRITEPORT, READIO, WRITEIO,
// HANDLENODE node - Used as a handle for various purposes.
HANDLENODE,
// BUILTIN_OP_END - This must be the last enum value in this list.
BUILTIN_OP_END,
@@ -408,6 +454,8 @@ public:
inline unsigned getNodeDepth() const;
inline unsigned getNumOperands() const;
inline const SDOperand &getOperand(unsigned i) const;
inline bool isTargetOpcode() const;
inline unsigned getTargetOpcode() const;
/// hasOneUse - Return true if there is exactly one operation using this
/// result value of the defining operator.
@@ -460,6 +508,11 @@ public:
// Accessors
//
unsigned getOpcode() const { return NodeType; }
bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
unsigned getTargetOpcode() const {
assert(isTargetOpcode() && "Not a target opcode!");
return NodeType - ISD::BUILTIN_OP_END;
}
size_t use_size() const { return Uses.size(); }
bool use_empty() const { return Uses.empty(); }
@@ -507,22 +560,23 @@ public:
assert(ResNo < Values.size() && "Illegal result number!");
return Values[ResNo];
}
typedef std::vector<MVT::ValueType>::const_iterator value_iterator;
value_iterator value_begin() const { return Values.begin(); }
value_iterator value_end() const { return Values.end(); }
/// getOperationName - Return the opcode of this operation for printing.
///
const char* getOperationName() const;
const char* getOperationName(const SelectionDAG *G = 0) const;
void dump() const;
void dump(const SelectionDAG *G) const;
static bool classof(const SDNode *) { return true; }
/// setAdjCallChain - This method should only be used by the legalizer.
void setAdjCallChain(SDOperand N);
protected:
friend class SelectionDAG;
@@ -585,10 +639,24 @@ protected:
NodeDepth = ND+1;
}
virtual ~SDNode() {
// FIXME: Drop uses.
}
virtual ~SDNode() {}
/// MorphNodeTo - This clears the return value and operands list, and sets the
/// opcode of the node to the specified value. This should only be used by
/// the SelectionDAG class.
void MorphNodeTo(unsigned Opc) {
NodeType = Opc;
Values.clear();
// Clear the operands list, updating used nodes to remove this from their
// use list.
while (!Operands.empty()) {
SDNode *O = Operands.back().Val;
Operands.pop_back();
O->removeUser(this);
}
}
void setValueTypes(MVT::ValueType VT) {
Values.reserve(1);
Values.push_back(VT);
@@ -602,14 +670,58 @@ protected:
void setValueTypes(std::vector<MVT::ValueType> &VTs) {
std::swap(Values, VTs);
}
void setOperands(SDOperand Op0) {
Operands.reserve(1);
Operands.push_back(Op0);
Op0.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1) {
Operands.reserve(2);
Operands.push_back(Op0);
Operands.push_back(Op1);
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2) {
Operands.reserve(3);
Operands.push_back(Op0);
Operands.push_back(Op1);
Operands.push_back(Op2);
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
Op2.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3) {
Operands.reserve(4);
Operands.push_back(Op0);
Operands.push_back(Op1);
Operands.push_back(Op2);
Operands.push_back(Op3);
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3,
SDOperand Op4) {
Operands.reserve(5);
Operands.push_back(Op0);
Operands.push_back(Op1);
Operands.push_back(Op2);
Operands.push_back(Op3);
Operands.push_back(Op4);
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this);
Op4.Val->Uses.push_back(this);
}
void addUser(SDNode *User) {
Uses.push_back(User);
}
void removeUser(SDNode *User) {
// Remove this user from the operand's use list.
for (unsigned i = Uses.size(); ; --i) {
assert(i != 0 && "Didn't find user!");
if (Uses[i-1] == User) {
Uses.erase(Uses.begin()+i-1);
break;
Uses[i-1] = Uses.back();
Uses.pop_back();
return;
}
}
}
@@ -633,17 +745,37 @@ inline unsigned SDOperand::getNumOperands() const {
inline const SDOperand &SDOperand::getOperand(unsigned i) const {
return Val->getOperand(i);
}
inline bool SDOperand::isTargetOpcode() const {
return Val->isTargetOpcode();
}
inline unsigned SDOperand::getTargetOpcode() const {
return Val->getTargetOpcode();
}
inline bool SDOperand::hasOneUse() const {
return Val->hasNUsesOfValue(1, ResNo);
}
/// HandleSDNode - This class is used to form a handle around another node that
/// is persistant and is updated across invocations of replaceAllUsesWith on its
/// operand. This node should be directly created by end-users and not added to
/// the AllNodes list.
class HandleSDNode : public SDNode {
public:
HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, X) {}
~HandleSDNode() {
MorphNodeTo(ISD::HANDLENODE); // Drops operand uses.
}
SDOperand getValue() const { return getOperand(0); }
};
class ConstantSDNode : public SDNode {
uint64_t Value;
protected:
friend class SelectionDAG;
ConstantSDNode(uint64_t val, MVT::ValueType VT)
: SDNode(ISD::Constant, VT), Value(val) {
ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, VT), Value(val) {
}
public:
@@ -663,7 +795,8 @@ public:
static bool classof(const ConstantSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::Constant;
return N->getOpcode() == ISD::Constant ||
N->getOpcode() == ISD::TargetConstant;
}
};
@@ -682,19 +815,7 @@ public:
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values.
bool isExactlyValue(double V) const {
union {
double V;
uint64_t I;
} T1;
T1.V = Value;
union {
double V;
uint64_t I;
} T2;
T2.V = V;
return T1.I == T2.I;
}
bool isExactlyValue(double V) const;
static bool classof(const ConstantFPSDNode *) { return true; }
static bool classof(const SDNode *N) {
@@ -706,8 +827,8 @@ class GlobalAddressSDNode : public SDNode {
GlobalValue *TheGlobal;
protected:
friend class SelectionDAG;
GlobalAddressSDNode(const GlobalValue *GA, MVT::ValueType VT)
: SDNode(ISD::GlobalAddress, VT) {
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT)
: SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, VT) {
TheGlobal = const_cast<GlobalValue*>(GA);
}
public:
@@ -716,7 +837,8 @@ public:
static bool classof(const GlobalAddressSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::GlobalAddress;
return N->getOpcode() == ISD::GlobalAddress ||
N->getOpcode() == ISD::TargetGlobalAddress;
}
};
@@ -725,31 +847,34 @@ class FrameIndexSDNode : public SDNode {
int FI;
protected:
friend class SelectionDAG;
FrameIndexSDNode(int fi, MVT::ValueType VT)
: SDNode(ISD::FrameIndex, VT), FI(fi) {}
FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
: SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, VT), FI(fi) {}
public:
int getIndex() const { return FI; }
static bool classof(const FrameIndexSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::FrameIndex;
return N->getOpcode() == ISD::FrameIndex ||
N->getOpcode() == ISD::TargetFrameIndex;
}
};
class ConstantPoolSDNode : public SDNode {
unsigned CPI;
Constant *C;
protected:
friend class SelectionDAG;
ConstantPoolSDNode(unsigned cpi, MVT::ValueType VT)
: SDNode(ISD::ConstantPool, VT), CPI(cpi) {}
ConstantPoolSDNode(Constant *c, MVT::ValueType VT, bool isTarget)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
C(c) {}
public:
unsigned getIndex() const { return CPI; }
Constant *get() const { return C; }
static bool classof(const ConstantPoolSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::ConstantPool;
return N->getOpcode() == ISD::ConstantPool ||
N->getOpcode() == ISD::TargetConstantPool;
}
};
@@ -788,24 +913,19 @@ public:
};
class RegSDNode : public SDNode {
class RegisterSDNode : public SDNode {
unsigned Reg;
protected:
friend class SelectionDAG;
RegSDNode(unsigned Opc, SDOperand Chain, SDOperand Src, unsigned reg)
: SDNode(Opc, Chain, Src), Reg(reg) {
}
RegSDNode(unsigned Opc, SDOperand Chain, unsigned reg)
: SDNode(Opc, Chain), Reg(reg) {}
RegisterSDNode(unsigned reg, MVT::ValueType VT)
: SDNode(ISD::Register, VT), Reg(reg) {}
public:
unsigned getReg() const { return Reg; }
static bool classof(const RegSDNode *) { return true; }
static bool classof(const RegisterSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::CopyToReg ||
N->getOpcode() == ISD::CopyFromReg ||
N->getOpcode() == ISD::ImplicitDef;
return N->getOpcode() == ISD::Register;
}
};
@@ -813,8 +933,9 @@ class ExternalSymbolSDNode : public SDNode {
const char *Symbol;
protected:
friend class SelectionDAG;
ExternalSymbolSDNode(const char *Sym, MVT::ValueType VT)
: SDNode(ISD::ExternalSymbol, VT), Symbol(Sym) {
ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
: SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, VT),
Symbol(Sym) {
}
public:
@@ -822,64 +943,47 @@ public:
static bool classof(const ExternalSymbolSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::ExternalSymbol;
return N->getOpcode() == ISD::ExternalSymbol ||
N->getOpcode() == ISD::TargetExternalSymbol;
}
};
class SetCCSDNode : public SDNode {
class CondCodeSDNode : public SDNode {
ISD::CondCode Condition;
protected:
friend class SelectionDAG;
SetCCSDNode(ISD::CondCode Cond, SDOperand LHS, SDOperand RHS)
: SDNode(ISD::SETCC, LHS, RHS), Condition(Cond) {
CondCodeSDNode(ISD::CondCode Cond)
: SDNode(ISD::CONDCODE, MVT::Other), Condition(Cond) {
}
public:
ISD::CondCode getCondition() const { return Condition; }
ISD::CondCode get() const { return Condition; }
static bool classof(const SetCCSDNode *) { return true; }
static bool classof(const CondCodeSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::SETCC;
return N->getOpcode() == ISD::CONDCODE;
}
};
/// MVTSDNode - This class is used for operators that require an extra
/// value-type to be kept with the node.
class MVTSDNode : public SDNode {
MVT::ValueType ExtraValueType;
/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
/// to parameterize some operations.
class VTSDNode : public SDNode {
MVT::ValueType ValueType;
protected:
friend class SelectionDAG;
MVTSDNode(unsigned Opc, MVT::ValueType VT1, SDOperand Op0, MVT::ValueType EVT)
: SDNode(Opc, Op0), ExtraValueType(EVT) {
setValueTypes(VT1);
}
MVTSDNode(unsigned Opc, MVT::ValueType VT1, MVT::ValueType VT2,
SDOperand Op0, SDOperand Op1, SDOperand Op2, MVT::ValueType EVT)
: SDNode(Opc, Op0, Op1, Op2), ExtraValueType(EVT) {
setValueTypes(VT1, VT2);
}
MVTSDNode(unsigned Opc, MVT::ValueType VT,
SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3, MVT::ValueType EVT)
: SDNode(Opc, Op0, Op1, Op2, Op3), ExtraValueType(EVT) {
setValueTypes(VT);
}
VTSDNode(MVT::ValueType VT)
: SDNode(ISD::VALUETYPE, MVT::Other), ValueType(VT) {}
public:
MVT::ValueType getExtraValueType() const { return ExtraValueType; }
MVT::ValueType getVT() const { return ValueType; }
static bool classof(const MVTSDNode *) { return true; }
static bool classof(const VTSDNode *) { return true; }
static bool classof(const SDNode *N) {
return
N->getOpcode() == ISD::SIGN_EXTEND_INREG ||
N->getOpcode() == ISD::FP_ROUND_INREG ||
N->getOpcode() == ISD::EXTLOAD ||
N->getOpcode() == ISD::SEXTLOAD ||
N->getOpcode() == ISD::ZEXTLOAD ||
N->getOpcode() == ISD::TRUNCSTORE;
return N->getOpcode() == ISD::VALUETYPE;
}
};
class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
SDNode *Node;
unsigned Operand;
@@ -931,9 +1035,6 @@ template <> struct GraphTraits<SDNode*> {
}
};
} // end llvm namespace
#endif

View File

@@ -40,8 +40,9 @@ namespace MVT { // MVT = Machine Value Types
f64 = 8, // This is a 64 bit floating point value
f80 = 9, // This is a 80 bit floating point value
f128 = 10, // This is a 128 bit floating point value
Flag = 11, // This is a condition code or machine flag.
isVoid = 11, // This has no value
isVoid = 12, // This has no value
LAST_VALUETYPE, // This always remains at the end of the list.
};

View File

@@ -11,6 +11,9 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define if threads enabled */
#undef ENABLE_THREADS
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
@@ -121,6 +124,12 @@
/* Does not have hash_set in gnu namespace */
#undef HAVE_GNU_EXT_HASH_SET
/* Define if the Graphviz program is available */
#undef HAVE_GRAPHVIZ
/* Define if the gv program is available */
#undef HAVE_GV
/* Define to 1 if you have the `index' function. */
#undef HAVE_INDEX
@@ -151,6 +160,9 @@
/* Define to 1 if you have the `elf' library (-lelf). */
#undef HAVE_LIBELF
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -216,6 +228,9 @@
/* Define to have the %a format string */
#undef HAVE_PRINTF_A
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Have pthread_mutex_lock */
#undef HAVE_PTHREAD_MUTEX_LOCK
@@ -383,6 +398,12 @@
/* Define if this is Win32ish platform */
#undef LLVM_ON_WIN32
/* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */
#undef LLVM_PATH_GRAPHVIZ
/* Define to path to gv program if found or 'echo gv' otherwise */
#undef LLVM_PATH_GV
/* Installation prefix directory */
#undef LLVM_PREFIX

View File

@@ -61,12 +61,8 @@ public:
static inline bool classof(const Constant *) { return true; }
static inline bool classof(const GlobalValue *) { return true; }
static inline bool classof(const Value *V) {
return V->getValueType() == Value::SimpleConstantVal ||
V->getValueType() == Value::ConstantExprVal ||
V->getValueType() == Value::ConstantAggregateZeroVal ||
V->getValueType() == Value::FunctionVal ||
V->getValueType() == Value::GlobalVariableVal ||
V->getValueType() == Value::UndefValueVal;
return V->getValueType() >= ConstantFirstVal &&
V->getValueType() <= ConstantLastVal;
}
/// replaceUsesOfWithOnConstant - This method is a special form of
@@ -79,8 +75,7 @@ public:
/// use Value::replaceAllUsesWith, which automatically dispatches to this
/// method as needed.
///
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false) {
virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) {
// Provide a default implementation for constants (like integers) that
// cannot use any other values. This cannot be called at runtime, but needs
// to be here to avoid link errors.

View File

@@ -47,14 +47,28 @@ protected:
int64_t Signed;
uint64_t Unsigned;
} Val;
ConstantIntegral(const Type *Ty, uint64_t V);
ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
public:
/// getRawValue - return the underlying value of this constant as a 64-bit
/// unsigned integer value.
///
inline uint64_t getRawValue() const { return Val.Unsigned; }
/// getZExtValue - Return the constant zero extended as appropriate for this
/// type.
inline uint64_t getZExtValue() const {
unsigned Size = getType()->getPrimitiveSizeInBits();
return Val.Unsigned & (~0ULL >> (64-Size));
}
/// getSExtValue - Return the constant sign extended as appropriate for this
/// type.
inline int64_t getSExtValue() const {
unsigned Size = getType()->getPrimitiveSizeInBits();
return (Val.Signed << (64-Size)) >> (64-Size);
}
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue.
///
@@ -84,8 +98,9 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantIntegral *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->isIntegral();
return V->getValueType() == ConstantBoolVal ||
V->getValueType() == ConstantSIntVal ||
V->getValueType() == ConstantUIntVal;
}
};
@@ -120,7 +135,7 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantBool *) { return true; }
static bool classof(const Value *V) {
return (V == True) | (V == False);
return V->getValueType() == ConstantBoolVal;
}
};
@@ -132,7 +147,7 @@ public:
class ConstantInt : public ConstantIntegral {
protected:
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
ConstantInt(const Type *Ty, uint64_t V);
ConstantInt(const Type *Ty, ValueTy VT, uint64_t V);
public:
/// equalsInt - Provide a helper method that can be used to determine if the
/// constant contained within is equal to a constant. This only works for
@@ -159,8 +174,8 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantInt *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->isInteger();
return V->getValueType() == ConstantSIntVal ||
V->getValueType() == ConstantUIntVal;
}
};
@@ -213,8 +228,7 @@ public:
///
static inline bool classof(const ConstantSInt *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->isSigned();
return V->getValueType() == ConstantSIntVal;
}
};
@@ -249,8 +263,7 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantUInt *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->isUnsigned();
return V->getValueType() == ConstantUIntVal;
}
};
@@ -276,38 +289,18 @@ public:
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. Don't depend on == for doubles to tell us it's zero, it
/// considers -0.0 to be null as well as 0.0. :(
virtual bool isNullValue() const {
union {
double V;
uint64_t I;
} T;
T.V = Val;
return T.I == 0;
}
virtual bool isNullValue() const;
/// isExactlyValue - We don't rely on operator== working on double values, as
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values.
bool isExactlyValue(double V) const {
union {
double V;
uint64_t I;
} T1;
T1.V = Val;
union {
double V;
uint64_t I;
} T2;
T2.V = V;
return T1.I == T2.I;
}
bool isExactlyValue(double V) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantFP *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->isFloatingPoint();
return V->getValueType() == ConstantFPVal;
}
};
@@ -330,8 +323,6 @@ public:
virtual bool isNullValue() const { return true; }
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
///
@@ -379,14 +370,12 @@ public:
virtual bool isNullValue() const { return false; }
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantArray *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->getTypeID() == Type::ArrayTyID;
return V->getValueType() == ConstantArrayVal;
}
};
@@ -421,14 +410,12 @@ public:
}
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantStruct *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->getTypeID() == Type::StructTyID;
return V->getValueType() == ConstantStructVal;
}
};
@@ -460,14 +447,12 @@ public:
virtual bool isNullValue() const { return false; }
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantPacked *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
V->getType()->getTypeID() == Type::PackedTyID;
return V->getValueType() == ConstantPackedVal;
}
};
@@ -480,7 +465,7 @@ class ConstantPointerNull : public Constant {
protected:
ConstantPointerNull(const PointerType *T)
: Constant(reinterpret_cast<const Type*>(T),
Value::SimpleConstantVal, 0, 0) {}
Value::ConstantPointerNullVal, 0, 0) {}
public:
@@ -503,8 +488,7 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantPointerNull *) { return true; }
static bool classof(const Value *V) {
return V->getValueType() == SimpleConstantVal &&
isa<PointerType>(V->getType());
return V->getValueType() == ConstantPointerNullVal;
}
};
@@ -615,8 +599,7 @@ public:
const char *getOpcodeName() const;
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
/// Override methods to provide more type information...
inline Constant *getOperand(unsigned i) {

View File

@@ -19,6 +19,7 @@
#include <map>
#include <cassert>
#include <string>
#include "llvm/Support/MutexGuard.h"
namespace llvm {
@@ -33,10 +34,9 @@ class TargetData;
class Type;
class IntrinsicLowering;
class ExecutionEngine {
Module &CurMod;
const TargetData *TD;
class ExecutionEngineState {
private:
/// GlobalAddressMap - A mapping between LLVM global values and their
/// actualized version...
std::map<const GlobalValue*, void *> GlobalAddressMap;
@@ -46,6 +46,24 @@ class ExecutionEngine {
/// at the address. This map is not computed unless getGlobalValueAtAddress
/// is called at some point.
std::map<void *, const GlobalValue*> GlobalAddressReverseMap;
public:
std::map<const GlobalValue*, void *>& getGlobalAddressMap(const MutexGuard& locked) {
return GlobalAddressMap;
}
std::map<void *, const GlobalValue*>& getGlobalAddressReverseMap(const MutexGuard& locked) {
return GlobalAddressReverseMap;
}
};
class ExecutionEngine {
Module &CurMod;
const TargetData *TD;
ExecutionEngineState state;
protected:
ModuleProvider *MP;
@@ -54,6 +72,10 @@ protected:
}
public:
/// lock - This lock is protects the ExecutionEngine, JIT, JITResolver and JITEmitter classes.
/// It must be held while changing the internal state of any of those classes.
sys::Mutex lock; // Used to make this class and subclasses thread-safe
ExecutionEngine(ModuleProvider *P);
ExecutionEngine(Module *M);
virtual ~ExecutionEngine();
@@ -81,13 +103,15 @@ public:
void addGlobalMapping(const GlobalValue *GV, void *Addr) {
void *&CurVal = GlobalAddressMap[GV];
MutexGuard locked(lock);
void *&CurVal = state.getGlobalAddressMap(locked)[GV];
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
CurVal = Addr;
// If we are using the reverse mapping, add it too
if (!GlobalAddressReverseMap.empty()) {
const GlobalValue *&V = GlobalAddressReverseMap[Addr];
if (!state.getGlobalAddressReverseMap(locked).empty()) {
const GlobalValue *&V = state.getGlobalAddressReverseMap(locked)[Addr];
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
V = GV;
}
@@ -96,21 +120,25 @@ public:
/// clearAllGlobalMappings - Clear all global mappings and start over again
/// use in dynamic compilation scenarios when you want to move globals
void clearAllGlobalMappings() {
GlobalAddressMap.clear();
GlobalAddressReverseMap.clear();
MutexGuard locked(lock);
state.getGlobalAddressMap(locked).clear();
state.getGlobalAddressReverseMap(locked).clear();
}
/// updateGlobalMapping - Replace an existing mapping for GV with a new
/// address. This updates both maps as required.
void updateGlobalMapping(const GlobalValue *GV, void *Addr) {
void *&CurVal = GlobalAddressMap[GV];
if (CurVal && !GlobalAddressReverseMap.empty())
GlobalAddressReverseMap.erase(CurVal);
MutexGuard locked(lock);
void *&CurVal = state.getGlobalAddressMap(locked)[GV];
if (CurVal && !state.getGlobalAddressReverseMap(locked).empty())
state.getGlobalAddressReverseMap(locked).erase(CurVal);
CurVal = Addr;
// If we are using the reverse mapping, add it too
if (!GlobalAddressReverseMap.empty()) {
const GlobalValue *&V = GlobalAddressReverseMap[Addr];
if (!state.getGlobalAddressReverseMap(locked).empty()) {
const GlobalValue *&V = state.getGlobalAddressReverseMap(locked)[Addr];
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
V = GV;
}
@@ -120,8 +148,10 @@ public:
/// global value if it is available, otherwise it returns null.
///
void *getPointerToGlobalIfAvailable(const GlobalValue *GV) {
std::map<const GlobalValue*, void*>::iterator I = GlobalAddressMap.find(GV);
return I != GlobalAddressMap.end() ? I->second : 0;
MutexGuard locked(lock);
std::map<const GlobalValue*, void*>::iterator I = state.getGlobalAddressMap(locked).find(GV);
return I != state.getGlobalAddressMap(locked).end() ? I->second : 0;
}
/// getPointerToGlobal - This returns the address of the specified global

View File

@@ -57,8 +57,6 @@ public:
typedef ArgumentListType::iterator arg_iterator;
typedef ArgumentListType::const_iterator const_arg_iterator;
typedef arg_iterator aiterator; // legacy, deprecated
typedef const_arg_iterator const_aiterator; // legacy, deprecated
private:
// Important things that make up a function!

View File

@@ -101,7 +101,7 @@ public:
void removeDeadConstantUsers();
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const GlobalValue *T) { return true; }
static inline bool classof(const GlobalValue *) { return true; }
static inline bool classof(const Value *V) {
return V->getValueType() == Value::FunctionVal ||
V->getValueType() == Value::GlobalVariableVal;

View File

@@ -113,8 +113,7 @@ public:
/// Override Constant's implementation of this method so we can
/// replace constant initializers.
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
virtual void print(std::ostream &OS) const;

View File

@@ -128,13 +128,14 @@ HANDLE_OTHER_INST(29, Call , CallInst ) // Call a function
HANDLE_OTHER_INST(30, Shl , ShiftInst ) // Shift operations
HANDLE_OTHER_INST(31, Shr , ShiftInst )
HANDLE_OTHER_INST(32, VANext , VANextInst ) // vanext instruction
HANDLE_OTHER_INST(33, VAArg , VAArgInst ) // vaarg instruction
// 32 -> Empty slot used to be used for vanext in llvm 1.5 and before.
// 33 -> Empty slot used to be used for vaarg in llvm 1.5 and before.
HANDLE_OTHER_INST(34, Select , SelectInst ) // select instruction
HANDLE_OTHER_INST(35, UserOp1, Instruction) // May be used internally in a pass
HANDLE_OTHER_INST(36, UserOp2, Instruction)
LAST_OTHER_INST(36)
HANDLE_OTHER_INST(37, VAArg , VAArgInst ) // vaarg instruction
LAST_OTHER_INST(37)
#undef FIRST_TERM_INST
#undef HANDLE_TERM_INST

View File

@@ -93,6 +93,11 @@ public:
///
void eraseFromParent();
/// moveBefore - Unlink this instruction from its current basic block and
/// insert it into the basic block that MovePos lives in, right before
/// MovePos.
void moveBefore(Instruction *MovePos);
// ---------------------------------------------------------------------------
/// Subclass classification... getOpcode() returns a member of
/// one of the enums that is coming soon (down below)...
@@ -152,7 +157,7 @@ public:
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Instruction *I) { return true; }
static inline bool classof(const Instruction *) { return true; }
static inline bool classof(const Value *V) {
return V->getValueType() >= Value::InstructionVal;
}

View File

@@ -660,55 +660,12 @@ public:
}
};
//===----------------------------------------------------------------------===//
// VANextInst Class
//===----------------------------------------------------------------------===//
/// VANextInst - This class represents the va_next llvm instruction, which
/// advances a vararg list passed an argument of the specified type, returning
/// the resultant list.
///
class VANextInst : public UnaryInstruction {
PATypeHolder ArgTy;
VANextInst(const VANextInst &VAN)
: UnaryInstruction(VAN.getType(), VANext, VAN.getOperand(0)),
ArgTy(VAN.getArgType()) {
}
public:
VANextInst(Value *List, const Type *Ty, const std::string &Name = "",
Instruction *InsertBefore = 0)
: UnaryInstruction(List->getType(), VANext, List, Name, InsertBefore),
ArgTy(Ty) {
}
VANextInst(Value *List, const Type *Ty, const std::string &Name,
BasicBlock *InsertAtEnd)
: UnaryInstruction(List->getType(), VANext, List, Name, InsertAtEnd),
ArgTy(Ty) {
}
const Type *getArgType() const { return ArgTy; }
virtual VANextInst *clone() const;
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const VANextInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == VANext;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
//===----------------------------------------------------------------------===//
// VAArgInst Class
//===----------------------------------------------------------------------===//
/// VAArgInst - This class represents the va_arg llvm instruction, which returns
/// an argument of the specified type given a va_list.
/// an argument of the specified type given a va_list and increments that list
///
class VAArgInst : public UnaryInstruction {
VAArgInst(const VAArgInst &VAA)
@@ -724,6 +681,7 @@ public:
}
virtual VAArgInst *clone() const;
bool mayWriteToMemory() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const VAArgInst *) { return true; }
@@ -846,6 +804,11 @@ public:
return getIncomingValue(getBasicBlockIndex(BB));
}
/// hasConstantValue - If the specified PHI node always merges together the
/// same value, return the value, otherwise return null.
///
Value *hasConstantValue(bool AllowNonDominatingInstruction = false) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const PHINode *) { return true; }
static inline bool classof(const Instruction *I) {

View File

@@ -22,6 +22,7 @@
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/DataTypes.h"
namespace llvm {
@@ -51,17 +52,15 @@ public:
typedef iplist<Function> FunctionListType;
typedef SetVector<std::string> LibraryListType;
// Global Variable iterators...
typedef GlobalListType::iterator global_iterator;
typedef GlobalListType::const_iterator const_global_iterator;
typedef global_iterator giterator; // these are legacy, deprecated
typedef const_global_iterator const_giterator;
// Global Variable iterators.
typedef GlobalListType::iterator global_iterator;
typedef GlobalListType::const_iterator const_global_iterator;
// Function iterators...
// Function iterators.
typedef FunctionListType::iterator iterator;
typedef FunctionListType::const_iterator const_iterator;
// Library list iterators
// Library list iterators.
typedef LibraryListType::const_iterator lib_iterator;
enum Endianness { AnyEndianness, LittleEndian, BigEndian };
@@ -86,9 +85,11 @@ public:
Module(const std::string &ModuleID);
~Module();
const std::string& getModuleIdentifier() const { return ModuleID; }
const std::string& getTargetTriple() const { return TargetTriple; }
void setTargetTriple(const std::string& T) { TargetTriple = T; }
const std::string &getModuleIdentifier() const { return ModuleID; }
void setModuleIdentifier(const std::string &ID) { ModuleID = ID; }
const std::string &getTargetTriple() const { return TargetTriple; }
void setTargetTriple(const std::string &T) { TargetTriple = T; }
/// Target endian information...
Endianness getEndianness() const { return Endian; }
@@ -111,7 +112,8 @@ public:
/// table. If it does not exist, add a prototype for the function and return
/// it. This version of the method takes a null terminated list of function
/// arguments, which makes it easier for clients to use.
Function *getOrInsertFunction(const std::string &Name, const Type *RetTy,...);
Function *getOrInsertFunction(const std::string &Name, const Type *RetTy,...)
END_WITH_NULL;
/// getFunction - Look up the specified function in the module symbol table.
/// If it does not exist, return null.

View File

@@ -81,8 +81,7 @@ public:
//===----------------------------------------------------------------------===//
//
// Annotable - This class is used as a base class for all objects that would
// like to have annotation capability. One notable subclass is Value, which
// means annotations can be attached to almost everything in LLVM.
// like to have annotation capability.
//
// Annotable objects keep their annotation list sorted as annotations are
// inserted and deleted. This is used to ensure that annotations with identical

View File

@@ -21,6 +21,7 @@
#define LLVM_SUPPORT_COMMANDLINE_H
#include "llvm/Support/type_traits.h"
#include "llvm/Support/DataTypes.h"
#include <string>
#include <vector>
#include <utility>
@@ -66,21 +67,21 @@ enum NumOccurrences { // Flags for the number of occurrences allowed
//
ConsumeAfter = 0x05,
OccurrencesMask = 0x07,
OccurrencesMask = 0x07
};
enum ValueExpected { // Is a value required for the option?
ValueOptional = 0x08, // The value can appear... or not
ValueRequired = 0x10, // The value is required to appear!
ValueDisallowed = 0x18, // A value may not be specified (for flags)
ValueMask = 0x18,
ValueMask = 0x18
};
enum OptionHidden { // Control whether -help shows this option
NotHidden = 0x20, // Option included in --help & --help-hidden
Hidden = 0x40, // -help doesn't, but --help-hidden does
ReallyHidden = 0x60, // Neither --help nor --help-hidden show this arg
HiddenMask = 0x60,
HiddenMask = 0x60
};
// Formatting flags - This controls special features that the option might have
@@ -103,13 +104,13 @@ enum FormattingFlags {
Positional = 0x080, // Is a positional argument, no '-' required
Prefix = 0x100, // Can this option directly prefix its value?
Grouping = 0x180, // Can this option group with other options?
FormattingMask = 0x180, // Union of the above flags.
FormattingMask = 0x180 // Union of the above flags.
};
enum MiscFlags { // Miscellaneous flags to adjust argument
CommaSeparated = 0x200, // Should this cl::list split between commas?
PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args?
MiscMask = 0x600, // Union of the above flags.
MiscMask = 0x600 // Union of the above flags.
};
@@ -334,8 +335,8 @@ public:
};
template<class DataType>
ValuesClass<DataType> values(const char *Arg, DataType Val, const char *Desc,
...) {
ValuesClass<DataType> END_WITH_NULL values(const char *Arg, DataType Val,
const char *Desc, ...) {
va_list ValueArgs;
va_start(ValueArgs, Desc);
ValuesClass<DataType> Vals(Arg, Val, Desc, ValueArgs);
@@ -734,7 +735,8 @@ class opt : public Option,
virtual bool handleOccurrence(unsigned pos, const char *ArgName,
const std::string &Arg) {
typename ParserClass::parser_data_type Val;
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
return true; // Parse error!
setValue(Val);
@@ -893,7 +895,8 @@ class list : public Option, public list_storage<DataType, Storage> {
virtual bool handleOccurrence(unsigned pos, const char *ArgName,
const std::string &Arg) {
typename ParserClass::parser_data_type Val;
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
return true; // Parse Error!
addValue(Val);
@@ -981,6 +984,188 @@ public:
}
};
//===----------------------------------------------------------------------===//
// bits_storage class
// Default storage class definition: external storage. This implementation
// assumes the user will specify a variable to store the data into with the
// cl::location(x) modifier.
//
template<class DataType, class StorageClass>
class bits_storage {
unsigned *Location; // Where to store the bits...
template<class T>
static unsigned Bit(const T &V) {
unsigned BitPos = (unsigned)V;
assert(BitPos < sizeof(unsigned) * 8 &&
"enum exceeds width of bit vector!");
return 1 << BitPos;
}
public:
bits_storage() : Location(0) {}
bool setLocation(Option &O, unsigned &L) {
if (Location)
return O.error(": cl::location(x) specified more than once!");
Location = &L;
return false;
}
template<class T>
void addValue(const T &V) {
assert(Location != 0 && "cl::location(...) not specified for a command "
"line option with external storage!");
*Location |= Bit(V);
}
unsigned getBits() { return *Location; }
template<class T>
bool isSet(const T &V) {
return (*Location & Bit(V)) != 0;
}
};
// Define how to hold bits. Since we can inherit from a class, we do so.
// This makes us exactly compatible with the bits in all cases that it is used.
//
template<class DataType>
class bits_storage<DataType, bool> {
unsigned Bits; // Where to store the bits...
template<class T>
static unsigned Bit(const T &V) {
unsigned BitPos = (unsigned)V;
assert(BitPos < sizeof(unsigned) * 8 &&
"enum exceeds width of bit vector!");
return 1 << BitPos;
}
public:
template<class T>
void addValue(const T &V) {
Bits |= Bit(V);
}
unsigned getBits() { return Bits; }
template<class T>
bool isSet(const T &V) {
return (Bits & Bit(V)) != 0;
}
};
//===----------------------------------------------------------------------===//
// bits - A bit vector of command options.
//
template <class DataType, class Storage = bool,
class ParserClass = parser<DataType> >
class bits : public Option, public bits_storage<DataType, Storage> {
std::vector<unsigned> Positions;
ParserClass Parser;
virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
return ZeroOrMore;
}
virtual enum ValueExpected getValueExpectedFlagDefault() const {
return Parser.getValueExpectedFlagDefault();
}
virtual bool handleOccurrence(unsigned pos, const char *ArgName,
const std::string &Arg) {
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
return true; // Parse Error!
addValue(Val);
setPosition(pos);
Positions.push_back(pos);
return false;
}
// Forward printing stuff to the parser...
virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
virtual void printOptionInfo(unsigned GlobalWidth) const {
Parser.printOptionInfo(*this, GlobalWidth);
}
void done() {
addArgument(ArgStr);
Parser.initialize(*this);
}
public:
ParserClass &getParser() { return Parser; }
unsigned getPosition(unsigned optnum) const {
assert(optnum < this->size() && "Invalid option index");
return Positions[optnum];
}
// One option...
template<class M0t>
bits(const M0t &M0) {
apply(M0, this);
done();
}
// Two options...
template<class M0t, class M1t>
bits(const M0t &M0, const M1t &M1) {
apply(M0, this); apply(M1, this);
done();
}
// Three options...
template<class M0t, class M1t, class M2t>
bits(const M0t &M0, const M1t &M1, const M2t &M2) {
apply(M0, this); apply(M1, this); apply(M2, this);
done();
}
// Four options...
template<class M0t, class M1t, class M2t, class M3t>
bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
done();
}
// Five options...
template<class M0t, class M1t, class M2t, class M3t, class M4t>
bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3,
const M4t &M4) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
apply(M4, this);
done();
}
// Six options...
template<class M0t, class M1t, class M2t, class M3t,
class M4t, class M5t>
bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3,
const M4t &M4, const M5t &M5) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
apply(M4, this); apply(M5, this);
done();
}
// Seven options...
template<class M0t, class M1t, class M2t, class M3t,
class M4t, class M5t, class M6t>
bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3,
const M4t &M4, const M5t &M5, const M6t &M6) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
apply(M4, this); apply(M5, this); apply(M6, this);
done();
}
// Eight options...
template<class M0t, class M1t, class M2t, class M3t,
class M4t, class M5t, class M6t, class M7t>
bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3,
const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this);
done();
}
};
//===----------------------------------------------------------------------===//
// Aliased command line option (alias this name to a preexisting name)
//

View File

@@ -51,6 +51,12 @@ struct DefaultDOTGraphTraits {
static std::string getNodeLabel(const void *Node, const void *Graph) {
return "";
}
/// hasNodeAddressLabel - If this method returns true, the address of the node
/// is added to the label of the node.
static bool hasNodeAddressLabel(const void *Node, const void *Graph) {
return false;
}
/// If you want to specify custom node attributes, this is the place to do so
///

View File

@@ -1,10 +1,10 @@
//===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===//
//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//
//===----------------------------------------------------------------------===//
//
// This file contains definitions to figure out the size of _HOST_ data types.
@@ -67,6 +67,7 @@ typedef u_int64_t uint64_t;
// Visual C++ doesn't provide standard integer headers, but it does provide
// built-in data types.
#include <stddef.h>
#include <sys/types.h>
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef signed int int32_t;
@@ -98,4 +99,10 @@ typedef signed int ssize_t;
# define UINT64_MAX 0xffffffffffffffffULL
#endif
#if __GNUC__ > 3
#define END_WITH_NULL __attribute__((sentinel))
#else
#define END_WITH_NULL
#endif
#endif /* SUPPORT_DATATYPES_H */

View File

@@ -45,7 +45,7 @@ namespace llvm {
~FileRemover() {
if (DeleteIt)
try {
Filename.destroyFile();
Filename.eraseFromDisk();
} catch (...) {} // Ignore problems deleting the file.
}

View File

@@ -111,9 +111,14 @@ public:
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
O << "label=\"{";
if (!DOTTraits::renderGraphFromBottomUp())
if (!DOTTraits::renderGraphFromBottomUp()) {
O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
// If we should include the address of the node in the label, do so now.
if (DOTTraits::hasNodeAddressLabel(Node, G))
O << "|" << (void*)Node;
}
// Print out the fields of the current node...
child_iterator EI = GTraits::child_begin(Node);
child_iterator EE = GTraits::child_end(Node);
@@ -131,9 +136,15 @@ public:
O << "}";
if (DOTTraits::renderGraphFromBottomUp()) O << "|";
}
if (DOTTraits::renderGraphFromBottomUp())
if (DOTTraits::renderGraphFromBottomUp()) {
O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
// If we should include the address of the node in the label, do so now.
if (DOTTraits::hasNodeAddressLabel(Node, G))
O << "|" << (void*)Node;
}
O << "}\"];\n"; // Finish printing the "node" line
// Output all of the edges now

View File

@@ -174,7 +174,6 @@ public:
RetTy visitSelectInst(SelectInst &I) { DELEGATE(Instruction); }
RetTy visitCallInst(CallInst &I) { DELEGATE(Instruction); }
RetTy visitShiftInst(ShiftInst &I) { DELEGATE(Instruction); }
RetTy visitVANextInst(VANextInst &I) { DELEGATE(Instruction); }
RetTy visitVAArgInst(VAArgInst &I) { DELEGATE(Instruction); }
// Next level propagators... if the user does not overload a specific

View File

@@ -64,7 +64,8 @@ public:
/// does this for you, so there's no point calling it on the result
/// from getValueName.
///
static std::string makeNameProper(const std::string &x);
static std::string makeNameProper(const std::string &x,
const char *Prefix = "");
};
} // End llvm namespace

View File

@@ -18,32 +18,231 @@
namespace llvm {
#if defined(log2)
# undef log2
// NOTE: The following support functions use the _32/_64 extensions instead of
// type overloading so that signed and unsigned integers can be used without
// ambiguity.
// Hi_32 - This function returns the high 32 bits of a 64 bit value.
inline unsigned Hi_32(uint64_t Value) {
return (unsigned)(Value >> 32);
}
// Lo_32 - This function returns the low 32 bits of a 64 bit value.
inline unsigned Lo_32(uint64_t Value) {
return (unsigned)Value;
}
// is?Type - these functions produce optimal testing for integer data types.
inline bool isInt8 (int Value) { return ( signed char )Value == Value; }
inline bool isUInt8 (int Value) { return (unsigned char )Value == Value; }
inline bool isInt16 (int Value) { return ( signed short)Value == Value; }
inline bool isUInt16(int Value) { return (unsigned short)Value == Value; }
inline bool isInt32 (int64_t Value) { return ( signed int )Value == Value; }
inline bool isUInt32(int64_t Value) { return (unsigned int )Value == Value; }
// isMask_32 - This function returns true if the argument is a sequence of ones
// starting at the least significant bit with the remainder zero (32 bit version.)
// Ex. isMask_32(0x0000FFFFU) == true.
inline const bool isMask_32(unsigned Value) {
return Value && ((Value + 1) & Value) == 0;
}
// isMask_64 - This function returns true if the argument is a sequence of ones
// starting at the least significant bit with the remainder zero (64 bit version.)
inline const bool isMask_64(uint64_t Value) {
return Value && ((Value + 1) & Value) == 0;
}
// isShiftedMask_32 - This function returns true if the argument contains a
// sequence of ones with the remainder zero (32 bit version.)
// Ex. isShiftedMask_32(0x0000FF00U) == true.
inline const bool isShiftedMask_32(unsigned Value) {
return isMask_32((Value - 1) | Value);
}
// isShiftedMask_64 - This function returns true if the argument contains a
// sequence of ones with the remainder zero (64 bit version.)
inline const bool isShiftedMask_64(uint64_t Value) {
return isMask_64((Value - 1) | Value);
}
// isPowerOf2_32 - This function returns true if the argument is a power of
// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
inline bool isPowerOf2_32(unsigned Value) {
return Value && !(Value & (Value - 1));
}
// isPowerOf2_64 - This function returns true if the argument is a power of two
// > 0 (64 bit edition.)
inline bool isPowerOf2_64(uint64_t Value) {
return Value && !(Value & (Value - 1LL));
}
// CountLeadingZeros_32 - this function performs the platform optimal form of
// counting the number of zeros from the most significant bit to the first one
// bit. Ex. CountLeadingZeros_32(0x00F000FF) == 8.
// Returns 32 if the word is zero.
inline unsigned CountLeadingZeros_32(unsigned Value) {
unsigned Count; // result
#if __GNUC__ >= 4
// PowerPC is defined for __builtin_clz(0)
#if !defined(__ppc__) && !defined(__ppc64__)
if (!Value) return 32;
#endif
inline unsigned log2(uint64_t C) {
unsigned getPow;
for (getPow = 0; C > 1; ++getPow)
C >>= 1;
return getPow;
}
inline unsigned log2(unsigned C) {
unsigned getPow;
for (getPow = 0; C > 1; ++getPow)
C >>= 1;
return getPow;
}
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
if (C < 0) C = -C;
if (C > 0 && C == (C & ~(C - 1))) {
getPow = log2(static_cast<uint64_t>(C));
return true;
Count = __builtin_clz(Value);
#else
if (!Value) return 32;
Count = 0;
// bisecton method for count leading zeros
for (unsigned Shift = 32 >> 1; Shift; Shift >>= 1) {
unsigned Tmp = Value >> Shift;
if (Tmp) {
Value = Tmp;
} else {
Count |= Shift;
}
}
#endif
return Count;
}
return false;
// CountLeadingZeros_64 - This function performs the platform optimal form
// of counting the number of zeros from the most significant bit to the first
// one bit (64 bit edition.)
// Returns 64 if the word is zero.
inline unsigned CountLeadingZeros_64(uint64_t Value) {
unsigned Count; // result
#if __GNUC__ >= 4
// PowerPC is defined for __builtin_clzll(0)
#if !defined(__ppc__) && !defined(__ppc64__)
if (!Value) return 64;
#endif
Count = __builtin_clzll(Value);
#else
if (sizeof(long) == sizeof(int64_t)) {
if (!Value) return 64;
Count = 0;
// bisecton method for count leading zeros
for (uint64_t Shift = 64 >> 1; Shift; Shift >>= 1) {
uint64_t Tmp = Value >> Shift;
if (Tmp) {
Value = Tmp;
} else {
Count |= Shift;
}
}
} else {
// get hi portion
unsigned Hi = Hi_32(Value);
// if some bits in hi portion
if (Hi) {
// leading zeros in hi portion plus all bits in lo portion
Count = CountLeadingZeros_32(Hi);
} else {
// get lo portion
unsigned Lo = Lo_32(Value);
// same as 32 bit value
Count = CountLeadingZeros_32(Lo)+32;
}
}
#endif
return Count;
}
// CountTrailingZeros_32 - this function performs the platform optimal form of
// counting the number of zeros from the least significant bit to the first one
// bit. Ex. CountTrailingZeros_32(0xFF00FF00) == 8.
// Returns 32 if the word is zero.
inline unsigned CountTrailingZeros_32(unsigned Value) {
return 32 - CountLeadingZeros_32(~Value & (Value - 1));
}
// CountTrailingZeros_64 - This function performs the platform optimal form
// of counting the number of zeros from the least significant bit to the first
// one bit (64 bit edition.)
// Returns 64 if the word is zero.
inline unsigned CountTrailingZeros_64(uint64_t Value) {
return 64 - CountLeadingZeros_64(~Value & (Value - 1));
}
// CountPopulation_32 - this function counts the number of set bits in a value.
// Ex. CountPopulation(0xF000F000) = 8
// Returns 0 if the word is zero.
inline unsigned CountPopulation_32(unsigned Value) {
unsigned x, t;
x = Value - ((Value >> 1) & 0x55555555);
t = ((x >> 2) & 0x33333333);
x = (x & 0x33333333) + t;
x = (x + (x >> 4)) & 0x0F0F0F0F;
x = x + (x << 8);
x = x + (x << 16);
return x >> 24;
}
// CountPopulation_64 - this function counts the number of set bits in a value,
// (64 bit edition.)
inline unsigned CountPopulation_64(uint64_t Value) {
return CountPopulation_32(unsigned(Value >> 32)) +
CountPopulation_32(unsigned(Value));
}
// Log2_32 - This function returns the floor log base 2 of the specified value,
// -1 if the value is zero. (32 bit edition.)
// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1
inline unsigned Log2_32(unsigned Value) {
return 31 - CountLeadingZeros_32(Value);
}
// Log2_64 - This function returns the floor log base 2 of the specified value,
// -1 if the value is zero. (64 bit edition.)
inline unsigned Log2_64(uint64_t Value) {
return 63 - CountLeadingZeros_64(Value);
}
// BitsToDouble - This function takes a 64-bit integer and returns the bit
// equivalent double.
inline double BitsToDouble(uint64_t Bits) {
union {
uint64_t L;
double D;
} T;
T.L = Bits;
return T.D;
}
// BitsToFloat - This function takes a 32-bit integer and returns the bit
// equivalent float.
inline float BitsToFloat(uint32_t Bits) {
union {
uint32_t I;
float F;
} T;
T.I = Bits;
return T.F;
}
// DoubleToBits - This function takes a double and returns the bit
// equivalent 64-bit integer.
inline uint64_t DoubleToBits(double Double) {
union {
uint64_t L;
double D;
} T;
T.D = Double;
return T.L;
}
// FloatToBits - This function takes a float and returns the bit
// equivalent 32-bit integer.
inline uint32_t FloatToBits(float Float) {
union {
uint32_t I;
float F;
} T;
T.F = Float;
return T.I;
}
// Platform-independent wrappers for the C99 isnan() function.

View File

@@ -0,0 +1,41 @@
//===-- Support/MutexGuard.h - Acquire/Release Mutex In Scope ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a guard for a block of code that ensures a Mutex is locked
// upon construction and released upon destruction.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_MUTEXGUARD_H
#define LLVM_SUPPORT_MUTEXGUARD_H
#include <llvm/System/Mutex.h>
namespace llvm {
/// Instances of this class acquire a given Mutex Lock when constructed and
/// hold that lock until destruction. The intention is to instantiate one of
/// these on the stack at the top of some scope to be assured that C++
/// destruction of the object will always release the Mutex and thus avoid
/// a host of nasty multi-threading problems in the face of exceptions, etc.
/// @brief Guard a section of code with a Mutex.
class MutexGuard {
sys::Mutex &M;
MutexGuard(const MutexGuard &); // DO NOT IMPLEMENT
void operator=(const MutexGuard &); // DO NOT IMPLEMENT
public:
MutexGuard(sys::Mutex &m) : M(m) { M.acquire(); }
~MutexGuard() { M.release(); }
/// holds - Returns true if this locker instance holds the specified lock.
/// This is mostly used in assertions to validate that the correct mutex
/// is held.
bool holds(const sys::Mutex& lock) const { return &M == &lock; }
};
}
#endif // LLVM_SUPPORT_MUTEXGUARD_H

View File

@@ -71,7 +71,8 @@ inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
// Matchers for specific binary operators
//
template<typename LHS_t, typename RHS_t, unsigned Opcode>
template<typename LHS_t, typename RHS_t,
unsigned Opcode, typename ConcreteTy = BinaryOperator>
struct BinaryOp_match {
LHS_t L;
RHS_t R;
@@ -80,9 +81,11 @@ struct BinaryOp_match {
template<typename OpTy>
bool match(OpTy *V) {
if (Instruction *I = dyn_cast<Instruction>(V))
if (V->getValueType() == Value::InstructionVal + Opcode) {
ConcreteTy *I = cast<ConcreteTy>(V);
return I->getOpcode() == Opcode && L.match(I->getOperand(0)) &&
R.match(I->getOperand(1));
}
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
R.match(CE->getOperand(1));
@@ -139,15 +142,15 @@ inline BinaryOp_match<LHS, RHS, Instruction::Xor> m_Xor(const LHS &L,
}
template<typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::Shl> m_Shl(const LHS &L,
const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R);
inline BinaryOp_match<LHS, RHS, Instruction::Shl,
ShiftInst> m_Shl(const LHS &L, const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::Shl, ShiftInst>(L, R);
}
template<typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::Shr> m_Shr(const LHS &L,
const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::Shr>(L, R);
inline BinaryOp_match<LHS, RHS, Instruction::Shr,
ShiftInst> m_Shr(const LHS &L, const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::Shr, ShiftInst>(L, R);
}
//===----------------------------------------------------------------------===//

View File

@@ -1,34 +0,0 @@
//===-- llvm/Support/ThreadSupport-NoSupport.h - Generic Impl ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines a generic ThreadSupport implementation used when there is
// no supported threading mechanism on the current system. Users should never
// #include this file directly!
//
//===----------------------------------------------------------------------===//
// Users should never #include this file directly! As such, no include guards
// are needed.
#ifndef LLVM_SUPPORT_THREADSUPPORT_H
#error "Code should not #include Support/ThreadSupport-NoSupport.h directly!"
#endif
namespace llvm {
/// Mutex - This class allows user code to protect variables shared between
/// threads. It implements a "recursive" mutex, to simplify user code.
///
/// Since there is no platform support for _creating threads_, the non-thread
/// implementation of this class is a noop.
///
struct Mutex {
void acquire () {}
void release () {}
};
}

View File

@@ -1,65 +0,0 @@
//===-- llvm/Support/ThreadSupport-PThreads.h - PThreads support *- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines pthreads implementations of the generic threading
// mechanisms. Users should never #include this file directly!
//
//===----------------------------------------------------------------------===//
// Users should never #include this file directly! As such, no include guards
// are needed.
#ifndef LLVM_SUPPORT_THREADSUPPORT_H
#error "Code should not #include Support/ThreadSupport/PThreads.h directly!"
#endif
#include <pthread.h>
namespace llvm {
/// Mutex - This class allows user code to protect variables shared between
/// threads. It implements a "recursive" mutex, to simplify user code.
///
class Mutex {
pthread_mutex_t mutex;
Mutex(const Mutex &); // DO NOT IMPLEMENT
void operator=(const Mutex &); // DO NOT IMPLEMENT
public:
Mutex() {
// Initialize the mutex as a recursive mutex
pthread_mutexattr_t Attr;
int errorcode = pthread_mutexattr_init(&Attr);
assert(errorcode == 0);
errorcode = pthread_mutexattr_settype(&Attr, PTHREAD_MUTEX_RECURSIVE);
assert(errorcode == 0);
errorcode = pthread_mutex_init(&mutex, &Attr);
assert(errorcode == 0);
errorcode = pthread_mutexattr_destroy(&Attr);
assert(errorcode == 0);
}
~Mutex() {
int errorcode = pthread_mutex_destroy(&mutex);
assert(errorcode == 0);
}
void acquire () {
int errorcode = pthread_mutex_lock(&mutex);
assert(errorcode == 0);
}
void release () {
int errorcode = pthread_mutex_unlock(&mutex);
assert(errorcode == 0);
}
};
} // end namespace llvm

View File

@@ -1,42 +0,0 @@
//===-- Support/ThreadSupport.h - Generic threading support -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines platform-agnostic interfaces that can be used to write
// multi-threaded programs. Autoconf is used to chose the correct
// implementation of these interfaces, or default to a non-thread-capable system
// if no matching system support is available.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_THREADSUPPORT_H
#define LLVM_SUPPORT_THREADSUPPORT_H
#undef HAVE_PTHREAD_MUTEX_LOCK
#ifdef HAVE_PTHREAD_MUTEX_LOCK
#include "llvm/Support/ThreadSupport-PThreads.h"
#else
#include "llvm/Support/ThreadSupport-NoSupport.h"
#endif // If no system support is available
namespace llvm {
/// MutexLocker - Instances of this class acquire a given Lock when
/// constructed and hold that lock until destruction.
///
class MutexLocker {
Mutex &M;
MutexLocker(const MutexLocker &); // DO NOT IMPLEMENT
void operator=(const MutexLocker &); // DO NOT IMPLEMENT
public:
MutexLocker(Mutex &m) : M(m) { M.acquire(); }
~MutexLocker() { M.release(); }
};
}
#endif // SUPPORT_THREADSUPPORT_H

View File

@@ -43,9 +43,11 @@ namespace sys {
/// This method allocates a block of Read/Write/Execute memory that is
/// suitable for executing dynamically generated code (e.g. JIT). An
/// attempt to allocate \p NumBytes bytes of virtual memory is made.
/// \p NearBlock may point to an existing allocation in which case
/// an attempt is made to allocate more memory near the existing block.
/// @throws std::string if an error occurred.
/// @brief Allocate Read/Write/Execute memory.
static MemoryBlock AllocateRWX(unsigned NumBytes);
static MemoryBlock AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock);
/// This method releases a block of Read/Write/Execute memory that was
/// allocated with the AllocateRWX method. It should not be used to

View File

@@ -0,0 +1,84 @@
//===- llvm/System/Mutex.h - Mutex Operating System Concept -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the llvm::sys::Mutex class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SYSTEM_MUTEX_H
#define LLVM_SYSTEM_MUTEX_H
namespace llvm
{
namespace sys
{
/// @brief Platform agnostic Mutex class.
class Mutex
{
/// @name Constructors
/// @{
public:
/// Initializes the lock but doesn't acquire it. if \p recursive is set
/// to false, the lock will not be recursive which makes it cheaper but
/// also more likely to deadlock (same thread can't acquire more than
/// once).
/// @brief Default Constructor.
Mutex ( bool recursive = true );
/// Releases and removes the lock
/// @brief Destructor
~Mutex ( void );
/// @}
/// @name Methods
/// @{
public:
/// Attempts to unconditionally acquire the lock. If the lock is held by
/// another thread, this method will wait until it can acquire the lock.
/// @returns false if any kind of error occurs, true otherwise.
/// @brief Unconditionally acquire the lock.
bool acquire();
/// Attempts to release the lock. If the lock is held by the current
/// thread, the lock is released allowing other threads to acquire the
/// lock.
/// @returns false if any kind of error occurs, true otherwise.
/// @brief Unconditionally release the lock.
bool release(void);
/// Attempts to acquire the lock without blocking. If the lock is not
/// available, this function returns false quickly (without blocking). If
/// the lock is available, it is acquired.
/// @returns false if any kind of error occurs or the lock is not
/// available, true otherwise.
/// @brief Try to acquire the lock.
bool tryacquire();
//@}
/// @name Platform Dependent Data
/// @{
private:
#ifdef ENABLE_THREADS
void* data_; ///< We don't know what the data will be
#endif
/// @}
/// @name Do Not Implement
/// @{
private:
Mutex(const Mutex & original);
void operator=(const Mutex &);
/// @}
};
}
}
#endif

View File

@@ -27,21 +27,28 @@ namespace sys {
/// in the operating system's filesystem and provides various basic operations
/// on it. Note that this class only represents the name of a path to a file
/// or directory which may or may not be valid for a given machine's file
/// system. A Path ensures that the name it encapsulates is syntactical valid
/// for the operating system it is running on but does not ensure correctness
/// for any particular file system. A Path either references a file or a
/// directory and the distinction is consistently maintained. Most operations
/// on the class have invariants that require the Path object to be either a
/// file path or a directory path, but not both. Those operations will also
/// leave the object as either a file path or object path. There is exactly
/// one invalid Path which is the empty path. The class should never allow any
/// other syntactically invalid non-empty path name to be assigned. Empty
/// paths are required in order to indicate an error result. If the path is
/// empty, the isValid operation will return false. All operations will fail
/// if isValid is false. Operations that change the path will either return
/// false if it would cause a syntactically invalid path name (in which case
/// the Path object is left unchanged) or throw an std::string exception
/// indicating the error.
/// system. The class is patterned after the java.io.File class with various
/// extensions and several omissions (not relevant to LLVM). A Path object
/// ensures that the path it encapsulates is syntactically valid for the
/// operating system it is running on but does not ensure correctness for
/// any particular file system. That is, a syntactically valid path might
/// specify path components that do not exist in the file system and using
/// such a Path to act on the file system could produce errors. There is one
/// invalid Path value which is permitted: the empty path. The class should
/// never allow a syntactically invalid non-empty path name to be assigned.
/// Empty paths are required in order to indicate an error result in some
/// situations. If the path is empty, the isValid operation will return
/// false. All operations will fail if isValid is false. Operations that
/// change the path will either return false if it would cause a syntactically
/// invalid path name (in which case the Path object is left unchanged) or
/// throw an std::string exception indicating the error. The methods are
/// grouped into four basic categories: Path Accessors (provide information
/// about the path without accessing disk), Disk Accessors (provide
/// information about the underlying file or directory), Path Mutators
/// (change the path information, not the disk), and Disk Mutators (change
/// the disk file/directory referenced by the path). The Disk Mutator methods
/// all have the word "disk" embedded in their method name to reinforce the
/// notion that the operation modifies the file system.
/// @since 1.4
/// @brief An abstraction for operating system paths.
class Path {
@@ -76,8 +83,8 @@ namespace sys {
/// directory is a top level directory above which there are no more
/// directories. For example, on UNIX, the root directory is /. On Windows
/// it is C:\. Other operating systems may have different notions of
/// what the root directory is.
/// @throws nothing
/// what the root directory is or none at all. In that case, a consistent
/// default root directory will be used.
static Path GetRootDirectory();
/// Construct a path to a unique temporary directory that is created in
@@ -93,8 +100,7 @@ namespace sys {
/// library paths suitable for linking into programs. This function *must*
/// return the value of LLVM_LIB_SEARCH_PATH as the first item in \p Paths
/// if that environment variable is set and it references a directory.
/// @throws nothing
/// @brief Construct a path to the first system library directory
/// @brief Construct a path to the system library directory
static void GetSystemLibraryPaths(std::vector<sys::Path>& Paths);
/// Construct a vector of sys::Path that contains the "standard" bytecode
@@ -116,7 +122,6 @@ namespace sys {
/// implementation must ensure that this is a well-known (same on many
/// systems) directory in which llvm configuration files exist. For
/// example, on Unix, the /etc/llvm directory has been selected.
/// @throws nothing
/// @brief Construct a path to the default LLVM configuration directory
static Path GetLLVMDefaultConfigDir();
@@ -124,7 +129,6 @@ namespace sys {
/// implementation must ensure that this refers to the "etc" directory of
/// the LLVM installation. This is the location where configuration files
/// will be located for a particular installation of LLVM on a machine.
/// @throws nothing
/// @brief Construct a path to the LLVM installed configuration directory
static Path GetLLVMConfigDir();
@@ -134,7 +138,6 @@ namespace sys {
/// variable "HOME" could be used on Unix. If a given operating system
/// does not have the concept of a user's home directory, this static
/// constructor must provide the same result as GetRootDirectory.
/// @throws nothing
/// @brief Construct a path to the current user's "home" directory
static Path GetUserHomeDirectory();
@@ -151,16 +154,15 @@ namespace sys {
/// empty one. Other invalid names are not permitted. Empty paths are
/// provided so that they can be used to indicate null or error results in
/// other lib/System functionality.
/// @throws nothing
/// @brief Construct an empty (and invalid) path.
Path() : path() {}
/// This constructor will accept a std::string as a path but if verifies
/// This constructor will accept a std::string as a path but it verifies
/// that the path string has a legal syntax for the operating system on
/// which it is running. This allows a path to be taken in from outside
/// the program. However, if the path is not valid, the Path object will
/// be set to an empty string and an exception will be thrown.
/// @throws std::string if the path string is not legal.
/// @throws std::string if \p unverified_path is not legal.
/// @param unverified_path The path to verify and assign.
/// @brief Construct a Path from a string.
explicit Path(const std::string& unverified_path);
@@ -171,7 +173,6 @@ namespace sys {
public:
/// Makes a copy of \p that to \p this.
/// @returns \p this
/// @throws nothing
/// @brief Assignment Operator
Path & operator = ( const Path & that ) {
path = that.path;
@@ -180,7 +181,6 @@ namespace sys {
/// Compares \p this Path with \p that Path for equality.
/// @returns true if \p this and \p that refer to the same thing.
/// @throws nothing
/// @brief Equality Operator
bool operator == (const Path& that) const {
return 0 == path.compare(that.path) ;
@@ -188,7 +188,6 @@ namespace sys {
/// Compares \p this Path with \p that Path for inequality.
/// @returns true if \p this and \p that refer to different things.
/// @throws nothing
/// @brief Inequality Operator
bool operator !=( const Path & that ) const {
return 0 != path.compare( that.path );
@@ -199,14 +198,13 @@ namespace sys {
/// std::map). The comparison is done lexicographically as defined by
/// the std::string::compare method.
/// @returns true if \p this path is lexicographically less than \p that.
/// @throws nothing
/// @brief Less Than Operator
bool operator< (const Path& that) const {
return 0 > path.compare( that.path );
}
/// @}
/// @name Accessors
/// @name Path Accessors
/// @{
public:
/// This function will use an operating system specific algorithm to
@@ -219,28 +217,64 @@ namespace sys {
bool isValid() const;
/// This function determines if the contents of the path name are
/// empty. That is, the path has a zero length.
/// empty. That is, the path has a zero length. This does NOT determine if
/// if the file is empty. Use the getSize method for that.
/// @returns true iff the path is empty.
/// @brief Determines if the path name is empty (invalid).
bool isEmpty() const { return path.empty(); }
/// This function determines if the path name in this object is intended
/// to reference a legal file name (as opposed to a directory name). This
/// function does not verify anything with the file system, it merely
/// determines if the syntax of the path represents a file name or not.
/// This function returns the current contents of the path as a
/// std::string. This allows the underlying path string to be manipulated.
/// @returns std::string containing the path name.
/// @brief Returns the path as a std::string.
const std::string& toString() const { return path; }
/// This function returns the last component of the path name. The last
/// component is the file or directory name occuring after the last
/// directory separator. If no directory separator is present, the entire
/// path name is returned (i.e. same as toString).
/// @returns std::string containing the last component of the path name.
/// @brief Returns the last component of the path name.
std::string getLast() const;
/// This function strips off the path and suffix of the file or directory
/// name and returns just the basename. For example /a/foo.bar would cause
/// this function to return "foo".
/// @returns std::string containing the basename of the path
/// @brief Get the base name of the path
std::string getBasename() const;
/// Obtain a 'C' string for the path name.
/// @returns a 'C' string containing the path name.
/// @brief Returns the path as a C string.
const char* const c_str() const { return path.c_str(); }
/// @}
/// @name Disk Accessors
/// @{
public:
/// This function determines if the object referenced by this path is
/// a file or not. This function accesses the underlying file system to
/// determine the type of entity referenced by the path.
/// @returns true if this path name references a file.
/// @brief Determines if the path name references a file.
bool isFile() const;
/// This function determines if the path name in this object is intended
/// to reference a legal directory name (as opposed to a file name). This
/// function does not verify anything with the file system, it merely
/// determines if the syntax of the path represents a directory name or
/// not.
/// This function determines if the object referenced by this path is a
/// directory or not. This function accesses the underlying file system to
/// determine the type of entity referenced by the path.
/// @returns true if the path name references a directory
/// @brief Determines if the path name references a directory.
bool isDirectory() const;
/// This function determines if the path refers to a hidden file. The
/// notion of hidden files is defined by the underlying system. The
/// system may not support hidden files in which case this function always
/// returns false on such systems. Hidden files have the "hidden"
/// attribute set on Win32. On Unix, hidden files start with a period.
/// @brief Determines if the path name references a hidden file.
bool isHidden() const;
/// This function determines if the path name in this object references
/// the root (top level directory) of the file system. The details of what
/// is considered the "root" may vary from system to system so this method
@@ -289,62 +323,38 @@ namespace sys {
bool isDynamicLibrary() const;
/// This function determines if the path name references an existing file
/// or directory in the file system. Unlike isFile and isDirectory, this
/// function actually checks for the existence of the file or directory.
/// @returns true if the pathname references an existing file.
/// or directory in the file system.
/// @returns true if the pathname references an existing file or
/// directory.
/// @brief Determines if the path is a file or directory in
/// the file system.
bool exists() const;
/// This function determines if the path name references a readable file
/// or directory in the file system. Unlike isFile and isDirectory, this
/// function actually checks for the existence and readability (by the
/// current program) of the file or directory.
/// or directory in the file system. This function checks for
/// the existence and readability (by the current program) of the file
/// or directory.
/// @returns true if the pathname references a readable file.
/// @brief Determines if the path is a readable file or directory
/// in the file system.
bool readable() const;
bool canRead() const;
/// This function determines if the path name references a writable file
/// or directory in the file system. Unlike isFile and isDirectory, this
/// function actually checks for the existence and writability (by the
/// current program) of the file or directory.
/// or directory in the file system. This function checks for the
/// existence and writability (by the current program) of the file or
/// directory.
/// @returns true if the pathname references a writable file.
/// @brief Determines if the path is a writable file or directory
/// in the file system.
bool writable() const;
bool canWrite() const;
/// This function determines if the path name references an executable
/// file in the file system. Unlike isFile and isDirectory, this
/// function actually checks for the existence and executability (by
/// the current program) of the file.
/// file in the file system. This function checks for the existence and
/// executability (by the current program) of the file.
/// @returns true if the pathname references an executable file.
/// @brief Determines if the path is an executable file in the file
/// system.
bool executable() const;
/// This function returns the current contents of the path as a
/// std::string. This allows the underlying path string to be manipulated
/// by other software.
/// @returns std::string containing the path name.
/// @brief Returns the path as a std::string.
const std::string& toString() const { return path; }
/// This function returns the last component of the path name. If the
/// isDirectory() function would return true then this returns the name
/// of the last directory in the path. If the isFile() function would
/// return true then this function returns the name of the file without
/// any of the preceding directories.
/// @returns std::string containing the last component of the path name.
/// @brief Returns the last component of the path name.
std::string getLast() const;
/// This function strips off the path and suffix of the file name and
/// returns just the basename.
/// @returns std::string containing the basename of the path
/// @throws nothing
/// @brief Get the base name of the path
std::string getBasename() const;
bool canExecute() const;
/// This function builds a list of paths that are the names of the
/// files and directories in a directory.
@@ -353,46 +363,10 @@ namespace sys {
/// @brief Build a list of directory's contents.
bool getDirectoryContents(std::set<Path>& paths) const;
/// This method attempts to destroy the directory named by the last in
/// the Path name. If \p remove_contents is false, an attempt will be
/// made to remove just the directory that this Path object refers to
/// (the final Path component). If \p remove_contents is true, an attempt
/// will be made to remove the entire contents of the directory,
/// recursively.
/// @param destroy_contents Indicates whether the contents of a destroyed
/// directory should also be destroyed (recursively).
/// @returns false if the Path does not refer to a directory, true
/// otherwise.
/// @throws std::string if there is an error.
/// @brief Removes the file or directory from the filesystem.
bool destroyDirectory( bool destroy_contents = false ) const;
/// This method attempts to destroy the file named by the last item in the
/// Path name.
/// @returns false if the Path does not refer to a file, true otherwise.
/// @throws std::string if there is an error.
/// @brief Destroy the file this Path refers to.
bool destroyFile() const;
/// Obtain a 'C' string for the path name.
/// @returns a 'C' string containing the path name.
/// @brief Returns the path as a C string.
const char* const c_str() const { return path.c_str(); }
/// @}
/// @name Mutators
/// @{
public:
/// The path name is cleared and becomes empty. This is an invalid
/// path name but is the *only* invalid path name. This is provided
/// so that path objects can be used to indicate the lack of a
/// valid path being found.
void clear() { path.clear(); }
/// This function returns status information about the file. The type of
/// path (file or directory) is updated to reflect the actual contents
/// of the file system. If the file does not exist, false is returned.
/// For other (hard I/O) errors, a std::string is throwing indicating the
/// For other (hard I/O) errors, a std::string is thrown indicating the
/// problem.
/// @throws std::string if an error occurs.
/// @brief Get file status.
@@ -413,80 +387,40 @@ namespace sys {
StatusInfo info; getStatusInfo(info); return info.fileSize;
}
/// This method attempts to make the file referenced by the Path object
/// available for reading so that the readable() method will return true.
/// @brief Make the file readable;
void makeReadable();
/// @}
/// @name Path Mutators
/// @{
public:
/// The path name is cleared and becomes empty. This is an invalid
/// path name but is the *only* invalid path name. This is provided
/// so that path objects can be used to indicate the lack of a
/// valid path being found.
/// @brief Make the path empty.
void clear() { path.clear(); }
/// This method attempts to make the file referenced by the Path object
/// available for writing so that the writable() method will return true.
/// @brief Make the file writable;
void makeWriteable();
/// This method attempts to make the file referenced by the Path object
/// available for execution so that the executable() method will return
/// true.
/// @brief Make the file readable;
void makeExecutable();
/// This method attempts to set the Path object to \p unverified_path
/// and interpret the name as a directory name. The \p unverified_path
/// is verified. If verification succeeds then \p unverified_path
/// is accepted as a directory and true is returned. Otherwise,
/// the Path object remains unchanged and false is returned.
/// This method sets the Path object to \p unverified_path. This can fail
/// if the \p unverified_path does not pass the syntactic checks of the
/// isValid() method. If verification fails, the Path object remains
/// unchanged and false is returned. Otherwise true is returned and the
/// Path object takes on the path value of \p unverified_path
/// @returns true if the path was set, false otherwise.
/// @param unverified_path The path to be set in Path object.
/// @throws nothing
/// @brief Set a full path from a std::string
bool setDirectory(const std::string& unverified_path);
bool set(const std::string& unverified_path);
/// This method attempts to set the Path object to \p unverified_path
/// and interpret the name as a file name. The \p unverified_path
/// is verified. If verification succeeds then \p unverified_path
/// is accepted as a file name and true is returned. Otherwise,
/// the Path object remains unchanged and false is returned.
/// @returns true if the path was set, false otherwise.
/// @param unverified_path The path to be set in Path object.
/// @throws nothing
/// @brief Set a full path from a std::string
bool setFile(const std::string& unverified_path);
/// The \p dirname is added to the end of the Path if it is a legal
/// directory name for the operating system. The precondition for this
/// function is that the Path must reference a directory name (i.e.
/// isDirectory() returns true).
/// @param dirname A string providing the directory name to
/// be added to the end of the path.
/// @returns false if the directory name could not be added
/// @throws nothing
/// @brief Adds the name of a directory to a Path.
bool appendDirectory( const std::string& dirname );
/// One directory component is removed from the Path name. The Path must
/// refer to a non-root directory name (i.e. isDirectory() returns true
/// but isRootDirectory() returns false). Upon exit, the Path will
/// refer to the directory above it.
/// @throws nothing
/// @returns false if the directory name could not be removed.
/// One path component is removed from the Path. If only one component is
/// present in the path, the Path object becomes empty. If the Path object
/// is empty, no change is made.
/// @returns false if the path component could not be removed.
/// @brief Removes the last directory component of the Path.
bool elideDirectory();
bool eraseComponent();
/// The \p filename is added to the end of the Path if it is a legal
/// directory name for the operating system. The precondition for this
/// function is that the Path reference a directory name (i.e.
/// isDirectory() returns true).
/// @throws nothing
/// @returns false if the file name could not be added.
/// @brief Appends the name of a file.
bool appendFile( const std::string& filename );
/// One file component is removed from the Path name. The Path must
/// refer to a file (i.e. isFile() returns true). Upon exit,
/// the Path will refer to the directory above it.
/// @throws nothing
/// @returns false if the file name could not be removed
/// @brief Removes the last file component of the path.
bool elideFile();
/// The \p component is added to the end of the Path if it is a legal
/// name for the operating system. A directory separator will be added if
/// needed.
/// @returns false if the path component could not be added.
/// @brief Appends one path component to the Path.
bool appendComponent( const std::string& component );
/// A period and the \p suffix are appended to the end of the pathname.
/// The precondition for this function is that the Path reference a file
@@ -494,20 +428,18 @@ namespace sys {
/// action is taken and the function returns false. If the path would
/// become invalid for the host operating system, false is returned.
/// @returns false if the suffix could not be added, true if it was.
/// @throws nothing
/// @brief Adds a period and the \p suffix to the end of the pathname.
bool appendSuffix(const std::string& suffix);
/// The suffix of the filename is removed. The suffix begins with and
/// The suffix of the filename is erased. The suffix begins with and
/// includes the last . character in the filename after the last directory
/// separator and extends until the end of the name. If no . character is
/// after the last directory separator, then the file name is left
/// unchanged (i.e. it was already without a suffix) but the function
/// returns false.
/// @returns false if there was no suffix to remove, true otherwise.
/// @throws nothing
/// @brief Remove the suffix from a path name.
bool elideSuffix();
bool eraseSuffix();
/// The current Path name is made unique in the file system. Upon return,
/// the Path will have been changed to make a unique file in the file
@@ -517,30 +449,57 @@ namespace sys {
/// @brief Make the current path name unique in the file system.
void makeUnique( bool reuse_current = true );
/// @}
/// @name Disk Mutators
/// @{
public:
/// This method attempts to make the file referenced by the Path object
/// available for reading so that the canRead() method will return true.
/// @brief Make the file readable;
void makeReadableOnDisk();
/// This method attempts to make the file referenced by the Path object
/// available for writing so that the canWrite() method will return true.
/// @brief Make the file writable;
void makeWriteableOnDisk();
/// This method attempts to make the file referenced by the Path object
/// available for execution so that the canExecute() method will return
/// true.
/// @brief Make the file readable;
void makeExecutableOnDisk();
/// This method allows the last modified time stamp and permission bits
/// to be set on the disk object referenced by the Path.
/// @throws std::string if an error occurs.
/// @returns true
/// @brief Set the status information.
bool setStatusInfoOnDisk(const StatusInfo& si) const;
/// This method attempts to create a directory in the file system with the
/// same name as the Path object. The \p create_parents parameter controls
/// whether intermediate directories are created or not. if \p
/// create_parents is true, then an attempt will be made to create all
/// intermediate directories. If \p create_parents is false, then only the
/// final directory component of the Path name will be created. The
/// created directory will have no entries.
/// intermediate directories, as needed. If \p create_parents is false,
/// then only the final directory component of the Path name will be
/// created. The created directory will have no entries.
/// @returns false if the Path does not reference a directory, true
/// otherwise.
/// @param create_parents Determines whether non-existent directory
/// components other than the last one (the "parents") are created or not.
/// @throws std::string if an error occurs.
/// @brief Create the directory this Path refers to.
bool createDirectory( bool create_parents = false );
bool createDirectoryOnDisk( bool create_parents = false );
/// This method attempts to create a file in the file system with the same
/// name as the Path object. The intermediate directories must all exist
/// at the time this method is called. Use createDirectories to
/// at the time this method is called. Use createDirectoriesOnDisk to
/// accomplish that. The created file will be empty upon return from this
/// function.
/// @returns false if the Path does not reference a file, true otherwise.
/// @throws std::string if an error occurs.
/// @brief Create the file this Path refers to.
bool createFile();
bool createFileOnDisk();
/// This is like createFile except that it creates a temporary file. A
/// unique temporary file name is generated based on the contents of
@@ -548,24 +507,37 @@ namespace sys {
/// file is created. Note that this will both change the Path object
/// *and* create the corresponding file. This function will ensure that
/// the newly generated temporary file name is unique in the file system.
/// @throws std::string if there is an error
/// @param reuse_current When set to true, this parameter indicates that
/// if the current file name does not exist then it will be used without
/// modification.
/// @returns true if successful, false if the file couldn't be created.
/// @throws std::string if there is a hard error creating the temp file
/// name.
/// @brief Create a unique temporary file
bool createTemporaryFile(bool reuse_current = false);
bool createTemporaryFileOnDisk(bool reuse_current = false);
/// This method renames the file referenced by \p this as \p newName. Both
/// files must exist before making this call.
/// @returns false if the Path does not refer to a file, true otherwise.
/// This method renames the file referenced by \p this as \p newName. The
/// file referenced by \p this must exist. The file referenced by
/// \p newName does not need to exist.
/// @returns true
/// @throws std::string if there is an file system error.
/// @brief Rename one file as another.
bool renameFile(const Path& newName);
bool renamePathOnDisk(const Path& newName);
/// This method sets the access time, modification time, and permission
/// mode of the file associated with \p this as given by \p si.
/// @returns false if the Path does not refer to a file, true otherwise.
/// @throws std::string if the file could not be modified
/// @brief Set file times and mode.
bool setStatusInfo(const StatusInfo& si ) const ;
/// This method attempts to destroy the file or directory named by the
/// last component of the Path. If the Path refers to a directory and the
/// \p destroy_contents is false, an attempt will be made to remove just
/// the directory (the final Path component). If \p destroy_contents is
/// true, an attempt will be made to remove the entire contents of the
/// directory, recursively. If the Path refers to a file, the
/// \p destroy_contents parameter is ignored.
/// @param destroy_contents Indicates whether the contents of a destroyed
/// directory should also be destroyed (recursively).
/// @returns true if the file/directory was destroyed, false if the path
/// refers to something that is neither a file nor a directory.
/// @throws std::string if there is an error.
/// @brief Removes the file or directory from the filesystem.
bool eraseFromDisk( bool destroy_contents = false ) const;
/// @}
/// @name Data
@@ -602,5 +574,4 @@ inline std::ostream& operator<<(std::ostream& strm, const sys::Path& aPath) {
}
#endif

View File

@@ -67,7 +67,7 @@ namespace sys {
/// Not all operating systems support this feature. Where it is not
/// supported, the function should return 65536 as the value.
static int GetCurrentUserId();
/// This static function will return the process' current group id number.
/// Not all operating systems support this feature. Where it is not
/// supported, the function should return 65536 as the value.

View File

@@ -36,6 +36,16 @@ namespace sys {
/// @brief Print a stack trace if a fatal signal occurs.
void PrintStackTraceOnErrorSignal();
/// This function registers a function to be called when the user "interrupts"
/// the program (typically by pressing ctrl-c). When the user interrupts the
/// program, the specified interrupt function is called instead of the program
/// being killed, and the interrupt function automatically disabled. Note
/// that interrupt functions are not allowed to call any non-reentrant
/// functions. An null interrupt function pointer disables the current
/// installed function. Note also that the handler may be executed on a
/// different thread on some platforms.
/// @brief Register a function to be called when ctrl-c is pressed.
void SetInterruptFunction(void (*IF)());
} // End sys namespace
} // End llvm namespace

View File

@@ -17,6 +17,7 @@
#define LLVM_TARGET_MREGISTERINFO_H
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/ValueTypes.h"
#include <cassert>
#include <functional>
@@ -25,18 +26,17 @@ namespace llvm {
class Type;
class MachineFunction;
class MachineInstr;
class TargetRegisterClass;
/// MRegisterDesc - This record contains all of the information known about a
/// particular register. The AliasSet field (if not null) contains a pointer to
/// a Zero terminated array of registers that this register aliases. This is
/// TargetRegisterDesc - This record contains all of the information known about
/// a particular register. The AliasSet field (if not null) contains a pointer
/// to a Zero terminated array of registers that this register aliases. This is
/// needed for architectures like X86 which have AL alias AX alias EAX.
/// Registers that this does not apply to simply should set this to null.
///
struct MRegisterDesc {
struct TargetRegisterDesc {
const char *Name; // Assembly language name for the register
const unsigned *AliasSet; // Register Alias Set, described above
unsigned char SpillSize; // Size of this register in bytes
unsigned char SpillAlignment; // Alignment of stack slot for this reg
};
class TargetRegisterClass {
@@ -45,13 +45,18 @@ public:
typedef const unsigned* const_iterator;
private:
const MVT::ValueType VT;
const unsigned RegSize, Alignment; // Size & Alignment of register in bytes
const iterator RegsBegin, RegsEnd;
public:
TargetRegisterClass(unsigned RS, unsigned Al, iterator RB, iterator RE)
: RegSize(RS), Alignment(Al), RegsBegin(RB), RegsEnd(RE) {}
TargetRegisterClass(MVT::ValueType vt, unsigned RS, unsigned Al, iterator RB, iterator RE)
: VT(vt), RegSize(RS), Alignment(Al), RegsBegin(RB), RegsEnd(RE) {}
virtual ~TargetRegisterClass() {} // Allow subclasses
/// getType - Return the declared value type for this register class.
///
MVT::ValueType getType() const { return VT; }
// begin/end - Return all of the registers in this class.
iterator begin() const { return RegsBegin; }
iterator end() const { return RegsEnd; }
@@ -106,22 +111,22 @@ public:
/// MRegisterInfo base class - We assume that the target defines a static array
/// of MRegisterDesc objects that represent all of the machine registers that
/// the target has. As such, we simply have to track a pointer to this array so
/// that we can turn register number into a register descriptor.
/// of TargetRegisterDesc objects that represent all of the machine registers
/// that the target has. As such, we simply have to track a pointer to this
/// array so that we can turn register number into a register descriptor.
///
class MRegisterInfo {
public:
typedef const TargetRegisterClass * const * regclass_iterator;
private:
const MRegisterDesc *Desc; // Pointer to the descriptor array
const TargetRegisterDesc *Desc; // Pointer to the descriptor array
unsigned NumRegs; // Number of entries in the array
regclass_iterator RegClassBegin, RegClassEnd; // List of regclasses
int CallFrameSetupOpcode, CallFrameDestroyOpcode;
protected:
MRegisterInfo(const MRegisterDesc *D, unsigned NR,
MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
regclass_iterator RegClassBegin, regclass_iterator RegClassEnd,
int CallFrameSetupOpcode = -1, int CallFrameDestroyOpcode = -1);
virtual ~MRegisterInfo();
@@ -163,7 +168,7 @@ public:
/// indicating if a register is allocatable or not.
std::vector<bool> getAllocatableSet(MachineFunction &MF) const;
const MRegisterDesc &operator[](unsigned RegNo) const {
const TargetRegisterDesc &operator[](unsigned RegNo) const {
assert(RegNo < NumRegs &&
"Attempting to access record for invalid register number!");
return Desc[RegNo];
@@ -172,7 +177,9 @@ public:
/// Provide a get method, equivalent to [], but more useful if we have a
/// pointer to this object.
///
const MRegisterDesc &get(unsigned RegNo) const { return operator[](RegNo); }
const TargetRegisterDesc &get(unsigned RegNo) const {
return operator[](RegNo);
}
/// getAliasSet - Return the set of registers aliased by the specified
/// register, or a null list of there are none. The list returned is zero
@@ -188,18 +195,6 @@ public:
return get(RegNo).Name;
}
/// getSpillSize - Return the size in bits required of a stack slot used to
/// spill register into.
unsigned getSpillSize(unsigned RegNo) const {
return get(RegNo).SpillSize;
}
/// getSpillAlignment - Return the alignment required by a stack slot used to
/// spill register into.
unsigned getSpillAlignment(unsigned RegNo) const {
return get(RegNo).SpillAlignment;
}
/// getNumRegs - Return the number of registers this target has
/// (useful for sizing arrays holding per register information)
unsigned getNumRegs() const {
@@ -214,8 +209,14 @@ public:
return false;
}
/// getCalleeSaveRegs - Return a null-terminated list of all of the
/// callee-save registers on this target.
virtual const unsigned* getCalleeSaveRegs() const = 0;
/// getCalleeSaveRegClasses - Return a null-terminated list of the preferred
/// register classes to spill each callee-saved register with. The order and
/// length of this list match the getCalleeSaveRegs() list.
virtual const TargetRegisterClass* const *getCalleeSaveRegClasses() const = 0;
//===--------------------------------------------------------------------===//
// Register Class Information
@@ -239,17 +240,27 @@ public:
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
unsigned SrcReg, int FrameIndex) const = 0;
unsigned SrcReg, int FrameIndex,
const TargetRegisterClass *RC) const = 0;
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
unsigned DestReg, int FrameIndex) const = 0;
unsigned DestReg, int FrameIndex,
const TargetRegisterClass *RC) const = 0;
virtual void copyRegToReg(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
unsigned DestReg, unsigned SrcReg,
const TargetRegisterClass *RC) const = 0;
/// isLoadFromStackSlot - If the specified machine instruction is a direct
/// load from a stack slot, return the virtual or physical register number of
/// the destination along with the FrameIndex of the loaded stack slot. If
/// not, return 0. This predicate must return false if the instruction has
/// any side effects other than loading from the stack slot.
virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const{
return 0;
}
/// foldMemoryOperand - Attempt to fold a load or store of the
/// specified stack slot into the specified machine instruction for

View File

@@ -0,0 +1,108 @@
//===-- llvm/Target/SubtargetFeature.h - CPU characteristics ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Jim Laskey and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines and manages user or tool specified CPU characteristics.
// The intent is to be able to package specific features that should or should
// not be used on a specific target processor. A tool, such as llc, could, as
// as example, gather chip info from the command line, a long with features
// that should be used on that chip.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TARGET_SUBTARGETFEATURE_H
#define LLVM_TARGET_SUBTARGETFEATURE_H
#include <string>
#include <vector>
#include <iosfwd>
#include "llvm/Support/DataTypes.h"
namespace llvm {
//===----------------------------------------------------------------------===//
///
/// SubtargetFeatureKV - Used to provide key value pairs for feature and
/// CPU bit flags.
//
struct SubtargetFeatureKV {
const char *Key; // K-V key string
const char *Desc; // Help descriptor
uint32_t Value; // K-V integer value
// Compare routine for std binary search
bool operator<(const std::string &S) const {
return strcmp(Key, S.c_str()) < 0;
}
};
//===----------------------------------------------------------------------===//
///
/// SubtargetInfoKV - Used to provide key value pairs for CPU and arbitrary
/// pointers.
//
struct SubtargetInfoKV {
const char *Key; // K-V key string
void *Value; // K-V pointer value
// Compare routine for std binary search
bool operator<(const std::string &S) const {
return strcmp(Key, S.c_str()) < 0;
}
};
//===----------------------------------------------------------------------===//
///
/// SubtargetFeatures - Manages the enabling and disabling of subtarget
/// specific features. Features are encoded as a string of the form
/// "cpu,+attr1,+attr2,-attr3,...,+attrN"
/// A comma separates each feature from the next (all lowercase.)
/// The first feature is always the CPU subtype (eg. pentiumm). If the CPU
/// value is "generic" then the CPU subtype should be generic for the target.
/// Each of the remaining features is prefixed with + or - indicating whether
/// that feature should be enabled or disabled contrary to the cpu
/// specification.
///
class SubtargetFeatures {
std::vector<std::string> Features; // Subtarget features as a vector
public:
SubtargetFeatures(const std::string &Initial = std::string());
/// Features string accessors.
std::string getString() const;
void setString(const std::string &Initial);
/// Set the CPU string. Replaces previous setting. Setting to "" clears CPU.
void setCPU(const std::string &String);
/// Setting CPU string only if no string is set.
void setCPUIfNone(const std::string &String);
/// Adding Features.
void AddFeature(const std::string &String, bool IsEnabled = true);
/// Get feature bits.
uint32_t getBits(const SubtargetFeatureKV *CPUTable,
size_t CPUTableSize,
const SubtargetFeatureKV *FeatureTable,
size_t FeatureTableSize);
/// Get info pointer
void *getInfo(const SubtargetInfoKV *Table, size_t TableSize);
/// Print feature string.
void print(std::ostream &OS) const;
// Dump feature info.
void dump() const;
};
} // End namespace llvm
#endif

Some files were not shown because too many files have changed in this diff Show More