OLD | NEW |
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// | 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 REGARM32_VEC128_TABLE | 204 REGARM32_VEC128_TABLE |
205 #undef X | 205 #undef X |
206 ; | 206 ; |
207 std::array<uint32_t, NumVec128Args> Vec128ArgInitializer; | 207 std::array<uint32_t, NumVec128Args> Vec128ArgInitializer; |
208 } // end of anonymous namespace | 208 } // end of anonymous namespace |
209 | 209 |
210 TargetARM32::TargetARM32(Cfg *Func) | 210 TargetARM32::TargetARM32(Cfg *Func) |
211 : TargetLowering(Func), NeedSandboxing(Ctx->getFlags().getUseSandboxing()), | 211 : TargetLowering(Func), NeedSandboxing(Ctx->getFlags().getUseSandboxing()), |
212 CPUFeatures(Func->getContext()->getFlags()) {} | 212 CPUFeatures(Func->getContext()->getFlags()) {} |
213 | 213 |
214 void TargetARM32::staticInit() { | 214 void TargetARM32::staticInit(const ClFlags &Flags) { |
| 215 (void)Flags; |
215 // Limit this size (or do all bitsets need to be the same width)??? | 216 // Limit this size (or do all bitsets need to be the same width)??? |
216 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM); | 217 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM); |
217 llvm::SmallBitVector I64PairRegisters(RegARM32::Reg_NUM); | 218 llvm::SmallBitVector I64PairRegisters(RegARM32::Reg_NUM); |
218 llvm::SmallBitVector Float32Registers(RegARM32::Reg_NUM); | 219 llvm::SmallBitVector Float32Registers(RegARM32::Reg_NUM); |
219 llvm::SmallBitVector Float64Registers(RegARM32::Reg_NUM); | 220 llvm::SmallBitVector Float64Registers(RegARM32::Reg_NUM); |
220 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM); | 221 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM); |
221 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM); | 222 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM); |
222 ScratchRegs.resize(RegARM32::Reg_NUM); | 223 ScratchRegs.resize(RegARM32::Reg_NUM); |
223 #define X(val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr, \ | 224 #define X(val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr, \ |
224 isInt, isI64Pair, isFP32, isFP64, isVec128, alias_init) \ | 225 isInt, isI64Pair, isFP32, isFP64, isVec128, alias_init) \ |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 } | 877 } |
877 assert(!Var->isRematerializable()); | 878 assert(!Var->isRematerializable()); |
878 int32_t Offset = Var->getStackOffset(); | 879 int32_t Offset = Var->getStackOffset(); |
879 int32_t BaseRegNum = Var->getBaseRegNum(); | 880 int32_t BaseRegNum = Var->getBaseRegNum(); |
880 if (BaseRegNum == Variable::NoRegister) { | 881 if (BaseRegNum == Variable::NoRegister) { |
881 BaseRegNum = getFrameOrStackReg(); | 882 BaseRegNum = getFrameOrStackReg(); |
882 } | 883 } |
883 const Type VarTy = Var->getType(); | 884 const Type VarTy = Var->getType(); |
884 Str << "[" << getRegName(BaseRegNum, VarTy); | 885 Str << "[" << getRegName(BaseRegNum, VarTy); |
885 if (Offset != 0) { | 886 if (Offset != 0) { |
886 Str << ", " << getConstantPrefix() << Offset; | 887 Str << ", #" << Offset; |
887 } | 888 } |
888 Str << "]"; | 889 Str << "]"; |
889 } | 890 } |
890 | 891 |
891 TargetARM32::CallingConv::CallingConv() | 892 TargetARM32::CallingConv::CallingConv() |
892 : GPRegsUsed(RegARM32::Reg_NUM), | 893 : GPRegsUsed(RegARM32::Reg_NUM), |
893 GPRArgs(GPRArgInitializer.rbegin(), GPRArgInitializer.rend()), | 894 GPRArgs(GPRArgInitializer.rbegin(), GPRArgInitializer.rend()), |
894 I64Args(I64ArgInitializer.rbegin(), I64ArgInitializer.rend()), | 895 I64Args(I64ArgInitializer.rbegin(), I64ArgInitializer.rend()), |
895 VFPRegsUsed(RegARM32::Reg_NUM), | 896 VFPRegsUsed(RegARM32::Reg_NUM), |
896 FP32Args(FP32ArgInitializer.rbegin(), FP32ArgInitializer.rend()), | 897 FP32Args(FP32ArgInitializer.rbegin(), FP32ArgInitializer.rend()), |
(...skipping 4791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5688 (void)Permutation; | 5689 (void)Permutation; |
5689 (void)ExcludeRegisters; | 5690 (void)ExcludeRegisters; |
5690 (void)Salt; | 5691 (void)Salt; |
5691 UnimplementedError(Func->getContext()->getFlags()); | 5692 UnimplementedError(Func->getContext()->getFlags()); |
5692 } | 5693 } |
5693 | 5694 |
5694 void TargetARM32::emit(const ConstantInteger32 *C) const { | 5695 void TargetARM32::emit(const ConstantInteger32 *C) const { |
5695 if (!BuildDefs::dump()) | 5696 if (!BuildDefs::dump()) |
5696 return; | 5697 return; |
5697 Ostream &Str = Ctx->getStrEmit(); | 5698 Ostream &Str = Ctx->getStrEmit(); |
5698 Str << getConstantPrefix() << C->getValue(); | 5699 Str << "#" << C->getValue(); |
5699 } | 5700 } |
5700 | 5701 |
5701 void TargetARM32::emit(const ConstantInteger64 *) const { | 5702 void TargetARM32::emit(const ConstantInteger64 *) const { |
5702 llvm::report_fatal_error("Not expecting to emit 64-bit integers"); | 5703 llvm::report_fatal_error("Not expecting to emit 64-bit integers"); |
5703 } | 5704 } |
5704 | 5705 |
5705 void TargetARM32::emit(const ConstantFloat *C) const { | 5706 void TargetARM32::emit(const ConstantFloat *C) const { |
5706 (void)C; | 5707 (void)C; |
5707 UnimplementedError(Ctx->getFlags()); | 5708 UnimplementedError(Ctx->getFlags()); |
5708 } | 5709 } |
5709 | 5710 |
5710 void TargetARM32::emit(const ConstantDouble *C) const { | 5711 void TargetARM32::emit(const ConstantDouble *C) const { |
5711 (void)C; | 5712 (void)C; |
5712 UnimplementedError(Ctx->getFlags()); | 5713 UnimplementedError(Ctx->getFlags()); |
5713 } | 5714 } |
5714 | 5715 |
5715 void TargetARM32::emit(const ConstantUndef *) const { | 5716 void TargetARM32::emit(const ConstantUndef *) const { |
5716 llvm::report_fatal_error("undef value encountered by emitter."); | 5717 llvm::report_fatal_error("undef value encountered by emitter."); |
5717 } | 5718 } |
5718 | 5719 |
| 5720 void TargetARM32::emit(const ConstantRelocatable *C) const { |
| 5721 if (!BuildDefs::dump()) |
| 5722 return; |
| 5723 Ostream &Str = Ctx->getStrEmit(); |
| 5724 Str << "#"; |
| 5725 emitWithoutPrefix(C); |
| 5726 } |
| 5727 |
5719 void TargetARM32::lowerInt1ForSelect(Variable *Dest, Operand *Boolean, | 5728 void TargetARM32::lowerInt1ForSelect(Variable *Dest, Operand *Boolean, |
5720 Operand *TrueValue, Operand *FalseValue) { | 5729 Operand *TrueValue, Operand *FalseValue) { |
5721 Operand *_1 = legalize(Ctx->getConstantInt1(1), Legal_Reg | Legal_Flex); | 5730 Operand *_1 = legalize(Ctx->getConstantInt1(1), Legal_Reg | Legal_Flex); |
5722 | 5731 |
5723 assert(Boolean->getType() == IceType_i1); | 5732 assert(Boolean->getType() == IceType_i1); |
5724 | 5733 |
5725 bool NeedsAnd1 = false; | 5734 bool NeedsAnd1 = false; |
5726 if (TrueValue->getType() == IceType_i1) { | 5735 if (TrueValue->getType() == IceType_i1) { |
5727 assert(FalseValue->getType() == IceType_i1); | 5736 assert(FalseValue->getType() == IceType_i1); |
5728 | 5737 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6233 if (Target->NeedSandboxing) { | 6242 if (Target->NeedSandboxing) { |
6234 Target->_bic(SP, SP, memOpBicMask(Target->Func)); | 6243 Target->_bic(SP, SP, memOpBicMask(Target->Func)); |
6235 } | 6244 } |
6236 } | 6245 } |
6237 | 6246 |
6238 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx) | 6247 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx) |
6239 : TargetDataLowering(Ctx) {} | 6248 : TargetDataLowering(Ctx) {} |
6240 | 6249 |
6241 void TargetDataARM32::lowerGlobals(const VariableDeclarationList &Vars, | 6250 void TargetDataARM32::lowerGlobals(const VariableDeclarationList &Vars, |
6242 const IceString &SectionSuffix) { | 6251 const IceString &SectionSuffix) { |
| 6252 const bool IsPIC = Ctx->getFlags().getUseNonsfi(); |
6243 switch (Ctx->getFlags().getOutFileType()) { | 6253 switch (Ctx->getFlags().getOutFileType()) { |
6244 case FT_Elf: { | 6254 case FT_Elf: { |
6245 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 6255 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
6246 Writer->writeDataSection(Vars, llvm::ELF::R_ARM_ABS32, SectionSuffix); | 6256 Writer->writeDataSection(Vars, llvm::ELF::R_ARM_ABS32, SectionSuffix, |
| 6257 IsPIC); |
6247 } break; | 6258 } break; |
6248 case FT_Asm: | 6259 case FT_Asm: |
6249 case FT_Iasm: { | 6260 case FT_Iasm: { |
6250 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); | 6261 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); |
6251 OstreamLocker _(Ctx); | 6262 OstreamLocker _(Ctx); |
6252 for (const VariableDeclaration *Var : Vars) { | 6263 for (const VariableDeclaration *Var : Vars) { |
6253 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { | 6264 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { |
6254 emitGlobal(*Var, SectionSuffix); | 6265 emitGlobal(*Var, SectionSuffix); |
6255 } | 6266 } |
6256 } | 6267 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6423 // Technically R9 is used for TLS with Sandboxing, and we reserve it. | 6434 // Technically R9 is used for TLS with Sandboxing, and we reserve it. |
6424 // However, for compatibility with current NaCl LLVM, don't claim that. | 6435 // However, for compatibility with current NaCl LLVM, don't claim that. |
6425 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; | 6436 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; |
6426 } | 6437 } |
6427 | 6438 |
6428 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM]; | 6439 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM]; |
6429 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; | 6440 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; |
6430 llvm::SmallBitVector TargetARM32::ScratchRegs; | 6441 llvm::SmallBitVector TargetARM32::ScratchRegs; |
6431 | 6442 |
6432 } // end of namespace Ice | 6443 } // end of namespace Ice |
OLD | NEW |