Home | History | Annotate | Download | only in slang
      1 /*
      2  * Copyright 2014, 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 _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_  // NOLINT
     18 #define _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_
     19 
     20 #include "llvm/Option/ArgList.h"
     21 #include "llvm/Option/Option.h"
     22 #include "llvm/Option/OptTable.h"
     23 
     24 #include "slang.h"
     25 #include "slang_rs_reflect_utils.h"
     26 
     27 #include <string>
     28 #include <vector>
     29 
     30 namespace llvm {
     31 namespace opt {
     32 class OptTable;
     33 }
     34 }
     35 
     36 namespace slang {
     37 
     38 // Options for the RenderScript compiler llvm-rs-cc
     39 class RSCCOptions {
     40  public:
     41   // User-defined include paths.
     42   std::vector<std::string> mIncludePaths;
     43 
     44   // The output directory for writing the bitcode files
     45   // (i.e. out/target/common/obj/APPS/.../src/renderscript/res/raw).
     46   std::string mBitcodeOutputDir;
     47 
     48   // Type of file to emit (bitcode, dependency, ...).
     49   slang::Slang::OutputType mOutputType;
     50 
     51   // Allow user-defined functions prefixed with 'rs'.
     52   bool mAllowRSPrefix;
     53 
     54   // 32-bit or 64-bit target
     55   uint32_t mBitWidth;
     56 
     57   // The path for storing reflected Java source files
     58   // (i.e. out/target/common/obj/APPS/.../src/renderscript/src).
     59   std::string mJavaReflectionPathBase;
     60 
     61   // Force package name. This may override the package name specified by a
     62   // #pragma in the .rs file.
     63   std::string mJavaReflectionPackageName;
     64 
     65   // Force the RS package name to use. This can override the default value of
     66   // "android.renderscript" used for the standard RS APIs.
     67   std::string mRSPackageName;
     68 
     69   // Where to store the generated bitcode (resource, Java source, C++ source).
     70   slang::BitCodeStorageType mBitcodeStorage;
     71 
     72   // Emit output dependency file for each input file.
     73   bool mEmitDependency;
     74 
     75   // The output directory for writing dependency files
     76   // (i.e. out/target/common/obj/APPS/.../src/renderscript).
     77   std::string mDependencyOutputDir;
     78 
     79   // User-defined files added to the dependencies (i.e. for adding fake
     80   // dependency files like RenderScript.stamp).
     81   std::vector<std::string> mAdditionalDepTargets;
     82 
     83   bool mShowHelp;     // Show the -help text.
     84   bool mShowVersion;  // Show the -version text.
     85 
     86   // The target API we are generating code for (see slang_version.h).
     87   unsigned int mTargetAPI;
     88 
     89   // Enable emission of debugging symbols.
     90   bool mDebugEmission;
     91 
     92   // The optimization level used in CodeGen, and encoded in emitted bitcode.
     93   llvm::CodeGenOpt::Level mOptimizationLevel;
     94 
     95   // Display verbose information about the compilation on stdout.
     96   bool mVerbose;
     97 
     98   // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources).
     99   bool mEmit3264;
    100 
    101   RSCCOptions() {
    102     mOutputType = slang::Slang::OT_Bitcode;
    103     mBitWidth = 32;
    104     mBitcodeStorage = slang::BCST_APK_RESOURCE;
    105     mEmitDependency = 0;
    106     mShowHelp = 0;
    107     mShowVersion = 0;
    108     mTargetAPI = RS_VERSION;
    109     mDebugEmission = 0;
    110     mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
    111     mVerbose = false;
    112     mEmit3264 = false;
    113   }
    114 };
    115 
    116 /* Return a valid OptTable (useful for dumping help information)
    117  */
    118 llvm::opt::OptTable *createRSCCOptTable();
    119 
    120 /* Parse ArgVector and return a list of Inputs (source files) and Opts
    121  * (options affecting the compilation of those source files).
    122  *
    123  * \param ArgVector - the input arguments to llvm-rs-cc
    124  * \param Inputs - returned list of actual input source filenames
    125  * \param Opts - returned options after command line has been processed
    126  * \param DiagEngine - input for issuing warnings/errors on arguments
    127  */
    128 void ParseArguments(llvm::SmallVectorImpl<const char *> &ArgVector,
    129                     llvm::SmallVectorImpl<const char *> &Inputs,
    130                     RSCCOptions &Opts, clang::DiagnosticsEngine &DiagEngine);
    131 
    132 }  // namespace slang
    133 
    134 #endif  // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_
    135