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 4546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4557 } | 4557 } |
4558 | 4558 |
4559 void ConstantUndef::emit(GlobalContext *) const { | 4559 void ConstantUndef::emit(GlobalContext *) const { |
4560 llvm_unreachable("undef value encountered by emitter."); | 4560 llvm_unreachable("undef value encountered by emitter."); |
4561 } | 4561 } |
4562 | 4562 |
4563 TargetGlobalX8632::TargetGlobalX8632(GlobalContext *Ctx) | 4563 TargetGlobalX8632::TargetGlobalX8632(GlobalContext *Ctx) |
4564 : TargetGlobalLowering(Ctx) {} | 4564 : TargetGlobalLowering(Ctx) {} |
4565 | 4565 |
4566 void TargetGlobalX8632::lowerInit(const VariableDeclaration &Var) const { | 4566 void TargetGlobalX8632::lowerInit(const VariableDeclaration &Var) const { |
4567 // TODO(jvoung): handle this without text. | |
4568 if (Ctx->getFlags().UseELFWriter) | |
4569 return; | |
4570 | |
4571 Ostream &Str = Ctx->getStrEmit(); | |
4572 | |
4573 const VariableDeclaration::InitializerListType &Initializers = | |
4574 Var.getInitializers(); | |
4575 | |
4576 // If external and not initialized, this must be a cross test. | 4567 // If external and not initialized, this must be a cross test. |
4577 // Don't generate a declaration for such cases. | 4568 // Don't generate a declaration for such cases. |
4578 bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal; | 4569 bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal; |
4579 if (IsExternal && !Var.hasInitializer()) | 4570 if (IsExternal && !Var.hasInitializer()) |
4580 return; | 4571 return; |
4581 | 4572 |
| 4573 Ostream &Str = Ctx->getStrEmit(); |
| 4574 const VariableDeclaration::InitializerListType &Initializers = |
| 4575 Var.getInitializers(); |
4582 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); | 4576 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); |
4583 bool IsConstant = Var.getIsConstant(); | 4577 bool IsConstant = Var.getIsConstant(); |
4584 uint32_t Align = Var.getAlignment(); | 4578 uint32_t Align = Var.getAlignment(); |
4585 SizeT Size = Var.getNumBytes(); | 4579 SizeT Size = Var.getNumBytes(); |
4586 IceString MangledName = Var.mangleName(Ctx); | 4580 IceString MangledName = Var.mangleName(Ctx); |
4587 IceString SectionSuffix = ""; | 4581 IceString SectionSuffix = ""; |
4588 if (Ctx->getFlags().DataSections) | 4582 if (Ctx->getFlags().DataSections) |
4589 SectionSuffix = "." + MangledName; | 4583 SectionSuffix = "." + MangledName; |
4590 | 4584 |
4591 Str << "\t.type\t" << MangledName << ",@object\n"; | 4585 Str << "\t.type\t" << MangledName << ",@object\n"; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4638 } else | 4632 } else |
4639 // NOTE: for non-constant zero initializers, this is BSS (no bits), | 4633 // NOTE: for non-constant zero initializers, this is BSS (no bits), |
4640 // 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 |
4641 // virtual offsets, but the .s writer still needs this .zero and | 4635 // virtual offsets, but the .s writer still needs this .zero and |
4642 // cannot simply use the .size to advance offsets. | 4636 // cannot simply use the .size to advance offsets. |
4643 Str << "\t.zero\t" << Size << "\n"; | 4637 Str << "\t.zero\t" << Size << "\n"; |
4644 | 4638 |
4645 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4639 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
4646 } | 4640 } |
4647 | 4641 |
| 4642 void |
| 4643 TargetGlobalX8632::lowerInitELF(const VariableDeclarationList &Vars) const { |
| 4644 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 4645 Writer->writeDataSection(Vars, llvm::ELF::R_386_32); |
| 4646 } |
| 4647 |
4648 template <typename T> struct PoolTypeConverter {}; | 4648 template <typename T> struct PoolTypeConverter {}; |
4649 | 4649 |
4650 template <> struct PoolTypeConverter<float> { | 4650 template <> struct PoolTypeConverter<float> { |
4651 typedef uint32_t PrimitiveIntType; | 4651 typedef uint32_t PrimitiveIntType; |
4652 typedef ConstantFloat IceType; | 4652 typedef ConstantFloat IceType; |
4653 static const Type Ty = IceType_f32; | 4653 static const Type Ty = IceType_f32; |
4654 static const char *TypeName; | 4654 static const char *TypeName; |
4655 static const char *AsmTag; | 4655 static const char *AsmTag; |
4656 static const char *PrintfString; | 4656 static const char *PrintfString; |
4657 }; | 4657 }; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4711 Writer->writeConstantPool<ConstantFloat>(IceType_f32); | 4711 Writer->writeConstantPool<ConstantFloat>(IceType_f32); |
4712 Writer->writeConstantPool<ConstantDouble>(IceType_f64); | 4712 Writer->writeConstantPool<ConstantDouble>(IceType_f64); |
4713 } else { | 4713 } else { |
4714 OstreamLocker L(Ctx); | 4714 OstreamLocker L(Ctx); |
4715 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4715 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
4716 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4716 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
4717 } | 4717 } |
4718 } | 4718 } |
4719 | 4719 |
4720 } // end of namespace Ice | 4720 } // end of namespace Ice |
OLD | NEW |