Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2443)

Side by Side Diff: src/IceTargetLoweringX8664.cpp

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Refactor the link commands Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::FK_PcRel;
105
106 template <>
107 FixupKind TargetX86Base<TargetX8664>::AbsFixup =
108 TargetX86Base<TargetX8664>::Traits::FK_Abs;
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 _movp(Dest, ReturnReg); 338 _movp(Dest, ReturnReg);
331 } else { 339 } else {
332 assert(isScalarFloatingType(Dest->getType()) || 340 assert(isScalarFloatingType(Dest->getType()) ||
333 isScalarIntegerType(Dest->getType())); 341 isScalarIntegerType(Dest->getType()));
334 _mov(Dest, ReturnReg); 342 _mov(Dest, ReturnReg);
335 } 343 }
336 } 344 }
337 345
338 void TargetX8664::lowerArguments() { 346 void TargetX8664::lowerArguments() {
339 VarList &Args = Func->getArgs(); 347 VarList &Args = Func->getArgs();
340 // The first eight vetcor typed arguments (as well as fp arguments) are 348 // The first eight vector typed arguments (as well as fp arguments) are
341 // passed in %xmm0 through %xmm7 regardless of their position in the argument 349 // passed in %xmm0 through %xmm7 regardless of their position in the argument
342 // list. 350 // list.
343 unsigned NumXmmArgs = 0; 351 unsigned NumXmmArgs = 0;
344 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx, 352 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx,
345 // %rcx, %r8, and %r9 regardless of their position in the argument list. 353 // %rcx, %r8, and %r9 regardless of their position in the argument list.
346 unsigned NumGprArgs = 0; 354 unsigned NumGprArgs = 0;
347 355
348 Context.init(Func->getEntryNode()); 356 Context.init(Func->getEntryNode());
349 Context.setInsertPoint(Context.getCur()); 357 Context.setInsertPoint(Context.getCur());
350 358
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); 880 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx);
873 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); 881 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx);
874 882
875 emitConstantPool<PoolTypeConverter<float>>(Ctx); 883 emitConstantPool<PoolTypeConverter<float>>(Ctx);
876 emitConstantPool<PoolTypeConverter<double>>(Ctx); 884 emitConstantPool<PoolTypeConverter<double>>(Ctx);
877 } break; 885 } break;
878 } 886 }
879 } 887 }
880 888
881 void TargetDataX8664::lowerJumpTables() { 889 void TargetDataX8664::lowerJumpTables() {
890 const bool IsPIC = Ctx->getFlags().getUseNonsfi();
882 switch (Ctx->getFlags().getOutFileType()) { 891 switch (Ctx->getFlags().getOutFileType()) {
883 case FT_Elf: { 892 case FT_Elf: {
884 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 893 ELFObjectWriter *Writer = Ctx->getObjectWriter();
885 for (const JumpTableData &JumpTable : Ctx->getJumpTables()) 894 for (const JumpTableData &JumpTable : Ctx->getJumpTables())
886 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::RelFixup); 895 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::FK_Abs, IsPIC);
887 } break; 896 } break;
888 case FT_Asm: 897 case FT_Asm:
889 // Already emitted from Cfg 898 // Already emitted from Cfg
890 break; 899 break;
891 case FT_Iasm: { 900 case FT_Iasm: {
892 if (!BuildDefs::dump()) 901 if (!BuildDefs::dump())
893 return; 902 return;
894 Ostream &Str = Ctx->getStrEmit(); 903 Ostream &Str = Ctx->getStrEmit();
895 for (const JumpTableData &JT : Ctx->getJumpTables()) { 904 for (const JumpTableData &JT : Ctx->getJumpTables()) {
896 Str << "\t.section\t.rodata." << JT.getFunctionName() 905 Str << "\t.section\t.rodata." << JT.getFunctionName()
897 << "$jumptable,\"a\",@progbits\n"; 906 << "$jumptable,\"a\",@progbits\n";
898 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; 907 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n";
899 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; 908 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":";
900 909
901 // On X8664 ILP32 pointers are 32-bit hence the use of .long 910 // On X8664 ILP32 pointers are 32-bit hence the use of .long
902 for (intptr_t TargetOffset : JT.getTargetOffsets()) 911 for (intptr_t TargetOffset : JT.getTargetOffsets())
903 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; 912 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset;
904 Str << "\n"; 913 Str << "\n";
905 } 914 }
906 } break; 915 } break;
907 } 916 }
908 } 917 }
909 918
910 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars, 919 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars,
911 const IceString &SectionSuffix) { 920 const IceString &SectionSuffix) {
921 const bool IsPIC = Ctx->getFlags().getUseNonsfi();
912 switch (Ctx->getFlags().getOutFileType()) { 922 switch (Ctx->getFlags().getOutFileType()) {
913 case FT_Elf: { 923 case FT_Elf: {
914 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 924 ELFObjectWriter *Writer = Ctx->getObjectWriter();
915 Writer->writeDataSection(Vars, TargetX8664::Traits::RelFixup, 925 Writer->writeDataSection(Vars, TargetX8664::Traits::FK_Abs, SectionSuffix,
916 SectionSuffix); 926 IsPIC);
917 } break; 927 } break;
918 case FT_Asm: 928 case FT_Asm:
919 case FT_Iasm: { 929 case FT_Iasm: {
920 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); 930 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly();
921 OstreamLocker L(Ctx); 931 OstreamLocker L(Ctx);
922 for (const VariableDeclaration *Var : Vars) { 932 for (const VariableDeclaration *Var : Vars) {
923 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { 933 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) {
924 emitGlobal(*Var, SectionSuffix); 934 emitGlobal(*Var, SectionSuffix);
925 } 935 }
926 } 936 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // case the high-level table has extra entries. 1036 // case the high-level table has extra entries.
1027 #define X(tag, sizeLog2, align, elts, elty, str) \ 1037 #define X(tag, sizeLog2, align, elts, elty, str) \
1028 static_assert(_table1_##tag == _table2_##tag, \ 1038 static_assert(_table1_##tag == _table2_##tag, \
1029 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE"); 1039 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE");
1030 ICETYPE_TABLE 1040 ICETYPE_TABLE
1031 #undef X 1041 #undef X
1032 } // end of namespace dummy3 1042 } // end of namespace dummy3
1033 } // end of anonymous namespace 1043 } // end of anonymous namespace
1034 1044
1035 } // end of namespace Ice 1045 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698