a Sample for Sparc backend
Bahram Yarahmadi
bahram.yarahmadi at gmail.com
Sun Apr 24 06:34:56 UTC 2016
Hello guys,
I want to generate code for different ISAs ( for example SPARC which is
currently in graal code base) before migrating to old revisions ( my main
target is PTX)
I have written a very simple program ,that is :
RuntimeProvider runtimeProvider =
Graal.getRequiredCapability(RuntimeProvider.class);
Backend backend = runtimeProvider.getBackend(SPARC.class);
Providers providers=backend.getProviders();
MetaAccess metaAccess = providers.getMetaAccess();
CodeCache codeCache = providers.getCodeCache();
ResolvedJavaMethod method = findMethod(ScrachTest.class,
"AddTwoNumbers"); //ScrachTest.class is a simple class with a method in it
StructuredGraph graph = new StructuredGraph(method,
AllowAssumptions.YES);
PhaseSuite<HighTierContext> graphBuilderSuite =
backend.getSuites().getDefaultGraphBuilderSuite();
Suites suites = backend.getSuites().getDefaultSuites();
LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites();
OptimisticOptimizations optimisticOpts =
OptimisticOptimizations.ALL;
ProfilingInfo profilingInfo = graph.getProfilingInfo(method);
CompilationResult compilationResult = new CompilationResult();
CompilationResultBuilderFactory factory =
CompilationResultBuilderFactory.Default;
GraalCompiler.compileGraph(graph, method, providers, backend,
graphBuilderSuite,
optimisticOpts, profilingInfo, suites, lirSuites,
compilationResult, factory);
CompiledCode compiledCode = backend.createCompiledCode(method,
compilationResult);
InstalledCode installedCode = codeCache.addCode(method,
compiledCode, null, null);
When I want to test my program I get these Errors
(com.oracle.graal.compiler.test.tutorial.GraalTutorial)
java.lang.NullPointerException
at
com.oracle.graal.compiler.test.tutorial.InvokeGraal.<init>(InvokeGraal.java:76)
at
com.oracle.graal.compiler.test.tutorial.GraalTutorial.<init>(GraalTutorial.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at
org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
at
org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
Could you please tell me how can I generate code for different ISAs ?
Thanks
Regards
More information about the graal-dev
mailing list