mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-03 11:24:18 +00:00
Split GlobalValue into GlobalValue and GlobalObject.
This allows code to statically accept a Function or a GlobalVariable, but not an alias. This is already a cleanup by itself IMHO, but the main reason for it is that it gives a lot more confidence that the refactoring to fix the design of GlobalAlias is correct. That will be a followup patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208716 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
58
include/llvm/IR/GlobalObject.h
Normal file
58
include/llvm/IR/GlobalObject.h
Normal file
@ -0,0 +1,58 @@
|
||||
//===-- llvm/GlobalObject.h - Class to represent a global object *- C++ -*-===//
|
||||
//
|
||||
// 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/Constant.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Module;
|
||||
|
||||
class GlobalObject : public GlobalValue {
|
||||
GlobalObject(const GlobalObject &) LLVM_DELETED_FUNCTION;
|
||||
|
||||
protected:
|
||||
GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
|
||||
LinkageTypes Linkage, const Twine &Name)
|
||||
: GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name) {
|
||||
setGlobalValueSubClassData(0);
|
||||
}
|
||||
|
||||
std::string Section; // Section to emit this into, empty means default
|
||||
public:
|
||||
unsigned getAlignment() const {
|
||||
return (1u << getGlobalValueSubClassData()) >> 1;
|
||||
}
|
||||
void setAlignment(unsigned Align);
|
||||
|
||||
bool hasSection() const { return !getSection().empty(); }
|
||||
const std::string &getSection() const { return Section; }
|
||||
void setSection(StringRef S);
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user