Fix failing test cases with joined live intervals. It turns out that
[oota-llvm.git] / include / llvm / GlobalValue.h
index af2ff23c82edfedc56fbea6dcb7dc02e0d0a059c..942d9b9a4081ded2b6e951a24dfbea4943ba8d43 100644 (file)
@@ -1,4 +1,11 @@
-//===-- llvm/GlobalValue.h - Class to represent a global value ---*- C++ -*--=//
+//===-- llvm/GlobalValue.h - Class to represent a global value --*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file is a common base class of all globally definable objects.  As such,
 // it is subclassed by GlobalVariable and by Function.  This is used because you
 #define LLVM_GLOBALVALUE_H
 
 #include "llvm/User.h"
+
+namespace llvm {
+
 class PointerType;
 class Module;
 
 class GlobalValue : public User {
   GlobalValue(const GlobalValue &);             // do not implement
+public:
+  enum LinkageTypes {
+    ExternalLinkage,   // Externally visible function
+    LinkOnceLinkage,   // Keep one copy of named function when linking (inline)
+    WeakLinkage,       // Keep one copy of named function when linking (weak)
+    AppendingLinkage,  // Special purpose, only applies to global arrays
+    InternalLinkage    // Rename collisions when linking (static functions)
+  };
 protected:
-  GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
+  GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage,
              const std::string &name = "")
-    : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
+    : User(Ty, vty, name), Linkage(linkage), Parent(0) {}
 
-  bool HasInternalLinkage;    // Is this value accessable externally?
+  LinkageTypes Linkage;   // The linkage of this global
   Module *Parent;
 public:
   ~GlobalValue() {}
 
   /// getType - Global values are always pointers.
   inline const PointerType *getType() const {
-    return (const PointerType*)User::getType();
+    return reinterpret_cast<const PointerType*>(User::getType());
   }
 
-  /// Internal Linkage - True if the global value is inaccessible to 
-  bool hasInternalLinkage() const { return HasInternalLinkage; }
-  bool hasExternalLinkage() const { return !HasInternalLinkage; }
-  void setInternalLinkage(bool HIL) { HasInternalLinkage = HIL; }
+  bool hasExternalLinkage()  const { return Linkage == ExternalLinkage; }
+  bool hasLinkOnceLinkage()  const { return Linkage == LinkOnceLinkage; }
+  bool hasWeakLinkage()      const { return Linkage == WeakLinkage; }
+  bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
+  bool hasInternalLinkage()  const { return Linkage == InternalLinkage; }
+  void setLinkage(LinkageTypes LT) { Linkage = LT; }
+  LinkageTypes getLinkage() const { return Linkage; }
 
   /// isExternal - Return true if the primary definition of this global value is
   /// outside of the current translation unit...
@@ -53,4 +74,6 @@ public:
   }
 };
 
+} // End llvm namespace
+
 #endif