Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010, 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 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 17 | #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_H_ // NOLINT |
| 18 | #define _FRAMEWORKS_COMPILE_SLANG_SLANG_H_ |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 19 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 20 | #include <cstdio> |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 21 | #include <list> |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 22 | #include <string> |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 23 | #include <utility> |
Ying Wang | e2e522f | 2010-09-01 13:24:01 -0700 | [diff] [blame] | 24 | #include <vector> |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 25 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 26 | #include "llvm/ADT/StringMap.h" |
| 27 | |
| 28 | #include "slang_rs_reflect_utils.h" |
| 29 | #include "slang_version.h" |
| 30 | |
Stephen Hines | 23c4358 | 2013-01-09 20:02:04 -0800 | [diff] [blame] | 31 | // Terrible workaround for TargetOptions.h not using llvm::RefCountedBase! |
| 32 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
| 33 | using llvm::RefCountedBase; |
| 34 | |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 35 | #include "clang/Basic/LangOptions.h" |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 36 | #include "clang/Basic/TargetOptions.h" |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 37 | #include "clang/Frontend/CodeGenOptions.h" |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 38 | #include "clang/Lex/ModuleLoader.h" |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 39 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 40 | #include "llvm/ADT/StringRef.h" |
| 41 | |
mkopec1 | c460b37 | 2012-01-09 11:21:50 -0500 | [diff] [blame] | 42 | #include "llvm/Target/TargetMachine.h" |
| 43 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 44 | #include "slang_diagnostic_buffer.h" |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 45 | #include "slang_pragma_recorder.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 46 | |
| 47 | namespace llvm { |
Zonr Chang | e8c263a | 2010-10-12 00:35:29 +0800 | [diff] [blame] | 48 | class tool_output_file; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 49 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 50 | |
| 51 | namespace clang { |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 52 | class ASTConsumer; |
| 53 | class ASTContext; |
| 54 | class Backend; |
| 55 | class CodeGenOptions; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 56 | class Diagnostic; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 57 | class DiagnosticsEngine; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 58 | class FileManager; |
Shih-wei Liao | df5bcce | 2011-02-28 18:39:23 -0800 | [diff] [blame] | 59 | class FileSystemOptions; |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 60 | class LangOptions; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 61 | class Preprocessor; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 62 | class SourceManager; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 63 | class TargetInfo; |
Stephen Hines | e67239d | 2012-02-24 15:08:36 -0800 | [diff] [blame] | 64 | } // namespace clang |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 65 | |
| 66 | namespace slang { |
| 67 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 68 | class RSCCOptions; |
| 69 | class RSContext; |
| 70 | class RSExportRecordType; |
| 71 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 72 | class Slang : public clang::ModuleLoader { |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 73 | public: |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 74 | enum OutputType { |
Stephen Hines | cc0efad | 2010-10-04 16:13:02 -0700 | [diff] [blame] | 75 | OT_Dependency, |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 76 | OT_Assembly, |
| 77 | OT_LLVMAssembly, |
| 78 | OT_Bitcode, |
| 79 | OT_Nothing, |
| 80 | OT_Object, |
| 81 | |
| 82 | OT_Default = OT_Bitcode |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 83 | }; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 84 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 85 | private: |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 86 | // Language options (define the language feature for compiler such as C99) |
| 87 | clang::LangOptions LangOpts; |
| 88 | // Code generation options for the compiler |
| 89 | clang::CodeGenOptions CodeGenOpts; |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 90 | |
| 91 | // Returns true if this is a Filterscript file. |
| 92 | static bool isFilterscript(const char *Filename); |
| 93 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 94 | // Diagnostics Engine (Producer and Diagnostics Reporter) |
Stephen Hines | 8f4d972 | 2011-12-05 14:14:42 -0800 | [diff] [blame] | 95 | clang::DiagnosticsEngine *mDiagEngine; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 96 | |
| 97 | // Diagnostics Consumer |
| 98 | // NOTE: The ownership is taken by mDiagEngine after creation. |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 99 | DiagnosticBuffer *mDiagClient; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 100 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 101 | // The target being compiled for |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 102 | std::shared_ptr<clang::TargetOptions> mTargetOpts; |
| 103 | std::unique_ptr<clang::TargetInfo> mTarget; |
Stephen Hines | 9ae18b2 | 2014-06-10 23:53:00 -0700 | [diff] [blame] | 104 | void createTarget(uint32_t BitWidth); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 105 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 106 | // File manager (for prepocessor doing the job such as header file search) |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 107 | std::unique_ptr<clang::FileManager> mFileMgr; |
| 108 | std::unique_ptr<clang::FileSystemOptions> mFileSysOpt; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 109 | void createFileManager(); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 110 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 111 | // Source manager (responsible for the source code handling) |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 112 | std::unique_ptr<clang::SourceManager> mSourceMgr; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 113 | void createSourceManager(); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 114 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 115 | // Preprocessor (source code preprocessor) |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 116 | std::unique_ptr<clang::Preprocessor> mPP; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 117 | void createPreprocessor(); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 118 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 119 | // AST context (the context to hold long-lived AST nodes) |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 120 | std::unique_ptr<clang::ASTContext> mASTContext; |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 121 | void createASTContext(); |
Shih-wei Liao | 001fb6d | 2010-06-21 11:17:11 -0700 | [diff] [blame] | 122 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 123 | // AST consumer, responsible for code generation |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 124 | std::unique_ptr<clang::ASTConsumer> mBackend; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 125 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 126 | // File names |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 127 | std::string mInputFileName; |
| 128 | std::string mOutputFileName; |
Stephen Hines | 9ae18b2 | 2014-06-10 23:53:00 -0700 | [diff] [blame] | 129 | std::string mOutput32FileName; |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 130 | |
Stephen Hines | 0b7ef1a | 2010-10-07 16:36:59 -0700 | [diff] [blame] | 131 | std::string mDepOutputFileName; |
Stephen Hines | cc0efad | 2010-10-04 16:13:02 -0700 | [diff] [blame] | 132 | std::string mDepTargetBCFileName; |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 133 | std::vector<std::string> mAdditionalDepTargets; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 134 | |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 135 | OutputType mOT; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 136 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 137 | // Output stream |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 138 | std::unique_ptr<llvm::tool_output_file> mOS; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 139 | |
Stephen Hines | 0b7ef1a | 2010-10-07 16:36:59 -0700 | [diff] [blame] | 140 | // Dependency output stream |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 141 | std::unique_ptr<llvm::tool_output_file> mDOS; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 142 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 143 | std::vector<std::string> mIncludePaths; |
Ying Wang | e2e522f | 2010-09-01 13:24:01 -0700 | [diff] [blame] | 144 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 145 | // Context for Renderscript |
| 146 | RSContext *mRSContext; |
| 147 | |
| 148 | bool mAllowRSPrefix; |
| 149 | |
| 150 | unsigned int mTargetAPI; |
| 151 | |
| 152 | bool mVerbose; |
| 153 | |
| 154 | bool mIsFilterscript; |
| 155 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 156 | // Collect generated filenames (without the .java) for dependency generation |
| 157 | std::vector<std::string> mGeneratedFileNames; |
| 158 | |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 159 | PragmaList mPragmas; |
| 160 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 161 | // FIXME: Should be std::list<RSExportable *> here. But currently we only |
| 162 | // check ODR on record type. |
| 163 | // |
| 164 | // ReflectedDefinitions maps record type name to a pair: |
| 165 | // <its RSExportRecordType instance, |
| 166 | // the first file contains this record type definition> |
| 167 | typedef std::pair<RSExportRecordType*, const char*> ReflectedDefinitionTy; |
| 168 | typedef llvm::StringMap<ReflectedDefinitionTy> ReflectedDefinitionListTy; |
| 169 | ReflectedDefinitionListTy ReflectedDefinitions; |
| 170 | |
| 171 | bool generateJavaBitcodeAccessor(const std::string &OutputPathBase, |
| 172 | const std::string &PackageName, |
| 173 | const std::string *LicenseNote); |
| 174 | |
| 175 | // CurInputFile is the pointer to a char array holding the input filename |
| 176 | // and is valid before compile() ends. |
| 177 | bool checkODR(const char *CurInputFile); |
| 178 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 179 | clang::DiagnosticsEngine &getDiagnostics() { return *mDiagEngine; } |
| 180 | clang::TargetInfo const &getTargetInfo() const { return *mTarget; } |
| 181 | clang::FileManager &getFileManager() { return *mFileMgr; } |
| 182 | clang::SourceManager &getSourceManager() { return *mSourceMgr; } |
| 183 | clang::Preprocessor &getPreprocessor() { return *mPP; } |
| 184 | clang::ASTContext &getASTContext() { return *mASTContext; } |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 185 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 186 | inline clang::TargetOptions const &getTargetOptions() const |
Stephen Hines | 7ac9d0d | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 187 | { return *mTargetOpts.get(); } |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 188 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 189 | void initPreprocessor(); |
| 190 | void initASTContext(); |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 191 | |
David Gross | 2770d0e | 2015-08-03 14:58:59 -0700 | [diff] [blame] | 192 | clang::ASTConsumer *createBackend(const RSCCOptions &Opts, |
| 193 | const clang::CodeGenOptions &CodeGenOpts, |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 194 | llvm::raw_ostream *OS, |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 195 | OutputType OT); |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 196 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 197 | public: |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 198 | static const llvm::StringRef PragmaMetadataName; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 199 | |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 200 | static void GlobalInitialization(); |
| 201 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 202 | static bool IsRSHeaderFile(const char *File); |
| 203 | // FIXME: Determine whether a location is in RS header (i.e., one of the RS |
| 204 | // built-in APIs) should only need its names (we need a "list" of RS |
| 205 | // built-in APIs). |
| 206 | static bool IsLocInRSHeaderFile(const clang::SourceLocation &Loc, |
| 207 | const clang::SourceManager &SourceMgr); |
| 208 | |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 209 | Slang(uint32_t BitWidth, clang::DiagnosticsEngine *DiagEngine, |
| 210 | DiagnosticBuffer *DiagClient); |
Zonr Chang | 641558f | 2010-10-12 21:07:06 +0800 | [diff] [blame] | 211 | |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 212 | virtual ~Slang(); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 213 | |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 214 | bool setInputSource(llvm::StringRef InputFile); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 215 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 216 | std::string const &getInputFileName() const { return mInputFileName; } |
Ying Wang | e2e522f | 2010-09-01 13:24:01 -0700 | [diff] [blame] | 217 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 218 | void setIncludePaths(const std::vector<std::string> &IncludePaths) { |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 219 | mIncludePaths = IncludePaths; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 220 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 221 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 222 | void setOutputType(OutputType OT) { mOT = OT; } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 223 | |
Stephen Hines | 0b7ef1a | 2010-10-07 16:36:59 -0700 | [diff] [blame] | 224 | bool setOutput(const char *OutputFile); |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 225 | |
Stephen Hines | 0b7ef1a | 2010-10-07 16:36:59 -0700 | [diff] [blame] | 226 | bool setDepOutput(const char *OutputFile); |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 227 | |
| 228 | void setDepTargetBC(const char *TargetBCFile) { |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 229 | mDepTargetBCFileName = TargetBCFile; |
| 230 | } |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 231 | |
| 232 | void setAdditionalDepTargets( |
| 233 | std::vector<std::string> const &AdditionalDepTargets) { |
Shih-wei Liao | b81c6a4 | 2010-10-10 14:15:00 -0700 | [diff] [blame] | 234 | mAdditionalDepTargets = AdditionalDepTargets; |
| 235 | } |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 236 | |
| 237 | void appendGeneratedFileName(std::string const &GeneratedFileName) { |
Stephen Hines | 4cc67fc | 2011-01-31 16:48:57 -0800 | [diff] [blame] | 238 | mGeneratedFileNames.push_back(GeneratedFileName); |
| 239 | } |
Stephen Hines | cc0efad | 2010-10-04 16:13:02 -0700 | [diff] [blame] | 240 | |
Ying Wang | 21c94c9 | 2015-07-22 16:27:14 -0700 | [diff] [blame] | 241 | int generateDepFile(bool PhonyTarget); |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 242 | |
David Gross | 2770d0e | 2015-08-03 14:58:59 -0700 | [diff] [blame] | 243 | int compile(const RSCCOptions &Opts); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 244 | |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 245 | char const *getErrorMessage() { return mDiagClient->str().c_str(); } |
Shih-wei Liao | 4c9f742 | 2010-08-05 04:30:02 -0700 | [diff] [blame] | 246 | |
mkopec1 | c460b37 | 2012-01-09 11:21:50 -0500 | [diff] [blame] | 247 | void setDebugMetadataEmission(bool EmitDebug); |
| 248 | |
| 249 | void setOptimizationLevel(llvm::CodeGenOpt::Level OptimizationLevel); |
| 250 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 251 | // Compile bunch of RS files given in the llvm-rs-cc arguments. Return true if |
| 252 | // all given input files are successfully compiled without errors. |
| 253 | // |
| 254 | // @IOFiles - List of pairs of <input file path, output file path>. |
| 255 | // |
| 256 | // @DepFiles - List of pairs of <output dep. file path, dependent bitcode |
| 257 | // target>. If @OutputDep is true, this parameter must be given |
| 258 | // with the same number of pairs given in @IOFiles. |
| 259 | // |
| 260 | // @Opts - Selection of options defined from invoking llvm-rs-cc |
| 261 | bool |
| 262 | compile(const std::list<std::pair<const char *, const char *>> &IOFiles64, |
| 263 | const std::list<std::pair<const char *, const char *>> &IOFiles32, |
| 264 | const std::list<std::pair<const char *, const char *>> &DepFiles, |
Jean-Luc Brouillet | 5309b0c | 2015-05-01 16:13:11 -0700 | [diff] [blame] | 265 | const RSCCOptions &Opts, |
| 266 | clang::DiagnosticOptions &DiagOpts); |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 267 | |
| 268 | clang::ModuleLoadResult loadModule(clang::SourceLocation ImportLoc, |
| 269 | clang::ModuleIdPath Path, |
| 270 | clang::Module::NameVisibilityKind VK, |
| 271 | bool IsInclusionDirective) override; |
| 272 | |
| 273 | void makeModuleVisible(clang::Module *Mod, |
| 274 | clang::Module::NameVisibilityKind Visibility, |
Pirama Arumuga Nainar | 1906a00 | 2015-06-29 10:30:41 -0700 | [diff] [blame] | 275 | clang::SourceLocation ImportLoc) override {} |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 276 | |
| 277 | clang::GlobalModuleIndex * |
Stephen Hines | 383f0b8 | 2015-06-10 17:08:16 -0700 | [diff] [blame] | 278 | loadGlobalModuleIndex(clang::SourceLocation TriggerLoc) override { |
| 279 | // We don't support C++ modules for RenderScript. |
| 280 | return nullptr; |
| 281 | } |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 282 | |
| 283 | bool lookupMissingImports(llvm::StringRef Name, |
Stephen Hines | 383f0b8 | 2015-06-10 17:08:16 -0700 | [diff] [blame] | 284 | clang::SourceLocation TriggerLoc) override { |
| 285 | // We don't support C++ modules for RenderScript. |
| 286 | return false; |
| 287 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 288 | }; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 289 | |
Jean-Luc Brouillet | 8024ed5 | 2015-05-04 23:02:25 -0700 | [diff] [blame] | 290 | } // namespace slang |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 291 | |
| 292 | #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_H_ NOLINT |