blob: 9df27ae9524e87408eab81e4c4cb163da8e9fddd [file] [log] [blame]
Matt Walac0c5dd82015-07-23 17:29:37 -07001/*
2 * Copyright 2015, 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_EXPORT_REDUCE_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_REDUCE_H_
19
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/SmallVector.h"
22
23#include "slang_rs_context.h"
24#include "slang_rs_exportable.h"
25#include "slang_rs_export_type.h"
26
27namespace clang {
28 class FunctionDecl;
29} // namespace clang
30
31namespace slang {
32
33// Base class for reflecting control-side reduce
34class RSExportReduce : public RSExportable {
35 public:
36 typedef llvm::SmallVectorImpl<const clang::ParmVarDecl*> InVec;
37 typedef InVec::const_iterator InIter;
38
39 private:
40 // Function name
41 std::string mName;
42 // Input and output type
43 RSExportType *mType;
44 // Inputs
45 llvm::SmallVector<const clang::ParmVarDecl *, 2> mIns;
46
47 RSExportReduce(RSContext *Context, const llvm::StringRef &Name)
48 : RSExportable(Context, RSExportable::EX_REDUCE),
49 mName(Name.data(), Name.size()), mType(nullptr), mIns(2) {
50 }
51
52 RSExportReduce(const RSExportReduce &) = delete;
53 RSExportReduce &operator=(const RSExportReduce &) = delete;
54
55 // Given a reduce kernel declaration, validate the parameters to the
56 // reduce kernel.
57 bool validateAndConstructParams(RSContext *Context,
58 const clang::FunctionDecl *FD);
59
60 public:
61 static RSExportReduce *Create(RSContext *Context,
62 const clang::FunctionDecl *FD);
63
64 const std::string &getName() const {
65 return mName;
66 }
67
68 const InVec &getIns() const {
69 return mIns;
70 }
71
72 const RSExportType *getType() const {
73 return mType;
74 }
75
76 static bool isRSReduceFunc(unsigned int targetAPI,
77 const clang::FunctionDecl *FD);
78
79}; // RSExportReduce
80
81} // namespace slang
82
83#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_REDUCE_H_ NOLINT