OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// | 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// |
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 5866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5877 assert(Traits::Is64Bit); | 5877 assert(Traits::Is64Bit); |
5878 _mov(Index, RangeIndex); // trunc | 5878 _mov(Index, RangeIndex); // trunc |
5879 } else { | 5879 } else { |
5880 _movzx(Index, RangeIndex); | 5880 _movzx(Index, RangeIndex); |
5881 } | 5881 } |
5882 } else { | 5882 } else { |
5883 Index = legalizeToReg(RangeIndex); | 5883 Index = legalizeToReg(RangeIndex); |
5884 } | 5884 } |
5885 | 5885 |
5886 constexpr RelocOffsetT RelocOffset = 0; | 5886 constexpr RelocOffsetT RelocOffset = 0; |
5887 GlobalString FunctionName = Func->getFunctionName(); | |
5888 constexpr Variable *NoBase = nullptr; | 5887 constexpr Variable *NoBase = nullptr; |
5889 auto JTName = GlobalString::createWithString( | 5888 auto JTName = GlobalString::createWithString(Ctx, JumpTable->getName()); |
5890 Ctx, InstJumpTable::makeName(FunctionName, JumpTable->getId())); | |
5891 Constant *Offset = Ctx->getConstantSym(RelocOffset, JTName); | 5889 Constant *Offset = Ctx->getConstantSym(RelocOffset, JTName); |
5892 uint16_t Shift = typeWidthInBytesLog2(PointerType); | 5890 uint16_t Shift = typeWidthInBytesLog2(PointerType); |
5893 constexpr auto Segment = X86OperandMem::SegmentRegisters::DefaultSegment; | 5891 constexpr auto Segment = X86OperandMem::SegmentRegisters::DefaultSegment; |
5894 | 5892 |
5895 Variable *Target = nullptr; | 5893 Variable *Target = nullptr; |
5896 if (Traits::Is64Bit && NeedSandboxing) { | 5894 if (Traits::Is64Bit && NeedSandboxing) { |
5897 assert(Index != nullptr && Index->getType() == IceType_i32); | 5895 assert(Index != nullptr && Index->getType() == IceType_i32); |
5898 } | 5896 } |
5899 auto *TargetInMemory = X86OperandMem::create(Func, PointerType, NoBase, | 5897 auto *TargetInMemory = X86OperandMem::create(Func, PointerType, NoBase, |
5900 Offset, Index, Shift, Segment); | 5898 Offset, Index, Shift, Segment); |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7283 const Cfg *Func, const InstJumpTable *JumpTable) const { | 7281 const Cfg *Func, const InstJumpTable *JumpTable) const { |
7284 if (!BuildDefs::dump()) | 7282 if (!BuildDefs::dump()) |
7285 return; | 7283 return; |
7286 Ostream &Str = Ctx->getStrEmit(); | 7284 Ostream &Str = Ctx->getStrEmit(); |
7287 const bool UseNonsfi = Ctx->getFlags().getUseNonsfi(); | 7285 const bool UseNonsfi = Ctx->getFlags().getUseNonsfi(); |
7288 GlobalString FunctionName = Func->getFunctionName(); | 7286 GlobalString FunctionName = Func->getFunctionName(); |
7289 const char *Prefix = UseNonsfi ? ".data.rel.ro." : ".rodata."; | 7287 const char *Prefix = UseNonsfi ? ".data.rel.ro." : ".rodata."; |
7290 Str << "\t.section\t" << Prefix << FunctionName | 7288 Str << "\t.section\t" << Prefix << FunctionName |
7291 << "$jumptable,\"a\",@progbits\n"; | 7289 << "$jumptable,\"a\",@progbits\n"; |
7292 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; | 7290 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; |
7293 Str << InstJumpTable::makeName(FunctionName, JumpTable->getId()) << ":"; | 7291 Str << JumpTable->getName() << ":"; |
7294 | 7292 |
7295 // On X86 ILP32 pointers are 32-bit hence the use of .long | 7293 // On X86 ILP32 pointers are 32-bit hence the use of .long |
7296 for (SizeT I = 0; I < JumpTable->getNumTargets(); ++I) | 7294 for (SizeT I = 0; I < JumpTable->getNumTargets(); ++I) |
7297 Str << "\n\t.long\t" << JumpTable->getTarget(I)->getAsmName(); | 7295 Str << "\n\t.long\t" << JumpTable->getTarget(I)->getAsmName(); |
7298 Str << "\n"; | 7296 Str << "\n"; |
7299 } | 7297 } |
7300 | 7298 |
7301 template <typename TraitsType> | 7299 template <typename TraitsType> |
7302 template <typename T> | 7300 template <typename T> |
7303 void TargetDataX86<TraitsType>::emitConstantPool(GlobalContext *Ctx) { | 7301 void TargetDataX86<TraitsType>::emitConstantPool(GlobalContext *Ctx) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7385 } break; | 7383 } break; |
7386 case FT_Asm: | 7384 case FT_Asm: |
7387 // Already emitted from Cfg | 7385 // Already emitted from Cfg |
7388 break; | 7386 break; |
7389 case FT_Iasm: { | 7387 case FT_Iasm: { |
7390 if (!BuildDefs::dump()) | 7388 if (!BuildDefs::dump()) |
7391 return; | 7389 return; |
7392 Ostream &Str = Ctx->getStrEmit(); | 7390 Ostream &Str = Ctx->getStrEmit(); |
7393 const char *Prefix = IsPIC ? ".data.rel.ro." : ".rodata."; | 7391 const char *Prefix = IsPIC ? ".data.rel.ro." : ".rodata."; |
7394 for (const JumpTableData &JT : Ctx->getJumpTables()) { | 7392 for (const JumpTableData &JT : Ctx->getJumpTables()) { |
7395 Str << "\t.section\t" << Prefix << JT.getFunctionName() | 7393 Str << "\t.section\t" << Prefix << JT.getSectionName() |
7396 << "$jumptable,\"a\",@progbits\n"; | 7394 << ",\"a\",@progbits\n"; |
7397 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; | 7395 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; |
7398 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; | 7396 Str << JT.getName().toString() << ":"; |
7399 | 7397 |
7400 // On X8664 ILP32 pointers are 32-bit hence the use of .long | 7398 // On X8664 ILP32 pointers are 32-bit hence the use of .long |
7401 for (intptr_t TargetOffset : JT.getTargetOffsets()) | 7399 for (intptr_t TargetOffset : JT.getTargetOffsets()) |
7402 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; | 7400 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; |
7403 Str << "\n"; | 7401 Str << "\n"; |
7404 } | 7402 } |
7405 } break; | 7403 } break; |
7406 } | 7404 } |
7407 } | 7405 } |
7408 | 7406 |
(...skipping 15 matching lines...) Expand all Loading... |
7424 emitGlobal(*Var, SectionSuffix); | 7422 emitGlobal(*Var, SectionSuffix); |
7425 } | 7423 } |
7426 } | 7424 } |
7427 } break; | 7425 } break; |
7428 } | 7426 } |
7429 } | 7427 } |
7430 } // end of namespace X86NAMESPACE | 7428 } // end of namespace X86NAMESPACE |
7431 } // end of namespace Ice | 7429 } // end of namespace Ice |
7432 | 7430 |
7433 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 7431 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
OLD | NEW |