use of org.graalvm.compiler.phases.tiers.CompilerConfiguration in project graal by oracle.
the class CompilerConfigurationFactory method selectFactory.
/**
* Selects and instantiates a {@link CompilerConfigurationFactory}. The selection algorithm is
* as follows: if {@code name} is non-null, then select the factory with the same name else if
* {@code Options.CompilerConfiguration.getValue()} is non-null then select the factory whose
* name matches the value else select the factory with the highest
* {@link #autoSelectionPriority} value.
*
* @param name the name of the compiler configuration to select (optional)
*/
@SuppressWarnings("try")
public static CompilerConfigurationFactory selectFactory(String name, OptionValues options) {
CompilerConfigurationFactory factory = null;
try (InitTimer t = timer("CompilerConfigurationFactory.selectFactory")) {
String value = name == null ? Options.CompilerConfiguration.getValue(options) : name;
if ("help".equals(value)) {
System.out.println("The available Graal compiler configurations are:");
for (CompilerConfigurationFactory candidate : getAllCandidates()) {
System.out.println(" " + candidate.name);
}
System.exit(0);
} else if (value != null) {
for (CompilerConfigurationFactory candidate : GraalServices.load(CompilerConfigurationFactory.class)) {
if (candidate.name.equals(value)) {
factory = candidate;
break;
}
}
if (factory == null) {
throw new GraalError("Graal compiler configuration '%s' not found. Available configurations are: %s", value, getAllCandidates().stream().map(c -> c.name).collect(Collectors.joining(", ")));
}
} else {
List<CompilerConfigurationFactory> candidates = getAllCandidates();
if (candidates.isEmpty()) {
throw new GraalError("No %s providers found", CompilerConfigurationFactory.class.getName());
}
factory = candidates.get(0);
}
}
ShowConfigurationLevel level = Options.ShowConfiguration.getValue(options);
if (level != ShowConfigurationLevel.none) {
switch(level) {
case info:
{
printConfigInfo(factory);
break;
}
case verbose:
{
printConfigInfo(factory);
CompilerConfiguration config = factory.createCompilerConfiguration();
TTY.println("High tier: " + phaseNames(config.createHighTier(options)));
TTY.println("Mid tier: " + phaseNames(config.createMidTier(options)));
TTY.println("Low tier: " + phaseNames(config.createLowTier(options)));
TTY.println("Pre regalloc stage: " + phaseNames(config.createPreAllocationOptimizationStage(options)));
TTY.println("Regalloc stage: " + phaseNames(config.createAllocationStage(options)));
TTY.println("Post regalloc stage: " + phaseNames(config.createPostAllocationOptimizationStage(options)));
config.createAllocationStage(options);
break;
}
}
}
return factory;
}
Aggregations