2014-11-05 02:36:22 +01:00
|
|
|
//===-- llvm/GlobalObject.h - Class to represent global objects -*- C++ -*-===//
|
2014-05-13 20:45:48 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This represents an independent object. That is, a function or a global
|
|
|
|
// variable, but not an alias.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_IR_GLOBALOBJECT_H
|
|
|
|
#define LLVM_IR_GLOBALOBJECT_H
|
|
|
|
|
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/GlobalValue.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2014-06-27 20:19:56 +02:00
|
|
|
class Comdat;
|
2014-05-13 20:45:48 +02:00
|
|
|
class Module;
|
|
|
|
|
|
|
|
class GlobalObject : public GlobalValue {
|
2015-02-15 23:54:22 +01:00
|
|
|
GlobalObject(const GlobalObject &) = delete;
|
2014-05-13 20:45:48 +02:00
|
|
|
|
|
|
|
protected:
|
2015-08-21 23:35:28 +02:00
|
|
|
GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
|
|
|
|
LinkageTypes Linkage, const Twine &Name,
|
|
|
|
unsigned AddressSpace = 0)
|
2015-09-14 23:47:27 +02:00
|
|
|
: GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name, AddressSpace),
|
2015-08-21 23:35:28 +02:00
|
|
|
ObjComdat(nullptr) {
|
2014-05-13 20:45:48 +02:00
|
|
|
setGlobalValueSubClassData(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Section; // Section to emit this into, empty means default
|
2014-06-27 20:19:56 +02:00
|
|
|
Comdat *ObjComdat;
|
2014-10-24 20:13:04 +02:00
|
|
|
static const unsigned AlignmentBits = 5;
|
|
|
|
static const unsigned GlobalObjectSubClassDataBits =
|
|
|
|
GlobalValueSubClassDataBits - AlignmentBits;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const unsigned AlignmentMask = (1 << AlignmentBits) - 1;
|
|
|
|
|
2014-05-13 20:45:48 +02:00
|
|
|
public:
|
|
|
|
unsigned getAlignment() const {
|
2014-10-24 20:13:04 +02:00
|
|
|
unsigned Data = getGlobalValueSubClassData();
|
|
|
|
unsigned AlignmentData = Data & AlignmentMask;
|
|
|
|
return (1u << AlignmentData) >> 1;
|
2014-05-13 20:45:48 +02:00
|
|
|
}
|
|
|
|
void setAlignment(unsigned Align);
|
|
|
|
|
2014-10-24 20:13:04 +02:00
|
|
|
unsigned getGlobalObjectSubClassData() const;
|
|
|
|
void setGlobalObjectSubClassData(unsigned Val);
|
|
|
|
|
2014-06-03 04:41:57 +02:00
|
|
|
bool hasSection() const { return !StringRef(getSection()).empty(); }
|
|
|
|
const char *getSection() const { return Section.c_str(); }
|
2014-05-13 20:45:48 +02:00
|
|
|
void setSection(StringRef S);
|
|
|
|
|
2014-06-27 20:19:56 +02:00
|
|
|
bool hasComdat() const { return getComdat() != nullptr; }
|
|
|
|
const Comdat *getComdat() const { return ObjComdat; }
|
|
|
|
Comdat *getComdat() { return ObjComdat; }
|
|
|
|
void setComdat(Comdat *C) { ObjComdat = C; }
|
|
|
|
|
2014-05-13 20:45:48 +02:00
|
|
|
void copyAttributesFrom(const GlobalValue *Src) override;
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return V->getValueID() == Value::FunctionVal ||
|
|
|
|
V->getValueID() == Value::GlobalVariableVal;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2014-05-13 20:45:48 +02:00
|
|
|
|
|
|
|
#endif
|