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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 874353006: Write out global initializers and data rel directly to ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: pull statics out Created 5 years, 10 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
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
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 TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 4616 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 } 4627 }
4628 4628
4629 void ConstantUndef::emit(GlobalContext *) const { 4629 void ConstantUndef::emit(GlobalContext *) const {
4630 llvm_unreachable("undef value encountered by emitter."); 4630 llvm_unreachable("undef value encountered by emitter.");
4631 } 4631 }
4632 4632
4633 TargetGlobalInitX8632::TargetGlobalInitX8632(GlobalContext *Ctx) 4633 TargetGlobalInitX8632::TargetGlobalInitX8632(GlobalContext *Ctx)
4634 : TargetGlobalInitLowering(Ctx) {} 4634 : TargetGlobalInitLowering(Ctx) {}
4635 4635
4636 void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) { 4636 void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) {
4637 // TODO(jvoung): handle this without text.
4638 if (Ctx->getFlags().UseELFWriter)
4639 return;
4640
4641 Ostream &Str = Ctx->getStrEmit();
4642
4643 const VariableDeclaration::InitializerListType &Initializers =
4644 Var.getInitializers();
4645
4646 // If external and not initialized, this must be a cross test. 4637 // If external and not initialized, this must be a cross test.
4647 // Don't generate a declaration for such cases. 4638 // Don't generate a declaration for such cases.
4648 bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal; 4639 bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal;
4649 if (IsExternal && !Var.hasInitializer()) return; 4640 if (IsExternal && !Var.hasInitializer()) return;
4650 4641
4642 const VariableDeclaration::InitializerListType &Initializers =
4643 Var.getInitializers();
4651 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); 4644 bool HasNonzeroInitializer = Var.hasNonzeroInitializer();
4652 bool IsConstant = Var.getIsConstant(); 4645 bool IsConstant = Var.getIsConstant();
4653 uint32_t Align = Var.getAlignment(); 4646 uint32_t Align = Var.getAlignment();
4654 SizeT Size = Var.getNumBytes(); 4647 SizeT Size = Var.getNumBytes();
4655 IceString MangledName = Var.mangleName(Ctx); 4648 IceString MangledName = Var.mangleName(Ctx);
4656 IceString SectionSuffix = ""; 4649 IceString SectionSuffix = "";
4657 if (Ctx->getFlags().DataSections) 4650 if (Ctx->getFlags().DataSections)
4658 SectionSuffix = "." + MangledName; 4651 SectionSuffix = "." + MangledName;
4659 4652
4653 Ostream &Str = Ctx->getStrEmit();
4654
4660 Str << "\t.type\t" << MangledName << ",@object\n"; 4655 Str << "\t.type\t" << MangledName << ",@object\n";
4661 4656
4662 if (IsConstant) 4657 if (IsConstant)
4663 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n"; 4658 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n";
4664 else if (HasNonzeroInitializer) 4659 else if (HasNonzeroInitializer)
4665 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n"; 4660 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n";
4666 else 4661 else
4667 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n"; 4662 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n";
4668 4663
4669 if (IsExternal) 4664 if (IsExternal)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4707 } else 4702 } else
4708 // NOTE: for non-constant zero initializers, this is BSS (no bits), 4703 // NOTE: for non-constant zero initializers, this is BSS (no bits),
4709 // so an ELF writer would not write to the file, and only track 4704 // so an ELF writer would not write to the file, and only track
4710 // virtual offsets, but the .s writer still needs this .zero and 4705 // virtual offsets, but the .s writer still needs this .zero and
4711 // cannot simply use the .size to advance offsets. 4706 // cannot simply use the .size to advance offsets.
4712 Str << "\t.zero\t" << Size << "\n"; 4707 Str << "\t.zero\t" << Size << "\n";
4713 4708
4714 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4709 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4715 } 4710 }
4716 4711
4712 void TargetGlobalInitX8632::lowerGlobalsELF(
4713 const VariableDeclarationList &Vars) {
4714 ELFObjectWriter *Writer = Ctx->getObjectWriter();
4715 Writer->writeDataSection(Vars, llvm::ELF::R_386_32);
4716 }
4717
4717 } // end of namespace Ice 4718 } // end of namespace Ice
OLDNEW
« src/IceGlobalInits.h ('K') | « src/IceTargetLoweringX8632.h ('k') | src/IceTimerTree.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698