1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Remove the MCObjectFormat class.

llvm-svn: 122147
This commit is contained in:
Rafael Espindola 2010-12-18 05:37:28 +00:00
parent 4c1b83e53f
commit 7f9be9e112
13 changed files with 24 additions and 139 deletions

View File

@ -1,54 +0,0 @@
//===-- llvm/MC/MCObjectFormat.h - Object Format Info -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_MC_MCOBJECTFORMAT_H
#define LLVM_MC_MCOBJECTFORMAT_H
namespace llvm {
class MCSymbol;
class MCObjectFormat {
public:
virtual ~MCObjectFormat();
/// isAbsolute - Check if A - B is an absolute value
///
/// \param InSet - True if this expression is in a set. For example:
/// a:
/// ...
/// b:
/// tmp = a - b
/// .long tmp
/// \param A - LHS
/// \param B - RHS
virtual bool isAbsolute(bool InSet, const MCSymbol &A,
const MCSymbol &B) const = 0;
};
class MCELFObjectFormat : public MCObjectFormat {
public:
virtual bool isAbsolute(bool InSet, const MCSymbol &A,
const MCSymbol &B) const;
};
class MCMachOObjectFormat : public MCObjectFormat {
public:
virtual bool isAbsolute(bool InSet, const MCSymbol &A,
const MCSymbol &B) const;
};
class MCCOFFObjectFormat : public MCObjectFormat {
public:
virtual bool isAbsolute(bool InSet, const MCSymbol &A,
const MCSymbol &B) const;
};
} // End llvm namespace
#endif

View File

@ -20,6 +20,7 @@ class MCAsmLayout;
class MCAssembler; class MCAssembler;
class MCFixup; class MCFixup;
class MCFragment; class MCFragment;
class MCSymbol;
class MCSymbolRefExpr; class MCSymbolRefExpr;
class MCValue; class MCValue;
class raw_ostream; class raw_ostream;
@ -98,6 +99,9 @@ public:
bool IsPCRel, bool IsPCRel,
const MCFragment *DF) const = 0; const MCFragment *DF) const = 0;
virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const = 0;
/// Write the object file. /// Write the object file.
/// ///
/// This routine is called by the assembler after layout and relaxation is /// This routine is called by the assembler after layout and relaxation is

View File

@ -18,7 +18,6 @@
namespace llvm { namespace llvm {
class MCFixup; class MCFixup;
class MCInst; class MCInst;
class MCObjectFormat;
class MCObjectWriter; class MCObjectWriter;
class MCSection; class MCSection;
template<typename T> template<typename T>
@ -37,8 +36,6 @@ protected: // Can only create subclasses.
public: public:
virtual ~TargetAsmBackend(); virtual ~TargetAsmBackend();
virtual const MCObjectFormat &getObjectFormat() const = 0;
/// createObjectWriter - Create a new MCObjectWriter instance for use by the /// createObjectWriter - Create a new MCObjectWriter instance for use by the
/// assembler backend to emit the final object file. /// assembler backend to emit the final object file.
virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0; virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;

View File

@ -20,7 +20,6 @@ add_llvm_library(LLVMMC
MCMachObjectTargetWriter.cpp MCMachObjectTargetWriter.cpp
MCNullStreamer.cpp MCNullStreamer.cpp
MCObjectStreamer.cpp MCObjectStreamer.cpp
MCObjectFormat.cpp
MCObjectWriter.cpp MCObjectWriter.cpp
MCPureStreamer.cpp MCPureStreamer.cpp
MCSection.cpp MCSection.cpp

View File

@ -352,6 +352,12 @@ namespace {
return false; 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, virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target, const MCValue Target,
bool IsPCRel, bool IsPCRel,

View File

@ -14,7 +14,6 @@
#include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
@ -388,8 +387,8 @@ static bool EvaluateSymbolicAdd(const MCAssembler *Asm,
if (Asm && A && B) { if (Asm && A && B) {
const MCSymbol &SA = A->getSymbol(); const MCSymbol &SA = A->getSymbol();
const MCSymbol &SB = B->getSymbol(); const MCSymbol &SB = B->getSymbol();
const MCObjectFormat &F = Asm->getBackend().getObjectFormat(); if (SA.isDefined() && SB.isDefined() &&
if (SA.isDefined() && SB.isDefined() && F.isAbsolute(InSet, SA, SB)) { Asm->getWriter().isAbsolute(InSet, SA, SB)) {
MCSymbolData &AD = Asm->getSymbolData(A->getSymbol()); MCSymbolData &AD = Asm->getSymbolData(A->getSymbol());
MCSymbolData &BD = Asm->getSymbolData(B->getSymbol()); MCSymbolData &BD = Asm->getSymbolData(B->getSymbol());

View File

@ -1,34 +0,0 @@
//===- lib/MC/MCObjectFormat.cpp - MCObjectFormat implementation ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCSymbol.h"
using namespace llvm;
MCObjectFormat::~MCObjectFormat() {
}
bool MCELFObjectFormat::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();
}
bool MCMachOObjectFormat::isAbsolute(bool IsSet, const MCSymbol &A,
const MCSymbol &B) const {
// On MachO A - B is absolute only if in a set.
return IsSet;
}
bool MCCOFFObjectFormat::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();
}

View File

@ -1123,6 +1123,12 @@ public:
UndefinedSymbolData); 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, bool IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A, const MCSymbolRefExpr *A,
const MCSymbolRefExpr *B) const { const MCSymbolRefExpr *B) const {

View File

@ -187,6 +187,12 @@ public:
return false; 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, virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target, const MCValue Target,
bool IsPCRel, bool IsPCRel,

View File

@ -16,7 +16,6 @@
#include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
@ -350,17 +349,11 @@ namespace {
// FIXME: This should be in a separate file. // FIXME: This should be in a separate file.
// ELF is an ELF of course... // ELF is an ELF of course...
class ELFARMAsmBackend : public ARMAsmBackend { class ELFARMAsmBackend : public ARMAsmBackend {
MCELFObjectFormat Format;
public: public:
Triple::OSType OSType; Triple::OSType OSType;
ELFARMAsmBackend(const Target &T, Triple::OSType _OSType) ELFARMAsmBackend(const Target &T, Triple::OSType _OSType)
: ARMAsmBackend(T), OSType(_OSType) { } : ARMAsmBackend(T), OSType(_OSType) { }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
uint64_t Value) const; uint64_t Value) const;
@ -389,14 +382,9 @@ void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
// FIXME: This should be in a separate file. // FIXME: This should be in a separate file.
class DarwinARMAsmBackend : public ARMAsmBackend { class DarwinARMAsmBackend : public ARMAsmBackend {
MCMachOObjectFormat Format;
public: public:
DarwinARMAsmBackend(const Target &T) : ARMAsmBackend(T) { } DarwinARMAsmBackend(const Target &T) : ARMAsmBackend(T) { }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
uint64_t Value) const; uint64_t Value) const;

View File

@ -16,7 +16,6 @@
#include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCELFSymbolFlags.h" #include "llvm/MC/MCELFSymbolFlags.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
@ -108,18 +107,11 @@ bool MBlazeAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
namespace { namespace {
class ELFMBlazeAsmBackend : public MBlazeAsmBackend { class ELFMBlazeAsmBackend : public MBlazeAsmBackend {
MCELFObjectFormat Format;
public: public:
Triple::OSType OSType; Triple::OSType OSType;
ELFMBlazeAsmBackend(const Target &T, Triple::OSType _OSType) ELFMBlazeAsmBackend(const Target &T, Triple::OSType _OSType)
: MBlazeAsmBackend(T), OSType(_OSType) { } : MBlazeAsmBackend(T), OSType(_OSType) { }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
uint64_t Value) const; uint64_t Value) const;

View File

@ -12,7 +12,6 @@
#include "PPCFixupKinds.h" #include "PPCFixupKinds.h"
#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/Object/MachOFormat.h" #include "llvm/Object/MachOFormat.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
@ -82,14 +81,9 @@ public:
// FIXME: This should be in a separate file. // FIXME: This should be in a separate file.
namespace { namespace {
class DarwinPPCAsmBackend : public PPCAsmBackend { class DarwinPPCAsmBackend : public PPCAsmBackend {
MCMachOObjectFormat Format;
public: public:
DarwinPPCAsmBackend(const Target &T) : PPCAsmBackend(T) { } DarwinPPCAsmBackend(const Target &T) : PPCAsmBackend(T) { }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
uint64_t Value) const { uint64_t Value) const {
assert(0 && "UNIMP"); assert(0 && "UNIMP");

View File

@ -16,7 +16,6 @@
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectFormat.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionELF.h"
@ -295,8 +294,6 @@ bool X86AsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
namespace { namespace {
class ELFX86AsmBackend : public X86AsmBackend { class ELFX86AsmBackend : public X86AsmBackend {
MCELFObjectFormat Format;
public: public:
Triple::OSType OSType; Triple::OSType OSType;
ELFX86AsmBackend(const Target &T, Triple::OSType _OSType) ELFX86AsmBackend(const Target &T, Triple::OSType _OSType)
@ -304,10 +301,6 @@ public:
HasReliableSymbolDifference = true; HasReliableSymbolDifference = true;
} }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
virtual bool doesSectionRequireSymbols(const MCSection &Section) const { virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
const MCSectionELF &ES = static_cast<const MCSectionELF&>(Section); const MCSectionELF &ES = static_cast<const MCSectionELF&>(Section);
return ES.getFlags() & MCSectionELF::SHF_MERGE; return ES.getFlags() & MCSectionELF::SHF_MERGE;
@ -340,7 +333,6 @@ public:
class WindowsX86AsmBackend : public X86AsmBackend { class WindowsX86AsmBackend : public X86AsmBackend {
bool Is64Bit; bool Is64Bit;
MCCOFFObjectFormat Format;
public: public:
WindowsX86AsmBackend(const Target &T, bool is64Bit) WindowsX86AsmBackend(const Target &T, bool is64Bit)
@ -348,25 +340,15 @@ public:
, Is64Bit(is64Bit) { , Is64Bit(is64Bit) {
} }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const { MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createWinCOFFObjectWriter(OS, Is64Bit); return createWinCOFFObjectWriter(OS, Is64Bit);
} }
}; };
class DarwinX86AsmBackend : public X86AsmBackend { class DarwinX86AsmBackend : public X86AsmBackend {
MCMachOObjectFormat Format;
public: public:
DarwinX86AsmBackend(const Target &T) DarwinX86AsmBackend(const Target &T)
: X86AsmBackend(T) { } : X86AsmBackend(T) { }
virtual const MCObjectFormat &getObjectFormat() const {
return Format;
}
}; };
class DarwinX86_32AsmBackend : public DarwinX86AsmBackend { class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {