Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java @ 13234:7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Dec 2013 18:02:11 +0100 |
parents | 325b4e4efb60 |
children | d3b3c6e17d40 |
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 | 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 | 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 | 80 } |
81 | |
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 |
13234
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
97 public boolean hasFrame() { |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
98 return true; |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
99 } |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
100 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
102 public void enter(CompilationResultBuilder crb) { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 Debug.log("Nothing to do here"); |
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 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
107 public void leave(CompilationResultBuilder crb) { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 Debug.log("Nothing to do here"); |
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 } |
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 @Override |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 protected AbstractAssembler createAssembler(FrameMap frameMap) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
114 return new HSAILAssembler(getTarget()); |
10662
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 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 @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
|
118 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
|
119 FrameMap frameMap = lirGen.frameMap; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
120 AbstractAssembler masm = createAssembler(frameMap); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 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
|
122 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
|
123 crb.setFrameSize(frameMap.frameSize()); |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
124 return crb; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
128 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
|
129 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
|
130 // Emit the prologue. |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
131 codeBuffer = crb.asm.codeBuffer; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 codeBuffer.emitString0("version 0:95: $full : $large;"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 codeBuffer.emitString(""); |
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 Signature signature = method.getSignature(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 int sigParamCount = signature.getParameterCount(false); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 // 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
|
138 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 int nonConstantParamCount = sigParamCount - 1; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 boolean isStatic = (Modifier.isStatic(method.getModifiers())); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 // Determine if this is an object lambda. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 boolean isObjectLambda = true; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
143 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 if (signature.getParameterType(nonConstantParamCount, null).getKind() == Kind.Int) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 isObjectLambda = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 // Add space for gid int reg. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 nonConstantParamCount++; |
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 // 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
|
152 // as the first parameter. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 if (!isStatic) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 nonConstantParamCount++; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 // Add in any "constant" parameters (currently none). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 int totalParamCount = nonConstantParamCount; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 JavaType[] paramtypes = new JavaType[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 String[] paramNames = new String[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 int pidx = 0; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
161 MetaAccessProvider metaAccess = getProviders().getMetaAccess(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 for (int i = 0; i < totalParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 if (i == 0 && !isStatic) { |
12363
78e5badf4b8e
moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12045
diff
changeset
|
164 paramtypes[i] = metaAccess.lookupJavaType(Object.class); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 paramNames[i] = "%_this"; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } else if (i < nonConstantParamCount) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 if (isObjectLambda && (i == (nonConstantParamCount))) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 // 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
|
169 paramtypes[i] = metaAccess.lookupJavaType(int.class); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 paramNames[i] = "%_gid"; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 paramtypes[i] = signature.getParameterType(pidx++, null); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 paramNames[i] = "%_arg" + i; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 } |
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 } |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
177 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 codeBuffer.emitString0("// " + (isStatic ? "static" : "instance") + " method " + method); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 codeBuffer.emitString(""); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 codeBuffer.emitString0("kernel &run ("); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 codeBuffer.emitString(""); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
182 |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
183 FrameMap frameMap = crb.frameMap; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 RegisterConfig regConfig = frameMap.registerConfig; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 // 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
|
186 JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 // Include the gid. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 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
|
189 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
190 // 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
|
191 // 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
|
192 if (sigParamCount > 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
193 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
|
194 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
195 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
|
196 |
10662
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 * 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
|
199 * (which is the gid). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 String[] paramHsailSizes = new String[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 for (int i = 0; i < totalParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 String paramtypeStr = paramtypes[i].toString(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 String sizeStr = paramTypeMap.get(paramtypeStr); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 // 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
|
207 paramHsailSizes[i] = (sizeStr != null ? sizeStr : "u64"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 // Emit the kernel function parameters. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 for (int i = 0; i < totalParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 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
|
212 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 if (i != totalParamCount - 1) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 str += ","; |
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 codeBuffer.emitString(str); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 codeBuffer.emitString(") {"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 |
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 * 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
|
222 * 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
|
223 * loaded up front but will be loaded as needed. |
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 for (int i = 0; i < nonConstantParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
226 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
|
227 } |
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 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
230 * 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
|
231 * 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
|
232 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 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
|
234 codeBuffer.emitString("workitemabsid_u32 " + workItemReg + ", 0;"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 |
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 * 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
|
238 * 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
|
239 * 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
|
240 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 int spillsegDeclarationPosition = codeBuffer.position() + 1; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 String spillsegTemplate = "align 4 spill_u8 %spillseg[123456];"; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 codeBuffer.emitString(spillsegTemplate); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 // Emit object array load prologue here. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 if (isObjectLambda) { |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
246 boolean useCompressedOops = getRuntime().getConfig().useCompressedOops; |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
247 final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(Kind.Object); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 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
|
249 // 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
|
250 // 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
|
251 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
|
252 // Convert gid to long. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
253 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
|
254 // 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
|
255 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
|
256 // Adjust for actual data start. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 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
|
258 // Add to array ref ptr. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 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
|
260 // 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
|
261 if (useCompressedOops) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
262 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
263 // 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
|
264 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
|
265 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
266 long narrowOopBase = getRuntime().getConfig().narrowOopBase; |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
267 long narrowOopShift = getRuntime().getConfig().narrowOopShift; |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
268 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
269 if (narrowOopBase == 0 && narrowOopShift == 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
270 // 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
|
271 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
|
272 } else { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
273 if (narrowOopBase == 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
274 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
|
275 } else if (narrowOopShift == 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
276 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
|
277 } else { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
278 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
|
279 } |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
280 } |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
281 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
282 } else { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
283 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
|
284 } |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
285 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
286 // Prologue done, Emit code for the LIR. |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
287 lirGen.lir.emitCode(crb); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
288 // 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
|
289 long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
290 String spillsegStringFinal; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 if (maxStackSize == 0) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
292 // If no spilling, get rid of spillseg declaration. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
293 char[] array = new char[spillsegTemplate.length()]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
294 Arrays.fill(array, ' '); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
295 spillsegStringFinal = new String(array); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
296 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
297 spillsegStringFinal = spillsegTemplate.replace("123456", String.format("%6d", maxStackSize)); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 codeBuffer.emitString(spillsegStringFinal, spillsegDeclarationPosition); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
300 // Emit the epilogue. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
301 codeBuffer.emitString0("};"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 codeBuffer.emitString(""); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
304 } |