Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: src/IceInstX8632.cpp

Issue 693393002: Subzero: Support multiple fixups in one instruction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add the original test source in a comment Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstX8632.cpp
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 081658f3fa55e711c2fd7165c105b2b7a9af1b19..f5e4550794234e5c1285b76142c543c8629155c4 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -349,13 +349,8 @@ void emitIASBytes(const Cfg *Func, const x86::AssemblerX86 *Asm,
GlobalContext *Ctx = Func->getContext();
Ostream &Str = Ctx->getStrEmit();
intptr_t EndPosition = Asm->GetPosition();
- intptr_t LastFixupLoc = -1;
- AssemblerFixup *LastFixup = NULL;
- if (Asm->GetLatestFixup()) {
- LastFixup = Asm->GetLatestFixup();
- LastFixupLoc = LastFixup->position();
- }
- if (LastFixupLoc < StartPosition) {
+ AssemblerFixup *LastFixup = Asm->GetLatestFixup(StartPosition);
+ if (LastFixup == NULL) {
// The fixup doesn't apply to this current block.
for (intptr_t i = StartPosition; i < EndPosition; ++i) {
Str << "\t.byte 0x";
@@ -364,25 +359,32 @@ void emitIASBytes(const Cfg *Func, const x86::AssemblerX86 *Asm,
}
return;
}
+ intptr_t LastFixupLoc = LastFixup->position();
const intptr_t FixupSize = 4;
- assert(LastFixupLoc + FixupSize <= EndPosition);
// The fixup does apply to this current block.
for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
}
- Str << "\t.long ";
- const ConstantRelocatable *Reloc = LastFixup->value();
- if (Reloc->getSuppressMangling())
- Str << Reloc->getName();
- else
- Str << Ctx->mangleName(Reloc->getName());
- if (LastFixup->value()->getOffset()) {
- Str << " + " << LastFixup->value()->getOffset();
+ while (LastFixup) {
+ Str << "\t.long ";
+ const ConstantRelocatable *Reloc = LastFixup->value();
+ if (Reloc->getSuppressMangling())
+ Str << Reloc->getName();
+ else
+ Str << Ctx->mangleName(Reloc->getName());
+ if (LastFixup->value()->getOffset()) {
+ Str << " + " << LastFixup->value()->getOffset();
+ }
+ Str << "\n";
+ LastFixupLoc += FixupSize;
+ assert(LastFixupLoc <= EndPosition);
+ LastFixup = Asm->GetLatestFixup(LastFixupLoc);
+ // Assume multi-fixups are adjacent in the instruction encoding.
+ assert(LastFixup == NULL || LastFixup->position() == LastFixupLoc);
}
- Str << "\n";
- for (intptr_t i = LastFixupLoc + FixupSize; i < EndPosition; ++i) {
+ for (intptr_t i = LastFixupLoc; i < EndPosition; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
« no previous file with comments | « no previous file | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698