[llvm-branch-commits] [llvm-branch] r104766 - in /llvm/branches/Apple/whitney: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MachObjectWriter.cpp lib/Target/X86/X86AsmBackend.cpp
Daniel Dunbar
daniel at zuster.org
Wed May 26 15:28:54 PDT 2010
Author: ddunbar
Date: Wed May 26 17:28:53 2010
New Revision: 104766
URL: http://llvm.org/viewvc/llvm-project?rev=104766&view=rev
Log:
MC: Use accessors for access to MCAsmFixup.
Modified:
llvm/branches/Apple/whitney/include/llvm/MC/MCAssembler.h
llvm/branches/Apple/whitney/lib/MC/MCAssembler.cpp
llvm/branches/Apple/whitney/lib/MC/MCMachOStreamer.cpp
llvm/branches/Apple/whitney/lib/MC/MachObjectWriter.cpp
llvm/branches/Apple/whitney/lib/Target/X86/X86AsmBackend.cpp
Modified: llvm/branches/Apple/whitney/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/include/llvm/MC/MCAssembler.h?rev=104766&r1=104765&r2=104766&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/include/llvm/MC/MCAssembler.h (original)
+++ llvm/branches/Apple/whitney/include/llvm/MC/MCAssembler.h Wed May 26 17:28:53 2010
@@ -42,7 +42,6 @@
//
// FIXME: This should probably just be merged with MCFixup.
class MCAsmFixup {
-public:
/// Offset - The offset inside the fragment which needs to be rewritten.
uint64_t Offset;
@@ -55,6 +54,13 @@
public:
MCAsmFixup(uint64_t _Offset, const MCExpr &_Value, MCFixupKind _Kind)
: Offset(_Offset), Value(&_Value), Kind(_Kind) {}
+
+ MCFixupKind getKind() const { return MCFixupKind(Kind); }
+
+ uint64_t getOffset() const { return Offset; }
+ void setOffset(uint64_t Value) { Offset = Value; }
+
+ const MCExpr *getValue() const { return Value; }
};
class MCFragment : public ilist_node<MCFragment> {
@@ -150,7 +156,7 @@
void addFixup(MCAsmFixup Fixup) {
// Enforce invariant that fixups are in offset order.
- assert((Fixups.empty() || Fixup.Offset > Fixups.back().Offset) &&
+ assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
"Fixups must be added in order!");
Fixups.push_back(Fixup);
}
Modified: llvm/branches/Apple/whitney/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/MC/MCAssembler.cpp?rev=104766&r1=104765&r2=104766&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/MC/MCAssembler.cpp (original)
+++ llvm/branches/Apple/whitney/lib/MC/MCAssembler.cpp Wed May 26 17:28:53 2010
@@ -347,7 +347,7 @@
MCValue &Target, uint64_t &Value) const {
++stats::EvaluateFixup;
- if (!Fixup.Value->EvaluateAsRelocatable(Target, &Layout))
+ if (!Fixup.getValue()->EvaluateAsRelocatable(Target, &Layout))
report_fatal_error("expected relocatable expression");
// FIXME: How do non-scattered symbols work in ELF? I presume the linker
@@ -356,8 +356,8 @@
Value = Target.getConstant();
- bool IsPCRel =
- Emitter.getFixupKindInfo(Fixup.Kind).Flags & MCFixupKindInfo::FKF_IsPCRel;
+ bool IsPCRel = Emitter.getFixupKindInfo(
+ Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel;
bool IsResolved = true;
if (const MCSymbolRefExpr *A = Target.getSymA()) {
if (A->getSymbol().isDefined())
@@ -399,7 +399,7 @@
}
if (IsPCRel)
- Value -= Layout.getFragmentAddress(DF) + Fixup.Offset;
+ Value -= Layout.getFragmentAddress(DF) + Fixup.getOffset();
return IsResolved;
}
@@ -905,8 +905,9 @@
namespace llvm {
raw_ostream &operator<<(raw_ostream &OS, const MCAsmFixup &AF) {
- OS << "<MCAsmFixup" << " Offset:" << AF.Offset << " Value:" << *AF.Value
- << " Kind:" << AF.Kind << ">";
+ OS << "<MCAsmFixup" << " Offset:" << AF.getOffset()
+ << " Value:" << *AF.getValue()
+ << " Kind:" << AF.getKind() << ">";
return OS;
}
Modified: llvm/branches/Apple/whitney/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/MC/MCMachOStreamer.cpp?rev=104766&r1=104765&r2=104766&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/branches/Apple/whitney/lib/MC/MCMachOStreamer.cpp Wed May 26 17:28:53 2010
@@ -470,7 +470,7 @@
// Add the fixups and data.
MCDataFragment *DF = getOrCreateDataFragment();
for (unsigned i = 0, e = AsmFixups.size(); i != e; ++i) {
- AsmFixups[i].Offset += DF->getContents().size();
+ AsmFixups[i].setOffset(AsmFixups[i].getOffset() + DF->getContents().size());
DF->addFixup(AsmFixups[i]);
}
DF->getContents().append(Code.begin(), Code.end());
Modified: llvm/branches/Apple/whitney/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/MC/MachObjectWriter.cpp?rev=104766&r1=104765&r2=104766&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/branches/Apple/whitney/lib/MC/MachObjectWriter.cpp Wed May 26 17:28:53 2010
@@ -472,13 +472,15 @@
const MCFragment *Fragment,
const MCAsmFixup &Fixup, MCValue Target,
uint64_t &FixedValue) {
- unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
- unsigned IsRIPRel = isFixupKindRIPRel(Fixup.Kind);
- unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
+ unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind());
+ unsigned IsRIPRel = isFixupKindRIPRel(Fixup.getKind());
+ unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
// See <reloc.h>.
- uint32_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.Offset;
- uint32_t FixupAddress = Layout.getFragmentAddress(Fragment) + Fixup.Offset;
+ uint32_t FixupOffset =
+ Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
+ uint32_t FixupAddress =
+ Layout.getFragmentAddress(Fragment) + Fixup.getOffset();
int64_t Value = 0;
unsigned Index = 0;
unsigned IsExtern = 0;
@@ -604,7 +606,7 @@
// x86_64 distinguishes movq foo at GOTPCREL so that the linker can
// rewrite the movq to an leaq at link time if the symbol ends up in
// the same linkage unit.
- if (unsigned(Fixup.Kind) == X86::reloc_riprel_4byte_movq_load)
+ if (unsigned(Fixup.getKind()) == X86::reloc_riprel_4byte_movq_load)
Type = RIT_X86_64_GOTLoad;
else
Type = RIT_X86_64_GOT;
@@ -676,9 +678,9 @@
const MCFragment *Fragment,
const MCAsmFixup &Fixup, MCValue Target,
uint64_t &FixedValue) {
- uint32_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.Offset;
- unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
- unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
+ uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
+ unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind());
+ unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
unsigned Type = RIT_Vanilla;
// See <reloc.h>.
@@ -738,8 +740,8 @@
return;
}
- unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
- unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
+ unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind());
+ unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
// If this is a difference or a defined symbol plus an offset, then we need
// a scattered relocation entry.
@@ -763,7 +765,7 @@
Target, FixedValue);
// See <reloc.h>.
- uint32_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.Offset;
+ uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
uint32_t Value = 0;
unsigned Index = 0;
unsigned IsExtern = 0;
Modified: llvm/branches/Apple/whitney/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/Target/X86/X86AsmBackend.cpp?rev=104766&r1=104765&r2=104766&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/branches/Apple/whitney/lib/Target/X86/X86AsmBackend.cpp Wed May 26 17:28:53 2010
@@ -46,12 +46,12 @@
void ApplyFixup(const MCAsmFixup &Fixup, MCDataFragment &DF,
uint64_t Value) const {
- unsigned Size = 1 << getFixupKindLog2Size(Fixup.Kind);
+ unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind());
- assert(Fixup.Offset + Size <= DF.getContents().size() &&
+ assert(Fixup.getOffset() + Size <= DF.getContents().size() &&
"Invalid fixup offset!");
for (unsigned i = 0; i != Size; ++i)
- DF.getContents()[Fixup.Offset + i] = uint8_t(Value >> (i * 8));
+ DF.getContents()[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8));
}
bool MayNeedRelaxation(const MCInst &Inst,
@@ -91,6 +91,8 @@
bool X86AsmBackend::MayNeedRelaxation(const MCInst &Inst,
const SmallVectorImpl<MCAsmFixup> &Fixups) const {
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
+ const MCAsmFixup &F = Fixups[i];
+
// We don't support relaxing anything else currently. Make sure we error out
// if we see a non-constant 1 or 2 byte fixup.
//
@@ -98,13 +100,13 @@
// object writer which should be verifying that any final relocations match
// the expected fixup. However, that code is more complicated and hasn't
// been written yet. See the FIXMEs in MachObjectWriter.cpp.
- if ((Fixups[i].Kind == FK_Data_1 || Fixups[i].Kind == FK_Data_2) &&
- !isa<MCConstantExpr>(Fixups[i].Value))
+ if ((F.getKind() == FK_Data_1 || F.getKind() == FK_Data_2) &&
+ !isa<MCConstantExpr>(F.getValue()))
report_fatal_error("unexpected small fixup with a non-constant operand!");
// Check for a 1byte pcrel fixup, and enforce that we would know how to
// relax this instruction.
- if (unsigned(Fixups[i].Kind) == X86::reloc_pcrel_1byte) {
+ if (unsigned(F.getKind()) == X86::reloc_pcrel_1byte) {
assert(getRelaxedOpcode(Inst.getOpcode()) != Inst.getOpcode());
return true;
}
More information about the llvm-branch-commits
mailing list