mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Make EmitIntValue more efficient and more like what we do for leb128. The
difference is much smaller (about 0.3s) but significant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120787 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6cfab3748c
commit
2df042cb32
@ -246,7 +246,8 @@ namespace llvm {
|
|||||||
|
|
||||||
/// EmitIntValue - Special case of EmitValue that avoids the client having
|
/// EmitIntValue - Special case of EmitValue that avoids the client having
|
||||||
/// to pass in a MCExpr for constant integers.
|
/// to pass in a MCExpr for constant integers.
|
||||||
void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0);
|
virtual void EmitIntValue(uint64_t Value, unsigned Size,
|
||||||
|
unsigned AddrSpace = 0);
|
||||||
|
|
||||||
|
|
||||||
virtual void EmitULEB128Value(const MCExpr *Value,
|
virtual void EmitULEB128Value(const MCExpr *Value,
|
||||||
|
@ -152,6 +152,8 @@ public:
|
|||||||
|
|
||||||
virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace,
|
virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace,
|
||||||
bool UseSet = false);
|
bool UseSet = false);
|
||||||
|
virtual void EmitIntValue(uint64_t Value, unsigned Size,
|
||||||
|
unsigned AddrSpace = 0);
|
||||||
|
|
||||||
virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
|
virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
|
||||||
|
|
||||||
@ -504,6 +506,11 @@ void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
|
|||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size,
|
||||||
|
unsigned AddrSpace) {
|
||||||
|
EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace);
|
||||||
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size,
|
void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size,
|
||||||
unsigned AddrSpace, bool UseSet) {
|
unsigned AddrSpace, bool UseSet) {
|
||||||
assert(CurSection && "Cannot emit contents before setting section!");
|
assert(CurSection && "Cannot emit contents before setting section!");
|
||||||
|
@ -83,16 +83,14 @@ void MCObjectStreamer::EmitValue(const MCExpr *Value, unsigned Size,
|
|||||||
|
|
||||||
// Avoid fixups when possible.
|
// Avoid fixups when possible.
|
||||||
int64_t AbsValue;
|
int64_t AbsValue;
|
||||||
if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue)) {
|
if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, &getAssembler())) {
|
||||||
// FIXME: Endianness assumption.
|
EmitIntValue(AbsValue, Size, AddrSpace);
|
||||||
for (unsigned i = 0; i != Size; ++i)
|
return;
|
||||||
DF->getContents().push_back(uint8_t(AbsValue >> (i * 8)));
|
}
|
||||||
} else {
|
|
||||||
DF->addFixup(MCFixup::Create(DF->getContents().size(),
|
DF->addFixup(MCFixup::Create(DF->getContents().size(),
|
||||||
AddValueSymbols(Value),
|
AddValueSymbols(Value),
|
||||||
MCFixup::getKindForSize(Size, false)));
|
MCFixup::getKindForSize(Size, false)));
|
||||||
DF->getContents().resize(DF->getContents().size() + Size, 0);
|
DF->getContents().resize(DF->getContents().size() + Size, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
|
void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||||
|
@ -46,7 +46,12 @@ void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta,
|
|||||||
/// pass in a MCExpr for constant integers.
|
/// pass in a MCExpr for constant integers.
|
||||||
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
|
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
|
||||||
unsigned AddrSpace) {
|
unsigned AddrSpace) {
|
||||||
EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace);
|
assert(Size <= 8);
|
||||||
|
char buf[8];
|
||||||
|
// FIXME: Endianness assumption.
|
||||||
|
for (unsigned i = 0; i != Size; ++i)
|
||||||
|
buf[i] = uint8_t(Value >> (i * 8));
|
||||||
|
EmitBytes(StringRef(buf, Size), AddrSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
|
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
|
||||||
|
Loading…
Reference in New Issue
Block a user