| OLD | NEW |
| 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 4621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4632 } else | 4632 } else |
| 4633 // NOTE: for non-constant zero initializers, this is BSS (no bits), | 4633 // NOTE: for non-constant zero initializers, this is BSS (no bits), |
| 4634 // so an ELF writer would not write to the file, and only track | 4634 // so an ELF writer would not write to the file, and only track |
| 4635 // virtual offsets, but the .s writer still needs this .zero and | 4635 // virtual offsets, but the .s writer still needs this .zero and |
| 4636 // cannot simply use the .size to advance offsets. | 4636 // cannot simply use the .size to advance offsets. |
| 4637 Str << "\t.zero\t" << Size << "\n"; | 4637 Str << "\t.zero\t" << Size << "\n"; |
| 4638 | 4638 |
| 4639 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4639 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
| 4640 } | 4640 } |
| 4641 | 4641 |
| 4642 void | 4642 void TargetDataX8632::lowerGlobals( |
| 4643 TargetDataX8632::lowerGlobalsELF(const VariableDeclarationList &Vars) const { | 4643 std::unique_ptr<VariableDeclarationList> Vars) const { |
| 4644 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 4644 if (Ctx->getFlags().getUseELFWriter()) { |
| 4645 Writer->writeDataSection(Vars, llvm::ELF::R_386_32); | 4645 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 4646 Writer->writeDataSection(*Vars, llvm::ELF::R_386_32); |
| 4647 } else { |
| 4648 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
| 4649 OstreamLocker L(Ctx); |
| 4650 for (const VariableDeclaration *Var : *Vars) { |
| 4651 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { |
| 4652 lowerGlobal(*Var); |
| 4653 } |
| 4654 } |
| 4655 } |
| 4646 } | 4656 } |
| 4647 | 4657 |
| 4648 template <typename T> struct PoolTypeConverter {}; | 4658 template <typename T> struct PoolTypeConverter {}; |
| 4649 | 4659 |
| 4650 template <> struct PoolTypeConverter<float> { | 4660 template <> struct PoolTypeConverter<float> { |
| 4651 typedef uint32_t PrimitiveIntType; | 4661 typedef uint32_t PrimitiveIntType; |
| 4652 typedef ConstantFloat IceType; | 4662 typedef ConstantFloat IceType; |
| 4653 static const Type Ty = IceType_f32; | 4663 static const Type Ty = IceType_f32; |
| 4654 static const char *TypeName; | 4664 static const char *TypeName; |
| 4655 static const char *AsmTag; | 4665 static const char *AsmTag; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4694 snprintf(buf, llvm::array_lengthof(buf), T::PrintfString, RawValue); | 4704 snprintf(buf, llvm::array_lengthof(buf), T::PrintfString, RawValue); |
| 4695 assert(CharsPrinted >= 0 && | 4705 assert(CharsPrinted >= 0 && |
| 4696 (size_t)CharsPrinted < llvm::array_lengthof(buf)); | 4706 (size_t)CharsPrinted < llvm::array_lengthof(buf)); |
| 4697 (void)CharsPrinted; // avoid warnings if asserts are disabled | 4707 (void)CharsPrinted; // avoid warnings if asserts are disabled |
| 4698 Const->emitPoolLabel(Str); | 4708 Const->emitPoolLabel(Str); |
| 4699 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " | 4709 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " |
| 4700 << Value << "\n"; | 4710 << Value << "\n"; |
| 4701 } | 4711 } |
| 4702 } | 4712 } |
| 4703 | 4713 |
| 4704 void TargetDataX8632::lowerConstants(GlobalContext *Ctx) const { | 4714 void TargetDataX8632::lowerConstants() const { |
| 4705 if (Ctx->getFlags().getDisableTranslation()) | 4715 if (Ctx->getFlags().getDisableTranslation()) |
| 4706 return; | 4716 return; |
| 4707 // No need to emit constants from the int pool since (for x86) they | 4717 // No need to emit constants from the int pool since (for x86) they |
| 4708 // are embedded as immediates in the instructions, just emit float/double. | 4718 // are embedded as immediates in the instructions, just emit float/double. |
| 4709 if (Ctx->getFlags().getUseELFWriter()) { | 4719 if (Ctx->getFlags().getUseELFWriter()) { |
| 4710 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 4720 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 4711 Writer->writeConstantPool<ConstantFloat>(IceType_f32); | 4721 Writer->writeConstantPool<ConstantFloat>(IceType_f32); |
| 4712 Writer->writeConstantPool<ConstantDouble>(IceType_f64); | 4722 Writer->writeConstantPool<ConstantDouble>(IceType_f64); |
| 4713 } else { | 4723 } else { |
| 4714 OstreamLocker L(Ctx); | 4724 OstreamLocker L(Ctx); |
| 4715 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4725 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
| 4716 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4726 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
| 4717 } | 4727 } |
| 4718 } | 4728 } |
| 4719 | 4729 |
| 4720 } // end of namespace Ice | 4730 } // end of namespace Ice |
| OLD | NEW |