blob: cc60560a1da9be00c7e17f8bae7c5aca2e58300b [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
Ying Wang21c94c92015-07-22 16:27:14 -070078 // Emit phony targets for each header dependency, which can avoid make errors
79 // when the header gets deleted. See -MP option of cc.
80 bool mEmitPhonyDependency;
81
Stephen Hines7f5704e2014-06-10 18:06:50 -070082 // The output directory for writing dependency files
83 // (i.e. out/target/common/obj/APPS/.../src/renderscript).
84 std::string mDependencyOutputDir;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070085
Stephen Hines7f5704e2014-06-10 18:06:50 -070086 // User-defined files added to the dependencies (i.e. for adding fake
87 // dependency files like RenderScript.stamp).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070088 std::vector<std::string> mAdditionalDepTargets;
89
Stephen Hines7f5704e2014-06-10 18:06:50 -070090 bool mShowHelp; // Show the -help text.
91 bool mShowVersion; // Show the -version text.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070092
Stephen Hines7f5704e2014-06-10 18:06:50 -070093 // The target API we are generating code for (see slang_version.h).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070094 unsigned int mTargetAPI;
95
Stephen Hines7f5704e2014-06-10 18:06:50 -070096 // Enable emission of debugging symbols.
97 bool mDebugEmission;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070098
Stephen Hines7f5704e2014-06-10 18:06:50 -070099 // The optimization level used in CodeGen, and encoded in emitted bitcode.
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700100 llvm::CodeGenOpt::Level mOptimizationLevel;
101
Stephen Hinesfc4f78b2014-06-10 18:07:10 -0700102 // Display verbose information about the compilation on stdout.
103 bool mVerbose;
104
David Gross2770d0e2015-08-03 14:58:59 -0700105 // Display AST.
106 bool mASTPrint;
107
Stephen Hines9ae18b22014-06-10 23:53:00 -0700108 // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources).
109 bool mEmit3264;
110
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700111 RSCCOptions() {
112 mOutputType = slang::Slang::OT_Bitcode;
Stephen Hines9ae18b22014-06-10 23:53:00 -0700113 mBitWidth = 32;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700114 mBitcodeStorage = slang::BCST_APK_RESOURCE;
Stephen Hines7f5704e2014-06-10 18:06:50 -0700115 mEmitDependency = 0;
Ying Wang21c94c92015-07-22 16:27:14 -0700116 mEmitPhonyDependency = 0;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700117 mShowHelp = 0;
118 mShowVersion = 0;
119 mTargetAPI = RS_VERSION;
120 mDebugEmission = 0;
121 mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
Stephen Hinesfc4f78b2014-06-10 18:07:10 -0700122 mVerbose = false;
David Gross2770d0e2015-08-03 14:58:59 -0700123 mASTPrint = false;
124 mEmit3264 = true;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700125 }
126};
127
128/* Return a valid OptTable (useful for dumping help information)
129 */
130llvm::opt::OptTable *createRSCCOptTable();
131
132/* Parse ArgVector and return a list of Inputs (source files) and Opts
133 * (options affecting the compilation of those source files).
134 *
135 * \param ArgVector - the input arguments to llvm-rs-cc
136 * \param Inputs - returned list of actual input source filenames
137 * \param Opts - returned options after command line has been processed
138 * \param DiagEngine - input for issuing warnings/errors on arguments
139 */
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700140
Jean-Luc Brouillet5309b0c2015-05-01 16:13:11 -0700141bool ParseArguments(const llvm::ArrayRef<const char *> &ArgsIn,
142 llvm::SmallVectorImpl<const char *> &Inputs,
143 RSCCOptions &Opts, clang::DiagnosticOptions &DiagOpts,
Pirama Arumuga Nainar1906a002015-06-29 10:30:41 -0700144 llvm::StringSaver &StringSaver);
Jean-Luc Brouillet5309b0c2015-05-01 16:13:11 -0700145
146} // namespace slang
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700147
148#endif // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_