| 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 4999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5010 C->emitPoolLabel(Str); | 5010 C->emitPoolLabel(Str); |
| 5011 } | 5011 } |
| 5012 | 5012 |
| 5013 void TargetX8632::emit(const ConstantUndef *) const { | 5013 void TargetX8632::emit(const ConstantUndef *) const { |
| 5014 llvm::report_fatal_error("undef value encountered by emitter."); | 5014 llvm::report_fatal_error("undef value encountered by emitter."); |
| 5015 } | 5015 } |
| 5016 | 5016 |
| 5017 TargetDataX8632::TargetDataX8632(GlobalContext *Ctx) | 5017 TargetDataX8632::TargetDataX8632(GlobalContext *Ctx) |
| 5018 : TargetDataLowering(Ctx) {} | 5018 : TargetDataLowering(Ctx) {} |
| 5019 | 5019 |
| 5020 void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) const { | 5020 void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) { |
| 5021 // If external and not initialized, this must be a cross test. | 5021 // If external and not initialized, this must be a cross test. |
| 5022 // Don't generate a declaration for such cases. | 5022 // Don't generate a declaration for such cases. |
| 5023 bool IsExternal = Var.isExternal() || Ctx->getFlags().getDisableInternal(); | 5023 bool IsExternal = Var.isExternal() || Ctx->getFlags().getDisableInternal(); |
| 5024 if (IsExternal && !Var.hasInitializer()) | 5024 if (IsExternal && !Var.hasInitializer()) |
| 5025 return; | 5025 return; |
| 5026 | 5026 |
| 5027 Ostream &Str = Ctx->getStrEmit(); | 5027 Ostream &Str = Ctx->getStrEmit(); |
| 5028 const VariableDeclaration::InitializerListType &Initializers = | 5028 const VariableDeclaration::InitializerListType &Initializers = |
| 5029 Var.getInitializers(); | 5029 Var.getInitializers(); |
| 5030 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); | 5030 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5087 // NOTE: for non-constant zero initializers, this is BSS (no bits), | 5087 // NOTE: for non-constant zero initializers, this is BSS (no bits), |
| 5088 // so an ELF writer would not write to the file, and only track | 5088 // so an ELF writer would not write to the file, and only track |
| 5089 // virtual offsets, but the .s writer still needs this .zero and | 5089 // virtual offsets, but the .s writer still needs this .zero and |
| 5090 // cannot simply use the .size to advance offsets. | 5090 // cannot simply use the .size to advance offsets. |
| 5091 Str << "\t.zero\t" << Size << "\n"; | 5091 Str << "\t.zero\t" << Size << "\n"; |
| 5092 | 5092 |
| 5093 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 5093 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
| 5094 } | 5094 } |
| 5095 | 5095 |
| 5096 void TargetDataX8632::lowerGlobals( | 5096 void TargetDataX8632::lowerGlobals( |
| 5097 std::unique_ptr<VariableDeclarationList> Vars) const { | 5097 std::unique_ptr<VariableDeclarationList> Vars) { |
| 5098 switch (Ctx->getFlags().getOutFileType()) { | 5098 switch (Ctx->getFlags().getOutFileType()) { |
| 5099 case FT_Elf: { | 5099 case FT_Elf: { |
| 5100 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 5100 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 5101 Writer->writeDataSection(*Vars, llvm::ELF::R_386_32); | 5101 Writer->writeDataSection(*Vars, llvm::ELF::R_386_32); |
| 5102 } break; | 5102 } break; |
| 5103 case FT_Asm: | 5103 case FT_Asm: |
| 5104 case FT_Iasm: { | 5104 case FT_Iasm: { |
| 5105 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 5105 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
| 5106 OstreamLocker L(Ctx); | 5106 OstreamLocker L(Ctx); |
| 5107 for (const VariableDeclaration *Var : *Vars) { | 5107 for (const VariableDeclaration *Var : *Vars) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5163 snprintf(buf, llvm::array_lengthof(buf), T::PrintfString, RawValue); | 5163 snprintf(buf, llvm::array_lengthof(buf), T::PrintfString, RawValue); |
| 5164 assert(CharsPrinted >= 0 && | 5164 assert(CharsPrinted >= 0 && |
| 5165 (size_t)CharsPrinted < llvm::array_lengthof(buf)); | 5165 (size_t)CharsPrinted < llvm::array_lengthof(buf)); |
| 5166 (void)CharsPrinted; // avoid warnings if asserts are disabled | 5166 (void)CharsPrinted; // avoid warnings if asserts are disabled |
| 5167 Const->emitPoolLabel(Str); | 5167 Const->emitPoolLabel(Str); |
| 5168 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " | 5168 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " |
| 5169 << Value << "\n"; | 5169 << Value << "\n"; |
| 5170 } | 5170 } |
| 5171 } | 5171 } |
| 5172 | 5172 |
| 5173 void TargetDataX8632::lowerConstants() const { | 5173 void TargetDataX8632::lowerConstants() { |
| 5174 if (Ctx->getFlags().getDisableTranslation()) | 5174 if (Ctx->getFlags().getDisableTranslation()) |
| 5175 return; | 5175 return; |
| 5176 // No need to emit constants from the int pool since (for x86) they | 5176 // No need to emit constants from the int pool since (for x86) they |
| 5177 // are embedded as immediates in the instructions, just emit float/double. | 5177 // are embedded as immediates in the instructions, just emit float/double. |
| 5178 switch (Ctx->getFlags().getOutFileType()) { | 5178 switch (Ctx->getFlags().getOutFileType()) { |
| 5179 case FT_Elf: { | 5179 case FT_Elf: { |
| 5180 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 5180 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 5181 Writer->writeConstantPool<ConstantFloat>(IceType_f32); | 5181 Writer->writeConstantPool<ConstantFloat>(IceType_f32); |
| 5182 Writer->writeConstantPool<ConstantDouble>(IceType_f64); | 5182 Writer->writeConstantPool<ConstantDouble>(IceType_f64); |
| 5183 } break; | 5183 } break; |
| 5184 case FT_Asm: | 5184 case FT_Asm: |
| 5185 case FT_Iasm: { | 5185 case FT_Iasm: { |
| 5186 OstreamLocker L(Ctx); | 5186 OstreamLocker L(Ctx); |
| 5187 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 5187 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
| 5188 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 5188 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
| 5189 } break; | 5189 } break; |
| 5190 } | 5190 } |
| 5191 } | 5191 } |
| 5192 | 5192 |
| 5193 TargetHeaderX8632::TargetHeaderX8632(GlobalContext *Ctx) | 5193 TargetHeaderX8632::TargetHeaderX8632(GlobalContext *Ctx) |
| 5194 : TargetHeaderLowering(Ctx) {} | 5194 : TargetHeaderLowering(Ctx) {} |
| 5195 | 5195 |
| 5196 } // end of namespace Ice | 5196 } // end of namespace Ice |
| OLD | NEW |