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

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: misc stuff Created 5 years, 11 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 Ostream &Str = Ctx->getStrEmit();
4643 const VariableDeclaration::InitializerListType &Initializers =
4644 Var.getInitializers();
4651 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); 4645 bool HasNonzeroInitializer = Var.hasNonzeroInitializer();
4652 bool IsConstant = Var.getIsConstant(); 4646 bool IsConstant = Var.getIsConstant();
4653 uint32_t Align = Var.getAlignment(); 4647 uint32_t Align = Var.getAlignment();
4654 SizeT Size = Var.getNumBytes(); 4648 SizeT Size = Var.getNumBytes();
4655 IceString MangledName = Var.mangleName(Ctx); 4649 IceString MangledName = Var.mangleName(Ctx);
4656 IceString SectionSuffix = ""; 4650 IceString SectionSuffix = "";
4657 if (Ctx->getFlags().DataSections) 4651 if (Ctx->getFlags().DataSections)
4658 SectionSuffix = "." + MangledName; 4652 SectionSuffix = "." + MangledName;
4659 4653
4660 Str << "\t.type\t" << MangledName << ",@object\n"; 4654 Str << "\t.type\t" << MangledName << ",@object\n";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4707 } else 4701 } else
4708 // NOTE: for non-constant zero initializers, this is BSS (no bits), 4702 // 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 4703 // 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 4704 // virtual offsets, but the .s writer still needs this .zero and
4711 // cannot simply use the .size to advance offsets. 4705 // cannot simply use the .size to advance offsets.
4712 Str << "\t.zero\t" << Size << "\n"; 4706 Str << "\t.zero\t" << Size << "\n";
4713 4707
4714 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4708 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4715 } 4709 }
4716 4710
4711 void TargetGlobalInitX8632::lowerGlobalsELF(
4712 const VariableDeclarationList &Vars) {
4713 ELFObjectWriter *Writer = Ctx->getObjectWriter();
4714 Writer->writeDataSection(Vars, llvm::ELF::R_386_32);
4715 }
4716
4717 } // end of namespace Ice 4717 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698