RSCompilerDriver.h revision 06731a6150ae8014d37258d5f32ef8bc14a3db63
1/* 2 * Copyright 2012, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef BCC_RS_COMPILER_DRIVER_H 18#define BCC_RS_COMPILER_DRIVER_H 19 20#include "bcc/ExecutionEngine/CompilerRTSymbolResolver.h" 21#include "bcc/ExecutionEngine/SymbolResolvers.h" 22#include "bcc/ExecutionEngine/SymbolResolverProxy.h" 23#include "bcc/Renderscript/RSInfo.h" 24#include "bcc/Renderscript/RSCompiler.h" 25 26namespace bcc { 27 28class BCCContext; 29class CompilerConfig; 30class RSExecutable; 31class RSScript; 32 33class RSCompilerDriver { 34private: 35 CompilerConfig *mConfig; 36 RSCompiler mCompiler; 37 38 CompilerRTSymbolResolver *mCompilerRuntime; 39 LookupFunctionSymbolResolver<void*> mRSRuntime; 40 SymbolResolverProxy mResolver; 41 42 RSExecutable *loadScriptCache(const char *pOutputPath, 43 const RSInfo::DependencyTableTy &pDeps); 44 45 // Setup the compiler config for the given script. Return true if mConfig has 46 // been changed and false if it remains unchanged. 47 bool setupConfig(const RSScript &pScript); 48 49 RSExecutable *compileScript(RSScript &pScript, 50 const char* pScriptName, 51 const char *pOutputPath, 52 const char *pRuntimePath, 53 const RSInfo::DependencyTableTy &pDeps, 54 bool pSkipLoad); 55 56public: 57 RSCompilerDriver(bool pUseCompilerRT = true); 58 ~RSCompilerDriver(); 59 60 inline void setRSRuntimeLookupFunction( 61 LookupFunctionSymbolResolver<>::LookupFunctionTy pLookupFunc) 62 { mRSRuntime.setLookupFunction(pLookupFunc); } 63 inline void setRSRuntimeLookupContext(void *pContext) 64 { mRSRuntime.setContext(pContext); } 65 66 RSCompiler *getCompiler() { 67 return &mCompiler; 68 } 69 70 void setConfig(CompilerConfig *config) { 71 mConfig = config; 72 } 73 74 // FIXME: This method accompany with loadScriptCache and compileScript should 75 // all be const-methods. They're not now because the getAddress() in 76 // SymbolResolverInterface is not a const-method. 77 RSExecutable *build(BCCContext &pContext, 78 const char *pCacheDir, const char *pResName, 79 const char *pBitcode, size_t pBitcodeSize, 80 const char *pRuntimePath, 81 RSLinkRuntimeCallback pLinkRuntimeCallback = NULL); 82 RSExecutable *build(RSScript &pScript, const char *pOut, 83 const char *pRuntimePath); 84}; 85 86} // end namespace bcc 87 88#endif // BCC_RS_COMPILER_DRIVER_H 89