RSScript.h revision 86a0b797c221d4c3373dc10c8229b75b6747f6e7
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_SCRIPT_H 18#define BCC_RS_SCRIPT_H 19 20#include "bcc/Script.h" 21#include "bcc/Support/Sha1Util.h" 22 23namespace bcc { 24 25class RSInfo; 26class Source; 27 28class RSScript : public Script { 29public: 30 // This is one-one mapping with the llvm::CodeGenOpt::Level in 31 // llvm/Support/CodeGen.h. Therefore, value of this type can safely cast 32 // to llvm::CodeGenOpt::Level. This makes RSScript LLVM-free. 33 enum OptimizationLevel { 34 kOptLvl0, // -O0 35 kOptLvl1, // -O1 36 kOptLvl2, // -O2, -Os 37 kOptLvl3 // -O3 38 }; 39 40private: 41 const RSInfo *mInfo; 42 43 unsigned mCompilerVersion; 44 45 OptimizationLevel mOptimizationLevel; 46 47 bool mEmbedInfo; 48 49private: 50 // This will be invoked when the containing source has been reset. 51 virtual bool doReset(); 52 53public: 54 static bool LinkRuntime(RSScript &pScript, const char *rt_path = NULL); 55 56 RSScript(Source &pSource); 57 58 // Set the associated RSInfo of the script. 59 void setInfo(const RSInfo *pInfo) { 60 mInfo = pInfo; 61 } 62 63 const RSInfo *getInfo() const { 64 return mInfo; 65 } 66 67 void setCompilerVersion(unsigned pCompilerVersion) { 68 mCompilerVersion = pCompilerVersion; 69 } 70 71 unsigned getCompilerVersion() const { 72 return mCompilerVersion; 73 } 74 75 void setOptimizationLevel(OptimizationLevel pOptimizationLevel) { 76 mOptimizationLevel = pOptimizationLevel; 77 } 78 79 OptimizationLevel getOptimizationLevel() const { 80 return mOptimizationLevel; 81 } 82 83 void setEmbedInfo(bool pEnable) { 84 mEmbedInfo = pEnable; 85 } 86 87 bool getEmbedInfo() const { 88 return mEmbedInfo; 89 } 90}; 91 92} // end namespace bcc 93 94#endif // BCC_RS_SCRIPT_H 95