AutoUpgrade.h revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines//===- 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// 103f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault// These functions are implemented by lib/IR/AutoUpgrade.cpp. 116994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth// 126994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth//===----------------------------------------------------------------------===// 136994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 1436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#ifndef LLVM_IR_AUTOUPGRADE_H 1536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVM_IR_AUTOUPGRADE_H 166994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 176994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruthnamespace llvm { 181572ba716bad4944a83040adef76c186c4841e95Matt Arsenault class CallInst; 1959d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault class Constant; 206994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth class Function; 21804f034bd18789e9bbf4c70c10189dd6dbf04128Manman Ren class Instruction; 221572ba716bad4944a83040adef76c186c4841e95Matt Arsenault class Module; 231572ba716bad4944a83040adef76c186c4841e95Matt Arsenault class GlobalVariable; 2459d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault class Type; 251572ba716bad4944a83040adef76c186c4841e95Matt Arsenault class Value; 266994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 273f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault /// This is a more granular function that simply checks an intrinsic function 28f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng /// for upgrading, and returns true if it requires upgrading. It may return 29f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng /// null in NewFn if the all calls to the original intrinsic function 30f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng /// should be transformed to non-function-call instructions. 31f9b83fcf95e8a280d7b117af8858596fe5b10d94Evan Cheng bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn); 326994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 333f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault /// This is the complement to the above, replacing a specific call to an 346994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth /// intrinsic function with a call to the specified new function. 356994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn); 363f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault 373f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault /// This is an auto-upgrade hook for any old intrinsic function syntaxes 383f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault /// which need to have both the function updated as well as all calls updated 393f49322818a3f2b9ca6fe75f49c7541c8dfb538dMatt Arsenault /// to the new function. This should only be run in a post-processing fashion 406994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth /// so that it can update all calls to the old function. 416994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth void UpgradeCallsToIntrinsic(Function* F); 426994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 43de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling /// This checks for global variables which should be upgraded. It returns true 44de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling /// if it requires upgrading. 45de49f360ec4780acb382a3ae923d1716fdb0dc03Bill Wendling bool UpgradeGlobalVariable(GlobalVariable *GV); 46804f034bd18789e9bbf4c70c10189dd6dbf04128Manman Ren 47804f034bd18789e9bbf4c70c10189dd6dbf04128Manman Ren /// If the TBAA tag for the given instruction uses the scalar TBAA format, 48804f034bd18789e9bbf4c70c10189dd6dbf04128Manman Ren /// we upgrade it to the struct-path aware TBAA format. 49804f034bd18789e9bbf4c70c10189dd6dbf04128Manman Ren void UpgradeInstWithTBAATag(Instruction *I); 5059d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault 5159d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault /// This is an auto-upgrade for bitcast between pointers with different 5259d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr. 5359d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, 5459d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault Instruction *&Temp); 5559d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault 5659d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault /// This is an auto-upgrade for bitcast constant expression between pointers 5759d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault /// with different address spaces: the instruction is replaced by a pair 5859d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault /// ptrtoint+inttoptr. 5959d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy); 6027457ac42f7a9267ab7e0190424a95fecf0ea201Manman Ren 6127457ac42f7a9267ab7e0190424a95fecf0ea201Manman Ren /// Check the debug info version number, if it is out-dated, drop the debug 6227457ac42f7a9267ab7e0190424a95fecf0ea201Manman Ren /// info. Return true if module is modified. 6327457ac42f7a9267ab7e0190424a95fecf0ea201Manman Ren bool UpgradeDebugInfo(Module &M); 646994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth} // End llvm namespace 656994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth 666994040a952e5fb27605eb3cf29ed86c4e59cf62Chandler Carruth#endif 67