• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/BCCRuntimeSymbolResolver.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 
26 namespace bcc {
27 
28 class BCCContext;
29 class CompilerConfig;
30 class RSExecutable;
31 class RSScript;
32 
33 class RSCompilerDriver {
34 private:
35   CompilerConfig *mConfig;
36   RSCompiler mCompiler;
37 
38   BCCRuntimeSymbolResolver mBCCRuntime;
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 RSInfo::DependencyTableTy &pDeps);
53 
54 public:
55   RSCompilerDriver();
56   ~RSCompilerDriver();
57 
setRSRuntimeLookupFunction(LookupFunctionSymbolResolver<>::LookupFunctionTy pLookupFunc)58   inline void setRSRuntimeLookupFunction(
59       LookupFunctionSymbolResolver<>::LookupFunctionTy pLookupFunc)
60   { mRSRuntime.setLookupFunction(pLookupFunc); }
setRSRuntimeLookupContext(void * pContext)61   inline void setRSRuntimeLookupContext(void *pContext)
62   { mRSRuntime.setContext(pContext); }
63 
64   // FIXME: This method accompany with loadScriptCache and compileScript should
65   //        all be const-methods. They're not now because the getAddress() in
66   //        SymbolResolverInterface is not a const-method.
67   RSExecutable *build(BCCContext &pContext,
68                       const char *pCacheDir, const char *pResName,
69                       const char *pBitcode, size_t pBitcodeSize);
70 };
71 
72 } // end namespace bcc
73 
74 #endif // BCC_RS_COMPILER_DRIVER_H
75