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