blob: e45dae04a2d5ea2a8bf4b2e3afff6b9c43f35228 [file] [log] [blame]
Stephen Hines8b5c5c62014-06-06 18:03:18 -07001/*
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
30namespace llvm {
Jean-Luc Brouillet5309b0c2015-05-01 16:13:11 -070031namespace cl {
32class StringSaver;
33}
Stephen Hines8b5c5c62014-06-06 18:03:18 -070034namespace opt {
35class OptTable;
36}
37}
38
39namespace slang {
40
41// Options for the RenderScript compiler llvm-rs-cc
42class RSCCOptions {
43 public:
Stephen Hines7f5704e2014-06-10 18:06:50 -070044 // User-defined include paths.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070045 std::vector<std::string> mIncludePaths;
46
Stephen Hines7f5704e2014-06-10 18:06:50 -070047 // 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 Hines8b5c5c62014-06-06 18:03:18 -070050
Stephen Hines7f5704e2014-06-10 18:06:50 -070051 // Type of file to emit (bitcode, dependency, ...).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070052 slang::Slang::OutputType mOutputType;
53
Stephen Hines7f5704e2014-06-10 18:06:50 -070054 // Allow user-defined functions prefixed with 'rs'.
55 bool mAllowRSPrefix;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070056
Stephen Hines9ae18b22014-06-10 23:53:00 -070057 // 32-bit or 64-bit target
58 uint32_t mBitWidth;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070059
Stephen Hines7f5704e2014-06-10 18:06:50 -070060 // The path for storing reflected Java source files
61 // (i.e. out/target/common/obj/APPS/.../src/renderscript/src).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070062 std::string mJavaReflectionPathBase;
63
Stephen Hines7f5704e2014-06-10 18:06:50 -070064 // Force package name. This may override the package name specified by a
65 // #pragma in the .rs file.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070066 std::string mJavaReflectionPackageName;
67
Stephen Hines7f5704e2014-06-10 18:06:50 -070068 // Force the RS package name to use. This can override the default value of
69 // "android.renderscript" used for the standard RS APIs.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070070 std::string mRSPackageName;
71
Stephen Hines7f5704e2014-06-10 18:06:50 -070072 // Where to store the generated bitcode (resource, Java source, C++ source).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070073 slang::BitCodeStorageType mBitcodeStorage;
74
Stephen Hines7f5704e2014-06-10 18:06:50 -070075 // Emit output dependency file for each input file.
76 bool mEmitDependency;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070077
Stephen Hines7f5704e2014-06-10 18:06:50 -070078 // The output directory for writing dependency files
79 // (i.e. out/target/common/obj/APPS/.../src/renderscript).
80 std::string mDependencyOutputDir;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070081
Stephen Hines7f5704e2014-06-10 18:06:50 -070082 // User-defined files added to the dependencies (i.e. for adding fake
83 // dependency files like RenderScript.stamp).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070084 std::vector<std::string> mAdditionalDepTargets;
85
Stephen Hines7f5704e2014-06-10 18:06:50 -070086 bool mShowHelp; // Show the -help text.
87 bool mShowVersion; // Show the -version text.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070088
Stephen Hines7f5704e2014-06-10 18:06:50 -070089 // The target API we are generating code for (see slang_version.h).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070090 unsigned int mTargetAPI;
91
Stephen Hines7f5704e2014-06-10 18:06:50 -070092 // Enable emission of debugging symbols.
93 bool mDebugEmission;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070094
Stephen Hines7f5704e2014-06-10 18:06:50 -070095 // The optimization level used in CodeGen, and encoded in emitted bitcode.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070096 llvm::CodeGenOpt::Level mOptimizationLevel;
97
Stephen Hinesfc4f78b2014-06-10 18:07:10 -070098 // Display verbose information about the compilation on stdout.
99 bool mVerbose;
100
Stephen Hines9ae18b22014-06-10 23:53:00 -0700101 // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources).
102 bool mEmit3264;
103
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700104 RSCCOptions() {
105 mOutputType = slang::Slang::OT_Bitcode;
Stephen Hines9ae18b22014-06-10 23:53:00 -0700106 mBitWidth = 32;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700107 mBitcodeStorage = slang::BCST_APK_RESOURCE;
Stephen Hines7f5704e2014-06-10 18:06:50 -0700108 mEmitDependency = 0;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700109 mShowHelp = 0;
110 mShowVersion = 0;
111 mTargetAPI = RS_VERSION;
112 mDebugEmission = 0;
113 mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
Stephen Hinesfc4f78b2014-06-10 18:07:10 -0700114 mVerbose = false;
Stephen Hines9ae18b22014-06-10 23:53:00 -0700115 mEmit3264 = false;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700116 }
117};
118
119/* Return a valid OptTable (useful for dumping help information)
120 */
121llvm::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 Hines8b5c5c62014-06-06 18:03:18 -0700131
Jean-Luc Brouillet5309b0c2015-05-01 16:13:11 -0700132bool 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 Hines8b5c5c62014-06-06 18:03:18 -0700138
139#endif // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_