16994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//===-- llvm/AutoUpgrade.h - AutoUpgrade Helpers ----------------*- C++ -*-===//
26994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//
36994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//                     The LLVM Compiler Infrastructure
46994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
76994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//
86994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//===----------------------------------------------------------------------===//
96994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//
106994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//  These functions are implemented by lib/VMCore/AutoUpgrade.cpp.
116994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//
126994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//===----------------------------------------------------------------------===//
136994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
146994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth#ifndef LLVM_AUTOUPGRADE_H
156994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth#define LLVM_AUTOUPGRADE_H
166994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
176994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruthnamespace llvm {
18e4b275610a7a05b7ee4c0378a906a6330e4c4ab0Devang Patel  class Module;
19de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling  class GlobalVariable;
206994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  class Function;
216994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  class CallInst;
226994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
236994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// This is a more granular function that simply checks an intrinsic function
24f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng  /// for upgrading, and returns true if it requires upgrading. It may return
25f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng  /// null in NewFn if the all calls to the original intrinsic function
26f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng  /// should be transformed to non-function-call instructions.
27f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng  bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn);
286994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
296994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// This is the complement to the above, replacing a specific call to an
306994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// intrinsic function with a call to the specified new function.
316994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn);
326994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
336994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// This is an auto-upgrade hook for any old intrinsic function syntaxes
346994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// which need to have both the function updated as well as all calls updated
356994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// to the new function. This should only be run in a post-processing fashion
366994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  /// so that it can update all calls to the old function.
376994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth  void UpgradeCallsToIntrinsic(Function* F);
386994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
39de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling  /// This checks for global variables which should be upgraded. It returns true
40de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling  /// if it requires upgrading.
41de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling  bool UpgradeGlobalVariable(GlobalVariable *GV);
426994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth} // End llvm namespace
436994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth
446994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth#endif
45