OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8664.cpp - x86-64 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8664.cpp - x86-64 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 template <> | 93 template <> |
94 std::array<llvm::SmallBitVector, | 94 std::array<llvm::SmallBitVector, |
95 TargetX86Base<TargetX8664>::Traits::RegisterSet::Reg_NUM> | 95 TargetX86Base<TargetX8664>::Traits::RegisterSet::Reg_NUM> |
96 TargetX86Base<TargetX8664>::RegisterAliases = {{}}; | 96 TargetX86Base<TargetX8664>::RegisterAliases = {{}}; |
97 | 97 |
98 template <> | 98 template <> |
99 llvm::SmallBitVector | 99 llvm::SmallBitVector |
100 TargetX86Base<TargetX8664>::ScratchRegs = llvm::SmallBitVector(); | 100 TargetX86Base<TargetX8664>::ScratchRegs = llvm::SmallBitVector(); |
101 | 101 |
| 102 template <> |
| 103 FixupKind TargetX86Base<TargetX8664>::PcRelFixup = |
| 104 TargetX86Base<TargetX8664>::Traits::FixupKindPcRel; |
| 105 |
| 106 template <> |
| 107 FixupKind TargetX86Base<TargetX8664>::RelFixup = |
| 108 TargetX86Base<TargetX8664>::Traits::FixupKindAbs; |
| 109 |
102 } // end of namespace X86Internal | 110 } // end of namespace X86Internal |
103 | 111 |
104 //------------------------------------------------------------------------------ | 112 //------------------------------------------------------------------------------ |
105 // __ ______ __ __ ______ ______ __ __ __ ______ | 113 // __ ______ __ __ ______ ______ __ __ __ ______ |
106 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ | 114 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ |
107 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ | 115 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ |
108 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ | 116 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ |
109 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ | 117 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ |
110 // | 118 // |
111 //------------------------------------------------------------------------------ | 119 //------------------------------------------------------------------------------ |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 _movp(Dest, ReturnReg); | 309 _movp(Dest, ReturnReg); |
302 } else { | 310 } else { |
303 assert(isScalarFloatingType(Dest->getType()) || | 311 assert(isScalarFloatingType(Dest->getType()) || |
304 isScalarIntegerType(Dest->getType())); | 312 isScalarIntegerType(Dest->getType())); |
305 _mov(Dest, ReturnReg); | 313 _mov(Dest, ReturnReg); |
306 } | 314 } |
307 } | 315 } |
308 | 316 |
309 void TargetX8664::lowerArguments() { | 317 void TargetX8664::lowerArguments() { |
310 VarList &Args = Func->getArgs(); | 318 VarList &Args = Func->getArgs(); |
311 // The first eight vetcor typed arguments (as well as fp arguments) are | 319 // The first eight vector typed arguments (as well as fp arguments) are |
312 // passed in %xmm0 through %xmm7 regardless of their position in the argument | 320 // passed in %xmm0 through %xmm7 regardless of their position in the argument |
313 // list. | 321 // list. |
314 unsigned NumXmmArgs = 0; | 322 unsigned NumXmmArgs = 0; |
315 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx, | 323 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx, |
316 // %rcx, %r8, and %r9 regardless of their position in the argument list. | 324 // %rcx, %r8, and %r9 regardless of their position in the argument list. |
317 unsigned NumGprArgs = 0; | 325 unsigned NumGprArgs = 0; |
318 | 326 |
319 Context.init(Func->getEntryNode()); | 327 Context.init(Func->getEntryNode()); |
320 Context.setInsertPoint(Context.getCur()); | 328 Context.setInsertPoint(Context.getCur()); |
321 | 329 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); | 831 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); |
824 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); | 832 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); |
825 | 833 |
826 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 834 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
827 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 835 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
828 } break; | 836 } break; |
829 } | 837 } |
830 } | 838 } |
831 | 839 |
832 void TargetDataX8664::lowerJumpTables() { | 840 void TargetDataX8664::lowerJumpTables() { |
| 841 const bool IsPIC = Ctx->getFlags().getUseNonsfi(); |
833 switch (Ctx->getFlags().getOutFileType()) { | 842 switch (Ctx->getFlags().getOutFileType()) { |
834 case FT_Elf: { | 843 case FT_Elf: { |
835 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 844 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
836 for (const JumpTableData &JumpTable : Ctx->getJumpTables()) | 845 for (const JumpTableData &JumpTable : Ctx->getJumpTables()) |
837 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::RelFixup); | 846 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::FixupKindAbs, |
| 847 IsPIC); |
838 } break; | 848 } break; |
839 case FT_Asm: | 849 case FT_Asm: |
840 // Already emitted from Cfg | 850 // Already emitted from Cfg |
841 break; | 851 break; |
842 case FT_Iasm: { | 852 case FT_Iasm: { |
843 if (!BuildDefs::dump()) | 853 if (!BuildDefs::dump()) |
844 return; | 854 return; |
845 Ostream &Str = Ctx->getStrEmit(); | 855 Ostream &Str = Ctx->getStrEmit(); |
846 for (const JumpTableData &JT : Ctx->getJumpTables()) { | 856 for (const JumpTableData &JT : Ctx->getJumpTables()) { |
847 Str << "\t.section\t.rodata." << JT.getFunctionName() | 857 Str << "\t.section\t.rodata." << JT.getFunctionName() |
848 << "$jumptable,\"a\",@progbits\n"; | 858 << "$jumptable,\"a\",@progbits\n"; |
849 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; | 859 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; |
850 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; | 860 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; |
851 | 861 |
852 // On X8664 ILP32 pointers are 32-bit hence the use of .long | 862 // On X8664 ILP32 pointers are 32-bit hence the use of .long |
853 for (intptr_t TargetOffset : JT.getTargetOffsets()) | 863 for (intptr_t TargetOffset : JT.getTargetOffsets()) |
854 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; | 864 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; |
855 Str << "\n"; | 865 Str << "\n"; |
856 } | 866 } |
857 } break; | 867 } break; |
858 } | 868 } |
859 } | 869 } |
860 | 870 |
861 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars, | 871 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars, |
862 const IceString &SectionSuffix) { | 872 const IceString &SectionSuffix) { |
| 873 const bool IsPIC = Ctx->getFlags().getUseNonsfi(); |
863 switch (Ctx->getFlags().getOutFileType()) { | 874 switch (Ctx->getFlags().getOutFileType()) { |
864 case FT_Elf: { | 875 case FT_Elf: { |
865 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 876 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
866 Writer->writeDataSection(Vars, TargetX8664::Traits::RelFixup, | 877 Writer->writeDataSection(Vars, TargetX8664::Traits::FixupKindAbs, |
867 SectionSuffix); | 878 SectionSuffix, IsPIC); |
868 } break; | 879 } break; |
869 case FT_Asm: | 880 case FT_Asm: |
870 case FT_Iasm: { | 881 case FT_Iasm: { |
871 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 882 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
872 OstreamLocker L(Ctx); | 883 OstreamLocker L(Ctx); |
873 for (const VariableDeclaration *Var : Vars) { | 884 for (const VariableDeclaration *Var : Vars) { |
874 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { | 885 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { |
875 emitGlobal(*Var, SectionSuffix); | 886 emitGlobal(*Var, SectionSuffix); |
876 } | 887 } |
877 } | 888 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 // case the high-level table has extra entries. | 988 // case the high-level table has extra entries. |
978 #define X(tag, sizeLog2, align, elts, elty, str) \ | 989 #define X(tag, sizeLog2, align, elts, elty, str) \ |
979 static_assert(_table1_##tag == _table2_##tag, \ | 990 static_assert(_table1_##tag == _table2_##tag, \ |
980 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE"); | 991 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE"); |
981 ICETYPE_TABLE | 992 ICETYPE_TABLE |
982 #undef X | 993 #undef X |
983 } // end of namespace dummy3 | 994 } // end of namespace dummy3 |
984 } // end of anonymous namespace | 995 } // end of anonymous namespace |
985 | 996 |
986 } // end of namespace Ice | 997 } // end of namespace Ice |
OLD | NEW |