Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 Cfg class, including constant pool | 10 // This file implements the Cfg class, including constant pool |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 void Cfg::emitTextHeader(const IceString &MangledName) { | 398 void Cfg::emitTextHeader(const IceString &MangledName) { |
| 399 // Note: Still used by emit IAS. | 399 // Note: Still used by emit IAS. |
| 400 Ostream &Str = Ctx->getStrEmit(); | 400 Ostream &Str = Ctx->getStrEmit(); |
| 401 Str << "\t.text\n"; | 401 Str << "\t.text\n"; |
| 402 if (Ctx->getFlags().FunctionSections) | 402 if (Ctx->getFlags().FunctionSections) |
| 403 Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n"; | 403 Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n"; |
| 404 if (!getInternal() || Ctx->getFlags().DisableInternal) { | 404 if (!getInternal() || Ctx->getFlags().DisableInternal) { |
| 405 Str << "\t.globl\t" << MangledName << "\n"; | 405 Str << "\t.globl\t" << MangledName << "\n"; |
| 406 Str << "\t.type\t" << MangledName << ",@function\n"; | 406 Str << "\t.type\t" << MangledName << ",@function\n"; |
| 407 } | 407 } |
| 408 Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x"; | 408 Assembler *Asm = getAssembler<Assembler>(); |
| 409 for (AsmCodeByte I : getTarget()->getNonExecBundlePadding()) | 409 Str << "\t.p2align " << Asm->getBundleAlignLog2Bytes() << ",0x"; |
| 410 for (uint8_t I : Asm->getNonExecBundlePadding()) | |
| 410 Str.write_hex(I); | 411 Str.write_hex(I); |
| 411 Str << "\n"; | 412 Str << "\n"; |
| 412 Str << MangledName << ":\n"; | 413 Str << MangledName << ":\n"; |
| 413 } | 414 } |
| 414 | 415 |
| 415 void Cfg::emit() { | 416 void Cfg::emit() { |
| 416 if (!ALLOW_DUMP) | 417 if (!ALLOW_DUMP) |
| 417 return; | 418 return; |
| 418 TimerMarker T(TimerStack::TT_emit, this); | 419 TimerMarker T(TimerStack::TT_emit, this); |
| 419 if (Ctx->getFlags().DecorateAsm) { | 420 if (Ctx->getFlags().DecorateAsm) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 437 emitTextHeader(MangledName); | 438 emitTextHeader(MangledName); |
| 438 for (CfgNode *Node : Nodes) | 439 for (CfgNode *Node : Nodes) |
| 439 Node->emit(this); | 440 Node->emit(this); |
| 440 Str << "\n"; | 441 Str << "\n"; |
| 441 } | 442 } |
| 442 | 443 |
| 443 void Cfg::emitIAS() { | 444 void Cfg::emitIAS() { |
| 444 TimerMarker T(TimerStack::TT_emit, this); | 445 TimerMarker T(TimerStack::TT_emit, this); |
| 445 assert(!Ctx->getFlags().DecorateAsm); | 446 assert(!Ctx->getFlags().DecorateAsm); |
| 446 IceString MangledName = getContext()->mangleName(getFunctionName()); | 447 IceString MangledName = getContext()->mangleName(getFunctionName()); |
| 447 emitTextHeader(MangledName); | 448 if (!Ctx->getFlags().UseELFWriter) |
| 449 emitTextHeader(MangledName); | |
| 448 for (CfgNode *Node : Nodes) | 450 for (CfgNode *Node : Nodes) |
| 449 Node->emitIAS(this); | 451 Node->emitIAS(this); |
| 450 getAssembler<Assembler>()->emitIASBytes(Ctx); | 452 // Now write the function to the file and track. |
| 453 if (Ctx->getFlags().UseELFWriter) { | |
| 454 getAssembler<Assembler>()->alignFunction(); | |
| 455 Ctx->getObjectWriter()->writeFunctionCode( | |
| 456 MangledName, getInternal(), getAssembler<Assembler>()->getBufferView()); | |
| 457 // Transfer remaining fixups too. They may need their offsets adjusted. | |
|
Jim Stichnoth
2014/11/21 21:32:22
Is this a TODO, or ... ?
jvoung (off chromium)
2014/11/24 21:35:45
Yes, a TODO and made that explicit.
Currently the
| |
| 458 } else { | |
| 459 getAssembler<Assembler>()->emitIASBytes(Ctx); | |
| 460 } | |
| 451 } | 461 } |
| 452 | 462 |
| 453 // Dumps the IR with an optional introductory message. | 463 // Dumps the IR with an optional introductory message. |
| 454 void Cfg::dump(const IceString &Message) { | 464 void Cfg::dump(const IceString &Message) { |
| 455 if (!ALLOW_DUMP) | 465 if (!ALLOW_DUMP) |
| 456 return; | 466 return; |
| 457 if (!Ctx->isVerbose()) | 467 if (!Ctx->isVerbose()) |
| 458 return; | 468 return; |
| 459 Ostream &Str = Ctx->getStrDump(); | 469 Ostream &Str = Ctx->getStrDump(); |
| 460 if (!Message.empty()) | 470 if (!Message.empty()) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 489 } | 499 } |
| 490 } | 500 } |
| 491 // Print each basic block | 501 // Print each basic block |
| 492 for (CfgNode *Node : Nodes) | 502 for (CfgNode *Node : Nodes) |
| 493 Node->dump(this); | 503 Node->dump(this); |
| 494 if (getContext()->isVerbose(IceV_Instructions)) | 504 if (getContext()->isVerbose(IceV_Instructions)) |
| 495 Str << "}\n"; | 505 Str << "}\n"; |
| 496 } | 506 } |
| 497 | 507 |
| 498 } // end of namespace Ice | 508 } // end of namespace Ice |
| OLD | NEW |