blob: 8bdd7bc4b72afb2a60792cded42a9df87a912112 [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 {
31namespace opt {
32class OptTable;
33}
34}
35
36namespace slang {
37
38// Options for the RenderScript compiler llvm-rs-cc
39class RSCCOptions {
40 public:
Stephen Hines7f5704e2014-06-10 18:06:50 -070041 // User-defined include paths.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070042 std::vector<std::string> mIncludePaths;
43
Stephen Hines7f5704e2014-06-10 18:06:50 -070044 // The output directory for writing the bitcode files
45 // (i.e. out/target/common/obj/APPS/.../src/renderscript/res/raw).
46 std::string mBitcodeOutputDir;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070047
Stephen Hines7f5704e2014-06-10 18:06:50 -070048 // Type of file to emit (bitcode, dependency, ...).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070049 slang::Slang::OutputType mOutputType;
50
Stephen Hines7f5704e2014-06-10 18:06:50 -070051 // Allow user-defined functions prefixed with 'rs'.
52 bool mAllowRSPrefix;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070053
Stephen Hines9ae18b22014-06-10 23:53:00 -070054 // 32-bit or 64-bit target
55 uint32_t mBitWidth;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070056
Stephen Hines7f5704e2014-06-10 18:06:50 -070057 // The path for storing reflected Java source files
58 // (i.e. out/target/common/obj/APPS/.../src/renderscript/src).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070059 std::string mJavaReflectionPathBase;
60
Stephen Hines7f5704e2014-06-10 18:06:50 -070061 // Force package name. This may override the package name specified by a
62 // #pragma in the .rs file.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070063 std::string mJavaReflectionPackageName;
64
Stephen Hines7f5704e2014-06-10 18:06:50 -070065 // Force the RS package name to use. This can override the default value of
66 // "android.renderscript" used for the standard RS APIs.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070067 std::string mRSPackageName;
68
Stephen Hines7f5704e2014-06-10 18:06:50 -070069 // Where to store the generated bitcode (resource, Java source, C++ source).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070070 slang::BitCodeStorageType mBitcodeStorage;
71
Stephen Hines7f5704e2014-06-10 18:06:50 -070072 // Emit output dependency file for each input file.
73 bool mEmitDependency;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070074
Stephen Hines7f5704e2014-06-10 18:06:50 -070075 // The output directory for writing dependency files
76 // (i.e. out/target/common/obj/APPS/.../src/renderscript).
77 std::string mDependencyOutputDir;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070078
Stephen Hines7f5704e2014-06-10 18:06:50 -070079 // User-defined files added to the dependencies (i.e. for adding fake
80 // dependency files like RenderScript.stamp).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070081 std::vector<std::string> mAdditionalDepTargets;
82
Stephen Hines7f5704e2014-06-10 18:06:50 -070083 bool mShowHelp; // Show the -help text.
84 bool mShowVersion; // Show the -version text.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070085
Stephen Hines7f5704e2014-06-10 18:06:50 -070086 // The target API we are generating code for (see slang_version.h).
Stephen Hines8b5c5c62014-06-06 18:03:18 -070087 unsigned int mTargetAPI;
88
Stephen Hines7f5704e2014-06-10 18:06:50 -070089 // Enable emission of debugging symbols.
90 bool mDebugEmission;
Stephen Hines8b5c5c62014-06-06 18:03:18 -070091
Stephen Hines7f5704e2014-06-10 18:06:50 -070092 // The optimization level used in CodeGen, and encoded in emitted bitcode.
Stephen Hines8b5c5c62014-06-06 18:03:18 -070093 llvm::CodeGenOpt::Level mOptimizationLevel;
94
Stephen Hinesfc4f78b2014-06-10 18:07:10 -070095 // Display verbose information about the compilation on stdout.
96 bool mVerbose;
97
Stephen Hines9ae18b22014-06-10 23:53:00 -070098 // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources).
99 bool mEmit3264;
100
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700101 RSCCOptions() {
102 mOutputType = slang::Slang::OT_Bitcode;
Stephen Hines9ae18b22014-06-10 23:53:00 -0700103 mBitWidth = 32;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700104 mBitcodeStorage = slang::BCST_APK_RESOURCE;
Stephen Hines7f5704e2014-06-10 18:06:50 -0700105 mEmitDependency = 0;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700106 mShowHelp = 0;
107 mShowVersion = 0;
108 mTargetAPI = RS_VERSION;
109 mDebugEmission = 0;
110 mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
Stephen Hinesfc4f78b2014-06-10 18:07:10 -0700111 mVerbose = false;
Stephen Hines9ae18b22014-06-10 23:53:00 -0700112 mEmit3264 = false;
Stephen Hines8b5c5c62014-06-06 18:03:18 -0700113 }
114};
115
116/* Return a valid OptTable (useful for dumping help information)
117 */
118llvm::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 */
128void 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_