Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 1 | /* |
Stephen Hines | 7b51b55 | 2012-02-16 00:12:38 -0800 | [diff] [blame] | 2 | * Copyright 2010-2012, The Android Open Source Project |
Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 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_RS_BACKEND_H_ // NOLINT |
| 18 | #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_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 "slang_backend.h" |
| 21 | #include "slang_pragma_recorder.h" |
Stephen Hines | 4b32ffd | 2010-11-05 18:47:11 -0700 | [diff] [blame] | 22 | #include "slang_rs_object_ref_count.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 23 | |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 24 | namespace llvm { |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 25 | class NamedMDNode; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 26 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 27 | |
| 28 | namespace clang { |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 29 | class ASTConsumer; |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 30 | class DiagnosticsEngine; |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 31 | class TargetOptions; |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 32 | class CodeGenerator; |
| 33 | class ASTContext; |
| 34 | class DeclGroupRef; |
Stephen Hines | cfae0f3 | 2010-11-01 18:57:31 -0700 | [diff] [blame] | 35 | class FunctionDecl; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 36 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 37 | |
| 38 | namespace slang { |
| 39 | |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 40 | class RSContext; |
| 41 | |
| 42 | class RSBackend : public Backend { |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 43 | private: |
| 44 | RSContext *mContext; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 45 | |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 46 | clang::SourceManager &mSourceMgr; |
| 47 | |
| 48 | bool mAllowRSPrefix; |
| 49 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 50 | llvm::NamedMDNode *mExportVarMetadata; |
| 51 | llvm::NamedMDNode *mExportFuncMetadata; |
Stephen Hines | 7b51b55 | 2012-02-16 00:12:38 -0800 | [diff] [blame] | 52 | llvm::NamedMDNode *mExportForEachNameMetadata; |
| 53 | llvm::NamedMDNode *mExportForEachSignatureMetadata; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 54 | llvm::NamedMDNode *mExportTypeMetadata; |
| 55 | llvm::NamedMDNode *mExportElementMetadata; |
Stephen Hines | b3a12fe | 2011-01-26 20:16:38 -0800 | [diff] [blame] | 56 | llvm::NamedMDNode *mRSObjectSlotsMetadata; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 57 | |
Stephen Hines | 4b32ffd | 2010-11-05 18:47:11 -0700 | [diff] [blame] | 58 | RSObjectRefCount mRefCount; |
| 59 | |
Stephen Hines | cfae0f3 | 2010-11-01 18:57:31 -0700 | [diff] [blame] | 60 | void AnnotateFunction(clang::FunctionDecl *FD); |
| 61 | |
Zonr Chang | 68fc02c | 2010-10-13 19:09:19 +0800 | [diff] [blame] | 62 | protected: |
Stephen Hines | 4cc499d | 2011-08-24 19:06:17 -0700 | [diff] [blame] | 63 | virtual unsigned int getTargetAPI() const { |
| 64 | return mContext->getTargetAPI(); |
| 65 | } |
| 66 | |
Logan Chien | fa6ef56 | 2011-11-25 13:50:02 +0800 | [diff] [blame] | 67 | virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); |
Zonr Chang | 68fc02c | 2010-10-13 19:09:19 +0800 | [diff] [blame] | 68 | |
Stephen Hines | c97a333 | 2010-11-30 15:31:08 -0800 | [diff] [blame] | 69 | virtual void HandleTranslationUnitPre(clang::ASTContext &C); |
Stephen Hines | fcda235 | 2010-10-19 16:49:32 -0700 | [diff] [blame] | 70 | |
Zonr Chang | 68fc02c | 2010-10-13 19:09:19 +0800 | [diff] [blame] | 71 | virtual void HandleTranslationUnitPost(llvm::Module *M); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 72 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 73 | public: |
| 74 | RSBackend(RSContext *Context, |
Logan Chien | 9207a2e | 2011-10-21 15:39:28 +0800 | [diff] [blame] | 75 | clang::DiagnosticsEngine *DiagEngine, |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 76 | const clang::CodeGenOptions &CodeGenOpts, |
| 77 | const clang::TargetOptions &TargetOpts, |
Stephen Hines | 3fd0a94 | 2011-01-18 12:27:39 -0800 | [diff] [blame] | 78 | PragmaList *Pragmas, |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 79 | llvm::raw_ostream *OS, |
Zonr Chang | 3a9ca1f | 2010-10-06 17:52:56 +0800 | [diff] [blame] | 80 | Slang::OutputType OT, |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 81 | clang::SourceManager &SourceMgr, |
Stephen Hines | 4a4bf92 | 2011-08-18 17:20:33 -0700 | [diff] [blame] | 82 | bool AllowRSPrefix); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 83 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 84 | virtual ~RSBackend(); |
| 85 | }; |
Stephen Hines | e67239d | 2012-02-24 15:08:36 -0800 | [diff] [blame] | 86 | } // namespace slang |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 87 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 88 | #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ NOLINT |