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

Side by Side Diff: src/IceTargetLowering.cpp

Issue 1197863003: Subzero: Reduce the amount of #ifdef'd code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup 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/IceRegAlloc.cpp ('k') | src/IceTargetLoweringARM32.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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 InstCall *TargetLowering::makeHelperCall(const IceString &Name, Variable *Dest, 404 InstCall *TargetLowering::makeHelperCall(const IceString &Name, Variable *Dest,
405 SizeT MaxSrcs) { 405 SizeT MaxSrcs) {
406 const bool HasTailCall = false; 406 const bool HasTailCall = false;
407 Constant *CallTarget = Ctx->getConstantExternSym(Name); 407 Constant *CallTarget = Ctx->getConstantExternSym(Name);
408 InstCall *Call = 408 InstCall *Call =
409 InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall); 409 InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall);
410 return Call; 410 return Call;
411 } 411 }
412 412
413 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C) const { 413 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C) const {
414 if (!ALLOW_DUMP) 414 if (!BuildDefs::dump())
415 return; 415 return;
416 Ostream &Str = Ctx->getStrEmit(); 416 Ostream &Str = Ctx->getStrEmit();
417 if (C->getSuppressMangling()) 417 if (C->getSuppressMangling())
418 Str << C->getName(); 418 Str << C->getName();
419 else 419 else
420 Str << Ctx->mangleName(C->getName()); 420 Str << Ctx->mangleName(C->getName());
421 RelocOffsetT Offset = C->getOffset(); 421 RelocOffsetT Offset = C->getOffset();
422 if (Offset) { 422 if (Offset) {
423 if (Offset > 0) 423 if (Offset > 0)
424 Str << "+"; 424 Str << "+";
425 Str << Offset; 425 Str << Offset;
426 } 426 }
427 } 427 }
428 428
429 void TargetLowering::emit(const ConstantRelocatable *C) const { 429 void TargetLowering::emit(const ConstantRelocatable *C) const {
430 if (!ALLOW_DUMP) 430 if (!BuildDefs::dump())
431 return; 431 return;
432 Ostream &Str = Ctx->getStrEmit(); 432 Ostream &Str = Ctx->getStrEmit();
433 Str << getConstantPrefix(); 433 Str << getConstantPrefix();
434 emitWithoutPrefix(C); 434 emitWithoutPrefix(C);
435 } 435 }
436 436
437 std::unique_ptr<TargetDataLowering> 437 std::unique_ptr<TargetDataLowering>
438 TargetDataLowering::createLowering(GlobalContext *Ctx) { 438 TargetDataLowering::createLowering(GlobalContext *Ctx) {
439 TargetArch Target = Ctx->getFlags().getTargetArch(); 439 TargetArch Target = Ctx->getFlags().getTargetArch();
440 #define SUBZERO_TARGET(X) \ 440 #define SUBZERO_TARGET(X) \
(...skipping 24 matching lines...) Expand all
465 } 465 }
466 466
467 assert(!SectionSuffix.empty()); 467 assert(!SectionSuffix.empty());
468 return "." + SectionSuffix; 468 return "." + SectionSuffix;
469 } 469 }
470 470
471 } // end of anonymous namespace 471 } // end of anonymous namespace
472 472
473 void TargetDataLowering::emitGlobal(const VariableDeclaration &Var, 473 void TargetDataLowering::emitGlobal(const VariableDeclaration &Var,
474 const IceString &SectionSuffix) { 474 const IceString &SectionSuffix) {
475 if (!ALLOW_DUMP) 475 if (!BuildDefs::dump())
476 return; 476 return;
477 477
478 // If external and not initialized, this must be a cross test. 478 // If external and not initialized, this must be a cross test.
479 // Don't generate a declaration for such cases. 479 // Don't generate a declaration for such cases.
480 const bool IsExternal = 480 const bool IsExternal =
481 Var.isExternal() || Ctx->getFlags().getDisableInternal(); 481 Var.isExternal() || Ctx->getFlags().getDisableInternal();
482 if (IsExternal && !Var.hasInitializer()) 482 if (IsExternal && !Var.hasInitializer())
483 return; 483 return;
484 484
485 Ostream &Str = Ctx->getStrEmit(); 485 Ostream &Str = Ctx->getStrEmit();
(...skipping 25 matching lines...) Expand all
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 (const std::unique_ptr<VariableDeclaration::Initializer> &Init : 517 for (const std::unique_ptr<VariableDeclaration::Initializer> &Init :
518 Var.getInitializers()) { 518 Var.getInitializers()) {
519 switch (Init->getKind()) { 519 switch (Init->getKind()) {
520 case VariableDeclaration::Initializer::DataInitializerKind: { 520 case VariableDeclaration::Initializer::DataInitializerKind: {
521 const auto &Data = llvm::cast<VariableDeclaration::DataInitializer>( 521 const auto &Data =
522 Init.get())->getContents(); 522 llvm::cast<VariableDeclaration::DataInitializer>(Init.get())
523 ->getContents();
523 for (SizeT i = 0; i < Init->getNumBytes(); ++i) { 524 for (SizeT i = 0; i < Init->getNumBytes(); ++i) {
524 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 525 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
525 } 526 }
526 break; 527 break;
527 } 528 }
528 case VariableDeclaration::Initializer::ZeroInitializerKind: 529 case VariableDeclaration::Initializer::ZeroInitializerKind:
529 Str << "\t.zero\t" << Init->getNumBytes() << "\n"; 530 Str << "\t.zero\t" << Init->getNumBytes() << "\n";
530 break; 531 break;
531 case VariableDeclaration::Initializer::RelocInitializerKind: { 532 case VariableDeclaration::Initializer::RelocInitializerKind: {
532 const auto *Reloc = 533 const auto *Reloc =
(...skipping 29 matching lines...) Expand all
562 if (Target == Target_##X) \ 563 if (Target == Target_##X) \
563 return TargetHeader##X::create(Ctx); 564 return TargetHeader##X::create(Ctx);
564 #include "llvm/Config/SZTargets.def" 565 #include "llvm/Config/SZTargets.def"
565 566
566 llvm::report_fatal_error("Unsupported target header lowering"); 567 llvm::report_fatal_error("Unsupported target header lowering");
567 } 568 }
568 569
569 TargetHeaderLowering::~TargetHeaderLowering() = default; 570 TargetHeaderLowering::~TargetHeaderLowering() = default;
570 571
571 } // end of namespace Ice 572 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceRegAlloc.cpp ('k') | src/IceTargetLoweringARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698