rs_cc_options.h revision 8b5c5c6566078d49c4dcd8d8c7a6364c33c09037
18b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/*
28b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * Copyright 2014, The Android Open Source Project
38b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines *
48b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * Licensed under the Apache License, Version 2.0 (the "License");
58b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * you may not use this file except in compliance with the License.
68b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * You may obtain a copy of the License at
78b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines *
88b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines *     http://www.apache.org/licenses/LICENSE-2.0
98b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines *
108b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * Unless required by applicable law or agreed to in writing, software
118b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * distributed under the License is distributed on an "AS IS" BASIS,
128b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * See the License for the specific language governing permissions and
148b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * limitations under the License.
158b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */
168b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
178b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#ifndef _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_  // NOLINT
188b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#define _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_
198b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
208b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include "llvm/Option/ArgList.h"
218b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include "llvm/Option/Option.h"
228b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include "llvm/Option/OptTable.h"
238b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
248b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include "slang.h"
258b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include "slang_rs_reflect_utils.h"
268b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
278b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include <string>
288b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#include <vector>
298b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
308b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesnamespace llvm {
318b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesnamespace opt {
328b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesclass OptTable;
338b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines}
348b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines}
358b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
368b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesnamespace slang {
378b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
388b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines// Options for the RenderScript compiler llvm-rs-cc
398b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesclass RSCCOptions {
408b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines public:
418b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The include search paths
428b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::vector<std::string> mIncludePaths;
438b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
448b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The output directory, if any.
458b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mOutputDir;
468b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
478b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The output type
488b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  slang::Slang::OutputType mOutputType;
498b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
508b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned mAllowRSPrefix : 1;
518b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
528b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The name of the target triple to compile for.
538b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mTriple;
548b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
558b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The name of the target CPU to generate code for.
568b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mCPU;
578b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
588b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The list of target specific features to enable or disable -- this should
598b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // be a list of strings starting with by '+' or '-'.
608b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::vector<std::string> mFeatures;
618b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
628b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mJavaReflectionPathBase;
638b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
648b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mJavaReflectionPackageName;
658b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
668b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mRSPackageName;
678b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
688b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  slang::BitCodeStorageType mBitcodeStorage;
698b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
708b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned mOutputDep : 1;
718b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
728b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::string mOutputDepDir;
738b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
748b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  std::vector<std::string> mAdditionalDepTargets;
758b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
768b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned mShowHelp : 1;     // Show the -help text.
778b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned mShowVersion : 1;  // Show the -version text.
788b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
798b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned int mTargetAPI;
808b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
818b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // Enable emission of debugging symbols
828b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  unsigned mDebugEmission : 1;
838b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
848b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  // The optimization level used in CodeGen, and encoded in emitted bitcode
858b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  llvm::CodeGenOpt::Level mOptimizationLevel;
868b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
878b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  RSCCOptions() {
888b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mOutputType = slang::Slang::OT_Bitcode;
898b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    // Triple/CPU/Features must be hard-coded to our chosen portable ABI.
908b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mTriple = "armv7-none-linux-gnueabi";
918b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mCPU = "";
928b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mFeatures.push_back("+long64");
938b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mBitcodeStorage = slang::BCST_APK_RESOURCE;
948b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mOutputDep = 0;
958b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mShowHelp = 0;
968b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mShowVersion = 0;
978b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mTargetAPI = RS_VERSION;
988b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mDebugEmission = 0;
998b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines    mOptimizationLevel = llvm::CodeGenOpt::Aggressive;
1008b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines  }
1018b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines};
1028b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
1038b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Return a valid OptTable (useful for dumping help information)
1048b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */
1058b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesllvm::opt::OptTable *createRSCCOptTable();
1068b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
1078b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Parse ArgVector and return a list of Inputs (source files) and Opts
1088b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * (options affecting the compilation of those source files).
1098b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines *
1108b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param ArgVector - the input arguments to llvm-rs-cc
1118b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Inputs - returned list of actual input source filenames
1128b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Opts - returned options after command line has been processed
1138b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param DiagEngine - input for issuing warnings/errors on arguments
1148b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */
1158b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesvoid ParseArguments(llvm::SmallVectorImpl<const char *> &ArgVector,
1168b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines                    llvm::SmallVectorImpl<const char *> &Inputs,
1178b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines                    RSCCOptions &Opts, clang::DiagnosticsEngine &DiagEngine);
1188b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
1198b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines}  // namespace slang
1208b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines
1218b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#endif  // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_
122