Chromium Code Reviews| Index: src/assembler.cpp |
| diff --git a/src/assembler.cpp b/src/assembler.cpp |
| index 50d82b73ff2cda99e099366c4f89ff10b8c586ae..79387c1d38e8968fbf3287a627bdec8b52c3a1c4 100644 |
| --- a/src/assembler.cpp |
| +++ b/src/assembler.cpp |
| @@ -19,7 +19,9 @@ |
| //===----------------------------------------------------------------------===// |
| #include "assembler.h" |
| +#include "IceGlobalContext.h" |
| #include "IceMemoryRegion.h" |
| +#include "IceOperand.h" |
| namespace Ice { |
| @@ -133,4 +135,39 @@ void AssemblerBuffer::ExtendCapacity() { |
| assert(Size() == old_size); |
| } |
| +void Assembler::emitIASBytes(GlobalContext *Ctx) const { |
| + Ostream &Str = Ctx->getStrEmit(); |
| + intptr_t EndPosition = buffer_.Size(); |
| + intptr_t StartPosition = 0; |
| + const intptr_t FixupSize = 4; |
| + while (StartPosition < EndPosition) { |
| + AssemblerFixup *LastFixup = buffer_.GetLatestFixup(StartPosition); |
|
Jim Stichnoth
2014/11/06 00:02:13
The total work done in all the calls to GetLatestF
jvoung (off chromium)
2014/11/06 00:47:13
Ah right, I wasn't looking at how GetLatestFixup()
|
| + intptr_t LastFixupLoc = LastFixup ? LastFixup->position() : EndPosition; |
| + for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) { |
| + Str << "\t.byte 0x"; |
| + Str.write_hex(buffer_.Load<uint8_t>(i)); |
| + Str << "\n"; |
| + } |
| + if (LastFixup) { |
| + Str << "\t.long "; |
| + const ConstantRelocatable *Reloc = LastFixup->value(); |
| + bool IsPCRel = LastFixup->kind() == FK_PcRel_4; |
| + if (Reloc->getSuppressMangling()) |
| + Str << Reloc->getName(); |
| + else |
| + Str << Ctx->mangleName(Reloc->getName()); |
| + if (Reloc->getOffset()) { |
| + Str << " + " << Reloc->getOffset(); |
| + } |
| + if (IsPCRel) |
| + Str << " - (. + " << FixupSize << ")"; |
| + Str << "\n"; |
| + LastFixupLoc += FixupSize; |
| + assert(LastFixupLoc <= EndPosition); |
| + } |
| + // Continue another round, after the latest fixup. |
| + StartPosition = LastFixupLoc; |
| + } |
| +} |
| + |
| } // end of namespace Ice |