|
28 | 28 | import java.util.List;
|
29 | 29 | import java.util.ListIterator;
|
30 | 30 |
|
| 31 | +import jdk.graal.compiler.core.aarch64.AArch64NodeMatchRules; |
| 32 | +import jdk.graal.compiler.core.amd64.AMD64NodeMatchRules; |
31 | 33 | import org.graalvm.collections.EconomicMap;
|
32 | 34 | import org.graalvm.nativeimage.ImageSingletons;
|
33 | 35 |
|
@@ -134,20 +136,28 @@ public String getCompilerConfigurationName() {
|
134 | 136 | return COMPILER_CONFIGURATION_NAME;
|
135 | 137 | }
|
136 | 138 |
|
| 139 | + protected void populateMatchRuleRegistry(HashMap<Class<? extends NodeMatchRules>, EconomicMap<Class<? extends Node>, List<MatchStatement>>> matchRuleRegistry, Class<? extends NodeMatchRules> c) { |
| 140 | + matchRuleRegistry.put(c, MatchRuleRegistry.createRules(c)); |
| 141 | + } |
| 142 | + |
137 | 143 | public void populateMatchRuleRegistry(HashMap<Class<? extends NodeMatchRules>, EconomicMap<Class<? extends Node>, List<MatchStatement>>> matchRuleRegistry) {
|
138 |
| - Class<? extends NodeMatchRules> matchRuleClass; |
| 144 | + /* |
| 145 | + * We create both types of match rules so the target machine could use vectorization for |
| 146 | + * run-time compilation even if the image does not support vectorization. This allows |
| 147 | + * Truffle to produce optimal code on a target machine. |
| 148 | + */ |
139 | 149 | final Architecture hostedArchitecture = ConfigurationValues.getTarget().arch;
|
140 | 150 | if (hostedArchitecture instanceof AMD64) {
|
141 |
| - matchRuleClass = AMD64VectorNodeMatchRules.class; |
| 151 | + populateMatchRuleRegistry(matchRuleRegistry, AMD64NodeMatchRules.class); |
| 152 | + populateMatchRuleRegistry(matchRuleRegistry, AMD64VectorNodeMatchRules.class); |
142 | 153 | } else if (hostedArchitecture instanceof AArch64) {
|
143 |
| - matchRuleClass = AArch64VectorNodeMatchRules.class; |
| 154 | + populateMatchRuleRegistry(matchRuleRegistry, AArch64NodeMatchRules.class); |
| 155 | + populateMatchRuleRegistry(matchRuleRegistry, AArch64VectorNodeMatchRules.class); |
144 | 156 | } else if (hostedArchitecture instanceof RISCV64) {
|
145 |
| - matchRuleClass = RISCV64NodeMatchRules.class; |
| 157 | + populateMatchRuleRegistry(matchRuleRegistry, RISCV64NodeMatchRules.class); |
146 | 158 | } else {
|
147 | 159 | throw VMError.shouldNotReachHere("Can not instantiate NodeMatchRules for architecture " + hostedArchitecture.getName());
|
148 | 160 | }
|
149 |
| - |
150 |
| - matchRuleRegistry.put(matchRuleClass, MatchRuleRegistry.createRules(matchRuleClass)); |
151 | 161 | }
|
152 | 162 |
|
153 | 163 | public SubstrateBackend createBackend(Providers newProviders) {
|
|
0 commit comments