Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/SpecializationData.java @ 7502:6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 18 Jan 2013 13:28:12 +0100 |
parents | |
children | ef1b41ea0a90 |
comparison
equal
deleted
inserted
replaced
7497:0f8c6dbf68be | 7502:6343a09b2ec1 |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.codegen.processor.node; | |
24 | |
25 import com.oracle.truffle.api.codegen.*; | |
26 import com.oracle.truffle.codegen.processor.template.*; | |
27 | |
28 public class SpecializationData extends TemplateMethod { | |
29 | |
30 private final int order; | |
31 private final boolean generic; | |
32 private final boolean uninitialized; | |
33 private final SpecializationThrowsData[] exceptions; | |
34 private SpecializationGuardData[] guards; | |
35 private ShortCircuitData[] shortCircuits; | |
36 | |
37 private NodeData node; | |
38 | |
39 public SpecializationData(TemplateMethod template, int order, SpecializationThrowsData[] exceptions) { | |
40 super(template); | |
41 this.order = order; | |
42 this.generic = false; | |
43 this.uninitialized = false; | |
44 this.exceptions = exceptions; | |
45 | |
46 for (SpecializationThrowsData exception : exceptions) { | |
47 exception.setSpecialization(this); | |
48 } | |
49 } | |
50 | |
51 public SpecializationData(TemplateMethod template, boolean generic, boolean uninitialized) { | |
52 super(template); | |
53 this.order = Specialization.DEFAULT_ORDER; | |
54 this.generic = generic; | |
55 this.uninitialized = uninitialized; | |
56 this.exceptions = new SpecializationThrowsData[0]; | |
57 this.guards = new SpecializationGuardData[0]; | |
58 } | |
59 | |
60 public NodeData getNode() { | |
61 return node; | |
62 } | |
63 | |
64 public void setNode(NodeData node) { | |
65 this.node = node; | |
66 } | |
67 | |
68 public void setGuards(SpecializationGuardData[] guards) { | |
69 this.guards = guards; | |
70 } | |
71 | |
72 public int getOrder() { | |
73 return order; | |
74 } | |
75 | |
76 public boolean isGeneric() { | |
77 return generic; | |
78 } | |
79 | |
80 public boolean isUninitialized() { | |
81 return uninitialized; | |
82 } | |
83 | |
84 public SpecializationThrowsData[] getExceptions() { | |
85 return exceptions; | |
86 } | |
87 | |
88 public SpecializationGuardData[] getGuards() { | |
89 return guards; | |
90 } | |
91 | |
92 public void setShortCircuits(ShortCircuitData[] shortCircuits) { | |
93 this.shortCircuits = shortCircuits; | |
94 } | |
95 | |
96 public ShortCircuitData[] getShortCircuits() { | |
97 return shortCircuits; | |
98 } | |
99 | |
100 public SpecializationData findNextSpecialization() { | |
101 SpecializationData[] specializations = node.getSpecializations(); | |
102 for (int i = 0; i < specializations.length - 1; i++) { | |
103 if (specializations[i] == this) { | |
104 return specializations[i + 1]; | |
105 } | |
106 } | |
107 return null; | |
108 } | |
109 | |
110 public boolean hasDynamicGuards() { | |
111 for (SpecializationGuardData guard : getGuards()) { | |
112 if (guard.isOnExecution()) { | |
113 return true; | |
114 } | |
115 } | |
116 return false; | |
117 } | |
118 | |
119 public ActualParameter getPreviousParam(ActualParameter searchParam) { | |
120 ActualParameter prev = null; | |
121 for (ActualParameter param : getParameters()) { | |
122 if (param == searchParam) { | |
123 return prev; | |
124 } | |
125 prev = param; | |
126 } | |
127 return prev; | |
128 } | |
129 | |
130 } |