Implement new LibCallSimplifier class
[oota-llvm.git] / include / llvm / Transforms / Utils / SimplifyLibCalls.h
1 //===- SimplifyLibCalls.h - Library call simplifier -------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes an interface to build some C language libcalls for
11 // optimization passes that need to call the various functions.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H
16 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H
17
18 namespace llvm {
19   class Value;
20   class CallInst;
21   class DataLayout;
22   class TargetLibraryInfo;
23   class LibCallSimplifierImpl;
24
25   /// LibCallSimplifier - This class implements a collection of optimizations
26   /// that replace well formed calls to library functions with a more optimal
27   /// form.  For example, replacing 'printf("Hello!")' with 'puts("Hello!")'.
28   class LibCallSimplifier {
29     /// Impl - A pointer to the actual implementation of the library call
30     /// simplifier.
31     LibCallSimplifierImpl *Impl;
32   public:
33     LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI);
34     virtual ~LibCallSimplifier();
35
36     /// optimizeCall - Take the given call instruction and return a more
37     /// optimal value to replace the instruction with or 0 if a more
38     /// optimal form can't be found.
39     Value *optimizeCall(CallInst *CI);
40   };
41 } // End llvm namespace
42
43 #endif