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 { 31666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouilletnamespace cl { 32666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouilletclass StringSaver; 33666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouillet} 348b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesnamespace opt { 358b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesclass OptTable; 368b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines} 378b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines} 388b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 398b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesnamespace slang { 408b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 418b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines// Options for the RenderScript compiler llvm-rs-cc 428b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesclass RSCCOptions { 438b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines public: 447f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // User-defined include paths. 458b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::vector<std::string> mIncludePaths; 468b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 477f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The output directory for writing the bitcode files 487f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript/res/raw). 497f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines std::string mBitcodeOutputDir; 508b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 517f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Type of file to emit (bitcode, dependency, ...). 528b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines slang::Slang::OutputType mOutputType; 538b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 547f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Allow user-defined functions prefixed with 'rs'. 557f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mAllowRSPrefix; 568b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 579ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines // 32-bit or 64-bit target 589ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines uint32_t mBitWidth; 598b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 607f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The path for storing reflected Java source files 617f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript/src). 628b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mJavaReflectionPathBase; 638b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 647f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Force package name. This may override the package name specified by a 657f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // #pragma in the .rs file. 668b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mJavaReflectionPackageName; 678b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 687f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Force the RS package name to use. This can override the default value of 697f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // "android.renderscript" used for the standard RS APIs. 708b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::string mRSPackageName; 718b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 727f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Where to store the generated bitcode (resource, Java source, C++ source). 738b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines slang::BitCodeStorageType mBitcodeStorage; 748b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 757f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Emit output dependency file for each input file. 767f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mEmitDependency; 778b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 787f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The output directory for writing dependency files 797f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // (i.e. out/target/common/obj/APPS/.../src/renderscript). 807f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines std::string mDependencyOutputDir; 818b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 827f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // User-defined files added to the dependencies (i.e. for adding fake 837f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // dependency files like RenderScript.stamp). 848b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines std::vector<std::string> mAdditionalDepTargets; 858b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 867f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mShowHelp; // Show the -help text. 877f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mShowVersion; // Show the -version text. 888b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 897f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The target API we are generating code for (see slang_version.h). 908b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines unsigned int mTargetAPI; 918b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 927f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // Enable emission of debugging symbols. 937f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines bool mDebugEmission; 948b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 957f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines // The optimization level used in CodeGen, and encoded in emitted bitcode. 968b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines llvm::CodeGenOpt::Level mOptimizationLevel; 978b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 98fc4f78b9c7941132fb048a83f0e4ba528c3b4fd0Stephen Hines // Display verbose information about the compilation on stdout. 99fc4f78b9c7941132fb048a83f0e4ba528c3b4fd0Stephen Hines bool mVerbose; 100fc4f78b9c7941132fb048a83f0e4ba528c3b4fd0Stephen Hines 1019ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines // Emit both 32-bit and 64-bit bitcode (embedded in the reflected sources). 1029ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines bool mEmit3264; 1039ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines 1048b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines RSCCOptions() { 1058b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mOutputType = slang::Slang::OT_Bitcode; 1069ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines mBitWidth = 32; 1078b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mBitcodeStorage = slang::BCST_APK_RESOURCE; 1087f5704efe0c59d5599f1ac7056976225dbfab946Stephen Hines mEmitDependency = 0; 1098b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mShowHelp = 0; 1108b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mShowVersion = 0; 1118b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mTargetAPI = RS_VERSION; 1128b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mDebugEmission = 0; 1138b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines mOptimizationLevel = llvm::CodeGenOpt::Aggressive; 114fc4f78b9c7941132fb048a83f0e4ba528c3b4fd0Stephen Hines mVerbose = false; 1159ae18b2bbee0b08afd400542e863dd665ff76059Stephen Hines mEmit3264 = false; 1168b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines } 1178b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines}; 1188b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1198b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Return a valid OptTable (useful for dumping help information) 1208b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */ 1218b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hinesllvm::opt::OptTable *createRSCCOptTable(); 1228b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1238b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines/* Parse ArgVector and return a list of Inputs (source files) and Opts 1248b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * (options affecting the compilation of those source files). 1258b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * 1268b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param ArgVector - the input arguments to llvm-rs-cc 1278b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Inputs - returned list of actual input source filenames 1288b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param Opts - returned options after command line has been processed 1298b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines * \param DiagEngine - input for issuing warnings/errors on arguments 1308b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines */ 131666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouillet 132666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouilletbool ParseArguments(const llvm::ArrayRef<const char *> &ArgsIn, 1338b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines llvm::SmallVectorImpl<const char *> &Inputs, 134666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouillet RSCCOptions &Opts, clang::DiagnosticOptions &DiagOpts, 135666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouillet llvm::cl::StringSaver &StringSaver); 1368b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 137666b0a7711c10ea31008302495c6b25d1bd0729bJean-Luc Brouillet} // namespace slang 1388b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines 1398b5c5c6566078d49c4dcd8d8c7a6364c33c09037Stephen Hines#endif // _FRAMEWORKS_COMPILE_SLANG_RS_CC_OPTIONS_H_ 140