annotate graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java @ 11757:ec058ce90a3d

pylint fixes
author Mick Jordan <mick.jordan@oracle.com>
date Mon, 23 Sep 2013 21:35:12 -0700
parents 395d34c10e26
children d7f8dd4fe876
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir.hsail;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.api.meta.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.asm.hsail.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.graph.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.lir.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.lir.asm.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.nodes.calc.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 * Implementation of control flow instructions.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 public class HSAILControlFlow {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 public static class ReturnOp extends HSAILLIRInstruction {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 @Use({REG, ILLEGAL}) protected Value x;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 public ReturnOp(Value x) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 this.x = x;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 if (tasm.frameContext != null) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 tasm.frameContext.leave(tasm);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 masm.exit();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55
10769
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
56
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
57 public static class ForeignCallNoArgOp extends HSAILLIRInstruction {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
58
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
59 @Def({REG}) protected Value out;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
60 String callName;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
61
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
62 public ForeignCallNoArgOp(String callName, Value out) {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
63 this.out = out;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
64 this.callName = callName;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
65 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
66
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
67 @Override
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
68 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
69 masm.emitComment("//ForeignCall to " + callName + " would have gone here");
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
70 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
71 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
72
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
73 public static class ForeignCall1ArgOp extends ForeignCallNoArgOp {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
74
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
75 @Use({REG, ILLEGAL}) protected Value arg1;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
76
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
77 public ForeignCall1ArgOp(String callName, Value out, Value arg1) {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
78 super(callName, out);
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
79 this.arg1 = arg1;
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
80 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
81 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
82
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10662
diff changeset
83
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 public static class CompareBranchOp extends HSAILLIRInstruction implements StandardOp.BranchOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 @Opcode protected final HSAILCompare opcode;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 @Use({REG, CONST}) protected Value x;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 @Use({REG, CONST}) protected Value y;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 @Def({REG}) protected Value z;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90 protected Condition condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91 protected LabelRef destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
92 protected boolean unordered = false;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
93 @Def({REG}) protected Value result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 public CompareBranchOp(HSAILCompare opcode, Condition condition, Value x, Value y, Value z, Value result, LabelRef destination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 this.condition = condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 this.opcode = opcode;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 this.x = x;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 this.y = y;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 this.z = z;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 this.result = result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 this.destination = destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 public LabelRef destination() {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107 return destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 public void negate(LabelRef newDestination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 destination = newDestination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 condition = condition.negate();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 masm.cbr(masm.nameOf(destination.label()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 public static class FloatCompareBranchOp extends CompareBranchOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 public FloatCompareBranchOp(HSAILCompare opcode, Condition condition, Value x, Value y, Value z, Value result, LabelRef destination, boolean unordered) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 super(opcode, condition, x, y, z, result, destination);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 this.unordered = unordered;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
130 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 public void negate(LabelRef newDestination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 destination = newDestination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 condition = condition.negate();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 unordered = !unordered;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 masm.cbr(masm.nameOf(destination.label()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 public static class DoubleCompareBranchOp extends CompareBranchOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 public DoubleCompareBranchOp(HSAILCompare opcode, Condition condition, Value x, Value y, Value z, Value result, LabelRef destination, boolean unordered) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 super(opcode, condition, x, y, z, result, destination);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 this.unordered = unordered;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 public void negate(LabelRef newDestination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 destination = newDestination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 condition = condition.negate();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 unordered = !unordered;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 masm.cbr(masm.nameOf(destination.label()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 public static class BranchOp extends HSAILLIRInstruction implements StandardOp.BranchOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 protected Condition condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 protected LabelRef destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 @Def({REG}) protected Value result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 public BranchOp(Condition condition, Value result, LabelRef destination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 this.condition = condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 this.destination = destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 this.result = result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 masm.cbr(masm.nameOf(destination.label()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 public LabelRef destination() {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 return destination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
187 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 public void negate(LabelRef newDestination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 destination = newDestination;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190 condition = condition.negate();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
191 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 public static class FloatBranchOp extends BranchOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 public FloatBranchOp(Condition condition, Value result, LabelRef destination) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 super(condition, result, destination);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 masm.cbr(masm.nameOf(destination.label()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 public static class CondMoveOp extends HSAILLIRInstruction {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 @Opcode protected final HSAILCompare opcode;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 @Def({REG, HINT}) protected Value result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 @Alive({REG}) protected Value trueValue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211 @Use({REG, STACK, CONST}) protected Value falseValue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 @Use({REG, STACK, CONST}) protected Value left;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 @Use({REG, STACK, CONST}) protected Value right;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 protected final Condition condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 public CondMoveOp(HSAILCompare opcode, Variable left, Variable right, Variable result, Condition condition, Variable trueValue, Value falseValue) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 this.opcode = opcode;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218 this.result = result;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 this.left = left;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 this.right = right;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221 this.condition = condition;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 this.trueValue = trueValue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 this.falseValue = falseValue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
227 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 HSAILCompare.emit(tasm, masm, condition, left, right, right, false);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229 cmove(tasm, masm, result, false, trueValue, falseValue);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 public static class FloatCondMoveOp extends CondMoveOp {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 private final boolean unorderedIsTrue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237 public FloatCondMoveOp(HSAILCompare opcode, Variable left, Variable right, Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Value falseValue) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 super(opcode, left, right, result, condition, trueValue, falseValue);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 this.unorderedIsTrue = unorderedIsTrue;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
243 public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 HSAILCompare.emit(tasm, masm, condition, left, right, right, unorderedIsTrue);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 cmove(tasm, masm, result, false, trueValue, falseValue);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
246 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
248
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 @SuppressWarnings("unused")
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
250 private static void cmove(TargetMethodAssembler tasm, HSAILAssembler masm, Value result, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
251 // Check that we don't overwrite an input operand before it is used.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
252 assert (result.getKind() == trueValue.getKind() && result.getKind() == falseValue.getKind());
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253 int width;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
254 switch (result.getKind()) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
255 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
256 * We don't need to pass the cond to the assembler. We will always use $c0 as the control
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
257 * register.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
258 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
259 case Float:
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
260 case Int:
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
261 width = 32;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
262 break;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
263 case Double:
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
264 case Long:
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
265 width = 64;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
266 break;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
267 default:
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
268 throw GraalInternalError.shouldNotReachHere();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
269 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
270 masm.cmovCommon(result, trueValue, falseValue, width);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
271 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
272 }