aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/Utils/SimplifyLibCalls.h
blob: 5db2d00181407c24efa60001e5d9d7a4cad26380 (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
//===- SimplifyLibCalls.h - Library call simplifier -------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file exposes an interface to build some C language libcalls for
// optimization passes that need to call the various functions.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H
#define LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H

namespace llvm {
  class Value;
  class CallInst;
  class DataLayout;
  class TargetLibraryInfo;
  class LibCallSimplifierImpl;

  /// LibCallSimplifier - This class implements a collection of optimizations
  /// that replace well formed calls to library functions with a more optimal
  /// form.  For example, replacing 'printf("Hello!")' with 'puts("Hello!")'.
  class LibCallSimplifier {
    /// Impl - A pointer to the actual implementation of the library call
    /// simplifier.
    LibCallSimplifierImpl *Impl;
  public:
    LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI);
    virtual ~LibCallSimplifier();

    /// optimizeCall - Take the given call instruction and return a more
    /// optimal value to replace the instruction with or 0 if a more
    /// optimal form can't be found.
    Value *optimizeCall(CallInst *CI);
  };
} // End llvm namespace

#endif