86af4eb70eeebbe8da57f8ff98d88b823f26c930
[oota-llvm.git] / include / llvm / Transforms / Utils / Cloning.h
1 //===- Cloning.h - Clone various parts of LLVM programs ---------*- C++ -*-===//
2 //
3 // This file defines various functions that are used to clone chunks of LLVM
4 // code for various purposes.  This varies from copying whole modules into new
5 // modules, to cloning functions with different arguments, to inlining
6 // functions, to copying basic blocks to support loop unrolling or superblock
7 // formation, etc.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef LLVM_TRANSFORMS_UTIlS_CLONING_H
12 #define LLVM_TRANSFORMS_UTIlS_CLONING_H
13
14 #include <vector>
15 class Module;
16 class Function;
17 class BasicBlock;
18 class Value;
19 class CallInst;
20
21 // Clone OldFunc into NewFunc, transforming the old arguments into references to
22 // ArgMap values.  Note that if NewFunc already has basic blocks, the ones
23 // cloned into it will be added to the end of the function.
24 //
25 void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
26                        const std::vector<Value*> &ArgMap);
27
28
29 // InlineFunction - This function forcibly inlines the called function into the
30 // basic block of the caller.  This returns true if it is not possible to inline
31 // this call.  The program is still in a well defined state if this occurs 
32 // though.
33 //
34 // Note that this only does one level of inlining.  For example, if the 
35 // instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now 
36 // exists in the instruction stream.  Similiarly this will inline a recursive
37 // function by one level.
38 //
39 bool InlineFunction(CallInst *C);
40
41 #endif