slang_rs_backend.h revision e639eb5caa2c386b4a60659a4929e8a6141a2cbe
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 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_object_ref_count.h" 23 24namespace llvm { 25 class NamedMDNode; 26} 27 28namespace clang { 29 class ASTConsumer; 30 class Diagnostic; 31 class TargetOptions; 32 class PragmaList; 33 class CodeGenerator; 34 class ASTContext; 35 class DeclGroupRef; 36 class FunctionDecl; 37} 38 39namespace slang { 40 41class RSContext; 42 43class RSBackend : public Backend { 44 private: 45 RSContext *mContext; 46 47 clang::SourceManager &mSourceMgr; 48 49 bool mAllowRSPrefix; 50 51 llvm::NamedMDNode *mExportVarMetadata; 52 llvm::NamedMDNode *mExportFuncMetadata; 53 llvm::NamedMDNode *mExportTypeMetadata; 54 llvm::NamedMDNode *mExportElementMetadata; 55 56 RSObjectRefCount mRefCount; 57 58 void AnnotateFunction(clang::FunctionDecl *FD); 59 60 protected: 61 virtual void HandleTopLevelDecl(clang::DeclGroupRef D); 62 63 virtual void HandleTranslationUnitPre(clang::ASTContext& C); 64 65 virtual void HandleTranslationUnitPost(llvm::Module *M); 66 67 public: 68 RSBackend(RSContext *Context, 69 clang::Diagnostic *Diags, 70 const clang::CodeGenOptions &CodeGenOpts, 71 const clang::TargetOptions &TargetOpts, 72 const PragmaList &Pragmas, 73 llvm::raw_ostream *OS, 74 Slang::OutputType OT, 75 clang::SourceManager &SourceMgr, 76 bool AllowRSPrefix); 77 78 virtual ~RSBackend(); 79}; 80} 81 82#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ NOLINT 83