1 /*
2  * Copyright 2013, 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 BCC_RS_SCRIPT_GROUP_FUSION_H
18 #define BCC_RS_SCRIPT_GROUP_FUSION_H
19 
20 #include <vector>
21 #include <string>
22 
23 namespace llvm {
24 class Module;
25 }
26 
27 namespace bcc {
28 
29 class Source;
30 class BCCContext;
31 
32 /// @brief Fuse kernels
33 ///
34 /// @param Context bcc context.
35 /// @param sources The Sources containing the kernels.
36 /// @param slots The slots where the kernels are located.
37 /// @param fusedName
38 /// @return True, if kernels are successfully fused. False, otherwise. It's up to
39 /// the caller on how to deal with unsuccessful fusion. A script group can
40 /// execute with either fused kernels or individual kernels.
41 bool fuseKernels(BCCContext& Context,
42                  const std::vector<Source *>& sources,
43                  const std::vector<int>& slots,
44                  const std::string& fusedName,
45                  llvm::Module* mergedModule);
46 
47 bool renameInvoke(BCCContext& Context, const Source* source, const int slot,
48                   const std::string& newName, llvm::Module* mergedModule);
49 }
50 
51 #endif /* BCC_RS_SCRIPT_GROUP_FUSION_H */
52