1 //===-- llvm/GlobalObject.h - Class to represent a global object *- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This represents an independent object. That is, a function or a global
11 // variable, but not an alias.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_IR_GLOBALOBJECT_H
16 #define LLVM_IR_GLOBALOBJECT_H
18 #include "llvm/IR/Constant.h"
19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/GlobalValue.h"
26 class GlobalObject : public GlobalValue {
27 GlobalObject(const GlobalObject &) LLVM_DELETED_FUNCTION;
30 GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
31 LinkageTypes Linkage, const Twine &Name)
32 : GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name) {
33 setGlobalValueSubClassData(0);
36 std::string Section; // Section to emit this into, empty means default
38 unsigned getAlignment() const {
39 return (1u << getGlobalValueSubClassData()) >> 1;
41 void setAlignment(unsigned Align);
43 bool hasSection() const { return !StringRef(getSection()).empty(); }
44 const char *getSection() const { return Section.c_str(); }
45 void setSection(StringRef S);
47 void copyAttributesFrom(const GlobalValue *Src) override;
49 // Methods for support type inquiry through isa, cast, and dyn_cast:
50 static inline bool classof(const Value *V) {
51 return V->getValueID() == Value::FunctionVal ||
52 V->getValueID() == Value::GlobalVariableVal;
56 } // End llvm namespace