Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:48:11

0001 //===- Utils.h - Utility functions for code generation ----------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains utility functions for the code generation.
0010 //===----------------------------------------------------------------------===//
0011 
0012 #ifndef POLLY_CODEGEN_UTILS_H
0013 #define POLLY_CODEGEN_UTILS_H
0014 
0015 #include <utility>
0016 
0017 namespace llvm {
0018 class Pass;
0019 class Value;
0020 class BasicBlock;
0021 class DominatorTree;
0022 class RegionInfo;
0023 class LoopInfo;
0024 class BranchInst;
0025 } // namespace llvm
0026 
0027 namespace polly {
0028 
0029 class Scop;
0030 
0031 using BBPair = std::pair<llvm::BasicBlock *, llvm::BasicBlock *>;
0032 /// Execute a Scop conditionally wrt @p RTC.
0033 ///
0034 /// In the CFG the optimized code of the Scop is generated next to the
0035 /// original code. Both the new and the original version of the code remain
0036 /// in the CFG. A branch statement decides which version is executed based on
0037 /// the runtime value of @p RTC.
0038 ///
0039 /// Before transformation:
0040 ///
0041 ///                        bb0
0042 ///                         |
0043 ///                     orig_scop
0044 ///                         |
0045 ///                        bb1
0046 ///
0047 /// After transformation:
0048 ///                        bb0
0049 ///                         |
0050 ///                  polly.splitBlock
0051 ///                     /       \.
0052 ///                     |     startBlock
0053 ///                     |        |
0054 ///               orig_scop   new_scop
0055 ///                     \      /
0056 ///                      \    /
0057 ///                        bb1 (joinBlock)
0058 ///
0059 /// @param S   The Scop to execute conditionally.
0060 /// @param P   A reference to the pass calling this function.
0061 /// @param RTC The runtime condition checked before executing the new SCoP.
0062 ///
0063 /// @return  An std::pair:
0064 ///              - The first element is a BBPair of (StartBlock, EndBlock).
0065 ///              - The second element is the BranchInst which conditionally
0066 ///                branches to the SCoP based on the RTC.
0067 ///
0068 std::pair<BBPair, llvm::BranchInst *>
0069 executeScopConditionally(Scop &S, llvm::Value *RTC, llvm::DominatorTree &DT,
0070                          llvm::RegionInfo &RI, llvm::LoopInfo &LI);
0071 } // namespace polly
0072 #endif