annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java @ 13229:325b4e4efb60

added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Dec 2013 16:33:41 +0100
parents 1a66453f73db
children 7e237378923d
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 */
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
23 package com.oracle.graal.hotspot.hsail;
10662
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.api.code.CallingConvention.Type.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
28 import java.lang.reflect.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
29 import java.util.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
30
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.api.code.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.api.meta.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.asm.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.asm.hsail.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.compiler.gen.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.debug.*;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
37 import com.oracle.graal.hotspot.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
38 import com.oracle.graal.hotspot.meta.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
39 import com.oracle.graal.hsail.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.lir.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.lir.asm.*;
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
42 import com.oracle.graal.lir.hsail.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.nodes.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44
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 * HSAIL specific backend.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 */
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
48 public class HSAILHotSpotBackend extends HotSpotBackend {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 private Map<String, String> paramTypeMap = new HashMap<>();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 private Buffer codeBuffer;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
53 public HSAILHotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
54 super(runtime, providers);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 paramTypeMap.put("HotSpotResolvedPrimitiveType<int>", "s32");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 paramTypeMap.put("HotSpotResolvedPrimitiveType<float>", "f32");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 paramTypeMap.put("HotSpotResolvedPrimitiveType<double>", "f64");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 paramTypeMap.put("HotSpotResolvedPrimitiveType<long>", "s64");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
61 @Override
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
62 public boolean shouldAllocateRegisters() {
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
63 return true;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
64 }
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
65
12797
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
66 @Override
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
67 public void completeInitialization() {
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
68 final HotSpotProviders providers = getProviders();
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
69 HotSpotVMConfig config = getRuntime().getConfig();
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
70 final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
71 lowerer.initialize(providers, config);
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
72 }
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
73
11739
b8695542d41b added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents: 10956
diff changeset
74 /**
b8695542d41b added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents: 10956
diff changeset
75 * Use the HSAIL register set when the compilation target is HSAIL.
b8695542d41b added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents: 10956
diff changeset
76 */
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 @Override
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
78 public FrameMap newFrameMap() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
79 return new HSAILFrameMap(getCodeCache());
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
80 }
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
81
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
82 @Override
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
84 return new HSAILHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir);
10662
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
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 public String getPartialCodeString() {
12469
2a833e0d4e0a gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
88 if (codeBuffer == null) {
2a833e0d4e0a gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
89 return "";
2a833e0d4e0a gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
90 }
2a833e0d4e0a gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
91 byte[] data = codeBuffer.copyData(0, codeBuffer.position());
2a833e0d4e0a gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
92 return (data == null ? "" : new String(data));
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
93 }
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 class HotSpotFrameContext implements FrameContext {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
98 public void enter(CompilationResultBuilder crb) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 Debug.log("Nothing to do here");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
103 public void leave(CompilationResultBuilder crb) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 Debug.log("Nothing to do here");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 @Override
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 protected AbstractAssembler createAssembler(FrameMap frameMap) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
110 return new HSAILAssembler(getTarget());
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 @Override
13229
325b4e4efb60 added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents: 13227
diff changeset
114 public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 FrameMap frameMap = lirGen.frameMap;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
116 AbstractAssembler masm = createAssembler(frameMap);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117 HotSpotFrameContext frameContext = new HotSpotFrameContext();
13229
325b4e4efb60 added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents: 13227
diff changeset
118 CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult);
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
119 crb.setFrameSize(frameMap.frameSize());
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
120 return crb;
10662
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 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
124 public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod method) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 assert method != null : lirGen.getGraph() + " is not associated with a method";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 // Emit the prologue.
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
127 codeBuffer = crb.asm.codeBuffer;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 codeBuffer.emitString0("version 0:95: $full : $large;");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 codeBuffer.emitString("");
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
130
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 Signature signature = method.getSignature();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 int sigParamCount = signature.getParameterCount(false);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 // We're subtracting 1 because we're not making the final gid as a parameter.
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
134
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 int nonConstantParamCount = sigParamCount - 1;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 boolean isStatic = (Modifier.isStatic(method.getModifiers()));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 // Determine if this is an object lambda.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 boolean isObjectLambda = true;
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
139
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 if (signature.getParameterType(nonConstantParamCount, null).getKind() == Kind.Int) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 isObjectLambda = false;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 // Add space for gid int reg.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 nonConstantParamCount++;
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
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 // If this is an instance method, include mappings for the "this" parameter
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 // as the first parameter.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 if (!isStatic) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 nonConstantParamCount++;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 // Add in any "constant" parameters (currently none).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 int totalParamCount = nonConstantParamCount;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 JavaType[] paramtypes = new JavaType[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 String[] paramNames = new String[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 int pidx = 0;
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
157 MetaAccessProvider metaAccess = getProviders().getMetaAccess();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 for (int i = 0; i < totalParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 if (i == 0 && !isStatic) {
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12045
diff changeset
160 paramtypes[i] = metaAccess.lookupJavaType(Object.class);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 paramNames[i] = "%_this";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 } else if (i < nonConstantParamCount) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 if (isObjectLambda && (i == (nonConstantParamCount))) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 // Set up the gid register mapping.
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12045
diff changeset
165 paramtypes[i] = metaAccess.lookupJavaType(int.class);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 paramNames[i] = "%_gid";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 paramtypes[i] = signature.getParameterType(pidx++, null);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 paramNames[i] = "%_arg" + i;
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 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 }
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
173
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 codeBuffer.emitString0("// " + (isStatic ? "static" : "instance") + " method " + method);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 codeBuffer.emitString("");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176 codeBuffer.emitString0("kernel &run (");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177 codeBuffer.emitString("");
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
178
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
179 FrameMap frameMap = crb.frameMap;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 RegisterConfig regConfig = frameMap.registerConfig;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 // Build list of param types which does include the gid (for cc register mapping query).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 // Include the gid.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 System.arraycopy(paramtypes, 0, ccParamTypes, 0, nonConstantParamCount);
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
185
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
186 // Last entry is always int (its register gets used in the workitemabsid instruction)
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
187 // this is true even for object stream labmdas
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
188 if (sigParamCount > 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
189 ccParamTypes[ccParamTypes.length - 1] = metaAccess.lookupJavaType(int.class);
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
190 }
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
191 CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, ccParamTypes, getTarget(), false);
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
192
10662
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 * Compute the hsail size mappings up to but not including the last non-constant parameter
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 * (which is the gid).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 String[] paramHsailSizes = new String[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 for (int i = 0; i < totalParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200 String paramtypeStr = paramtypes[i].toString();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 String sizeStr = paramTypeMap.get(paramtypeStr);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 // Catch all for any unmapped paramtype that is u64 (address of an object).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 paramHsailSizes[i] = (sizeStr != null ? sizeStr : "u64");
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 // Emit the kernel function parameters.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 for (int i = 0; i < totalParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 String str = "kernarg_" + paramHsailSizes[i] + " " + paramNames[i];
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
208
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 if (i != totalParamCount - 1) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 str += ",";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 codeBuffer.emitString(str);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 codeBuffer.emitString(") {");
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 /*
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 * End of parameters start of prolog code. Emit the load instructions for loading of the
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218 * kernel non-constant parameters into registers. The constant class parameters will not be
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 * loaded up front but will be loaded as needed.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221 for (int i = 0; i < nonConstantParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 codeBuffer.emitString("ld_kernarg_" + paramHsailSizes[i] + " " + HSAIL.mapRegister(cc.getArgument(i)) + ", [" + paramNames[i] + "];");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 }
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 * Emit the workitemaid instruction for loading the hidden gid parameter. This is assigned
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
227 * the register as if it were the last of the nonConstant parameters.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229 String workItemReg = "$s" + Integer.toString(asRegister(cc.getArgument(nonConstantParamCount)).encoding());
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 codeBuffer.emitString("workitemabsid_u32 " + workItemReg + ", 0;");
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 * Note the logic used for this spillseg size is to leave space and then go back and patch
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234 * in the correct size once we have generated all the instructions. This should probably be
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 * done in a more robust way by implementing something like codeBuffer.insertString.
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 int spillsegDeclarationPosition = codeBuffer.position() + 1;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 String spillsegTemplate = "align 4 spill_u8 %spillseg[123456];";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 codeBuffer.emitString(spillsegTemplate);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 // Emit object array load prologue here.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241 if (isObjectLambda) {
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
242 boolean useCompressedOops = getRuntime().getConfig().useCompressedOops;
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
243 final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(Kind.Object);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 String iterationObjArgReg = HSAIL.mapRegister(cc.getArgument(nonConstantParamCount - 1));
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
245 // iterationObjArgReg will be the highest $d register in use (it is the last parameter)
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
246 // so tempReg can be the next higher $d register
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
247 String tmpReg = "$d" + (asRegister(cc.getArgument(nonConstantParamCount - 1)).encoding() + 1);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
248 // Convert gid to long.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 codeBuffer.emitString("cvt_u64_s32 " + tmpReg + ", " + workItemReg + "; // Convert gid to long");
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
250 // Adjust index for sizeof ref. Where to pull this size from?
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
251 codeBuffer.emitString("mul_u64 " + tmpReg + ", " + tmpReg + ", " + (useCompressedOops ? 4 : 8) + "; // Adjust index for sizeof ref");
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
252 // Adjust for actual data start.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253 codeBuffer.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + arrayElementsOffset + "; // Adjust for actual elements data start");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
254 // Add to array ref ptr.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
255 codeBuffer.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + iterationObjArgReg + "; // Add to array ref ptr");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
256 // Load the object into the parameter reg.
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
257 if (useCompressedOops) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
258
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
259 // Load u32 into the d 64 reg since it will become an object address
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
260 codeBuffer.emitString("ld_global_u32 " + tmpReg + ", " + "[" + tmpReg + "]" + "; // Load compressed ptr from array");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
261
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
262 long narrowOopBase = getRuntime().getConfig().narrowOopBase;
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
263 long narrowOopShift = getRuntime().getConfig().narrowOopShift;
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
264
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
265 if (narrowOopBase == 0 && narrowOopShift == 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
266 // No more calculation to do, mov to target register
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
267 codeBuffer.emitString("mov_b64 " + iterationObjArgReg + ", " + tmpReg + "; // no shift or base addition");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
268 } else {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
269 if (narrowOopBase == 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
270 codeBuffer.emitString("shl_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopShift + "; // do narrowOopShift");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
271 } else if (narrowOopShift == 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
272 codeBuffer.emitString("add_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopBase + "; // add narrowOopBase");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
273 } else {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
274 codeBuffer.emitString("mad_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + (1 << narrowOopShift) + ", " + narrowOopBase + "; // shift and add narrowOopBase");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
275 }
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
276 }
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
277
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
278 } else {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
279 codeBuffer.emitString("ld_global_u64 " + iterationObjArgReg + ", " + "[" + tmpReg + "]" + "; // Load from array element into parameter reg");
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
280 }
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
281 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
282 // Prologue done, Emit code for the LIR.
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
283 lirGen.lir.emitCode(crb);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
284 // Now that code is emitted go back and figure out what the upper Bound stack size was.
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
285 long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
286 String spillsegStringFinal;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
287 if (maxStackSize == 0) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288 // If no spilling, get rid of spillseg declaration.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
289 char[] array = new char[spillsegTemplate.length()];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
290 Arrays.fill(array, ' ');
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
291 spillsegStringFinal = new String(array);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
292 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
293 spillsegStringFinal = spillsegTemplate.replace("123456", String.format("%6d", maxStackSize));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
295 codeBuffer.emitString(spillsegStringFinal, spillsegDeclarationPosition);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
296 // Emit the epilogue.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 codeBuffer.emitString0("};");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
298 codeBuffer.emitString("");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 }