RSCompilerDriver.h revision c72c4ddfcd79c74f70713da91a69569451b5c19e
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 200fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang#include <string> 210fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 22c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/BCCRuntimeSymbolResolver.h" 23c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/SymbolResolvers.h" 24c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/ExecutionEngine/SymbolResolverProxy.h" 25c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/RenderScript/RSCompiler.h" 260fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 270fffa7e4adc90079dc0f252359050fe872b360ddZonr Changnamespace bcc { 280fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 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 420fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSExecutable *loadScriptCache(const RSScript &pScript, 430fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang const std::string &pOutputPath); 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, 500fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang const std::string &pOutputPath); 510fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 520fffa7e4adc90079dc0f252359050fe872b360ddZonr Changpublic: 530fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSCompilerDriver(); 540fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang ~RSCompilerDriver(); 550fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 560fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang inline void setRSRuntimeLookupFunction( 570fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang LookupFunctionSymbolResolver<>::LookupFunctionTy pLookupFunc) 580fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang { mRSRuntime.setLookupFunction(pLookupFunc); } 590fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang inline void setRSRuntimeLookupContext(void *pContext) 600fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang { mRSRuntime.setContext(pContext); } 610fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 620fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // FIXME: This method accompany with loadScriptCache and compileScript should 630fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // all be const-methods. They're not now because the getAddress() in 640fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang // SymbolResolverInterface is not a const-method. 650fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang RSExecutable *build(RSScript &pScript, 660fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang const std::string &pOutputPath); 670fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang}; 680fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 690fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang} // end namespace bcc 700fffa7e4adc90079dc0f252359050fe872b360ddZonr Chang 71c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#endif // BCC_RS_COMPILER_DRIVER_H 72