1 //===- Utils.h - Utility functions for code generation ----------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains utility functions for the code generation. 10 //===----------------------------------------------------------------------===// 11 12 #ifndef POLLY_CODEGEN_UTILS_H 13 #define POLLY_CODEGEN_UTILS_H 14 15 #include <utility> 16 17 namespace llvm { 18 class Pass; 19 class Value; 20 class BasicBlock; 21 class DominatorTree; 22 class RegionInfo; 23 class LoopInfo; 24 class BranchInst; 25 } // namespace llvm 26 27 namespace polly { 28 29 class Scop; 30 31 using BBPair = std::pair<llvm::BasicBlock *, llvm::BasicBlock *>; 32 /// Execute a Scop conditionally wrt @p RTC. 33 /// 34 /// In the CFG the optimized code of the Scop is generated next to the 35 /// original code. Both the new and the original version of the code remain 36 /// in the CFG. A branch statement decides which version is executed based on 37 /// the runtime value of @p RTC. 38 /// 39 /// Before transformation: 40 /// 41 /// bb0 42 /// | 43 /// orig_scop 44 /// | 45 /// bb1 46 /// 47 /// After transformation: 48 /// bb0 49 /// | 50 /// polly.splitBlock 51 /// / \. 52 /// | startBlock 53 /// | | 54 /// orig_scop new_scop 55 /// \ / 56 /// \ / 57 /// bb1 (joinBlock) 58 /// 59 /// @param S The Scop to execute conditionally. 60 /// @param P A reference to the pass calling this function. 61 /// @param RTC The runtime condition checked before executing the new SCoP. 62 /// 63 /// @return An std::pair: 64 /// - The first element is a BBPair of (StartBlock, EndBlock). 65 /// - The second element is the BranchInst which conditionally 66 /// branches to the SCoP based on the RTC. 67 /// 68 std::pair<BBPair, llvm::BranchInst *> 69 executeScopConditionally(Scop &S, llvm::Value *RTC, llvm::DominatorTree &DT, 70 llvm::RegionInfo &RI, llvm::LoopInfo &LI); 71 } // namespace polly 72 #endif 73