mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
Do relaxations with FT_Org fragments. Fixes the FIXME:
// FIXME: We should compute this sooner, we don't want to recurse here, and
// we would like to be more functional.
In MCAssembler::ComputeFragmentSize.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
36958599a8
commit
187ce544b2
2 files changed
+34
-19
No files matched your search
@@ -319,10 +319,13 @@ class MCOrgFragment : public MCFragment {
|
|||||||
/// Value - Value to use for filling bytes.
|
/// Value - Value to use for filling bytes.
|
||||||
int8_t Value;
|
int8_t Value;
|
||||||
|
|
||||||
|
/// Size - The current estimate of the size.
|
||||||
|
unsigned Size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
|
MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
|
||||||
: MCFragment(FT_Org, SD),
|
: MCFragment(FT_Org, SD),
|
||||||
Offset(&_Offset), Value(_Value) {}
|
Offset(&_Offset), Value(_Value), Size(0) {}
|
||||||
|
|
||||||
/// @name Accessors
|
/// @name Accessors
|
||||||
/// @{
|
/// @{
|
||||||
@@ -331,6 +334,9 @@ public:
|
|||||||
|
|
||||||
uint8_t getValue() const { return Value; }
|
uint8_t getValue() const { return Value; }
|
||||||
|
|
||||||
|
unsigned getSize() const { return Size; }
|
||||||
|
|
||||||
|
void setSize(unsigned Size_) { Size = Size_; }
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
static bool classof(const MCFragment *F) {
|
static bool classof(const MCFragment *F) {
|
||||||
@@ -715,6 +721,9 @@ private:
|
|||||||
bool RelaxInstruction(const MCObjectWriter &Writer, MCAsmLayout &Layout,
|
bool RelaxInstruction(const MCObjectWriter &Writer, MCAsmLayout &Layout,
|
||||||
MCInstFragment &IF);
|
MCInstFragment &IF);
|
||||||
|
|
||||||
|
bool RelaxOrg(const MCObjectWriter &Writer, MCAsmLayout &Layout,
|
||||||
|
MCOrgFragment &OF);
|
||||||
|
|
||||||
bool RelaxLEB(const MCObjectWriter &Writer, MCAsmLayout &Layout,
|
bool RelaxLEB(const MCObjectWriter &Writer, MCAsmLayout &Layout,
|
||||||
MCLEBFragment &IF);
|
MCLEBFragment &IF);
|
||||||
|
|
||||||
|
|||||||
+24
-18
@@ -337,23 +337,8 @@ uint64_t MCAssembler::ComputeFragmentSize(MCAsmLayout &Layout,
|
|||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MCFragment::FT_Org: {
|
case MCFragment::FT_Org:
|
||||||
const MCOrgFragment &OF = cast<MCOrgFragment>(F);
|
return cast<MCOrgFragment>(F).getSize();
|
||||||
|
|
||||||
// FIXME: We should compute this sooner, we don't want to recurse here, and
|
|
||||||
// we would like to be more functional.
|
|
||||||
int64_t TargetLocation;
|
|
||||||
if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout))
|
|
||||||
report_fatal_error("expected assembly-time absolute expression");
|
|
||||||
|
|
||||||
// FIXME: We need a way to communicate this error.
|
|
||||||
int64_t Offset = TargetLocation - FragmentOffset;
|
|
||||||
if (Offset < 0 || Offset >= 0x40000000)
|
|
||||||
report_fatal_error("invalid .org offset '" + Twine(TargetLocation) +
|
|
||||||
"' (at offset '" + Twine(FragmentOffset) + "')");
|
|
||||||
|
|
||||||
return Offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MCFragment::FT_Dwarf: {
|
case MCFragment::FT_Dwarf: {
|
||||||
const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F);
|
const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F);
|
||||||
@@ -841,6 +826,25 @@ bool MCAssembler::RelaxInstruction(const MCObjectWriter &Writer,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MCAssembler::RelaxOrg(const MCObjectWriter &Writer,
|
||||||
|
MCAsmLayout &Layout,
|
||||||
|
MCOrgFragment &OF) {
|
||||||
|
int64_t TargetLocation;
|
||||||
|
if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout))
|
||||||
|
report_fatal_error("expected assembly-time absolute expression");
|
||||||
|
|
||||||
|
// FIXME: We need a way to communicate this error.
|
||||||
|
uint64_t FragmentOffset = Layout.getFragmentOffset(&OF);
|
||||||
|
int64_t Offset = TargetLocation - FragmentOffset;
|
||||||
|
if (Offset < 0 || Offset >= 0x40000000)
|
||||||
|
report_fatal_error("invalid .org offset '" + Twine(TargetLocation) +
|
||||||
|
"' (at offset '" + Twine(FragmentOffset) + "')");
|
||||||
|
|
||||||
|
unsigned OldSize = OF.getSize();
|
||||||
|
OF.setSize(Offset);
|
||||||
|
return OldSize != OF.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
bool MCAssembler::RelaxLEB(const MCObjectWriter &Writer,
|
bool MCAssembler::RelaxLEB(const MCObjectWriter &Writer,
|
||||||
MCAsmLayout &Layout,
|
MCAsmLayout &Layout,
|
||||||
MCLEBFragment &LF) {
|
MCLEBFragment &LF) {
|
||||||
@@ -857,7 +861,6 @@ bool MCAssembler::RelaxLEB(const MCObjectWriter &Writer,
|
|||||||
return OldSize != LF.getSize();
|
return OldSize != LF.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
|
bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
|
||||||
MCAsmLayout &Layout) {
|
MCAsmLayout &Layout) {
|
||||||
++stats::RelaxationSteps;
|
++stats::RelaxationSteps;
|
||||||
@@ -880,6 +883,9 @@ bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
|
|||||||
WasRelaxed |= RelaxInstruction(Writer, Layout,
|
WasRelaxed |= RelaxInstruction(Writer, Layout,
|
||||||
*cast<MCInstFragment>(it2));
|
*cast<MCInstFragment>(it2));
|
||||||
break;
|
break;
|
||||||
|
case MCFragment::FT_Org:
|
||||||
|
WasRelaxed |= RelaxOrg(Writer, Layout, *cast<MCOrgFragment>(it2));
|
||||||
|
break;
|
||||||
case MCFragment::FT_LEB:
|
case MCFragment::FT_LEB:
|
||||||
WasRelaxed |= RelaxLEB(Writer, Layout, *cast<MCLEBFragment>(it2));
|
WasRelaxed |= RelaxLEB(Writer, Layout, *cast<MCLEBFragment>(it2));
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user