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

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: Code review changes 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
« no previous file with comments | « src/IceTargetLoweringX8632Traits.h ('k') | src/IceTargetLoweringX8664Traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 std::unique_ptr<::Ice::TargetDataLowering> 25 std::unique_ptr<::Ice::TargetDataLowering>
26 createTargetDataLowering(::Ice::GlobalContext *Ctx) { 26 createTargetDataLowering(::Ice::GlobalContext *Ctx) {
27 return ::Ice::X8664::TargetDataX8664::create(Ctx); 27 return ::Ice::X8664::TargetDataX8664::create(Ctx);
28 } 28 }
29 29
30 std::unique_ptr<::Ice::TargetHeaderLowering> 30 std::unique_ptr<::Ice::TargetHeaderLowering>
31 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) { 31 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) {
32 return ::Ice::X8664::TargetHeaderX8664::create(Ctx); 32 return ::Ice::X8664::TargetHeaderX8664::create(Ctx);
33 } 33 }
34 34
35 void staticInit() { ::Ice::X8664::TargetX8664::staticInit(); } 35 void staticInit(const ::Ice::ClFlags &Flags) {
36 ::Ice::X8664::TargetX8664::staticInit(Flags);
37 }
36 } // end of namespace X8664 38 } // end of namespace X8664
37 39
38 namespace Ice { 40 namespace Ice {
39 namespace X8664 { 41 namespace X8664 {
40 42
41 //------------------------------------------------------------------------------ 43 //------------------------------------------------------------------------------
42 // ______ ______ ______ __ ______ ______ 44 // ______ ______ ______ __ ______ ______
43 // /\__ _\ /\ == \ /\ __ \ /\ \ /\__ _\ /\ ___\ 45 // /\__ _\ /\ == \ /\ __ \ /\ \ /\__ _\ /\ ___\
44 // \/_/\ \/ \ \ __< \ \ __ \ \ \ \ \/_/\ \/ \ \___ \ 46 // \/_/\ \/ \ \ __< \ \ __ \ \ \ \ \/_/\ \/ \ \___ \
45 // \ \_\ \ \_\ \_\ \ \_\ \_\ \ \_\ \ \_\ \/\_____\ 47 // \ \_\ \ \_\ \_\ \ \_\ \_\ \ \_\ \ \_\ \/\_____\
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 107
106 template <> 108 template <>
107 std::array<llvm::SmallBitVector, 109 std::array<llvm::SmallBitVector,
108 TargetX86Base<X8664::Traits>::Traits::RegisterSet::Reg_NUM> 110 TargetX86Base<X8664::Traits>::Traits::RegisterSet::Reg_NUM>
109 TargetX86Base<X8664::Traits>::RegisterAliases = {{}}; 111 TargetX86Base<X8664::Traits>::RegisterAliases = {{}};
110 112
111 template <> 113 template <>
112 llvm::SmallBitVector 114 llvm::SmallBitVector
113 TargetX86Base<X8664::Traits>::ScratchRegs = llvm::SmallBitVector(); 115 TargetX86Base<X8664::Traits>::ScratchRegs = llvm::SmallBitVector();
114 116
117 template <>
118 FixupKind TargetX86Base<X8664::Traits>::PcRelFixup =
119 TargetX86Base<X8664::Traits>::Traits::FK_PcRel;
120
121 template <>
122 FixupKind TargetX86Base<X8664::Traits>::AbsFixup =
123 TargetX86Base<X8664::Traits>::Traits::FK_Abs;
124
115 //------------------------------------------------------------------------------ 125 //------------------------------------------------------------------------------
116 // __ ______ __ __ ______ ______ __ __ __ ______ 126 // __ ______ __ __ ______ ______ __ __ __ ______
117 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ 127 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\
118 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ 128 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \
119 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ 129 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\
120 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ 130 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/
121 // 131 //
122 //------------------------------------------------------------------------------ 132 //------------------------------------------------------------------------------
123 namespace { 133 namespace {
124 static inline TargetX8664::Traits::RegisterSet::AllRegisters 134 static inline TargetX8664::Traits::RegisterSet::AllRegisters
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 _movp(Dest, ReturnReg); 351 _movp(Dest, ReturnReg);
342 } else { 352 } else {
343 assert(isScalarFloatingType(Dest->getType()) || 353 assert(isScalarFloatingType(Dest->getType()) ||
344 isScalarIntegerType(Dest->getType())); 354 isScalarIntegerType(Dest->getType()));
345 _mov(Dest, ReturnReg); 355 _mov(Dest, ReturnReg);
346 } 356 }
347 } 357 }
348 358
349 void TargetX8664::lowerArguments() { 359 void TargetX8664::lowerArguments() {
350 VarList &Args = Func->getArgs(); 360 VarList &Args = Func->getArgs();
351 // The first eight vetcor typed arguments (as well as fp arguments) are 361 // The first eight vector typed arguments (as well as fp arguments) are
352 // passed in %xmm0 through %xmm7 regardless of their position in the argument 362 // passed in %xmm0 through %xmm7 regardless of their position in the argument
353 // list. 363 // list.
354 unsigned NumXmmArgs = 0; 364 unsigned NumXmmArgs = 0;
355 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx, 365 // The first six integer typed arguments are passed in %rdi, %rsi, %rdx,
356 // %rcx, %r8, and %r9 regardless of their position in the argument list. 366 // %rcx, %r8, and %r9 regardless of their position in the argument list.
357 unsigned NumGprArgs = 0; 367 unsigned NumGprArgs = 0;
358 368
359 Context.init(Func->getEntryNode()); 369 Context.init(Func->getEntryNode());
360 Context.setInsertPoint(Context.getCur()); 370 Context.setInsertPoint(Context.getCur());
361 371
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx); 893 emitConstantPool<PoolTypeConverter<uint16_t>>(Ctx);
884 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx); 894 emitConstantPool<PoolTypeConverter<uint32_t>>(Ctx);
885 895
886 emitConstantPool<PoolTypeConverter<float>>(Ctx); 896 emitConstantPool<PoolTypeConverter<float>>(Ctx);
887 emitConstantPool<PoolTypeConverter<double>>(Ctx); 897 emitConstantPool<PoolTypeConverter<double>>(Ctx);
888 } break; 898 } break;
889 } 899 }
890 } 900 }
891 901
892 void TargetDataX8664::lowerJumpTables() { 902 void TargetDataX8664::lowerJumpTables() {
903 const bool IsPIC = Ctx->getFlags().getUseNonsfi();
893 switch (Ctx->getFlags().getOutFileType()) { 904 switch (Ctx->getFlags().getOutFileType()) {
894 case FT_Elf: { 905 case FT_Elf: {
895 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 906 ELFObjectWriter *Writer = Ctx->getObjectWriter();
896 for (const JumpTableData &JumpTable : Ctx->getJumpTables()) 907 for (const JumpTableData &JumpTable : Ctx->getJumpTables())
897 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::RelFixup); 908 Writer->writeJumpTable(JumpTable, TargetX8664::Traits::FK_Abs, IsPIC);
898 } break; 909 } break;
899 case FT_Asm: 910 case FT_Asm:
900 // Already emitted from Cfg 911 // Already emitted from Cfg
901 break; 912 break;
902 case FT_Iasm: { 913 case FT_Iasm: {
903 if (!BuildDefs::dump()) 914 if (!BuildDefs::dump())
904 return; 915 return;
905 Ostream &Str = Ctx->getStrEmit(); 916 Ostream &Str = Ctx->getStrEmit();
906 for (const JumpTableData &JT : Ctx->getJumpTables()) { 917 for (const JumpTableData &JT : Ctx->getJumpTables()) {
907 Str << "\t.section\t.rodata." << JT.getFunctionName() 918 Str << "\t.section\t.rodata." << JT.getFunctionName()
908 << "$jumptable,\"a\",@progbits\n"; 919 << "$jumptable,\"a\",@progbits\n";
909 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n"; 920 Str << "\t.align\t" << typeWidthInBytes(getPointerType()) << "\n";
910 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":"; 921 Str << InstJumpTable::makeName(JT.getFunctionName(), JT.getId()) << ":";
911 922
912 // On X8664 ILP32 pointers are 32-bit hence the use of .long 923 // On X8664 ILP32 pointers are 32-bit hence the use of .long
913 for (intptr_t TargetOffset : JT.getTargetOffsets()) 924 for (intptr_t TargetOffset : JT.getTargetOffsets())
914 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset; 925 Str << "\n\t.long\t" << JT.getFunctionName() << "+" << TargetOffset;
915 Str << "\n"; 926 Str << "\n";
916 } 927 }
917 } break; 928 } break;
918 } 929 }
919 } 930 }
920 931
921 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars, 932 void TargetDataX8664::lowerGlobals(const VariableDeclarationList &Vars,
922 const IceString &SectionSuffix) { 933 const IceString &SectionSuffix) {
934 const bool IsPIC = Ctx->getFlags().getUseNonsfi();
923 switch (Ctx->getFlags().getOutFileType()) { 935 switch (Ctx->getFlags().getOutFileType()) {
924 case FT_Elf: { 936 case FT_Elf: {
925 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 937 ELFObjectWriter *Writer = Ctx->getObjectWriter();
926 Writer->writeDataSection(Vars, TargetX8664::Traits::RelFixup, 938 Writer->writeDataSection(Vars, TargetX8664::Traits::FK_Abs, SectionSuffix,
927 SectionSuffix); 939 IsPIC);
928 } break; 940 } break;
929 case FT_Asm: 941 case FT_Asm:
930 case FT_Iasm: { 942 case FT_Iasm: {
931 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); 943 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly();
932 OstreamLocker L(Ctx); 944 OstreamLocker L(Ctx);
933 for (const VariableDeclaration *Var : Vars) { 945 for (const VariableDeclaration *Var : Vars) {
934 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { 946 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) {
935 emitGlobal(*Var, SectionSuffix); 947 emitGlobal(*Var, SectionSuffix);
936 } 948 }
937 } 949 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 #define X(tag, sizeLog2, align, elts, elty, str) \ 1050 #define X(tag, sizeLog2, align, elts, elty, str) \
1039 static_assert(_table1_##tag == _table2_##tag, \ 1051 static_assert(_table1_##tag == _table2_##tag, \
1040 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE"); 1052 "Inconsistency between ICETYPEX8664_TABLE and ICETYPE_TABLE");
1041 ICETYPE_TABLE 1053 ICETYPE_TABLE
1042 #undef X 1054 #undef X
1043 } // end of namespace dummy3 1055 } // end of namespace dummy3
1044 } // end of anonymous namespace 1056 } // end of anonymous namespace
1045 1057
1046 } // end of namespace X8664 1058 } // end of namespace X8664
1047 } // end of namespace Ice 1059 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632Traits.h ('k') | src/IceTargetLoweringX8664Traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698