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

Side by Side Diff: src/IceTargetLoweringARM32.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/IceTargetLoweringARM32.h ('k') | src/IceTargetLoweringMIPS32.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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 std::unique_ptr<::Ice::TargetDataLowering> 43 std::unique_ptr<::Ice::TargetDataLowering>
44 createTargetDataLowering(::Ice::GlobalContext *Ctx) { 44 createTargetDataLowering(::Ice::GlobalContext *Ctx) {
45 return ::Ice::ARM32::TargetDataARM32::create(Ctx); 45 return ::Ice::ARM32::TargetDataARM32::create(Ctx);
46 } 46 }
47 47
48 std::unique_ptr<::Ice::TargetHeaderLowering> 48 std::unique_ptr<::Ice::TargetHeaderLowering>
49 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) { 49 createTargetHeaderLowering(::Ice::GlobalContext *Ctx) {
50 return ::Ice::ARM32::TargetHeaderARM32::create(Ctx); 50 return ::Ice::ARM32::TargetHeaderARM32::create(Ctx);
51 } 51 }
52 52
53 void staticInit() { ::Ice::ARM32::TargetARM32::staticInit(); } 53 void staticInit(const ::Ice::ClFlags &Flags) {
54 ::Ice::ARM32::TargetARM32::staticInit(Flags);
55 }
54 } // end of namespace ARM32 56 } // end of namespace ARM32
55 57
56 namespace Ice { 58 namespace Ice {
57 namespace ARM32 { 59 namespace ARM32 {
58 60
59 // Defines the RegARM32::Table table with register information. 61 // Defines the RegARM32::Table table with register information.
60 constexpr RegARM32::TableType RegARM32::Table[]; 62 constexpr RegARM32::TableType RegARM32::Table[];
61 63
62 namespace { 64 namespace {
63 65
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 REGARM32_VEC128_TABLE 228 REGARM32_VEC128_TABLE
227 #undef X 229 #undef X
228 ; 230 ;
229 std::array<uint32_t, NumVec128Args> Vec128ArgInitializer; 231 std::array<uint32_t, NumVec128Args> Vec128ArgInitializer;
230 } // end of anonymous namespace 232 } // end of anonymous namespace
231 233
232 TargetARM32::TargetARM32(Cfg *Func) 234 TargetARM32::TargetARM32(Cfg *Func)
233 : TargetLowering(Func), NeedSandboxing(Ctx->getFlags().getUseSandboxing()), 235 : TargetLowering(Func), NeedSandboxing(Ctx->getFlags().getUseSandboxing()),
234 CPUFeatures(Func->getContext()->getFlags()) {} 236 CPUFeatures(Func->getContext()->getFlags()) {}
235 237
236 void TargetARM32::staticInit() { 238 void TargetARM32::staticInit(const ClFlags &Flags) {
239 (void)Flags;
237 // Limit this size (or do all bitsets need to be the same width)??? 240 // Limit this size (or do all bitsets need to be the same width)???
238 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM); 241 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM);
239 llvm::SmallBitVector I64PairRegisters(RegARM32::Reg_NUM); 242 llvm::SmallBitVector I64PairRegisters(RegARM32::Reg_NUM);
240 llvm::SmallBitVector Float32Registers(RegARM32::Reg_NUM); 243 llvm::SmallBitVector Float32Registers(RegARM32::Reg_NUM);
241 llvm::SmallBitVector Float64Registers(RegARM32::Reg_NUM); 244 llvm::SmallBitVector Float64Registers(RegARM32::Reg_NUM);
242 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM); 245 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM);
243 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM); 246 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM);
244 ScratchRegs.resize(RegARM32::Reg_NUM); 247 ScratchRegs.resize(RegARM32::Reg_NUM);
245 for (int i = 0; i < RegARM32::Reg_NUM; ++i) { 248 for (int i = 0; i < RegARM32::Reg_NUM; ++i) {
246 const auto &Entry = RegARM32::Table[i]; 249 const auto &Entry = RegARM32::Table[i];
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 893 }
891 assert(!Var->isRematerializable()); 894 assert(!Var->isRematerializable());
892 int32_t Offset = Var->getStackOffset(); 895 int32_t Offset = Var->getStackOffset();
893 int32_t BaseRegNum = Var->getBaseRegNum(); 896 int32_t BaseRegNum = Var->getBaseRegNum();
894 if (BaseRegNum == Variable::NoRegister) { 897 if (BaseRegNum == Variable::NoRegister) {
895 BaseRegNum = getFrameOrStackReg(); 898 BaseRegNum = getFrameOrStackReg();
896 } 899 }
897 const Type VarTy = Var->getType(); 900 const Type VarTy = Var->getType();
898 Str << "[" << getRegName(BaseRegNum, VarTy); 901 Str << "[" << getRegName(BaseRegNum, VarTy);
899 if (Offset != 0) { 902 if (Offset != 0) {
900 Str << ", " << getConstantPrefix() << Offset; 903 Str << ", #" << Offset;
901 } 904 }
902 Str << "]"; 905 Str << "]";
903 } 906 }
904 907
905 TargetARM32::CallingConv::CallingConv() 908 TargetARM32::CallingConv::CallingConv()
906 : GPRegsUsed(RegARM32::Reg_NUM), 909 : GPRegsUsed(RegARM32::Reg_NUM),
907 GPRArgs(GPRArgInitializer.rbegin(), GPRArgInitializer.rend()), 910 GPRArgs(GPRArgInitializer.rbegin(), GPRArgInitializer.rend()),
908 I64Args(I64ArgInitializer.rbegin(), I64ArgInitializer.rend()), 911 I64Args(I64ArgInitializer.rbegin(), I64ArgInitializer.rend()),
909 VFPRegsUsed(RegARM32::Reg_NUM), 912 VFPRegsUsed(RegARM32::Reg_NUM),
910 FP32Args(FP32ArgInitializer.rbegin(), FP32ArgInitializer.rend()), 913 FP32Args(FP32ArgInitializer.rbegin(), FP32ArgInitializer.rend()),
(...skipping 4788 matching lines...) Expand 10 before | Expand all | Expand 10 after
5699 (void)Permutation; 5702 (void)Permutation;
5700 (void)ExcludeRegisters; 5703 (void)ExcludeRegisters;
5701 (void)Salt; 5704 (void)Salt;
5702 UnimplementedError(Func->getContext()->getFlags()); 5705 UnimplementedError(Func->getContext()->getFlags());
5703 } 5706 }
5704 5707
5705 void TargetARM32::emit(const ConstantInteger32 *C) const { 5708 void TargetARM32::emit(const ConstantInteger32 *C) const {
5706 if (!BuildDefs::dump()) 5709 if (!BuildDefs::dump())
5707 return; 5710 return;
5708 Ostream &Str = Ctx->getStrEmit(); 5711 Ostream &Str = Ctx->getStrEmit();
5709 Str << getConstantPrefix() << C->getValue(); 5712 Str << "#" << C->getValue();
5710 } 5713 }
5711 5714
5712 void TargetARM32::emit(const ConstantInteger64 *) const { 5715 void TargetARM32::emit(const ConstantInteger64 *) const {
5713 llvm::report_fatal_error("Not expecting to emit 64-bit integers"); 5716 llvm::report_fatal_error("Not expecting to emit 64-bit integers");
5714 } 5717 }
5715 5718
5716 void TargetARM32::emit(const ConstantFloat *C) const { 5719 void TargetARM32::emit(const ConstantFloat *C) const {
5717 (void)C; 5720 (void)C;
5718 UnimplementedError(Ctx->getFlags()); 5721 UnimplementedError(Ctx->getFlags());
5719 } 5722 }
5720 5723
5721 void TargetARM32::emit(const ConstantDouble *C) const { 5724 void TargetARM32::emit(const ConstantDouble *C) const {
5722 (void)C; 5725 (void)C;
5723 UnimplementedError(Ctx->getFlags()); 5726 UnimplementedError(Ctx->getFlags());
5724 } 5727 }
5725 5728
5726 void TargetARM32::emit(const ConstantUndef *) const { 5729 void TargetARM32::emit(const ConstantUndef *) const {
5727 llvm::report_fatal_error("undef value encountered by emitter."); 5730 llvm::report_fatal_error("undef value encountered by emitter.");
5728 } 5731 }
5729 5732
5733 void TargetARM32::emit(const ConstantRelocatable *C) const {
5734 if (!BuildDefs::dump())
5735 return;
5736 Ostream &Str = Ctx->getStrEmit();
5737 Str << "#";
5738 emitWithoutPrefix(C);
5739 }
5740
5730 void TargetARM32::lowerInt1ForSelect(Variable *Dest, Operand *Boolean, 5741 void TargetARM32::lowerInt1ForSelect(Variable *Dest, Operand *Boolean,
5731 Operand *TrueValue, Operand *FalseValue) { 5742 Operand *TrueValue, Operand *FalseValue) {
5732 Operand *_1 = legalize(Ctx->getConstantInt1(1), Legal_Reg | Legal_Flex); 5743 Operand *_1 = legalize(Ctx->getConstantInt1(1), Legal_Reg | Legal_Flex);
5733 5744
5734 assert(Boolean->getType() == IceType_i1); 5745 assert(Boolean->getType() == IceType_i1);
5735 5746
5736 bool NeedsAnd1 = false; 5747 bool NeedsAnd1 = false;
5737 if (TrueValue->getType() == IceType_i1) { 5748 if (TrueValue->getType() == IceType_i1) {
5738 assert(FalseValue->getType() == IceType_i1); 5749 assert(FalseValue->getType() == IceType_i1);
5739 5750
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
6244 if (Target->NeedSandboxing) { 6255 if (Target->NeedSandboxing) {
6245 Target->_bic(SP, SP, memOpBicMask(Target->Func)); 6256 Target->_bic(SP, SP, memOpBicMask(Target->Func));
6246 } 6257 }
6247 } 6258 }
6248 6259
6249 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx) 6260 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx)
6250 : TargetDataLowering(Ctx) {} 6261 : TargetDataLowering(Ctx) {}
6251 6262
6252 void TargetDataARM32::lowerGlobals(const VariableDeclarationList &Vars, 6263 void TargetDataARM32::lowerGlobals(const VariableDeclarationList &Vars,
6253 const IceString &SectionSuffix) { 6264 const IceString &SectionSuffix) {
6265 const bool IsPIC = Ctx->getFlags().getUseNonsfi();
6254 switch (Ctx->getFlags().getOutFileType()) { 6266 switch (Ctx->getFlags().getOutFileType()) {
6255 case FT_Elf: { 6267 case FT_Elf: {
6256 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 6268 ELFObjectWriter *Writer = Ctx->getObjectWriter();
6257 Writer->writeDataSection(Vars, llvm::ELF::R_ARM_ABS32, SectionSuffix); 6269 Writer->writeDataSection(Vars, llvm::ELF::R_ARM_ABS32, SectionSuffix,
6270 IsPIC);
6258 } break; 6271 } break;
6259 case FT_Asm: 6272 case FT_Asm:
6260 case FT_Iasm: { 6273 case FT_Iasm: {
6261 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); 6274 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly();
6262 OstreamLocker _(Ctx); 6275 OstreamLocker _(Ctx);
6263 for (const VariableDeclaration *Var : Vars) { 6276 for (const VariableDeclaration *Var : Vars) {
6264 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { 6277 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) {
6265 emitGlobal(*Var, SectionSuffix); 6278 emitGlobal(*Var, SectionSuffix);
6266 } 6279 }
6267 } 6280 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
6435 // However, for compatibility with current NaCl LLVM, don't claim that. 6448 // However, for compatibility with current NaCl LLVM, don't claim that.
6436 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 6449 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
6437 } 6450 }
6438 6451
6439 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM]; 6452 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM];
6440 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; 6453 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM];
6441 llvm::SmallBitVector TargetARM32::ScratchRegs; 6454 llvm::SmallBitVector TargetARM32::ScratchRegs;
6442 6455
6443 } // end of namespace ARM32 6456 } // end of namespace ARM32
6444 } // end of namespace Ice 6457 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringARM32.h ('k') | src/IceTargetLoweringMIPS32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698