rs_cc_options.h revision 7f5704efe0c59d5599f1ac7056976225dbfab946
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: 417f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // User-defined include paths. 428b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::vector<std::string> mIncludePaths; 438b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 447f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The output directory for writing the bitcode files 457f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript/res/raw). 467f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines std::string mBitcodeOutputDir; 478b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 487f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Type of file to emit (bitcode, dependency, ...). 498b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines slang::Slang::OutputType mOutputType; 508b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 517f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Allow user-defined functions prefixed with 'rs'. 527f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mAllowRSPrefix; 538b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 548b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines // The name of the target triple to compile for. 558b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mTriple; 568b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 578b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines // The name of the target CPU to generate code for. 588b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mCPU; 598b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 608b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines // The list of target specific features to enable or disable -- this should 618b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines // be a list of strings starting with by '+' or '-'. 628b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::vector<std::string> mFeatures; 638b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 647f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The path for storing reflected Java source files 657f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript/src). 668b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mJavaReflectionPathBase; 678b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 687f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Force package name. This may override the package name specified by a 697f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // #pragma in the .rs file. 708b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mJavaReflectionPackageName; 718b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 727f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Force the RS package name to use. This can override the default value of 737f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // "android.renderscript" used for the standard RS APIs. 748b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mRSPackageName; 758b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 767f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Where to store the generated bitcode (resource, Java source, C++ source). 778b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines slang::BitCodeStorageType mBitcodeStorage; 788b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 797f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Emit output dependency file for each input file. 807f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mEmitDependency; 818b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 827f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The output directory for writing dependency files 837f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript). 847f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines std::string mDependencyOutputDir; 858b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 867f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // User-defined files added to the dependencies (i.e. for adding fake 877f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // dependency files like RenderScript.stamp). 888b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::vector<std::string> mAdditionalDepTargets; 898b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 907f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mShowHelp; // Show the -help text. 917f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mShowVersion; // Show the -version text. 928b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 937f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The target API we are generating code for (see slang_version.h). 948b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines unsigned int mTargetAPI; 958b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 967f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Enable emission of debugging symbols. 977f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mDebugEmission; 988b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 997f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The optimization level used in CodeGen, and encoded in emitted bitcode. 1008b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines llvm::CodeGenOpt::Level mOptimizationLevel; 1018b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1028b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines RSCCOptions() { 1038b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mOutputType = slang::Slang::OT_Bitcode; 1048b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines // Triple/CPU/Features must be hard-coded to our chosen portable ABI. 1058b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mTriple = "armv7-none-linux-gnueabi"; 1068b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mCPU = ""; 1078b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mFeatures.push_back("+long64"); 1088b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mBitcodeStorage = slang::BCST_APK_RESOURCE; 1097f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines mEmitDependency = 0; 1108b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mShowHelp = 0; 1118b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mShowVersion = 0; 1128b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mTargetAPI = RS_VERSION; 1138b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mDebugEmission = 0; 1148b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mOptimizationLevel = llvm::CodeGenOpt::Aggressive; 1158b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines } 1168b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines}; 1178b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1188b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Return a valid OptTable (useful for dumping help information) 1198b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */ 1208b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesllvm::opt::OptTable *createRSCCOptTable(); 1218b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1228b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Parse ArgVector and return a list of Inputs (source files) and Opts 1238b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * (options affecting the compilation of those source files). 1248b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * 1258b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param ArgVector - the input arguments to llvm-rs-cc 1268b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Inputs - returned list of actual input source filenames 1278b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Opts - returned options after command line has been processed 1288b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param DiagEngine - input for issuing warnings/errors on arguments 1298b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */ 1308b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesvoid ParseArguments(llvm::SmallVectorImpl<const char *> &ArgVector, 1318b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines llvm::SmallVectorImpl<const char *> &Inputs, 1328b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines RSCCOptions &Opts, clang::DiagnosticsEngine &DiagEngine); 1338b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1348b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines} // namespace slang 1358b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1368b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#endif // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_ 137