Merge isAbsolute into IsSymbolRefDifferenceFullyResolved.

llvm-svn: 122148
This commit is contained in:
Rafael Espindola 2010-12-18 06:27:54 +00:00
parent 7f9be9e112
commit df98fb74f6
6 changed files with 32 additions and 44 deletions

View File

@ -87,7 +87,8 @@ public:
virtual bool
IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B) const = 0;
const MCSymbolRefExpr *B,
bool InSet) const;
/// Check if a fixup is fully resolved.
///
@ -99,9 +100,6 @@ public:
bool IsPCRel,
const MCFragment *DF) const = 0;
virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const = 0;
/// Write the object file.
///
/// This routine is called by the assembler after layout and relaxation is

View File

@ -344,20 +344,6 @@ namespace {
MCDataFragment *F,
const MCSectionData *SD);
virtual bool
IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B) const {
// FIXME: Implement this!
return false;
}
virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const {
// On ELF A - B is absolute if A and B are in the same section.
return &A.getSection() == &B.getSection();
}
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target,
bool IsPCRel,

View File

@ -300,7 +300,7 @@ static void AttemptToFoldSymbolOffsetDifference(const MCAsmLayout *Layout,
const MCAssembler &Asm = Layout->getAssembler();
if (A && B &&
Asm.getWriter().IsSymbolRefDifferenceFullyResolved(Asm, A, B)) {
Asm.getWriter().IsSymbolRefDifferenceFullyResolved(Asm, A, B, false)) {
// Eagerly evaluate.
Addend += (Layout->getSymbolOffset(&Asm.getSymbolData(A->getSymbol())) -
Layout->getSymbolOffset(&Asm.getSymbolData(B->getSymbol())));
@ -385,10 +385,9 @@ static bool EvaluateSymbolicAdd(const MCAssembler *Asm,
"Must have an assembler object if layout is given!");
if (Asm && A && B) {
const MCSymbol &SA = A->getSymbol();
const MCSymbol &SB = B->getSymbol();
if (SA.isDefined() && SB.isDefined() &&
Asm->getWriter().isAbsolute(InSet, SA, SB)) {
if (A->getSymbol().isDefined() && B->getSymbol().isDefined() &&
Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B,
InSet)) {
MCSymbolData &AD = Asm->getSymbolData(A->getSymbol());
MCSymbolData &BD = Asm->getSymbolData(B->getSymbol());

View File

@ -7,7 +7,9 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSymbol.h"
using namespace llvm;
@ -39,3 +41,22 @@ void MCObjectWriter::EncodeULEB128(uint64_t Value, raw_ostream &OS) {
OS << char(Byte);
} while (Value != 0);
}
bool
MCObjectWriter::IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B,
bool InSet) const {
// Modified symbol references cannot be resolved.
if (A->getKind() != MCSymbolRefExpr::VK_None ||
B->getKind() != MCSymbolRefExpr::VK_None)
return false;
const MCSymbol &SA = A->getSymbol();
const MCSymbol &SB = B->getSymbol();
if (SA.isUndefined() || SB.isUndefined())
return false;
// On ELF and COFF A - B is absolute if A and B are in the same section.
return &SA.getSection() == &SB.getSection();
}

View File

@ -1123,15 +1123,13 @@ public:
UndefinedSymbolData);
}
bool isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const {
// On MachO A - B is absolute only if in a set.
return IsSet;
}
bool IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B) const {
const MCSymbolRefExpr *B,
bool InSet) const {
if (InSet)
return true;
if (!TargetObjectWriter->useAggressiveSymbolFolding())
return false;

View File

@ -179,20 +179,6 @@ public:
MCValue Target,
uint64_t &FixedValue);
virtual bool
IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B) const {
// FIXME: Implement this!
return false;
}
virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const {
// On COFF A - B is absolute if A and B are in the same section.
return &A.getSection() == &B.getSection();
}
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target,
bool IsPCRel,