--- old/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java 2013-12-12 12:32:45.993342610 -0600 +++ new/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java 2013-12-12 12:32:45.909342610 -0600 @@ -41,6 +41,8 @@ import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.hsail.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.Replacements; +import com.oracle.graal.replacements.hsail.*; /** * HSAIL specific backend. @@ -63,12 +65,27 @@ return true; } + /** + * Completes the initialization of the HSAIL backend. This includes initializing the providers + * and registering any method substitutions specified by the HSAIL backend. + */ @Override public void completeInitialization() { final HotSpotProviders providers = getProviders(); HotSpotVMConfig config = getRuntime().getConfig(); + // Initialize the lowering provider. final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer(); lowerer.initialize(providers, config); + // Register the replacements used by the HSAIL backend. + Replacements replacements = providers.getReplacements(); + try { + // Register the substitutions for java.lang.Math routines. + // replacements.registerSubstitutions(Class.forName("com.oracle.graal.replacements.hsail.HSAILMathSubstitutions")); + replacements.registerSubstitutions(HSAILMathSubstitutions.class); + + } catch (Exception e) { + e.printStackTrace(); + } } /**