mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Extend the relocation tracker handler, so we can filter on different 'kinds' of relocations required.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
004e27cc1b
commit
ab267a2823
@ -19,6 +19,12 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
template<typename T> class SmallVectorImpl;
|
template<typename T> class SmallVectorImpl;
|
||||||
|
|
||||||
|
namespace Reloc {
|
||||||
|
const unsigned Local = 1 << 0; ///< Local relocations are required
|
||||||
|
const unsigned Global = 1 << 1; ///< Global relocations are required
|
||||||
|
const unsigned LocalOrGlobal = Local | Global;
|
||||||
|
}
|
||||||
|
|
||||||
/// This is an important base class in LLVM. It provides the common facilities
|
/// This is an important base class in LLVM. It provides the common facilities
|
||||||
/// of all constant values in an LLVM program. A constant is a value that is
|
/// of all constant values in an LLVM program. A constant is a value that is
|
||||||
/// immutable at runtime. Functions are constants because their address is
|
/// immutable at runtime. Functions are constants because their address is
|
||||||
@ -62,9 +68,9 @@ public:
|
|||||||
/// true for things like constant expressions that could divide by zero.
|
/// true for things like constant expressions that could divide by zero.
|
||||||
bool canTrap() const;
|
bool canTrap() const;
|
||||||
|
|
||||||
/// ContaintsRelocations - Return true if the constant value contains
|
/// ContainsRelocations - Return true if the constant value contains
|
||||||
/// relocations which cannot be resolved at compile time.
|
/// relocations which cannot be resolved at compile time.
|
||||||
bool ContainsRelocations() const;
|
bool ContainsRelocations(unsigned Kind = Reloc::LocalOrGlobal) const;
|
||||||
|
|
||||||
// Specialize get/setOperand for Constants as their operands are always
|
// Specialize get/setOperand for Constants as their operands are always
|
||||||
// constants as well.
|
// constants as well.
|
||||||
|
@ -90,14 +90,29 @@ bool Constant::canTrap() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ContaintsRelocations - Return true if the constant value contains
|
/// ContainsRelocations - Return true if the constant value contains relocations
|
||||||
/// relocations which cannot be resolved at compile time.
|
/// which cannot be resolved at compile time. Kind argument is used to filter
|
||||||
bool Constant::ContainsRelocations() const {
|
/// only 'interesting' sorts of relocations.
|
||||||
if (isa<GlobalValue>(this))
|
bool Constant::ContainsRelocations(unsigned Kind) const {
|
||||||
return true;
|
if (const GlobalValue* GV = dyn_cast<GlobalValue>(this)) {
|
||||||
|
bool isLocal = GV->hasLocalLinkage();
|
||||||
|
if ((Kind & Reloc::Local) && isLocal) {
|
||||||
|
// Global has local linkage and 'local' kind of relocations are
|
||||||
|
// requested
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Kind & Reloc::Global) && !isLocal) {
|
||||||
|
// Global has non-local linkage and 'global' kind of relocations are
|
||||||
|
// requested
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
||||||
if (getOperand(i)->ContainsRelocations())
|
if (getOperand(i)->ContainsRelocations())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user