1193323Sed//===-- llvm/AutoUpgrade.h - AutoUpgrade Helpers ----------------*- C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10263508Sdim//  These functions are implemented by lib/IR/AutoUpgrade.cpp.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14193323Sed#ifndef LLVM_AUTOUPGRADE_H
15193323Sed#define LLVM_AUTOUPGRADE_H
16193323Sed
17193323Sednamespace llvm {
18263508Sdim  class CallInst;
19263508Sdim  class Constant;
20263508Sdim  class Function;
21263508Sdim  class Instruction;
22198090Srdivacky  class Module;
23212904Sdim  class GlobalVariable;
24263508Sdim  class Type;
25263508Sdim  class Value;
26193323Sed
27263508Sdim  /// This is a more granular function that simply checks an intrinsic function
28193323Sed  /// for upgrading, and returns true if it requires upgrading. It may return
29193323Sed  /// null in NewFn if the all calls to the original intrinsic function
30193323Sed  /// should be transformed to non-function-call instructions.
31193323Sed  bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn);
32193323Sed
33263508Sdim  /// This is the complement to the above, replacing a specific call to an
34193323Sed  /// intrinsic function with a call to the specified new function.
35193323Sed  void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn);
36263508Sdim
37263508Sdim  /// This is an auto-upgrade hook for any old intrinsic function syntaxes
38263508Sdim  /// which need to have both the function updated as well as all calls updated
39263508Sdim  /// to the new function. This should only be run in a post-processing fashion
40193323Sed  /// so that it can update all calls to the old function.
41193323Sed  void UpgradeCallsToIntrinsic(Function* F);
42193323Sed
43212904Sdim  /// This checks for global variables which should be upgraded. It returns true
44212904Sdim  /// if it requires upgrading.
45212904Sdim  bool UpgradeGlobalVariable(GlobalVariable *GV);
46263508Sdim
47263508Sdim  /// If the TBAA tag for the given instruction uses the scalar TBAA format,
48263508Sdim  /// we upgrade it to the struct-path aware TBAA format.
49263508Sdim  void UpgradeInstWithTBAATag(Instruction *I);
50263508Sdim
51263508Sdim  /// This is an auto-upgrade for bitcast between pointers with different
52263508Sdim  /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr.
53263508Sdim  Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
54263508Sdim                                  Instruction *&Temp);
55263508Sdim
56263508Sdim  /// This is an auto-upgrade for bitcast constant expression between pointers
57263508Sdim  /// with different address spaces: the instruction is replaced by a pair
58263508Sdim  /// ptrtoint+inttoptr.
59263508Sdim  Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
60263508Sdim
61263508Sdim  /// Check the debug info version number, if it is out-dated, drop the debug
62263508Sdim  /// info. Return true if module is modified.
63263508Sdim  bool UpgradeDebugInfo(Module &M);
64193323Sed} // End llvm namespace
65193323Sed
66193323Sed#endif
67