| 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 |
| 11 // management. | 11 // management. |
| 12 // | 12 // |
| 13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
| 14 | 14 |
| 15 #include "assembler.h" |
| 15 #include "IceCfg.h" | 16 #include "IceCfg.h" |
| 16 #include "IceCfgNode.h" | 17 #include "IceCfgNode.h" |
| 17 #include "IceClFlags.h" | 18 #include "IceClFlags.h" |
| 18 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceELFObjectWriter.h" |
| 19 #include "IceInst.h" | 21 #include "IceInst.h" |
| 20 #include "IceLiveness.h" | 22 #include "IceLiveness.h" |
| 21 #include "IceOperand.h" | 23 #include "IceOperand.h" |
| 22 #include "IceTargetLowering.h" | 24 #include "IceTargetLowering.h" |
| 23 | 25 |
| 24 namespace Ice { | 26 namespace Ice { |
| 25 | 27 |
| 26 thread_local const Cfg *Cfg::CurrentCfg = nullptr; | 28 thread_local const Cfg *Cfg::CurrentCfg = nullptr; |
| 27 | 29 |
| 28 ArenaAllocator<> *getCurrentCfgAllocator() { | 30 ArenaAllocator<> *getCurrentCfgAllocator() { |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 TimerMarker T(TimerStack::TT_emit, this); | 454 TimerMarker T(TimerStack::TT_emit, this); |
| 453 assert(!Ctx->getFlags().DecorateAsm); | 455 assert(!Ctx->getFlags().DecorateAsm); |
| 454 IceString MangledName = getContext()->mangleName(getFunctionName()); | 456 IceString MangledName = getContext()->mangleName(getFunctionName()); |
| 455 if (!Ctx->getFlags().UseELFWriter) | 457 if (!Ctx->getFlags().UseELFWriter) |
| 456 emitTextHeader(MangledName); | 458 emitTextHeader(MangledName); |
| 457 for (CfgNode *Node : Nodes) | 459 for (CfgNode *Node : Nodes) |
| 458 Node->emitIAS(this); | 460 Node->emitIAS(this); |
| 459 // Now write the function to the file and track. | 461 // Now write the function to the file and track. |
| 460 if (Ctx->getFlags().UseELFWriter) { | 462 if (Ctx->getFlags().UseELFWriter) { |
| 461 getAssembler<Assembler>()->alignFunction(); | 463 getAssembler<Assembler>()->alignFunction(); |
| 462 // TODO(jvoung): Transfer remaining fixups too. They may need their | 464 Ctx->getObjectWriter()->writeFunctionCode(MangledName, getInternal(), |
| 463 // offsets adjusted. | 465 getAssembler<Assembler>()); |
| 464 Ctx->getObjectWriter()->writeFunctionCode( | |
| 465 MangledName, getInternal(), getAssembler<Assembler>()->getBufferView()); | |
| 466 } else { | 466 } else { |
| 467 getAssembler<Assembler>()->emitIASBytes(Ctx); | 467 getAssembler<Assembler>()->emitIASBytes(Ctx); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 // Dumps the IR with an optional introductory message. | 471 // Dumps the IR with an optional introductory message. |
| 472 void Cfg::dump(const IceString &Message) { | 472 void Cfg::dump(const IceString &Message) { |
| 473 if (!ALLOW_DUMP) | 473 if (!ALLOW_DUMP) |
| 474 return; | 474 return; |
| 475 if (!Ctx->isVerbose()) | 475 if (!Ctx->isVerbose()) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 // Print each basic block | 509 // Print each basic block |
| 510 for (CfgNode *Node : Nodes) | 510 for (CfgNode *Node : Nodes) |
| 511 Node->dump(this); | 511 Node->dump(this); |
| 512 if (getContext()->isVerbose(IceV_Instructions)) | 512 if (getContext()->isVerbose(IceV_Instructions)) |
| 513 Str << "}\n"; | 513 Str << "}\n"; |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // end of namespace Ice | 516 } // end of namespace Ice |
| OLD | NEW |