Skip to content

[GR-65385] Populate MatchRuleRegistry with both vector and normal node match rules #11272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.List;
import java.util.ListIterator;

import jdk.graal.compiler.core.aarch64.AArch64NodeMatchRules;
import jdk.graal.compiler.core.amd64.AMD64NodeMatchRules;
import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.ImageSingletons;

Expand Down Expand Up @@ -134,20 +136,28 @@ public String getCompilerConfigurationName() {
return COMPILER_CONFIGURATION_NAME;
}

protected void populateMatchRuleRegistry(HashMap<Class<? extends NodeMatchRules>, EconomicMap<Class<? extends Node>, List<MatchStatement>>> matchRuleRegistry, Class<? extends NodeMatchRules> c) {
matchRuleRegistry.put(c, MatchRuleRegistry.createRules(c));
}

public void populateMatchRuleRegistry(HashMap<Class<? extends NodeMatchRules>, EconomicMap<Class<? extends Node>, List<MatchStatement>>> matchRuleRegistry) {
Class<? extends NodeMatchRules> matchRuleClass;
/*
* We create both types of match rules so the target machine could use vectorization for
* run-time compilation even if the image does not support vectorization. This allows
* Truffle to produce optimal code on a target machine.
*/
final Architecture hostedArchitecture = ConfigurationValues.getTarget().arch;
if (hostedArchitecture instanceof AMD64) {
matchRuleClass = AMD64VectorNodeMatchRules.class;
populateMatchRuleRegistry(matchRuleRegistry, AMD64NodeMatchRules.class);
populateMatchRuleRegistry(matchRuleRegistry, AMD64VectorNodeMatchRules.class);
} else if (hostedArchitecture instanceof AArch64) {
matchRuleClass = AArch64VectorNodeMatchRules.class;
populateMatchRuleRegistry(matchRuleRegistry, AArch64NodeMatchRules.class);
populateMatchRuleRegistry(matchRuleRegistry, AArch64VectorNodeMatchRules.class);
} else if (hostedArchitecture instanceof RISCV64) {
matchRuleClass = RISCV64NodeMatchRules.class;
populateMatchRuleRegistry(matchRuleRegistry, RISCV64NodeMatchRules.class);
} else {
throw VMError.shouldNotReachHere("Can not instantiate NodeMatchRules for architecture " + hostedArchitecture.getName());
}

matchRuleRegistry.put(matchRuleClass, MatchRuleRegistry.createRules(matchRuleClass));
}

public SubstrateBackend createBackend(Providers newProviders) {
Expand Down