1 //===- SimplifyLibCalls.h - Library call simplifier -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file exposes an interface to build some C language libcalls for
11 // optimization passes that need to call the various functions.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H
16 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYLIBCALLS_H
23 class TargetLibraryInfo;
24 class LibCallSimplifierImpl;
26 /// LibCallSimplifier - This class implements a collection of optimizations
27 /// that replace well formed calls to library functions with a more optimal
28 /// form. For example, replacing 'printf("Hello!")' with 'puts("Hello!")'.
29 class LibCallSimplifier {
30 /// Impl - A pointer to the actual implementation of the library call
32 LibCallSimplifierImpl *Impl;
35 LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI,
37 virtual ~LibCallSimplifier();
39 /// optimizeCall - Take the given call instruction and return a more
40 /// optimal value to replace the instruction with or 0 if a more
41 /// optimal form can't be found. Note that the returned value may
42 /// be equal to the instruction being optimized. In this case all
43 /// other instructions that use the given instruction were modified
44 /// and the given instruction is dead.
45 Value *optimizeCall(CallInst *CI);
47 /// replaceAllUsesWith - This method is used when the library call
48 /// simplifier needs to replace instructions other than the library
49 /// call being modified.
50 virtual void replaceAllUsesWith(Instruction *I, Value *With) const;
52 } // End llvm namespace