Move some ARM specific MCAssmebler bits into the ARMAsmBackend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach
2012-01-18 00:23:57 +00:00
parent 31867660cb
commit 9b5b125c34
3 changed files with 27 additions and 9 deletions

View File

@@ -17,12 +17,15 @@
namespace llvm { namespace llvm {
class MCAsmLayout; class MCAsmLayout;
class MCAssembler;
class MCELFObjectTargetWriter; class MCELFObjectTargetWriter;
class MCFixup; class MCFixup;
class MCFragment;
class MCInst; class MCInst;
class MCInstFragment; class MCInstFragment;
class MCObjectWriter; class MCObjectWriter;
class MCSection; class MCSection;
class MCValue;
template<typename T> template<typename T>
class SmallVectorImpl; class SmallVectorImpl;
class raw_ostream; class raw_ostream;
@@ -87,6 +90,13 @@ public:
/// getFixupKindInfo - Get information on a fixup kind. /// getFixupKindInfo - Get information on a fixup kind.
virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const; virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
/// processFixupValue - Target hook to adjust the literal value of a fixup
/// if necessary. The default does nothing.
virtual void processFixupValue(const MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFixup &Fixup, const MCFragment *DF,
MCValue &Target, uint64_t &Value) {}
/// @} /// @}
/// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided

View File

@@ -273,13 +273,10 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
Value = Target.getConstant(); Value = Target.getConstant();
bool IsThumb = false;
if (const MCSymbolRefExpr *A = Target.getSymA()) { if (const MCSymbolRefExpr *A = Target.getSymA()) {
const MCSymbol &Sym = A->getSymbol().AliasedSymbol(); const MCSymbol &Sym = A->getSymbol().AliasedSymbol();
if (Sym.isDefined()) if (Sym.isDefined())
Value += Layout.getSymbolOffset(&getSymbolData(Sym)); Value += Layout.getSymbolOffset(&getSymbolData(Sym));
if (isThumbFunc(&Sym))
IsThumb = true;
} }
if (const MCSymbolRefExpr *B = Target.getSymB()) { if (const MCSymbolRefExpr *B = Target.getSymB()) {
const MCSymbol &Sym = B->getSymbol().AliasedSymbol(); const MCSymbol &Sym = B->getSymbol().AliasedSymbol();
@@ -302,12 +299,8 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
Value -= Offset; Value -= Offset;
} }
// ARM fixups based from a thumb function address need to have the low // Let the backend adjust the fixup value if necessary.
// bit set. The actual value is always at least 16-bit aligned, so the Backend.processFixupValue(*this, Layout, Fixup, DF, Target, Value);
// low bit is normally clear and available for use as an ISA flag for
// interworking.
if (IsThumb)
Value |= 1;
return IsResolved; return IsResolved;
} }

View File

@@ -22,6 +22,7 @@
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Object/MachOFormat.h" #include "llvm/Object/MachOFormat.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@@ -101,6 +102,20 @@ public:
return Infos[Kind - FirstTargetFixupKind]; return Infos[Kind - FirstTargetFixupKind];
} }
/// processFixupValue - Target hook to process the literal value of a fixup
/// if necessary.
void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFixup &Fixup, const MCFragment *DF,
MCValue &Target, uint64_t &Value) {
// Some fixups to thumb function symbols need the low bit (thumb bit)
// twiddled.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
const MCSymbol &Sym = A->getSymbol().AliasedSymbol();
if (Asm.isThumbFunc(&Sym))
Value |= 1;
}
}
bool MayNeedRelaxation(const MCInst &Inst) const; bool MayNeedRelaxation(const MCInst &Inst) const;
bool fixupNeedsRelaxation(const MCFixup &Fixup, bool fixupNeedsRelaxation(const MCFixup &Fixup,