• 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_SCRIPT_H
18 #define BCC_RS_SCRIPT_H
19 
20 #include "bcc/Script.h"
21 #include "bcc/Support/Sha1Util.h"
22 
23 namespace bcc {
24 
25 class RSInfo;
26 class Source;
27 
28 class RSScript : public Script {
29 public:
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 
40 private:
41   const RSInfo *mInfo;
42 
43   unsigned mCompilerVersion;
44 
45   OptimizationLevel mOptimizationLevel;
46 
47 private:
48   // This will be invoked when the containing source has been reset.
49   virtual bool doReset();
50 
51 public:
52   static bool LinkRuntime(RSScript &pScript);
53 
54   RSScript(Source &pSource);
55 
56   // Set the associated RSInfo of the script.
setInfo(const RSInfo * pInfo)57   void setInfo(const RSInfo *pInfo)
58   { mInfo = pInfo; }
59 
getInfo()60   const RSInfo *getInfo() const
61   { return mInfo; }
62 
setCompilerVersion(unsigned pCompilerVersion)63   void setCompilerVersion(unsigned pCompilerVersion)
64   {  mCompilerVersion = pCompilerVersion; }
65 
getCompilerVersion()66   unsigned getCompilerVersion() const
67   {  return mCompilerVersion; }
68 
setOptimizationLevel(OptimizationLevel pOptimizationLevel)69   void setOptimizationLevel(OptimizationLevel pOptimizationLevel)
70   {  mOptimizationLevel = pOptimizationLevel; }
71 
getOptimizationLevel()72   OptimizationLevel getOptimizationLevel() const
73   {  return mOptimizationLevel; }
74 };
75 
76 } // end namespace bcc
77 
78 #endif // BCC_RS_SCRIPT_H
79