[llvm-commits] [llvm] r122148 - in /llvm/trunk: include/llvm/MC/MCObjectWriter.h lib/MC/ELFObjectWriter.cpp lib/MC/MCExpr.cpp lib/MC/MCObjectWriter.cpp lib/MC/MachObjectWriter.cpp lib/MC/WinCOFFObjectWriter.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri Dec 17 22:27:54 PST 2010
Author: rafael
Date: Sat Dec 18 00:27:54 2010
New Revision: 122148
URL: http://llvm.org/viewvc/llvm-project?rev=122148&view=rev
Log:
Merge isAbsolute into IsSymbolRefDifferenceFullyResolved.
Modified:
llvm/trunk/include/llvm/MC/MCObjectWriter.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/MC/MCObjectWriter.cpp
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectWriter.h?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectWriter.h Sat Dec 18 00:27:54 2010
@@ -87,7 +87,8 @@
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 @@
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
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sat Dec 18 00:27:54 2010
@@ -344,20 +344,6 @@
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,
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Sat Dec 18 00:27:54 2010
@@ -300,7 +300,7 @@
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 @@
"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());
Modified: llvm/trunk/lib/MC/MCObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectWriter.cpp?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectWriter.cpp Sat Dec 18 00:27:54 2010
@@ -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 @@
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();
+}
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Sat Dec 18 00:27:54 2010
@@ -1123,15 +1123,13 @@
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;
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=122148&r1=122147&r2=122148&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Sat Dec 18 00:27:54 2010
@@ -179,20 +179,6 @@
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,
More information about the llvm-commits
mailing list