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

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

Powered by Google App Engine
This is Rietveld 408576698