Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReadRegisterNode.java @ 16841:cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 11:34:38 +0200 |
parents | 5d468add216f |
children | 06c15e88d383 |
rev | line source |
---|---|
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15261
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8354
diff
changeset
|
23 package com.oracle.graal.replacements.nodes; |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.api.code.*; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
26 import com.oracle.graal.api.meta.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
14950
diff
changeset
|
27 import com.oracle.graal.compiler.common.type.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
28 import com.oracle.graal.nodeinfo.*; |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14633
diff
changeset
|
30 import com.oracle.graal.nodes.spi.*; |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
31 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
32 /** |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
33 * Access the value of a specific register. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 */ |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
35 @NodeInfo(nameTemplate = "ReadRegister %{p#register}") |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16094
diff
changeset
|
36 public class ReadRegisterNode extends FixedWithNextNode implements LIRLowerable { |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
37 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
38 /** |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
39 * The fixed register to access. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 */ |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
41 private final Register register; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
42 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
43 /** |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
44 * When true, subsequent uses of this node use the fixed register; when false, the value is |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
45 * moved into a new virtual register so that the fixed register is not seen by uses. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
46 */ |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
47 private final boolean directUse; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
48 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 /** |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 * When true, this node is also an implicit definition of the value for the register allocator, |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 * i.e., the register is an implicit incoming value; when false, the register must be defined in |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
52 * the same method or must be an register excluded from register allocation. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
53 */ |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
54 private final boolean incoming; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
56 public ReadRegisterNode(Register register, Kind kind, boolean directUse, boolean incoming) { |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 super(StampFactory.forKind(kind)); |
12793
af7fb87fc62e
pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents:
8416
diff
changeset
|
58 assert register != null; |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
59 this.register = register; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
60 this.directUse = directUse; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 this.incoming = incoming; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
63 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 /** |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
65 * Constructor to be used by node intrinsics where the stamp is inferred from the intrinsic |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
66 * definition. |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 */ |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
68 public ReadRegisterNode(Register register, boolean directUse, boolean incoming) { |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
69 super(StampFactory.forNodeIntrinsic()); |
12793
af7fb87fc62e
pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents:
8416
diff
changeset
|
70 assert register != null; |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
71 this.register = register; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
72 this.directUse = directUse; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
73 this.incoming = incoming; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
74 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
75 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
76 @Override |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
77 public void generate(NodeLIRBuilderTool generator) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15261
diff
changeset
|
78 LIRKind kind = generator.getLIRGeneratorTool().getLIRKind(stamp()); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15261
diff
changeset
|
79 Value result = register.asValue(kind); |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
80 if (incoming) { |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14633
diff
changeset
|
81 generator.getLIRGeneratorTool().emitIncomingValues(new Value[]{result}); |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
82 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 if (!directUse) { |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14633
diff
changeset
|
84 result = generator.getLIRGeneratorTool().emitMove(result); |
8354
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
85 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
86 generator.setResult(this, result); |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
87 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
88 |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 @Override |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
90 public String toString(Verbosity verbosity) { |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 if (verbosity == Verbosity.Name) { |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
92 return super.toString(Verbosity.Name) + "%" + register; |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
93 } else { |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
94 return super.toString(verbosity); |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
95 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
96 } |
55ef03d64f03
Generalize read and write of fixed register for snippets. Move to HotSpot-independent project.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
97 } |