00001 //===- LibCallSemantics.h - Describe library semantics --------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines interfaces that can be used to describe language specific 00011 // runtime library interfaces (e.g. libc, libm, etc) to LLVM optimizers. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_ANALYSIS_LIBCALLSEMANTICS_H 00016 #define LLVM_ANALYSIS_LIBCALLSEMANTICS_H 00017 00018 #include "llvm/Analysis/AliasAnalysis.h" 00019 00020 namespace llvm { 00021 00039 struct LibCallLocationInfo { 00040 // TODO: Flags: isContextSensitive etc. 00041 00047 enum LocResult { 00048 Yes, No, Unknown 00049 }; 00050 LocResult (*isLocation)(CallSite CS, const Value *Ptr, unsigned Size); 00051 }; 00052 00063 struct LibCallFunctionInfo { 00065 const char *Name; 00066 00068 00073 AliasAnalysis::ModRefResult UniversalBehavior; 00074 00077 struct LocationMRInfo { 00079 unsigned LocationID; 00081 AliasAnalysis::ModRefResult MRInfo; 00082 }; 00083 00086 enum { 00092 DoesOnly, 00093 00103 DoesNot 00104 } DetailsType; 00105 00118 const LocationMRInfo *LocationDetails; 00119 }; 00120 00121 00126 class LibCallInfo { 00127 // Implementation details of this object, private. 00128 mutable void *Impl; 00129 mutable const LibCallLocationInfo *Locations; 00130 mutable unsigned NumLocations; 00131 public: 00132 LibCallInfo() : Impl(0), Locations(0), NumLocations(0) {} 00133 virtual ~LibCallInfo(); 00134 00135 //===------------------------------------------------------------------===// 00136 // Accessor Methods: Efficient access to contained data. 00137 //===------------------------------------------------------------------===// 00138 00140 const LibCallLocationInfo &getLocationInfo(unsigned LocID) const; 00141 00142 00145 const LibCallFunctionInfo *getFunctionInfo(Function *F) const; 00146 00147 00148 //===------------------------------------------------------------------===// 00149 // Implementation Methods: Subclasses should implement these. 00150 //===------------------------------------------------------------------===// 00151 00154 virtual unsigned getLocationInfo(const LibCallLocationInfo *&Array) const { 00155 return 0; 00156 } 00157 00161 virtual const LibCallFunctionInfo *getFunctionInfoArray() const = 0; 00162 }; 00163 00164 } // end namespace llvm 00165 00166 #endif
1.5.8