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

Side by Side Diff: src/IceTargetLowering.cpp

Issue 1181013016: Subzero. Fixes memory leaks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses codereview comments. Created 5 years, 6 months 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/IceOperand.h ('k') | src/PNaClTranslator.cpp » ('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/IceTargetLowering.cpp - Basic lowering implementation --===// 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering 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 skeleton of the TargetLowering class, 10 // This file implements the skeleton of the TargetLowering class,
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (Align > 1) { 507 if (Align > 1) {
508 assert(llvm::isPowerOf2_32(Align)); 508 assert(llvm::isPowerOf2_32(Align));
509 // Use the .p2align directive, since the .align N directive can either 509 // Use the .p2align directive, since the .align N directive can either
510 // interpret N as bytes, or power of 2 bytes, depending on the target. 510 // interpret N as bytes, or power of 2 bytes, depending on the target.
511 Str << "\t.p2align\t" << llvm::Log2_32(Align) << "\n"; 511 Str << "\t.p2align\t" << llvm::Log2_32(Align) << "\n";
512 } 512 }
513 513
514 Str << MangledName << ":\n"; 514 Str << MangledName << ":\n";
515 515
516 if (HasNonzeroInitializer) { 516 if (HasNonzeroInitializer) {
517 for (VariableDeclaration::Initializer *Init : Var.getInitializers()) { 517 for (const std::unique_ptr<VariableDeclaration::Initializer> &Init :
518 Var.getInitializers()) {
518 switch (Init->getKind()) { 519 switch (Init->getKind()) {
519 case VariableDeclaration::Initializer::DataInitializerKind: { 520 case VariableDeclaration::Initializer::DataInitializerKind: {
520 const auto &Data = llvm::cast<VariableDeclaration::DataInitializer>( 521 const auto &Data = llvm::cast<VariableDeclaration::DataInitializer>(
521 Init)->getContents(); 522 Init.get())->getContents();
522 for (SizeT i = 0; i < Init->getNumBytes(); ++i) { 523 for (SizeT i = 0; i < Init->getNumBytes(); ++i) {
523 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 524 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
524 } 525 }
525 break; 526 break;
526 } 527 }
527 case VariableDeclaration::Initializer::ZeroInitializerKind: 528 case VariableDeclaration::Initializer::ZeroInitializerKind:
528 Str << "\t.zero\t" << Init->getNumBytes() << "\n"; 529 Str << "\t.zero\t" << Init->getNumBytes() << "\n";
529 break; 530 break;
530 case VariableDeclaration::Initializer::RelocInitializerKind: { 531 case VariableDeclaration::Initializer::RelocInitializerKind: {
531 const auto *Reloc = 532 const auto *Reloc =
532 llvm::cast<VariableDeclaration::RelocInitializer>(Init); 533 llvm::cast<VariableDeclaration::RelocInitializer>(Init.get());
533 Str << "\t" << getEmit32Directive() << "\t"; 534 Str << "\t" << getEmit32Directive() << "\t";
534 Str << Reloc->getDeclaration()->mangleName(Ctx); 535 Str << Reloc->getDeclaration()->mangleName(Ctx);
535 if (RelocOffsetT Offset = Reloc->getOffset()) { 536 if (RelocOffsetT Offset = Reloc->getOffset()) {
536 if (Offset >= 0 || (Offset == INT32_MIN)) 537 if (Offset >= 0 || (Offset == INT32_MIN))
537 Str << " + " << Offset; 538 Str << " + " << Offset;
538 else 539 else
539 Str << " - " << -Offset; 540 Str << " - " << -Offset;
540 } 541 }
541 Str << "\n"; 542 Str << "\n";
542 break; 543 break;
(...skipping 18 matching lines...) Expand all
561 if (Target == Target_##X) \ 562 if (Target == Target_##X) \
562 return TargetHeader##X::create(Ctx); 563 return TargetHeader##X::create(Ctx);
563 #include "llvm/Config/SZTargets.def" 564 #include "llvm/Config/SZTargets.def"
564 565
565 llvm::report_fatal_error("Unsupported target header lowering"); 566 llvm::report_fatal_error("Unsupported target header lowering");
566 } 567 }
567 568
568 TargetHeaderLowering::~TargetHeaderLowering() {} 569 TargetHeaderLowering::~TargetHeaderLowering() {}
569 570
570 } // end of namespace Ice 571 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceOperand.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698