Mercurial > hg > truffle
annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java @ 14000:958c99d0790c
Split convert node into separate nodes for different conversions.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 21 Feb 2014 11:53:48 +0100 |
parents | 2c4aa758ee18 |
children | 8db6e76cb658 |
rev | line source |
---|---|
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
9f3250602d69
Preliminary counted loop detection
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; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
25 import com.oracle.graal.graph.*; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
26 import com.oracle.graal.nodes.*; |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
27 import com.oracle.graal.nodes.type.*; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
29 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
30 * This class describes a value node that is an induction variable in a counted loop. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
31 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
32 public abstract class InductionVariable { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
33 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
34 public enum Direction { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
35 Up, Down; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
36 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 public Direction opposite() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
38 switch (this) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
39 case Up: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
40 return Down; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
41 case Down: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
42 return Up; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
43 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
44 throw GraalInternalError.shouldNotReachHere(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
47 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
49 public abstract StructuredGraph graph(); |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
50 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
51 protected final LoopEx loop; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 public InductionVariable(LoopEx loop) { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 this.loop = loop; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
57 public LoopEx getLoop() { |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
58 return loop; |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
59 } |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
60 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 public abstract Direction direction(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
62 |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
63 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
64 * Returns the value node that is described by this InductionVariable instance. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
65 */ |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 public abstract ValueNode valueNode(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
68 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
69 * Returns the node that gives the initial value of this induction variable. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
70 */ |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
71 public abstract ValueNode initNode(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
72 |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
73 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
74 * Returns the stride of the induction variable. The stride is the value that is added to the |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
75 * induction variable at each iteration. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
76 */ |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
77 public abstract ValueNode strideNode(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
78 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
79 public abstract boolean isConstantInit(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
80 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
81 public abstract boolean isConstantStride(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
82 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
83 public abstract long constantInit(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
84 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
85 public abstract long constantStride(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
86 |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
87 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
88 * Returns the extremum value of the induction variable. The extremum value is the value of the |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
89 * induction variable in the loop body of the last iteration. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
90 */ |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
91 public ValueNode extremumNode() { |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
92 return extremumNode(false, valueNode().stamp()); |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
93 } |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
94 |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
95 public abstract ValueNode extremumNode(boolean assumePositiveTripCount, Stamp stamp); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
96 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
97 public abstract boolean isConstantExtremum(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
98 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
99 public abstract long constantExtremum(); |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
100 |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
101 /** |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
102 * Returns the exit value of the induction variable. The exit value is the value of the |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
103 * induction variable at the loop exit. |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
104 */ |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
105 public abstract ValueNode exitValueNode(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
106 } |