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 4623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 TargetDataX8632::lowerGlobals( | 4642 void TargetDataX8632::lowerGlobals( |
4643 std::unique_ptr<VariableDeclarationList> Vars) const { | 4643 std::unique_ptr<VariableDeclarationList> Vars) const { |
4644 if (Ctx->getFlags().getUseELFWriter()) { | 4644 switch (Ctx->getFlags().getOutFileType()) { |
| 4645 case FT_Elf: { |
4645 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 4646 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
4646 Writer->writeDataSection(*Vars, llvm::ELF::R_386_32); | 4647 Writer->writeDataSection(*Vars, llvm::ELF::R_386_32); |
4647 } else { | 4648 } break; |
| 4649 case FT_Asm: |
| 4650 case FT_Iasm: { |
4648 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 4651 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
4649 OstreamLocker L(Ctx); | 4652 OstreamLocker L(Ctx); |
4650 for (const VariableDeclaration *Var : *Vars) { | 4653 for (const VariableDeclaration *Var : *Vars) { |
4651 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { | 4654 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { |
4652 lowerGlobal(*Var); | 4655 lowerGlobal(*Var); |
4653 } | 4656 } |
4654 } | 4657 } |
| 4658 } break; |
4655 } | 4659 } |
4656 } | 4660 } |
4657 | 4661 |
4658 template <typename T> struct PoolTypeConverter {}; | 4662 template <typename T> struct PoolTypeConverter {}; |
4659 | 4663 |
4660 template <> struct PoolTypeConverter<float> { | 4664 template <> struct PoolTypeConverter<float> { |
4661 typedef uint32_t PrimitiveIntType; | 4665 typedef uint32_t PrimitiveIntType; |
4662 typedef ConstantFloat IceType; | 4666 typedef ConstantFloat IceType; |
4663 static const Type Ty = IceType_f32; | 4667 static const Type Ty = IceType_f32; |
4664 static const char *TypeName; | 4668 static const char *TypeName; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4709 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " | 4713 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " |
4710 << Value << "\n"; | 4714 << Value << "\n"; |
4711 } | 4715 } |
4712 } | 4716 } |
4713 | 4717 |
4714 void TargetDataX8632::lowerConstants() const { | 4718 void TargetDataX8632::lowerConstants() const { |
4715 if (Ctx->getFlags().getDisableTranslation()) | 4719 if (Ctx->getFlags().getDisableTranslation()) |
4716 return; | 4720 return; |
4717 // No need to emit constants from the int pool since (for x86) they | 4721 // No need to emit constants from the int pool since (for x86) they |
4718 // are embedded as immediates in the instructions, just emit float/double. | 4722 // are embedded as immediates in the instructions, just emit float/double. |
4719 if (Ctx->getFlags().getUseELFWriter()) { | 4723 switch (Ctx->getFlags().getOutFileType()) { |
| 4724 case FT_Elf: { |
4720 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 4725 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
4721 Writer->writeConstantPool<ConstantFloat>(IceType_f32); | 4726 Writer->writeConstantPool<ConstantFloat>(IceType_f32); |
4722 Writer->writeConstantPool<ConstantDouble>(IceType_f64); | 4727 Writer->writeConstantPool<ConstantDouble>(IceType_f64); |
4723 } else { | 4728 } break; |
| 4729 case FT_Asm: |
| 4730 case FT_Iasm: { |
4724 OstreamLocker L(Ctx); | 4731 OstreamLocker L(Ctx); |
4725 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4732 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
4726 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4733 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
| 4734 } break; |
4727 } | 4735 } |
4728 } | 4736 } |
4729 | 4737 |
4730 } // end of namespace Ice | 4738 } // end of namespace Ice |
OLD | NEW |