Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java @ 6523:c8763a2deb0c
rename packages in graal.loop to match project name
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 07 Oct 2012 14:08:36 +0200 |
parents | graal/com.oracle.graal.loop/src/com/oracle/graal/compiler/loop/LoopEx.java@c612043278e9 |
children | 2e96dc4eb8e2 |
rev | line source |
---|---|
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
6523
c8763a2deb0c
rename packages in graal.loop to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
23 package com.oracle.graal.loop; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
25 import java.util.*; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
26 |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
28 import com.oracle.graal.debug.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.graph.*; |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
30 import com.oracle.graal.graph.iterators.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.lir.cfg.*; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
33 import com.oracle.graal.nodes.calc.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
34 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
35 public class LoopEx { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 private final Loop lirLoop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 private LoopFragmentInside inside; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
38 private LoopFragmentWhole whole; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
39 private CountedLoopInfo counted; //TODO (gd) detect |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
40 private LoopsData data; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
41 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 LoopEx(Loop lirLoop, LoopsData data) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
43 this.lirLoop = lirLoop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
44 this.data = data; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
47 public Loop lirLoop() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 return lirLoop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
49 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
50 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
51 public LoopFragmentInside inside() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 if (inside == null) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 inside = new LoopFragmentInside(this); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 return inside; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
57 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
58 public LoopFragmentWhole whole() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 if (whole == null) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
60 whole = new LoopFragmentWhole(this); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
62 return whole; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
63 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 |
5498
eb0d4946a1ea
Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5489
diff
changeset
|
65 @SuppressWarnings("unused") |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 public LoopFragmentInsideFrom insideFrom(FixedNode point) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 // TODO (gd) |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 return null; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
69 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
70 |
5498
eb0d4946a1ea
Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5489
diff
changeset
|
71 @SuppressWarnings("unused") |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
72 public LoopFragmentInsideBefore insideBefore(FixedNode point) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
73 // TODO (gd) |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
74 return null; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
75 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
76 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
77 public boolean isOutsideLoop(Node n) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
78 return !whole().contains(n); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
79 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
80 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
81 public LoopBeginNode loopBegin() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
82 return lirLoop().loopBegin(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
83 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
84 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
85 public FixedNode predecessor() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
86 return (FixedNode) loopBegin().forwardEnd().predecessor(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
87 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
88 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
89 public FixedNode entryPoint() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
90 return loopBegin().forwardEnd(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
91 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
92 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
93 public boolean isCounted() { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
94 return counted != null; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
95 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
96 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
97 public CountedLoopInfo counted() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
98 return counted; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
99 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
100 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
101 public LoopEx parent() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
102 if (lirLoop.parent == null) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
103 return null; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
104 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
105 return data.loop(lirLoop.parent); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
106 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
107 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
108 public int size() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
109 return whole().nodes().count(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
110 } |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
111 |
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
112 @Override |
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
113 public String toString() { |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
114 return (isCounted() ? "CountedLoop [" + counted() + "] " : "Loop ") + "(depth=" + lirLoop().depth + ") " + loopBegin(); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
115 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
116 |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
117 private class InvariantPredicate extends NodePredicate { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
118 @Override |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
119 public boolean apply(Node n) { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
120 return isOutsideLoop(n); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
121 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
122 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
123 |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
124 public void reassociateInvariants() { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
125 InvariantPredicate invariant = new InvariantPredicate(); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
126 StructuredGraph graph = (StructuredGraph) loopBegin().graph(); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
127 for (BinaryNode binary : whole().nodes().filter(BinaryNode.class)) { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
128 if (!BinaryNode.canTryReassociate(binary)) { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
129 continue; |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
130 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
131 BinaryNode result = BinaryNode.reassociate(binary, invariant); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
132 if (result != binary) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5675
diff
changeset
|
133 Debug.log(MetaUtil.format("%H::%n", Debug.contextLookup(ResolvedJavaMethod.class)) + " : Reassociated %s into %s", binary, result); |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
134 graph.replaceFloating(binary, result); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
135 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
136 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
137 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
138 |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
139 public void setCounted(CountedLoopInfo countedLoopInfo) { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
140 counted = countedLoopInfo; |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
141 } |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
142 |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
143 public LoopsData loopsData() { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
144 return data; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
145 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
146 |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
147 public NodeBitMap nodesInLoopFrom(BeginNode point, BeginNode until) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
148 Collection<BeginNode> blocks = new LinkedList<>(); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
149 Collection<BeginNode> exits = new LinkedList<>(); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
150 Queue<Block> work = new LinkedList<>(); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
151 ControlFlowGraph cfg = loopsData().controlFlowGraph(); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
152 work.add(cfg.blockFor(point)); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
153 Block untilBlock = until != null ? cfg.blockFor(until) : null; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
154 while (!work.isEmpty()) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
155 Block b = work.remove(); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
156 if (b == untilBlock) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
157 continue; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
158 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
159 if (lirLoop().exits.contains(b)) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
160 exits.add(b.getBeginNode()); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
161 } else if (lirLoop().blocks.contains(b)) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
162 blocks.add(b.getBeginNode()); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
163 work.addAll(b.getDominated()); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
164 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
165 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
166 return LoopFragment.computeNodes(point.graph(), blocks, exits); |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
167 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
168 } |