Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java @ 9968:3df534c97af1
Create Suites instance in runtime.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 10 Jun 2013 16:06:09 +0200 |
parents | 84890660eefb |
children | b270f0856a39 |
rev | line source |
---|---|
9001 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
23 package com.oracle.graal.phases.tiers; |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
24 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
25 import java.util.*; |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
26 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
27 import com.oracle.graal.graph.*; |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
28 import com.oracle.graal.options.*; |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
29 import com.oracle.graal.phases.*; |
9001 | 30 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
31 public final class Suites { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
32 |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
33 // @formatter:off |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
34 @Option(help = "The compiler configuration to use") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
35 private static final OptionValue<String> CompilerConfiguration = new OptionValue<>("basic"); |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
36 // @formatter:on |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
37 |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
38 private final PhaseSuite<HighTierContext> highTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
39 private final PhaseSuite<MidTierContext> midTier; |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
40 private final PhaseSuite<LowTierContext> lowTier; |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
41 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
42 private static final Map<String, CompilerConfiguration> configurations; |
9001 | 43 |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
44 public PhaseSuite<HighTierContext> getHighTier() { |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
45 return highTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
46 } |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
47 |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
48 public PhaseSuite<MidTierContext> getMidTier() { |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
49 return midTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
50 } |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
51 |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
52 public PhaseSuite<LowTierContext> getLowTier() { |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
53 return lowTier; |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
54 } |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
55 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
56 static { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
57 configurations = new HashMap<>(); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
58 for (CompilerConfiguration config : ServiceLoader.loadInstalled(CompilerConfiguration.class)) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
59 String name = config.getClass().getSimpleName(); |
9188
fb676e23ba51
Rename BasicConfiguration to BasicCompilerConfiguration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9142
diff
changeset
|
60 if (name.endsWith("CompilerConfiguration")) { |
fb676e23ba51
Rename BasicConfiguration to BasicCompilerConfiguration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9142
diff
changeset
|
61 name = name.substring(0, name.length() - "CompilerConfiguration".length()); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
62 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
63 configurations.put(name.toLowerCase(), config); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
64 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
65 } |
9001 | 66 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
67 private Suites(CompilerConfiguration config) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
68 highTier = config.createHighTier(); |
9137
f5c6a9b0262f
MidTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9122
diff
changeset
|
69 midTier = config.createMidTier(); |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
70 lowTier = config.createLowTier(); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
71 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
72 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
73 public static Suites createDefaultSuites() { |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
74 return createSuites(CompilerConfiguration.getValue()); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
75 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
76 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
77 public static Suites createSuites(String name) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
78 CompilerConfiguration config = configurations.get(name); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
79 if (config == null) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
80 throw new GraalInternalError("unknown compiler configuration: " + name); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
81 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
82 return new Suites(config); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
83 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
84 |
9001 | 85 } |