RSCompilerDriver.h revision 331310e1f3f86a795f78e42b3f03558a43829f09
10fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang/* 20fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * Copyright 2012, The Android Open Source Project 30fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * 40fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * Licensed under the Apache License, Version 2.0 (the "License"); 50fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * you may not use this file except in compliance with the License. 60fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * You may obtain a copy of the License at 70fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * 80fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * http://www.apache.org/licenses/LICENSE-2.0 90fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * 100fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * Unless required by applicable law or agreed to in writing, software 110fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * distributed under the License is distributed on an "AS IS" BASIS, 120fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * See the License for the specific language governing permissions and 140fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang * limitations under the License. 150fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang */ 160fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 17c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#ifndef BCC_RS_COMPILER_DRIVER_H 18c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#define BCC_RS_COMPILER_DRIVER_H 190fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 20c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/BCCRuntimeSymbolResolver.h" 21c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/SymbolResolvers.h" 22c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/SymbolResolverProxy.h" 23e198abec6c5e3eab380ccf6897b0a0b9c2dd92ddStephen Hines#include "bcc/Renderscript/RSInfo.h" 24e198abec6c5e3eab380ccf6897b0a0b9c2dd92ddStephen Hines#include "bcc/Renderscript/RSCompiler.h" 250fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 260fffa7e4adc90079dc0f252359050fe872b360ddZonr Changnamespace bcc { 270fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 287bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liaoclass BCCContext; 290fffa7e4adc90079dc0f252359050fe872b360ddZonr Changclass CompilerConfig; 300fffa7e4adc90079dc0f252359050fe872b360ddZonr Changclass RSExecutable; 310fffa7e4adc90079dc0f252359050fe872b360ddZonr Changclass RSScript; 320fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 330fffa7e4adc90079dc0f252359050fe872b360ddZonr Changclass RSCompilerDriver { 340fffa7e4adc90079dc0f252359050fe872b360ddZonr Changprivate: 350fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang CompilerConfig *mConfig; 360fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSCompiler mCompiler; 370fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 380fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang BCCRuntimeSymbolResolver mBCCRuntime; 390fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang LookupFunctionSymbolResolver<void*> mRSRuntime; 400fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang SymbolResolverProxy mResolver; 410fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 427bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liao RSExecutable *loadScriptCache(const char *pOutputPath, 437bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liao const RSInfo::DependencyTableTy &pDeps); 440fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 450fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // Setup the compiler config for the given script. Return true if mConfig has 460fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // been changed and false if it remains unchanged. 470fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang bool setupConfig(const RSScript &pScript); 480fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 490fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSExecutable *compileScript(RSScript &pScript, 50ba4206445e192f4c0fa519eae55c4b84cfb0efeeShih-wei Liao const char* pScriptName, 517bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liao const char *pOutputPath, 52331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines const char *pRuntimePath, 53331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines const RSInfo::DependencyTableTy &pDeps, 54331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines bool pSkipLoad); 550fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 560fffa7e4adc90079dc0f252359050fe872b360ddZonr Changpublic: 570fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSCompilerDriver(); 580fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang ~RSCompilerDriver(); 590fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 600fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang inline void setRSRuntimeLookupFunction( 610fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang LookupFunctionSymbolResolver<>::LookupFunctionTy pLookupFunc) 620fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang { mRSRuntime.setLookupFunction(pLookupFunc); } 630fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang inline void setRSRuntimeLookupContext(void *pContext) 640fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang { mRSRuntime.setContext(pContext); } 650fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 66331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines RSCompiler *getCompiler() { 67331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines return &mCompiler; 68331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines } 69331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines 70331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines void setConfig(CompilerConfig *config) { 71331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines mConfig = config; 72331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines } 73331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines 740fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // FIXME: This method accompany with loadScriptCache and compileScript should 750fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // all be const-methods. They're not now because the getAddress() in 760fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // SymbolResolverInterface is not a const-method. 777bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liao RSExecutable *build(BCCContext &pContext, 787bcec85228c1eceade6efc9cd7d02ef81c8d55e9Shih-wei Liao const char *pCacheDir, const char *pResName, 79331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines const char *pBitcode, size_t pBitcodeSize, 80331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines const char *pRuntimePath); 81331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines RSExecutable *build(RSScript &pScript, const char *pOut, 82331310e1f3f86a795f78e42b3f03558a43829f09Stephen Hines const char *pRuntimePath); 830fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang}; 840fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 850fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang} // end namespace bcc 860fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 87c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#endif // BCC_RS_COMPILER_DRIVER_H 88