OLD | NEW |
1 //===- subzero/src/IceTargetLoweringMIPS32.cpp - MIPS32 lowering ----------===// | 1 //===- subzero/src/IceTargetLoweringMIPS32.cpp - MIPS32 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 27 matching lines...) Expand all Loading... |
38 std::unique_ptr<::Ice::TargetDataLowering> | 38 std::unique_ptr<::Ice::TargetDataLowering> |
39 createTargetDataLowering(::Ice::GlobalContext *Ctx) { | 39 createTargetDataLowering(::Ice::GlobalContext *Ctx) { |
40 return ::Ice::MIPS32::TargetDataMIPS32::create(Ctx); | 40 return ::Ice::MIPS32::TargetDataMIPS32::create(Ctx); |
41 } | 41 } |
42 | 42 |
43 std::unique_ptr<::Ice::TargetHeaderLowering> | 43 std::unique_ptr<::Ice::TargetHeaderLowering> |
44 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) { | 44 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) { |
45 return ::Ice::MIPS32::TargetHeaderMIPS32::create(Ctx); | 45 return ::Ice::MIPS32::TargetHeaderMIPS32::create(Ctx); |
46 } | 46 } |
47 | 47 |
48 void staticInit() { ::Ice::MIPS32::TargetMIPS32::staticInit(); } | 48 void staticInit(const ::Ice::ClFlags &Flags) { |
| 49 ::Ice::MIPS32::TargetMIPS32::staticInit(Flags); |
| 50 } |
49 } // end of namespace MIPS32 | 51 } // end of namespace MIPS32 |
50 | 52 |
51 namespace Ice { | 53 namespace Ice { |
52 namespace MIPS32 { | 54 namespace MIPS32 { |
53 | 55 |
54 using llvm::isInt; | 56 using llvm::isInt; |
55 | 57 |
56 namespace { | 58 namespace { |
57 | 59 |
58 // The maximum number of arguments to pass in GPR registers. | 60 // The maximum number of arguments to pass in GPR registers. |
59 constexpr uint32_t MIPS32_MAX_GPR_ARG = 4; | 61 constexpr uint32_t MIPS32_MAX_GPR_ARG = 4; |
60 | 62 |
61 } // end of anonymous namespace | 63 } // end of anonymous namespace |
62 | 64 |
63 TargetMIPS32::TargetMIPS32(Cfg *Func) : TargetLowering(Func) {} | 65 TargetMIPS32::TargetMIPS32(Cfg *Func) : TargetLowering(Func) {} |
64 | 66 |
65 void TargetMIPS32::staticInit() { | 67 void TargetMIPS32::staticInit(const ClFlags &Flags) { |
| 68 (void)Flags; |
66 llvm::SmallBitVector IntegerRegisters(RegMIPS32::Reg_NUM); | 69 llvm::SmallBitVector IntegerRegisters(RegMIPS32::Reg_NUM); |
67 llvm::SmallBitVector I64PairRegisters(RegMIPS32::Reg_NUM); | 70 llvm::SmallBitVector I64PairRegisters(RegMIPS32::Reg_NUM); |
68 llvm::SmallBitVector Float32Registers(RegMIPS32::Reg_NUM); | 71 llvm::SmallBitVector Float32Registers(RegMIPS32::Reg_NUM); |
69 llvm::SmallBitVector Float64Registers(RegMIPS32::Reg_NUM); | 72 llvm::SmallBitVector Float64Registers(RegMIPS32::Reg_NUM); |
70 llvm::SmallBitVector VectorRegisters(RegMIPS32::Reg_NUM); | 73 llvm::SmallBitVector VectorRegisters(RegMIPS32::Reg_NUM); |
71 llvm::SmallBitVector InvalidRegisters(RegMIPS32::Reg_NUM); | 74 llvm::SmallBitVector InvalidRegisters(RegMIPS32::Reg_NUM); |
72 ScratchRegs.resize(RegMIPS32::Reg_NUM); | 75 ScratchRegs.resize(RegMIPS32::Reg_NUM); |
73 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \ | 76 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \ |
74 isI64Pair, isFP32, isFP64, isVec128, alias_init) \ | 77 isI64Pair, isFP32, isFP64, isVec128, alias_init) \ |
75 IntegerRegisters[RegMIPS32::val] = isInt; \ | 78 IntegerRegisters[RegMIPS32::val] = isInt; \ |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 void ConstantUndef::emit(GlobalContext *) const { | 976 void ConstantUndef::emit(GlobalContext *) const { |
974 llvm_unreachable("undef value encountered by emitter."); | 977 llvm_unreachable("undef value encountered by emitter."); |
975 } | 978 } |
976 */ | 979 */ |
977 | 980 |
978 TargetDataMIPS32::TargetDataMIPS32(GlobalContext *Ctx) | 981 TargetDataMIPS32::TargetDataMIPS32(GlobalContext *Ctx) |
979 : TargetDataLowering(Ctx) {} | 982 : TargetDataLowering(Ctx) {} |
980 | 983 |
981 void TargetDataMIPS32::lowerGlobals(const VariableDeclarationList &Vars, | 984 void TargetDataMIPS32::lowerGlobals(const VariableDeclarationList &Vars, |
982 const IceString &SectionSuffix) { | 985 const IceString &SectionSuffix) { |
| 986 const bool IsPIC = Ctx->getFlags().getUseNonsfi(); |
983 switch (Ctx->getFlags().getOutFileType()) { | 987 switch (Ctx->getFlags().getOutFileType()) { |
984 case FT_Elf: { | 988 case FT_Elf: { |
985 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 989 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
986 Writer->writeDataSection(Vars, llvm::ELF::R_MIPS_GLOB_DAT, SectionSuffix); | 990 Writer->writeDataSection(Vars, llvm::ELF::R_MIPS_GLOB_DAT, SectionSuffix, |
| 991 IsPIC); |
987 } break; | 992 } break; |
988 case FT_Asm: | 993 case FT_Asm: |
989 case FT_Iasm: { | 994 case FT_Iasm: { |
990 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 995 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
991 OstreamLocker L(Ctx); | 996 OstreamLocker L(Ctx); |
992 for (const VariableDeclaration *Var : Vars) { | 997 for (const VariableDeclaration *Var : Vars) { |
993 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { | 998 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { |
994 emitGlobal(*Var, SectionSuffix); | 999 emitGlobal(*Var, SectionSuffix); |
995 } | 1000 } |
996 } | 1001 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 Str << "\t.set\t" | 1101 Str << "\t.set\t" |
1097 << "nomips16\n"; | 1102 << "nomips16\n"; |
1098 } | 1103 } |
1099 | 1104 |
1100 llvm::SmallBitVector TargetMIPS32::TypeToRegisterSet[IceType_NUM]; | 1105 llvm::SmallBitVector TargetMIPS32::TypeToRegisterSet[IceType_NUM]; |
1101 llvm::SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; | 1106 llvm::SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; |
1102 llvm::SmallBitVector TargetMIPS32::ScratchRegs; | 1107 llvm::SmallBitVector TargetMIPS32::ScratchRegs; |
1103 | 1108 |
1104 } // end of namespace MIPS32 | 1109 } // end of namespace MIPS32 |
1105 } // end of namespace Ice | 1110 } // end of namespace Ice |
OLD | NEW |