1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-26 14:33:02 +02:00
Commit Graph

4145 Commits

Author SHA1 Message Date
Evan Cheng
62ee7cd439 When coalescing an EXTRACT_SUBREG and the dst register is a physical register,
the source register will be coalesced to the super register of the LHS. Properly
merge in the live ranges of the resulting coalesced interval that were part of
the original source interval to the live interval of the super-register.

llvm-svn: 42961
2007-10-14 10:08:34 +00:00
Evan Cheng
33df6a6bed Revert 42908 for now.
llvm-svn: 42960
2007-10-14 05:57:21 +00:00
Dale Johannesen
4cbce377c6 Disable some compile-time optimizations on PPC
long double.

llvm-svn: 42958
2007-10-14 01:56:47 +00:00
Chris Lattner
c146f449b5 Enhance the truncstore optimization code to handle shifted
values and propagate demanded bits through them in simple cases.

This allows this code:
void foo(char *P) {
   strcpy(P, "abc");
}
to compile to:

_foo:
        ldrb r3, [r1]
        ldrb r2, [r1, #+1]
        ldrb r12, [r1, #+2]!
        ldrb r1, [r1, #+1]
        strb r1, [r0, #+3]
        strb r2, [r0, #+1]
        strb r12, [r0, #+2]
        strb r3, [r0]
        bx lr

instead of:

_foo:
        ldrb r3, [r1, #+3]
        ldrb r2, [r1, #+2]
        orr r3, r2, r3, lsl #8
        ldrb r2, [r1, #+1]
        ldrb r1, [r1]
        orr r2, r1, r2, lsl #8
        orr r3, r2, r3, lsl #16
        strb r3, [r0]
        mov r2, r3, lsr #24
        strb r2, [r0, #+3]
        mov r2, r3, lsr #16
        strb r2, [r0, #+2]
        mov r3, r3, lsr #8
        strb r3, [r0, #+1]
        bx lr

testcase here: test/CodeGen/ARM/truncstore-dag-combine.ll

This also helps occasionally for X86 and other cases not involving 
unaligned load/stores.

llvm-svn: 42954
2007-10-13 06:58:48 +00:00
Chris Lattner
133baf6012 Add a simple optimization to simplify the input to
truncate and truncstore instructions, based on the 
knowledge that they don't demand the top bits.

llvm-svn: 42952
2007-10-13 06:35:54 +00:00
Evan Cheng
b9ab88ccd5 Local spiller optimization:
Turn this:
movswl  %ax, %eax
movl    %eax, -36(%ebp)
xorl    %edi, -36(%ebp)
into
movswl  %ax, %eax
xorl    %edi, %eax
movl    %eax, -36(%ebp)
by unfolding the load / store xorl into an xorl and a store when we know the
value in the spill slot is available in a register. This doesn't change the
number of instructions but reduce the number of times memory is accessed.

Also unfold some load folding instructions and reuse the value when similar
situation presents itself.

llvm-svn: 42947
2007-10-13 02:50:24 +00:00
Evan Cheng
2262b2a792 Optionally create a MachineInstr without default implicit operands.
llvm-svn: 42945
2007-10-13 02:23:01 +00:00
Arnold Schwaighofer
6bcd9e7ec2 Corrected many typing errors. And removed 'nest' parameter handling
for fastcc from X86CallingConv.td.  This means that nested functions
are not supported for calling convention 'fastcc'.

llvm-svn: 42934
2007-10-12 21:30:57 +00:00
Dale Johannesen
2f62d5da32 ppc long double. Implement fabs and fneg.
llvm-svn: 42924
2007-10-12 19:02:17 +00:00
Dale Johannesen
296cc4ca22 Implement i64->ppcf128 conversions.
llvm-svn: 42919
2007-10-12 17:52:03 +00:00
Evan Cheng
681a96d737 Did mean to leave this in. INSERT_SUBREG isn't being coalesced yet.
llvm-svn: 42916
2007-10-12 17:16:50 +00:00
Dan Gohman
a75e4a62e6 Change the names used for internal labels to use the current
function symbol name instead of a codegen-assigned function
number.

Thanks Evan! :-)

llvm-svn: 42908
2007-10-12 14:53:36 +00:00
Dan Gohman
330b7915da Fix some corner cases with vectors in copyToRegs and copyFromRegs.
llvm-svn: 42907
2007-10-12 14:33:11 +00:00
Dan Gohman
b0b156e238 Add support to SplitVectorOp for powi, where the second operand
is a scalar integer.

llvm-svn: 42906
2007-10-12 14:13:46 +00:00
Evan Cheng
9beb8daf9c Restrict EXTRACT_SUBREG coalescing to avoid negative performance impact.
llvm-svn: 42903
2007-10-12 09:15:53 +00:00
Evan Cheng
d11cd4a095 EXTRACT_SUBREG coalescing support. The coalescer now treats EXTRACT_SUBREG like
(almost) a register copy. However, it always coalesced to the register of the
RHS (the super-register). All uses of the result of a EXTRACT_SUBREG are sub-
register uses which adds subtle complications to load folding, spiller rewrite,
etc.

llvm-svn: 42899
2007-10-12 08:50:34 +00:00
Evan Cheng
8af3000e93 Some clean up.
llvm-svn: 42898
2007-10-12 08:45:27 +00:00
Dale Johannesen
4ade2701e0 PPC long double. Implement a couple more conversions.
llvm-svn: 42888
2007-10-12 01:37:08 +00:00
Dan Gohman
ab5c3ed0d1 Add intrinsics for sin, cos, and pow. These use llvm_anyfloat_ty, and so
may be overloaded with vector types. And add a testcase for codegen for
these.

llvm-svn: 42885
2007-10-12 00:01:22 +00:00
Dan Gohman
b9863c4738 Codegen support for vector intrinsics.
Factor out the code that expands the "nasty scalar code" for unrolling
vectors into a separate routine, teach it how to handle mixed
vector/scalar operands, as seen in powi, and use it for several operators,
including sin, cos, powi, and pow.

Add support in SplitVectorOp for fpow, fpowi and for several unary
operators.

llvm-svn: 42884
2007-10-11 23:57:53 +00:00
Dale Johannesen
781403c410 Implement ppc long double->uint conversion.
Make ppc long double constants print.

llvm-svn: 42882
2007-10-11 23:32:15 +00:00
Dan Gohman
f8ab690988 Add runtime library names for pow.
llvm-svn: 42880
2007-10-11 23:09:10 +00:00
Dan Gohman
bc5fc4f519 Add an ISD::FPOW node type.
llvm-svn: 42879
2007-10-11 23:06:37 +00:00
Arnold Schwaighofer
d47210011e Added tail call optimization to the x86 back end. It can be
enabled by passing -tailcallopt to llc.  The optimization is
performed if the following conditions are satisfied:
* caller/callee are fastcc
* elf/pic is disabled OR
  elf/pic enabled + callee is in module + callee has
  visibility protected or hidden

llvm-svn: 42870
2007-10-11 19:40:01 +00:00
Dale Johannesen
0ee2a2fb59 Next PPC long double bits. First cut at constants.
No compile-time support for constant operations yet,
just format transformations.  Make readers and
writers work.  Split constants into 2 doubles in
Legalize.

llvm-svn: 42865
2007-10-11 18:07:22 +00:00
Duncan Sands
a8baeb6dab Correct swapped arguments to getConstant.
llvm-svn: 42824
2007-10-10 09:54:50 +00:00
Dale Johannesen
76458ddf1e Next PPC long double bits: ppcf128->i32 conversion.
Surprisingly complicated.
Adds getTargetNode for 2 outputs, no inputs (missing).

llvm-svn: 42822
2007-10-10 01:01:31 +00:00
Evan Cheng
726b00c4dd Bad choice of variable name.
llvm-svn: 42821
2007-10-10 00:11:40 +00:00
Evan Cheng
f979e5b206 Fix an extremely stupid bug that prevented first round of coalescing (physical registers only) from happening.
llvm-svn: 42820
2007-10-09 23:36:27 +00:00
Dan Gohman
f8c79a885f Call getFunctionNumber() instead of referencing FunctionNumber directly,
for consistency.

llvm-svn: 42769
2007-10-08 21:27:12 +00:00
Dan Gohman
6df332f0cb Migrate X86 and ARM from using X86ISD::{,I}DIV and ARMISD::MULHILO{U,S} to
use ISD::{S,U}DIVREM and ISD::{S,U}MUL_HIO. Move the lowering code
associated with these operators into target-independent in LegalizeDAG.cpp
and TargetLowering.cpp.

llvm-svn: 42762
2007-10-08 18:33:35 +00:00
Dan Gohman
6f2a2b45fa DAGCombiner support for UDIVREM/SDIVREM and UMUL_LOHI/SMUL_LOHI.
Check if one of the two results unneeded so see if a simpler operator
could bs used. Also check to see if each of the two computations could be
simplified if they were split into separate operators. Factor out the code
that calls visit() so that it can be used for this purpose.

llvm-svn: 42759
2007-10-08 17:57:15 +00:00
Dan Gohman
9ee1c4eee7 Add convenience overloads of SelectionDAG::getNode that take a SDVTList
and individual SDOperand operands.

llvm-svn: 42753
2007-10-08 15:49:58 +00:00
Dan Gohman
58512cb6e2 In -debug mode, dump SelectionDAGs both before and after the
optimization passes.

llvm-svn: 42749
2007-10-08 15:12:17 +00:00
Evan Cheng
96099de5bb Kill cycle of an live range is always the last use index + 1.
llvm-svn: 42742
2007-10-08 06:59:30 +00:00
Neil Booth
6e01c5df37 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Evan Cheng
0eed7948ce Reapply 42677.
llvm-svn: 42692
2007-10-06 08:19:55 +00:00
Chris Lattner
63443a5bc3 revert evan's patch until the header is committed
llvm-svn: 42686
2007-10-06 06:08:17 +00:00
Evan Cheng
dc95020e30 Added DAG xforms. e.g.
(vextract (v4f32 s2v (f32 load $addr)), 0) -> (f32 load $addr) 
(vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
Remove x86 specific patterns.

llvm-svn: 42677
2007-10-06 02:46:29 +00:00
Dale Johannesen
9b7ac95116 Next powerpc long double bits. Comparisons work,
although not well, and shortening FP converts.

llvm-svn: 42672
2007-10-06 01:24:11 +00:00
Dale Johannesen
c7b51b678d First round of ppc long double. call/return and
basic arithmetic works.
Rename RTLIB long double functions to distinguish
different flavors of long double; the lib functions
have different names, alas.

llvm-svn: 42644
2007-10-05 20:04:43 +00:00
Dan Gohman
06e6956edb Legalize support for MUL_LOHI and DIVREM.
llvm-svn: 42636
2007-10-05 14:17:22 +00:00
Dan Gohman
6132098d91 Fix a typo in a comment.
llvm-svn: 42635
2007-10-05 14:11:58 +00:00
Dan Gohman
dab5fa8685 Provide names for MUL_LOHI and DIVREM operators.
llvm-svn: 42634
2007-10-05 14:11:04 +00:00
Evan Cheng
ed7614b4d6 Chain producing nodes cannot be moved, not chain reading nodes.
llvm-svn: 42627
2007-10-05 01:42:35 +00:00
Evan Cheng
20239e9725 Oops. Didn't mean to leave this in.
llvm-svn: 42626
2007-10-05 01:39:40 +00:00
Evan Cheng
de07843bf3 If a node that defines a physical register that is expensive to copy. The
scheduler will try a number of tricks in order to avoid generating the
copies. This may not be possible in case the node produces a chain value
that prevent movement. Try unfolding the load from the node before to allow
it to be moved / cloned.

llvm-svn: 42625
2007-10-05 01:39:18 +00:00
Evan Cheng
5ae84c0fa6 Add a variant of getTargetNode() that takes a vector of MVT::ValueType.
llvm-svn: 42620
2007-10-05 01:10:49 +00:00
Evan Cheng
ec6d5655c6 Silence a warning.
llvm-svn: 42619
2007-10-05 01:09:32 +00:00
Dan Gohman
30ba45b569 Use empty() member functions when that's what's being tested for instead
of comparing begin() and end().

llvm-svn: 42585
2007-10-03 19:26:29 +00:00
Dale Johannesen
a4e3643cb3 Rewrite sqrt and powi to use anyfloat. By popular demand.
llvm-svn: 42537
2007-10-02 17:43:59 +00:00
Dale Johannesen
d94f00234f Fix stride computations for long double arrays.
llvm-svn: 42508
2007-10-01 23:08:35 +00:00
Dan Gohman
d3dfb76a43 Move the code that emits the .file directives so that it runs after the
SourceFiles list is fully filled in so that it sees all of the files.

llvm-svn: 42506
2007-10-01 22:40:20 +00:00
Evan Cheng
d1a77589e9 Remove simple scheduler.
llvm-svn: 42499
2007-10-01 20:44:07 +00:00
Dale Johannesen
aa97ad6250 remove dup comment
llvm-svn: 42486
2007-09-30 19:08:12 +00:00
Dale Johannesen
2a0b2ab2fc Constant fold int-to-long-double conversions;
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).

llvm-svn: 42484
2007-09-30 18:19:03 +00:00
Gordon Henriksen
822397fb31 This is done already.
llvm-svn: 42467
2007-09-29 02:23:08 +00:00
Gordon Henriksen
2b019da6b0 Collector is the base class for garbage collection code generators.
This version enhances the previous patch to add root initialization
as discussed here:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070910/053455.html

Collector gives its subclasses control over generic algorithms:

  unsigned NeededSafePoints; //< Bitmask of required safe points.
  bool CustomReadBarriers;   //< Default is to insert loads.
  bool CustomWriteBarriers;  //< Default is to insert stores.
  bool CustomRoots;          //< Default is to pass through to backend.
  bool InitRoots;            //< If set, roots are nulled during lowering.

It also has callbacks which collectors can hook:

  /// If any of the actions are set to Custom, this is expected to
  /// be overriden to create a transform to lower those actions to
  /// LLVM IR.
  virtual Pass *createCustomLoweringPass() const;

  /// beginAssembly/finishAssembly - Emit module metadata as
  /// assembly code.
  virtual void beginAssembly(Module &M, std::ostream &OS,
                             AsmPrinter &AP,
                             const TargetAsmInfo &TAI) const;
  virtual void finishAssembly(Module &M,
                              CollectorModuleMetadata &CMM,
                              std::ostream &OS, AsmPrinter &AP,
                              const TargetAsmInfo &TAI) const;  

Various other independent algorithms could be implemented, but were
not necessary for the initial two collectors. Some examples are
listed here:

http://llvm.org/docs/GarbageCollection.html#collector-algos

llvm-svn: 42466
2007-09-29 02:13:43 +00:00
Dan Gohman
02f80006f8 Teach SplitVectorOp how to split INSERT_VECTOR_ELT.
llvm-svn: 42457
2007-09-28 23:53:40 +00:00
Evan Cheng
1a48cdc61e If two instructions are both two-address code, favors (schedule closer to
terminator) the one that has a CopyToReg use. This fixes
2006-05-11-InstrSched.ll with -new-cc-modeling-scheme.

llvm-svn: 42453
2007-09-28 22:32:30 +00:00
Evan Cheng
2fca1e4f84 Remove a poor scheduling heuristic.
llvm-svn: 42443
2007-09-28 19:37:35 +00:00
Evan Cheng
71904c241e Trim some unneeded fields.
llvm-svn: 42442
2007-09-28 19:24:24 +00:00
Dale Johannesen
8660e0ed82 Fix long double -> uint64 conversion.
llvm-svn: 42440
2007-09-28 18:44:17 +00:00
Dale Johannesen
a30678c8f0 minor long double related changes
llvm-svn: 42439
2007-09-28 18:06:58 +00:00
Dan Gohman
cf40e00d32 Make the checks for DW_FORM_data4 consistent with the others, and
add more such code for DIEDwarfLabel::SizeOf and DIEObjectLabel::SizeOf.

llvm-svn: 42435
2007-09-28 16:50:28 +00:00
Dan Gohman
8e1513ad66 Use 32-bit data directives for DW_FORM_data4 format data, even on
targets with 64-bit addresses.

llvm-svn: 42434
2007-09-28 15:43:33 +00:00
Dale Johannesen
e61886cee4 Add sqrt and powi intrinsics for long double.
llvm-svn: 42423
2007-09-28 01:08:20 +00:00
Dan Gohman
50747737a5 TargetAsmInfo::getAddressSize() was incorrect for x86-64 and 64-bit targets
other than PPC64. Instead of fixing it, just remove it and fix all the
places that use it to use TargetData::getPointerSize() instead, as there
aren't very many. Most of the references were in DwarfWriter.cpp.

llvm-svn: 42419
2007-09-27 23:12:31 +00:00
Gordon Henriksen
b20ff7f981 CollectorMetadata abstractly describes stack maps for a function.
It includes:

 - location and of each safe point in machine code (identified by a
   label)
 - location of each root within the stack frame (identified by an
   offset), including the metadata tag provided to llvm.gcroot in
   the user program
 - size of the stack frame (for collectors which want to cheat on
   stack crawling :)
 - and eventually will include liveness

It is to be populated by back-ends during code-generation.

CollectorModuleMetadata aggregates this information across the
entire module.

llvm-svn: 42418
2007-09-27 22:18:46 +00:00
Gordon Henriksen
2571db23f1 My previous Registry.h header, as well as Collectors.h, which is the
registry for dynamically-loaded garbage collection compiler plugins.

llvm-svn: 42415
2007-09-27 19:34:27 +00:00
Evan Cheng
02e1749295 Avoid inserting a live register more than once.
llvm-svn: 42410
2007-09-27 18:46:06 +00:00
Evan Cheng
7a9237420b Silence a compiler warning.
llvm-svn: 42389
2007-09-27 07:35:39 +00:00
Evan Cheng
2d4b603a75 Boogs.
llvm-svn: 42388
2007-09-27 07:29:27 +00:00
Evan Cheng
f2cd163dc5 Be smarter about which node to force schedule. Reduce # of duplications + copies; Added statistics.
llvm-svn: 42387
2007-09-27 07:09:03 +00:00
Evan Cheng
788683ab56 Backtracking only when it won't create a cycle.
llvm-svn: 42384
2007-09-27 00:25:29 +00:00
Dale Johannesen
089d2e760f Make temporaries explicit to avoid premature
destruction of compiler-created ones.

llvm-svn: 42383
2007-09-26 23:20:33 +00:00
Evan Cheng
29817845b3 - Move getPhysicalRegisterRegClass() from ScheduleDAG to MRegisterInfo.
- Added ability to emit cross class register copies to the BBRU scheduler.
- More aggressive backtracking.

llvm-svn: 42375
2007-09-26 21:36:17 +00:00
Dale Johannesen
69595b587f Enable codegen for long double abs, sin, cos
llvm-svn: 42368
2007-09-26 21:10:55 +00:00
Dale Johannesen
20674e6c52 Fix f80 UNDEF.
llvm-svn: 42359
2007-09-26 17:26:49 +00:00
Evan Cheng
5f9e291240 Allow copyRegToReg to emit cross register classes copies.
Tested with "make check"!

llvm-svn: 42346
2007-09-26 06:25:56 +00:00
Dan Gohman
8385890394 Move the setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand) and
the check to see if the assembler supports .loc from X86TargetLowering
into the superclass TargetLowering.

llvm-svn: 42297
2007-09-25 15:10:49 +00:00
Evan Cheng
6d8f155a63 Added major new capabilities to scheduler (only BURR for now) to support physical register dependency. The BURR scheduler can now backtrace and duplicate instructions in order to avoid "expensive / impossible to copy" values (e.g. status flag EFLAGS for x86) from being clobbered.
llvm-svn: 42284
2007-09-25 01:54:36 +00:00
Dan Gohman
db6903c748 Don't emit .debug_line header data if there aren't any lines to put in it,
such as will happen when .loc directives are used.

llvm-svn: 42277
2007-09-24 21:43:52 +00:00
Dan Gohman
a5a089d5f9 Move the Asm->EOL() call for EmitDebugARanges outside the #ifdef for
consistency with the other currently empty sections.

llvm-svn: 42276
2007-09-24 21:36:21 +00:00
Dan Gohman
7de5440570 Add support for emitting .file directives to set up file numbers for
use with .loc directives.

llvm-svn: 42275
2007-09-24 21:32:18 +00:00
Dan Gohman
d005faa65d Add a routine for emitting .file directives, for setting up
file numbers to use with .loc directives.

llvm-svn: 42272
2007-09-24 20:58:13 +00:00
Dan Gohman
dd675a5064 Use the correct result value type instead of using getValueType(0)
in ExpandEXTRACT_VECTOR_ELT and SplitVectorOp. This fixes an abort
in the included testcase.

llvm-svn: 42264
2007-09-24 15:54:53 +00:00
Chris Lattner
0fc154af3d When emitting .set directives, make sure the EH and Debug labels can't conflict.
llvm-svn: 42257
2007-09-24 03:35:37 +00:00
Chris Lattner
12ed5081b8 initialize isstore/isload fields in ctor, fixing PR1695
llvm-svn: 42222
2007-09-22 07:02:12 +00:00
Dale Johannesen
c7279629cc Change APFloat::convertFromInteger to take the incoming
bit width instead of number of words allocated, which
makes it actually work for int->APF conversions.
Adjust callers.  Add const to one of the APInt constructors
to prevent surprising match when called with const
argument.

llvm-svn: 42210
2007-09-21 22:09:37 +00:00
Chris Lattner
e82eb89d0f don't read Block after it is freed. This fixes PR1684
llvm-svn: 42204
2007-09-21 18:25:53 +00:00
Chris Lattner
eed3e42816 initialize SetCCResultContents, fixing PR1693
llvm-svn: 42193
2007-09-21 17:06:39 +00:00
Dale Johannesen
04682bdc81 More long double fixes. x86_64 should build now.
llvm-svn: 42155
2007-09-19 23:55:34 +00:00
Dale Johannesen
9e04c2d5af Fix longdouble -> uint conversion.
llvm-svn: 42143
2007-09-19 17:53:26 +00:00
Evan Cheng
4a117958df Use struct SDep instead of std::pair for SUnit pred and succ lists. First step
in tracking physical register output dependencies.

llvm-svn: 42125
2007-09-19 01:38:40 +00:00
Evan Cheng
2716b97b13 Fix a bogus splat xform:
shuffle <undef, undef, x, undef>, <undef, undef, undef, undef>, <2, 2, 2, 2>
!=
<undef, undef, x, undef>

llvm-svn: 42111
2007-09-18 21:54:37 +00:00
Dale Johannesen
83b2001d42 Prevent crash on long double.
llvm-svn: 42103
2007-09-18 18:36:59 +00:00
Bill Wendling
bfd2f2f6d7 Don't pass back a reference to a temporary.
llvm-svn: 42086
2007-09-18 09:10:16 +00:00
Bill Wendling
537b869514 The exception handling function info should be reset for each new
function. The information isn't used heavily -- it's only used at the end
of exception handling emission -- so there's no need to cache it.

llvm-svn: 42078
2007-09-18 05:03:44 +00:00
Bill Wendling
803e0d9970 Objective-C was generating EH frame info like this:
"_-[NSString(local) isNullOrNil]".eh = 0
        .no_dead_strip  "_-[NSString(local) isNullOrNil]".eh

The ".eh" should be inside the quotes.

llvm-svn: 42074
2007-09-18 01:47:22 +00:00