| 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 /// \file | 10 /// \file |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 static const Type Ty = IceType_i8; | 144 static const Type Ty = IceType_i8; |
| 145 static const char *TypeName; | 145 static const char *TypeName; |
| 146 static const char *AsmTag; | 146 static const char *AsmTag; |
| 147 static const char *PrintfString; | 147 static const char *PrintfString; |
| 148 }; | 148 }; |
| 149 const char *PoolTypeConverter<uint8_t>::TypeName = "i8"; | 149 const char *PoolTypeConverter<uint8_t>::TypeName = "i8"; |
| 150 const char *PoolTypeConverter<uint8_t>::AsmTag = ".byte"; | 150 const char *PoolTypeConverter<uint8_t>::AsmTag = ".byte"; |
| 151 const char *PoolTypeConverter<uint8_t>::PrintfString = "0x%x"; | 151 const char *PoolTypeConverter<uint8_t>::PrintfString = "0x%x"; |
| 152 } // end of anonymous namespace | 152 } // end of anonymous namespace |
| 153 | 153 |
| 154 void TargetX8632::emitJumpTable(const Cfg *Func, |
| 155 const InstJumpTable *JumpTable) const { |
| 156 if (!BuildDefs::dump()) |
| 157 return; |
| 158 Ostream &Str = Ctx->getStrEmit(); |
| 159 IceString MangledName = Ctx->mangleName(Func->getFunctionName()); |
| 160 Str << "\t.section\t.rodata." << MangledName |
| 161 << "$jumptable,\"a\",@progbits\n"; |
| 162 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; |
| 163 Str << InstJumpTable::makeName(MangledName, JumpTable->getId()) << ":"; |
| 164 |
| 165 // On X8632 pointers are 32-bit hence the use of .long |
| 166 for (SizeT I = 0; I < JumpTable->getNumTargets(); ++I) |
| 167 Str << "\n\t.long\t" << JumpTable->getTarget(I)->getAsmName(); |
| 168 Str << "\n"; |
| 169 } |
| 170 |
| 154 template <typename T> | 171 template <typename T> |
| 155 void TargetDataX8632::emitConstantPool(GlobalContext *Ctx) { | 172 void TargetDataX8632::emitConstantPool(GlobalContext *Ctx) { |
| 156 if (!BuildDefs::dump()) | 173 if (!BuildDefs::dump()) |
| 157 return; | 174 return; |
| 158 Ostream &Str = Ctx->getStrEmit(); | 175 Ostream &Str = Ctx->getStrEmit(); |
| 159 Type Ty = T::Ty; | 176 Type Ty = T::Ty; |
| 160 SizeT Align = typeAlignInBytes(Ty); | 177 SizeT Align = typeAlignInBytes(Ty); |
| 161 ConstantList Pool = Ctx->getConstantPool(Ty); | 178 ConstantList Pool = Ctx->getConstantPool(Ty); |
| 162 | 179 |
| 163 Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align | 180 Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 emitConstantPool<PoolTypeConverter<uint8_t>>(Ctx); | 232 emitConstantPool<PoolTypeConverter<uint8_t>>(Ctx); |
| 216 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); | 233 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); |
| 217 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); | 234 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); |
| 218 | 235 |
| 219 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 236 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
| 220 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 237 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
| 221 } break; | 238 } break; |
| 222 } | 239 } |
| 223 } | 240 } |
| 224 | 241 |
| 242 void TargetDataX8632::lowerJumpTables() { |
| 243 switch (Ctx->getFlags().getOutFileType()) { |
| 244 case FT_Elf: { |
| 245 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 246 for (const JumpTableData &JumpTable : *Ctx->getJumpTables()) |
| 247 Writer->writeJumpTable(JumpTable, llvm::ELF::R_386_32); |
| 248 } break; |
| 249 case FT_Asm: |
| 250 // Already emitted from Cfg |
| 251 break; |
| 252 case FT_Iasm: { |
| 253 if (!BuildDefs::dump()) |
| 254 return; |
| 255 Ostream &Str = Ctx->getStrEmit(); |
| 256 for (const JumpTableData &JT : *Ctx->getJumpTables()) { |
| 257 Str << "\t.section\t.rodata." << JT.getFunctionName() |
| 258 << "$jumptable,\"a\",@progbits\n"; |
| 259 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; |
| 260 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; |
| 261 |
| 262 // On X8632 pointers are 32-bit hence the use of .long |
| 263 for (intptr_t TargetOffset : JT.getTargetOffsets()) |
| 264 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; |
| 265 Str << "\n"; |
| 266 } |
| 267 } break; |
| 268 } |
| 269 } |
| 270 |
| 225 void TargetDataX8632::lowerGlobals(const VariableDeclarationList &Vars, | 271 void TargetDataX8632::lowerGlobals(const VariableDeclarationList &Vars, |
| 226 const IceString &SectionSuffix) { | 272 const IceString &SectionSuffix) { |
| 227 switch (Ctx->getFlags().getOutFileType()) { | 273 switch (Ctx->getFlags().getOutFileType()) { |
| 228 case FT_Elf: { | 274 case FT_Elf: { |
| 229 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 275 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
| 230 Writer->writeDataSection(Vars, llvm::ELF::R_386_32, SectionSuffix); | 276 Writer->writeDataSection(Vars, llvm::ELF::R_386_32, SectionSuffix); |
| 231 } break; | 277 } break; |
| 232 case FT_Asm: | 278 case FT_Asm: |
| 233 case FT_Iasm: { | 279 case FT_Iasm: { |
| 234 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 280 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // entries in case the high-level table has extra entries. | 393 // entries in case the high-level table has extra entries. |
| 348 #define X(tag, sizeLog2, align, elts, elty, str) \ | 394 #define X(tag, sizeLog2, align, elts, elty, str) \ |
| 349 static_assert(_table1_##tag == _table2_##tag, \ | 395 static_assert(_table1_##tag == _table2_##tag, \ |
| 350 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 396 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
| 351 ICETYPE_TABLE | 397 ICETYPE_TABLE |
| 352 #undef X | 398 #undef X |
| 353 } // end of namespace dummy3 | 399 } // end of namespace dummy3 |
| 354 } // end of anonymous namespace | 400 } // end of anonymous namespace |
| 355 | 401 |
| 356 } // end of namespace Ice | 402 } // end of namespace Ice |
| OLD | NEW |