aboutsummaryrefslogtreecommitdiffstats
path: root/rs_cc_options.h
blob: e45dae04a2d5ea2a8bf4b2e3afff6b9c43f35228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright 2014, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_  // NOLINT
#define _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_

#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Option/OptTable.h"

#include "slang.h"
#include "slang_rs_reflect_utils.h"

#include <string>
#include <vector>

namespace llvm {
namespace cl {
class StringSaver;
}
namespace opt {
class OptTable;
}
}

namespace slang {

// Options for the RenderScript compiler llvm-rs-cc
class RSCCOptions {
 public:
  // User-defined include paths.
  std::vector<std::string> mIncludePaths;

  // The output directory for writing the bitcode files
  // (i.e. out/target/common/obj/APPS/.../src/renderscript/res/raw).
  std::string mBitcodeOutputDir;

  // Type of file to emit (bitcode, dependency, ...).
  slang::Slang::OutputType mOutputType;

  // Allow user-defined functions prefixed with 'rs'.
  bool mAllowRSPrefix;

  // 32-bit or 64-bit target
  uint32_t mBitWidth;

  // The path for storing reflected Java source files
  // (i.e. out/target/common/obj/APPS/.../src/renderscript/src).
  std::string mJavaReflectionPathBase;

  // Force package name. This may override the package name specified by a
  // #pragma in the .rs file.
  std::string mJavaReflectionPackageName;

  // Force the RS package name to use. This can override the default value of
  // "android.renderscript" used for the standard RS APIs.
  std::string mRSPackageName;

  // Where to store the generated bitcode (resource, Java source, C++ source).
  slang::BitCodeStorageType mBitcodeStorage;

  // Emit output dependency file for each input file.
  bool mEmitDependency;

  // The output directory for writing dependency files
  // (i.e. out/target/common/obj/APPS/.../src/renderscript).
  std::string mDependencyOutputDir;

  // User-defined files added to the dependencies (i.e. for adding fake
  // dependency files like RenderScript.stamp).
  std::vector<std::string> mAdditionalDepTargets;

  bool mShowHelp;     // Show the -help text.
  bool mShowVersion;  // Show the -version text.

  // The target API we are generating code for (see slang_version.h).
  unsigned int mTargetAPI;

  // Enable emission of debugging symbols.
  bool mDebugEmission;

  // The optimization level used in CodeGen, and encoded in emitted bitcode.
  llvm::CodeGenOpt::Level mOptimizationLevel;

  // Display verbose information about the compilation on stdout.
  bool mVerbose;

  // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources).
  bool mEmit3264;

  RSCCOptions() {
    mOutputType = slang::Slang::OT_Bitcode;
    mBitWidth = 32;
    mBitcodeStorage = slang::BCST_APK_RESOURCE;
    mEmitDependency = 0;
    mShowHelp = 0;
    mShowVersion = 0;
    mTargetAPI = RS_VERSION;
    mDebugEmission = 0;
    mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
    mVerbose = false;
    mEmit3264 = false;
  }
};

/* Return a valid OptTable (useful for dumping help information)
 */
llvm::opt::OptTable *createRSCCOptTable();

/* Parse ArgVector and return a list of Inputs (source files) and Opts
 * (options affecting the compilation of those source files).
 *
 * \param ArgVector - the input arguments to llvm-rs-cc
 * \param Inputs - returned list of actual input source filenames
 * \param Opts - returned options after command line has been processed
 * \param DiagEngine - input for issuing warnings/errors on arguments
 */

bool ParseArguments(const llvm::ArrayRef<const char *> &ArgsIn,
                    llvm::SmallVectorImpl<const char *> &Inputs,
                    RSCCOptions &Opts, clang::DiagnosticOptions &DiagOpts,
                    llvm::cl::StringSaver &StringSaver);

} // namespace slang

#endif  // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_