blob: 77d706d6a42db869864a7562b00d86816a2007f2 [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
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 Hinese639eb52010-11-08 19:27:20 -080017#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_
Shih-wei Liao462aefd2010-06-04 15:32:04 -070019
zonr6315f762010-10-05 15:35:14 +080020#include "slang_backend.h"
21#include "slang_pragma_recorder.h"
Stephen Hines4b32ffd2010-11-05 18:47:11 -070022#include "slang_rs_object_ref_count.h"
Shih-wei Liao462aefd2010-06-04 15:32:04 -070023
Shih-wei Liao462aefd2010-06-04 15:32:04 -070024namespace llvm {
zonr6315f762010-10-05 15:35:14 +080025 class NamedMDNode;
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070026}
Shih-wei Liao462aefd2010-06-04 15:32:04 -070027
28namespace clang {
zonr6315f762010-10-05 15:35:14 +080029 class ASTConsumer;
30 class Diagnostic;
31 class TargetOptions;
zonr6315f762010-10-05 15:35:14 +080032 class CodeGenerator;
33 class ASTContext;
34 class DeclGroupRef;
Stephen Hinescfae0f32010-11-01 18:57:31 -070035 class FunctionDecl;
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070036}
Shih-wei Liao462aefd2010-06-04 15:32:04 -070037
38namespace slang {
39
Shih-wei Liao462aefd2010-06-04 15:32:04 -070040class RSContext;
41
42class RSBackend : public Backend {
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070043 private:
44 RSContext *mContext;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070045
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080046 clang::SourceManager &mSourceMgr;
47
48 bool mAllowRSPrefix;
49
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070050 llvm::NamedMDNode *mExportVarMetadata;
51 llvm::NamedMDNode *mExportFuncMetadata;
52 llvm::NamedMDNode *mExportTypeMetadata;
53 llvm::NamedMDNode *mExportElementMetadata;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070054
Stephen Hines4b32ffd2010-11-05 18:47:11 -070055 RSObjectRefCount mRefCount;
56
Stephen Hinescfae0f32010-11-01 18:57:31 -070057 void AnnotateFunction(clang::FunctionDecl *FD);
58
Zonr Chang68fc02c2010-10-13 19:09:19 +080059 protected:
60 virtual void HandleTopLevelDecl(clang::DeclGroupRef D);
61
Stephen Hinesc97a3332010-11-30 15:31:08 -080062 virtual void HandleTranslationUnitPre(clang::ASTContext &C);
Stephen Hinesfcda2352010-10-19 16:49:32 -070063
Zonr Chang68fc02c2010-10-13 19:09:19 +080064 virtual void HandleTranslationUnitPost(llvm::Module *M);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070065
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070066 public:
67 RSBackend(RSContext *Context,
Stephen Hinese639eb52010-11-08 19:27:20 -080068 clang::Diagnostic *Diags,
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070069 const clang::CodeGenOptions &CodeGenOpts,
70 const clang::TargetOptions &TargetOpts,
Stephen Hines3fd0a942011-01-18 12:27:39 -080071 PragmaList *Pragmas,
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070072 llvm::raw_ostream *OS,
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080073 Slang::OutputType OT,
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070074 clang::SourceManager &SourceMgr,
75 bool AllowRSPrefix);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070076
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070077 virtual ~RSBackend();
78};
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070079}
Shih-wei Liao462aefd2010-06-04 15:32:04 -070080
Stephen Hinese639eb52010-11-08 19:27:20 -080081#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_BACKEND_H_ NOLINT