1 /* 2 * Copyright 2010-2012, 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 17 #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ // NOLINT 18 #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ 19 20 #include "slang_backend.h" 21 #include "slang_pragma_recorder.h" 22 #include "slang_rs_check_ast.h" 23 #include "slang_rs_object_ref_count.h" 24 25 namespace llvm { 26 class NamedMDNode; 27 } 28 29 namespace clang { 30 class ASTConsumer; 31 class DiagnosticsEngine; 32 class TargetOptions; 33 class CodeGenerator; 34 class ASTContext; 35 class DeclGroupRef; 36 class FunctionDecl; 37 } 38 39 namespace slang { 40 41 class RSContext; 42 43 class RSBackend : public Backend { 44 private: 45 RSContext *mContext; 46 47 clang::SourceManager &mSourceMgr; 48 49 bool mAllowRSPrefix; 50 51 bool mIsFilterscript; 52 53 llvm::NamedMDNode *mExportVarMetadata; 54 llvm::NamedMDNode *mExportFuncMetadata; 55 llvm::NamedMDNode *mExportForEachNameMetadata; 56 llvm::NamedMDNode *mExportForEachSignatureMetadata; 57 llvm::NamedMDNode *mExportTypeMetadata; 58 llvm::NamedMDNode *mExportElementMetadata; 59 llvm::NamedMDNode *mRSObjectSlotsMetadata; 60 61 RSObjectRefCount mRefCount; 62 63 RSCheckAST mASTChecker; 64 65 void AnnotateFunction(clang::FunctionDecl *FD); 66 67 protected: getTargetAPI()68 virtual unsigned int getTargetAPI() const { 69 return mContext->getTargetAPI(); 70 } 71 72 virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); 73 74 virtual void HandleTranslationUnitPre(clang::ASTContext &C); 75 76 virtual void HandleTranslationUnitPost(llvm::Module *M); 77 78 public: 79 RSBackend(RSContext *Context, 80 clang::DiagnosticsEngine *DiagEngine, 81 const clang::CodeGenOptions &CodeGenOpts, 82 const clang::TargetOptions &TargetOpts, 83 PragmaList *Pragmas, 84 llvm::raw_ostream *OS, 85 Slang::OutputType OT, 86 clang::SourceManager &SourceMgr, 87 bool AllowRSPrefix, 88 bool IsFilterscript); 89 90 virtual ~RSBackend(); 91 }; 92 } // namespace slang 93 94 #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ NOLINT 95