1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===- BasicInliner.h - Basic function level inliner ------------*- C++ -*-===// 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// The LLVM Compiler Infrastructure 4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details. 7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file defines a simple function based inliner that does not use 11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// call graph information. 12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef BASICINLINER_H 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define BASICINLINER_H 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Analysis/InlineCost.h" 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm { 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class Function; 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class TargetData; 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman struct BasicInlinerImpl; 25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// BasicInliner - BasicInliner provides function level inlining interface. 27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// Clients provide list of functions which are inline without using 28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// module level call graph information. Note that the BasicInliner is 29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// free to delete a function if it is inlined into all call sites. 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class BasicInliner { 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman public: 32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman explicit BasicInliner(TargetData *T = NULL); 34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ~BasicInliner(); 35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// addFunction - Add function into the list of functions to process. 37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// All functions must be inserted using this interface before invoking 38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// inlineFunctions(). 39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void addFunction(Function *F); 40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// neverInlineFunction - Sometimes a function is never to be inlined 42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// because of one or other reason. 43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void neverInlineFunction(Function *F); 44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// inlineFuctions - Walk all call sites in all functions supplied by 46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// client. Inline as many call sites as possible. Delete completely 47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// inlined functions. 48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void inlineFunctions(); 49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman private: 51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman BasicInlinerImpl *Impl; 52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif 56