1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

MC: Add MCAssembler::addFixup, which enforces that fixups are added in order.

llvm-svn: 98379
This commit is contained in:
Daniel Dunbar 2010-03-12 21:00:38 +00:00
parent c101ad818c
commit 71473e6b15
2 changed files with 11 additions and 6 deletions

View File

@ -162,6 +162,13 @@ public:
/// @name Fixup Access /// @name Fixup Access
/// @{ /// @{
void addFixup(MCAsmFixup Fixup) {
// Enforce invariant that fixups are in offset order.
assert(Fixups.empty() || Fixup.Offset > Fixups.back().Offset &&
"Fixups must be added in order!");
Fixups.push_back(Fixup);
}
std::vector<MCAsmFixup> &getFixups() { return Fixups; } std::vector<MCAsmFixup> &getFixups() { return Fixups; }
const std::vector<MCAsmFixup> &getFixups() const { return Fixups; } const std::vector<MCAsmFixup> &getFixups() const { return Fixups; }

View File

@ -327,9 +327,8 @@ void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size,
for (unsigned i = 0; i != Size; ++i) for (unsigned i = 0; i != Size; ++i)
DF->getContents().push_back(uint8_t(AbsValue >> (i * 8))); DF->getContents().push_back(uint8_t(AbsValue >> (i * 8)));
} else { } else {
DF->getFixups().push_back(MCAsmFixup(DF->getContents().size(), DF->addFixup(MCAsmFixup(DF->getContents().size(), *AddValueSymbols(Value),
*AddValueSymbols(Value), MCFixup::getKindForSize(Size)));
MCFixup::getKindForSize(Size)));
DF->getContents().resize(DF->getContents().size() + Size, 0); DF->getContents().resize(DF->getContents().size() + Size, 0);
} }
} }
@ -388,9 +387,8 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
DF = new MCDataFragment(CurSectionData); DF = new MCDataFragment(CurSectionData);
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i]; MCFixup &F = Fixups[i];
DF->getFixups().push_back(MCAsmFixup(DF->getContents().size()+F.getOffset(), DF->addFixup(MCAsmFixup(DF->getContents().size()+F.getOffset(),
*F.getValue(), *F.getValue(), F.getKind()));
F.getKind()));
} }
DF->getContents().append(Code.begin(), Code.end()); DF->getContents().append(Code.begin(), Code.end());
} }