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