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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the InstX8632 and OperandX8632 classes, 10 // This file implements the InstX8632 and OperandX8632 classes,
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 // ======================== Dump routines ======================== // 343 // ======================== Dump routines ======================== //
344 344
345 namespace { 345 namespace {
346 346
347 void emitIASBytes(const Cfg *Func, const x86::AssemblerX86 *Asm, 347 void emitIASBytes(const Cfg *Func, const x86::AssemblerX86 *Asm,
348 intptr_t StartPosition) { 348 intptr_t StartPosition) {
349 GlobalContext *Ctx = Func->getContext(); 349 GlobalContext *Ctx = Func->getContext();
350 Ostream &Str = Ctx->getStrEmit(); 350 Ostream &Str = Ctx->getStrEmit();
351 intptr_t EndPosition = Asm->GetPosition(); 351 intptr_t EndPosition = Asm->GetPosition();
352 intptr_t LastFixupLoc = -1; 352 AssemblerFixup *LastFixup = Asm->GetLatestFixup(StartPosition);
353 AssemblerFixup *LastFixup = NULL; 353 if (LastFixup == NULL) {
354 if (Asm->GetLatestFixup()) {
355 LastFixup = Asm->GetLatestFixup();
356 LastFixupLoc = LastFixup->position();
357 }
358 if (LastFixupLoc < StartPosition) {
359 // The fixup doesn't apply to this current block. 354 // The fixup doesn't apply to this current block.
360 for (intptr_t i = StartPosition; i < EndPosition; ++i) { 355 for (intptr_t i = StartPosition; i < EndPosition; ++i) {
361 Str << "\t.byte 0x"; 356 Str << "\t.byte 0x";
362 Str.write_hex(Asm->LoadBuffer<uint8_t>(i)); 357 Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
363 Str << "\n"; 358 Str << "\n";
364 } 359 }
365 return; 360 return;
366 } 361 }
362 intptr_t LastFixupLoc = LastFixup->position();
367 const intptr_t FixupSize = 4; 363 const intptr_t FixupSize = 4;
368 assert(LastFixupLoc + FixupSize <= EndPosition);
369 // The fixup does apply to this current block. 364 // The fixup does apply to this current block.
370 for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) { 365 for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) {
371 Str << "\t.byte 0x"; 366 Str << "\t.byte 0x";
372 Str.write_hex(Asm->LoadBuffer<uint8_t>(i)); 367 Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
373 Str << "\n"; 368 Str << "\n";
374 } 369 }
375 Str << "\t.long "; 370 while (LastFixup) {
376 const ConstantRelocatable *Reloc = LastFixup->value(); 371 Str << "\t.long ";
377 if (Reloc->getSuppressMangling()) 372 const ConstantRelocatable *Reloc = LastFixup->value();
378 Str << Reloc->getName(); 373 if (Reloc->getSuppressMangling())
379 else 374 Str << Reloc->getName();
380 Str << Ctx->mangleName(Reloc->getName()); 375 else
381 if (LastFixup->value()->getOffset()) { 376 Str << Ctx->mangleName(Reloc->getName());
382 Str << " + " << LastFixup->value()->getOffset(); 377 if (LastFixup->value()->getOffset()) {
378 Str << " + " << LastFixup->value()->getOffset();
379 }
380 Str << "\n";
381 LastFixupLoc += FixupSize;
382 assert(LastFixupLoc <= EndPosition);
383 LastFixup = Asm->GetLatestFixup(LastFixupLoc);
384 // Assume multi-fixups are adjacent in the instruction encoding.
385 assert(LastFixup == NULL || LastFixup->position() == LastFixupLoc);
383 } 386 }
384 Str << "\n"; 387 for (intptr_t i = LastFixupLoc; i < EndPosition; ++i) {
385 for (intptr_t i = LastFixupLoc + FixupSize; i < EndPosition; ++i) {
386 Str << "\t.byte 0x"; 388 Str << "\t.byte 0x";
387 Str.write_hex(Asm->LoadBuffer<uint8_t>(i)); 389 Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
388 Str << "\n"; 390 Str << "\n";
389 } 391 }
390 } 392 }
391 393
392 void emitIASBytesBranch(const Cfg *Func, const x86::AssemblerX86 *Asm, 394 void emitIASBytesBranch(const Cfg *Func, const x86::AssemblerX86 *Asm,
393 intptr_t StartPosition, const x86::Label *Label, 395 intptr_t StartPosition, const x86::Label *Label,
394 const IceString &LabelName, bool Near) { 396 const IceString &LabelName, bool Near) {
395 // If this is a backward branch (label is bound), we're good and know 397 // If this is a backward branch (label is bound), we're good and know
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 } 2910 }
2909 Str << "("; 2911 Str << "(";
2910 if (Func) 2912 if (Func)
2911 Var->dump(Func); 2913 Var->dump(Func);
2912 else 2914 else
2913 Var->dump(Str); 2915 Var->dump(Str);
2914 Str << ")"; 2916 Str << ")";
2915 } 2917 }
2916 2918
2917 } // end of namespace Ice 2919 } // end of namespace Ice
OLDNEW
« 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