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

Side by Side Diff: src/IceCfg.cpp

Issue 700263003: Rearrange emit vs emitIAS. Wait till function is done before dumping text. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove comment... might end up using the iterator 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 | « src/IceCfg.h ('k') | src/IceCfgNode.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/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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 TimerMarker T(TimerStack::TT_doBranchOpt, this); 383 TimerMarker T(TimerStack::TT_doBranchOpt, this);
384 for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { 384 for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) {
385 auto NextNode = I; 385 auto NextNode = I;
386 ++NextNode; 386 ++NextNode;
387 (*I)->doBranchOpt(NextNode == E ? NULL : *NextNode); 387 (*I)->doBranchOpt(NextNode == E ? NULL : *NextNode);
388 } 388 }
389 } 389 }
390 390
391 // ======================== Dump routines ======================== // 391 // ======================== Dump routines ======================== //
392 392
393 void Cfg::emitTextHeader(const IceString &MangledName) {
394 Ostream &Str = Ctx->getStrEmit();
395 Str << "\t.text\n";
396 if (Ctx->getFlags().FunctionSections)
397 Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
398 if (!getInternal() || Ctx->getFlags().DisableInternal) {
399 Str << "\t.globl\t" << MangledName << "\n";
400 Str << "\t.type\t" << MangledName << ",@function\n";
401 }
402 Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
403 for (AsmCodeByte I : getTarget()->getNonExecBundlePadding())
404 Str.write_hex(I);
405 Str << "\n";
406 Str << MangledName << ":\n";
407 }
408
393 void Cfg::emit() { 409 void Cfg::emit() {
394 TimerMarker T(TimerStack::TT_emit, this); 410 TimerMarker T(TimerStack::TT_emit, this);
395 if (Ctx->getFlags().DecorateAsm) { 411 if (Ctx->getFlags().DecorateAsm) {
396 renumberInstructions(); 412 renumberInstructions();
397 getVMetadata()->init(VMK_Uses); 413 getVMetadata()->init(VMK_Uses);
398 liveness(Liveness_Basic); 414 liveness(Liveness_Basic);
399 dump("After recomputing liveness for -decorate-asm"); 415 dump("After recomputing liveness for -decorate-asm");
400 } 416 }
401 Ostream &Str = Ctx->getStrEmit(); 417 Ostream &Str = Ctx->getStrEmit();
402 if (!Ctx->testAndSetHasEmittedFirstMethod()) { 418 if (!Ctx->testAndSetHasEmittedFirstMethod()) {
403 // Print a helpful command for assembling the output. 419 // Print a helpful command for assembling the output.
404 // TODO: have the Target emit the header 420 // TODO: have the Target emit the header
405 // TODO: need a per-file emit in addition to per-CFG 421 // TODO: need a per-file emit in addition to per-CFG
406 Str << "# $LLVM_BIN_PATH/llvm-mc" 422 Str << "# $LLVM_BIN_PATH/llvm-mc"
407 << " -arch=x86" 423 << " -arch=x86"
408 << " -filetype=obj" 424 << " -filetype=obj"
409 << " -o=MyObj.o" 425 << " -o=MyObj.o"
410 << "\n\n"; 426 << "\n\n";
411 } 427 }
412 Str << "\t.text\n";
413 IceString MangledName = getContext()->mangleName(getFunctionName()); 428 IceString MangledName = getContext()->mangleName(getFunctionName());
414 if (Ctx->getFlags().FunctionSections) 429 emitTextHeader(MangledName);
415 Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
416 if (!getInternal() || Ctx->getFlags().DisableInternal) {
417 Str << "\t.globl\t" << MangledName << "\n";
418 Str << "\t.type\t" << MangledName << ",@function\n";
419 }
420 Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
421 for (AsmCodeByte I : getTarget()->getNonExecBundlePadding())
422 Str.write_hex(I);
423 Str << "\n";
424 for (CfgNode *Node : Nodes) 430 for (CfgNode *Node : Nodes)
425 Node->emit(this); 431 Node->emit(this);
426 Str << "\n"; 432 Str << "\n";
427 } 433 }
428 434
435 void Cfg::emitIAS() {
436 TimerMarker T(TimerStack::TT_emit, this);
437 assert(!Ctx->getFlags().DecorateAsm);
438 IceString MangledName = getContext()->mangleName(getFunctionName());
439 emitTextHeader(MangledName);
440 for (CfgNode *Node : Nodes)
441 Node->emitIAS(this);
442 getAssembler<Assembler>()->emitIASBytes(Ctx);
443 }
444
429 // Dumps the IR with an optional introductory message. 445 // Dumps the IR with an optional introductory message.
430 void Cfg::dump(const IceString &Message) { 446 void Cfg::dump(const IceString &Message) {
431 if (!Ctx->isVerbose()) 447 if (!Ctx->isVerbose())
432 return; 448 return;
433 Ostream &Str = Ctx->getStrDump(); 449 Ostream &Str = Ctx->getStrDump();
434 if (!Message.empty()) 450 if (!Message.empty())
435 Str << "================ " << Message << " ================\n"; 451 Str << "================ " << Message << " ================\n";
436 setCurrentNode(getEntryNode()); 452 setCurrentNode(getEntryNode());
437 // Print function name+args 453 // Print function name+args
438 if (getContext()->isVerbose(IceV_Instructions)) { 454 if (getContext()->isVerbose(IceV_Instructions)) {
(...skipping 24 matching lines...) Expand all
463 } 479 }
464 } 480 }
465 // Print each basic block 481 // Print each basic block
466 for (CfgNode *Node : Nodes) 482 for (CfgNode *Node : Nodes)
467 Node->dump(this); 483 Node->dump(this);
468 if (getContext()->isVerbose(IceV_Instructions)) 484 if (getContext()->isVerbose(IceV_Instructions))
469 Str << "}\n"; 485 Str << "}\n";
470 } 486 }
471 487
472 } // end of namespace Ice 488 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698