mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
MC: Tweak MCInstFragment to include the encoded data and fixups, so that we don't need to recompute them during relaxation. I will revisit this once all the other pieces of fast relaxation are in place.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1ccd91a5b1
commit
9799de910e
@ -180,28 +180,57 @@ public:
|
|||||||
virtual void dump();
|
virtual void dump();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
|
||||||
|
// it is almost entirely a duplicate of MCDataFragment. If we decide to stick
|
||||||
|
// with this approach (as opposed to making MCInstFragment a very light weight
|
||||||
|
// object with just the MCInst and a code size, then we should just change
|
||||||
|
// MCDataFragment to have an optional MCInst at its end.
|
||||||
class MCInstFragment : public MCFragment {
|
class MCInstFragment : public MCFragment {
|
||||||
/// Inst - The instruction this is a fragment for.
|
/// Inst - The instruction this is a fragment for.
|
||||||
MCInst Inst;
|
MCInst Inst;
|
||||||
|
|
||||||
/// InstSize - The size of the currently encoded instruction.
|
/// InstSize - The size of the currently encoded instruction.
|
||||||
unsigned InstSize;
|
SmallString<8> Code;
|
||||||
|
|
||||||
|
/// Fixups - The list of fixups in this fragment.
|
||||||
|
SmallVector<MCAsmFixup, 1> Fixups;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCInstFragment(MCInst _Inst, unsigned _InstSize, MCSectionData *SD = 0)
|
typedef SmallVectorImpl<MCAsmFixup>::const_iterator const_fixup_iterator;
|
||||||
: MCFragment(FT_Inst, SD), Inst(_Inst), InstSize(_InstSize) {}
|
typedef SmallVectorImpl<MCAsmFixup>::iterator fixup_iterator;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MCInstFragment(MCInst _Inst, MCSectionData *SD = 0)
|
||||||
|
: MCFragment(FT_Inst, SD), Inst(_Inst) {
|
||||||
|
}
|
||||||
|
|
||||||
/// @name Accessors
|
/// @name Accessors
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
unsigned getInstSize() const { return InstSize; }
|
SmallVectorImpl<char> &getCode() { return Code; }
|
||||||
|
const SmallVectorImpl<char> &getCode() const { return Code; }
|
||||||
|
|
||||||
|
unsigned getInstSize() const { return Code.size(); }
|
||||||
|
|
||||||
|
MCInst &getInst() { return Inst; }
|
||||||
const MCInst &getInst() const { return Inst; }
|
const MCInst &getInst() const { return Inst; }
|
||||||
|
|
||||||
void setInst(MCInst Inst, unsigned InstSize) {
|
void setInst(MCInst Value) { Inst = Value; }
|
||||||
this->Inst = Inst;
|
|
||||||
this->InstSize = InstSize;
|
/// @}
|
||||||
}
|
/// @name Fixup Access
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
SmallVectorImpl<MCAsmFixup> &getFixups() { return Fixups; }
|
||||||
|
const SmallVectorImpl<MCAsmFixup> &getFixups() const { return Fixups; }
|
||||||
|
|
||||||
|
fixup_iterator fixup_begin() { return Fixups.begin(); }
|
||||||
|
const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
|
||||||
|
|
||||||
|
fixup_iterator fixup_end() {return Fixups.end();}
|
||||||
|
const_fixup_iterator fixup_end() const {return Fixups.end();}
|
||||||
|
|
||||||
|
size_t fixup_size() const { return Fixups.size(); }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
@ -773,22 +773,14 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) {
|
|||||||
SD.getFragmentList().insert(it2, DF);
|
SD.getFragmentList().insert(it2, DF);
|
||||||
|
|
||||||
// Update the data fragments layout data.
|
// Update the data fragments layout data.
|
||||||
|
DF->setParent(IF->getParent());
|
||||||
DF->setOffset(IF->getOffset());
|
DF->setOffset(IF->getOffset());
|
||||||
DF->setFileSize(IF->getInstSize());
|
DF->setFileSize(IF->getInstSize());
|
||||||
|
|
||||||
// Encode the final instruction.
|
// Copy in the data and the fixups.
|
||||||
SmallVector<MCFixup, 4> Fixups;
|
DF->getContents().append(IF->getCode().begin(), IF->getCode().end());
|
||||||
raw_svector_ostream VecOS(DF->getContents());
|
for (unsigned i = 0, e = IF->getFixups().size(); i != e; ++i)
|
||||||
getEmitter().EncodeInstruction(IF->getInst(), VecOS, Fixups);
|
DF->getFixups().push_back(IF->getFixups()[i]);
|
||||||
|
|
||||||
// Copy over the fixups.
|
|
||||||
//
|
|
||||||
// FIXME-PERF: Encode fixups directly into the data fragment as well.
|
|
||||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
|
|
||||||
MCFixup &F = Fixups[i];
|
|
||||||
DF->addFixup(MCAsmFixup(DF->getContents().size()+F.getOffset(),
|
|
||||||
*F.getValue(), F.getKind()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the instruction fragment and update the iterator.
|
// Delete the instruction fragment and update the iterator.
|
||||||
SD.getFragmentList().erase(IF);
|
SD.getFragmentList().erase(IF);
|
||||||
|
Loading…
Reference in New Issue
Block a user