aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/Utils/FunctionUtils.h
blob: 821a61e99b74577588581f13f58bb811c959bec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//===-- Transform/Utils/FunctionUtils.h - Function Utils --------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This family of transformations manipulate LLVM functions.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_UTILS_FUNCTION_H
#define LLVM_TRANSFORMS_UTILS_FUNCTION_H

#include "llvm/ADT/ArrayRef.h"
#include <vector>

namespace llvm {
  class BasicBlock;
  class DominatorTree;
  class Function;
  class Loop;

  /// \brief Test whether a basic block is a viable candidate for extraction.
  ///
  /// This tests whether a particular basic block is viable for extraction into
  /// a separate function. It can be used to prune code extraction eagerly
  /// rather than waiting for one of the Extract* methods below to reject
  /// a request.
  bool isBlockViableForExtraction(const BasicBlock &BB);

  /// ExtractCodeRegion - Rip out a sequence of basic blocks into a new
  /// function.
  ///
  Function* ExtractCodeRegion(DominatorTree& DT,
                              ArrayRef<BasicBlock*> code,
                              bool AggregateArgs = false);

  /// ExtractLoop - Rip out a natural loop into a new function.
  ///
  Function* ExtractLoop(DominatorTree& DT, Loop *L,
                        bool AggregateArgs = false);

  /// ExtractBasicBlock - Rip out a basic block (and the associated landing pad)
  /// into a new function.
  ///
  Function* ExtractBasicBlock(ArrayRef<BasicBlock*> BBs,
                              bool AggregateArgs = false);
}

#endif