mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 07:09:08 +00:00
Move all of the MCSymbol COFF flags logic in to MCSymbolCOFF.
All flags setting/getting is now done in the class with helper methods instead of users having to get the bits in the correct order. Reviewed by Rafael Espíndola. llvm-svn: 239314
This commit is contained in:
parent
ad147e1d08
commit
97458cd6bb
@ -10,7 +10,6 @@
|
||||
#define LLVM_MC_MCSYMBOLCOFF_H
|
||||
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/COFF.h"
|
||||
|
||||
namespace llvm {
|
||||
class MCSymbolCOFF : public MCSymbol {
|
||||
@ -18,6 +17,14 @@ class MCSymbolCOFF : public MCSymbol {
|
||||
/// This corresponds to the e_type field of the COFF symbol.
|
||||
mutable uint16_t Type;
|
||||
|
||||
enum SymbolFlags : uint16_t {
|
||||
SF_ClassMask = 0x00FF,
|
||||
SF_ClassShift = 0,
|
||||
|
||||
SF_WeakExternal = 0x0100,
|
||||
SF_SafeSEH = 0x0200,
|
||||
};
|
||||
|
||||
public:
|
||||
MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
|
||||
: MCSymbol(SymbolKindCOFF, Name, isTemporary), Type(0) {}
|
||||
@ -29,6 +36,27 @@ public:
|
||||
Type = Ty;
|
||||
}
|
||||
|
||||
uint16_t getClass() const {
|
||||
return (getFlags() & SF_ClassMask) >> SF_ClassShift;
|
||||
}
|
||||
void setClass(uint16_t StorageClass) const {
|
||||
modifyFlags(StorageClass << SF_ClassShift, SF_ClassMask);
|
||||
}
|
||||
|
||||
bool isWeakExternal() const {
|
||||
return getFlags() & SF_WeakExternal;
|
||||
}
|
||||
void setIsWeakExternal() const {
|
||||
modifyFlags(SF_WeakExternal, SF_WeakExternal);
|
||||
}
|
||||
|
||||
bool isSafeSEH() const {
|
||||
return getFlags() & SF_SafeSEH;
|
||||
}
|
||||
void setIsSafeSEH() const {
|
||||
modifyFlags(SF_SafeSEH, SF_SafeSEH);
|
||||
}
|
||||
|
||||
static bool classof(const MCSymbol *S) { return S->isCOFF(); }
|
||||
};
|
||||
}
|
||||
|
@ -155,14 +155,6 @@ namespace COFF {
|
||||
uint8_t NumberOfAuxSymbols;
|
||||
};
|
||||
|
||||
enum SymbolFlags : uint16_t {
|
||||
SF_ClassMask = 0x00FF,
|
||||
SF_ClassShift = 0,
|
||||
|
||||
SF_WeakExternal = 0x0100,
|
||||
SF_SafeSEH = 0x0200,
|
||||
};
|
||||
|
||||
enum SymbolSectionNumber : int32_t {
|
||||
IMAGE_SYM_DEBUG = -2,
|
||||
IMAGE_SYM_ABSOLUTE = -1,
|
||||
|
@ -228,7 +228,7 @@ bool COFFSymbol::should_keep() const {
|
||||
}
|
||||
|
||||
// if this is a safeseh handler, keep it
|
||||
if (MC && (MC->getFlags() & COFF::SF_SafeSEH))
|
||||
if (MC && (cast<MCSymbolCOFF>(MC)->isSafeSEH()))
|
||||
return true;
|
||||
|
||||
// if the section its in is being droped, drop it
|
||||
@ -394,7 +394,7 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
COFFSymbol *coff_symbol = GetOrCreateCOFFSymbol(&Symbol);
|
||||
SymbolMap[&Symbol] = coff_symbol;
|
||||
|
||||
if (Symbol.getFlags() & COFF::SF_WeakExternal) {
|
||||
if (cast<MCSymbolCOFF>(Symbol).isWeakExternal()) {
|
||||
coff_symbol->Data.StorageClass = COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
|
||||
|
||||
if (Symbol.isVariable()) {
|
||||
@ -430,8 +430,7 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
|
||||
const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(Symbol);
|
||||
coff_symbol->Data.Type = SymbolCOFF.getType();
|
||||
coff_symbol->Data.StorageClass =
|
||||
(Symbol.getFlags() & COFF::SF_ClassMask) >> COFF::SF_ClassShift;
|
||||
coff_symbol->Data.StorageClass = SymbolCOFF.getClass();
|
||||
|
||||
// If no storage class was specified in the streamer, define it here.
|
||||
if (coff_symbol->Data.StorageClass == COFF::IMAGE_SYM_CLASS_NULL) {
|
||||
|
@ -102,7 +102,7 @@ bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||
default: return false;
|
||||
case MCSA_WeakReference:
|
||||
case MCSA_Weak:
|
||||
Symbol->modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
|
||||
cast<MCSymbolCOFF>(Symbol)->setIsWeakExternal();
|
||||
Symbol->setExternal(true);
|
||||
break;
|
||||
case MCSA_Global:
|
||||
@ -137,8 +137,7 @@ void MCWinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
|
||||
"' out of range");
|
||||
|
||||
getAssembler().registerSymbol(*CurSymbol);
|
||||
CurSymbol->modifyFlags(StorageClass << COFF::SF_ClassShift,
|
||||
COFF::SF_ClassMask);
|
||||
cast<MCSymbolCOFF>(CurSymbol)->setClass((uint16_t)StorageClass);
|
||||
}
|
||||
|
||||
void MCWinCOFFStreamer::EmitCOFFSymbolType(int Type) {
|
||||
@ -165,7 +164,7 @@ void MCWinCOFFStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
|
||||
Triple::x86)
|
||||
return;
|
||||
|
||||
if (Symbol->getFlags() & COFF::SF_SafeSEH)
|
||||
if (cast<MCSymbolCOFF>(Symbol)->isSafeSEH())
|
||||
return;
|
||||
|
||||
MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
|
||||
@ -176,7 +175,7 @@ void MCWinCOFFStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
|
||||
new MCSafeSEHFragment(Symbol, SXData);
|
||||
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
Symbol->modifyFlags(COFF::SF_SafeSEH, COFF::SF_SafeSEH);
|
||||
cast<MCSymbolCOFF>(Symbol)->setIsSafeSEH();
|
||||
}
|
||||
|
||||
void MCWinCOFFStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
||||
|
Loading…
Reference in New Issue
Block a user