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

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1755333002: Subzero. ARM32. Fixes bugs uncovered by the llvm test suite. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 4 years, 9 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') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 Instr->setDeleted(); 587 Instr->setDeleted();
588 return; 588 return;
589 } 589 }
590 } 590 }
591 llvm::report_fatal_error("Control flow should never have reached here."); 591 llvm::report_fatal_error("Control flow should never have reached here.");
592 } 592 }
593 case Inst::Cast: { 593 case Inst::Cast: {
594 Variable *Dest = Instr->getDest(); 594 Variable *Dest = Instr->getDest();
595 Operand *Src0 = Instr->getSrc(0); 595 Operand *Src0 = Instr->getSrc(0);
596 const Type DestTy = Dest->getType(); 596 const Type DestTy = Dest->getType();
597 const Type SrcTy = Src0->getType();
597 auto *CastInstr = llvm::cast<InstCast>(Instr); 598 auto *CastInstr = llvm::cast<InstCast>(Instr);
598 const InstCast::OpKind CastKind = CastInstr->getCastKind(); 599 const InstCast::OpKind CastKind = CastInstr->getCastKind();
599 600
600 if (isVectorType(DestTy)) { 601 if (isVectorType(DestTy) && CastKind != InstCast::Bitcast) {
602 // Bitcasting is done with function calls (e.g., v8i1 -> i8), or regular
603 // vmov (e.g., v4i32 -> v4f32)
601 scalarizeInstruction( 604 scalarizeInstruction(
602 Dest, [this, CastKind](Variable *Dest, Variable *Src) { 605 Dest, [this, CastKind](Variable *Dest, Variable *Src) {
603 return Context.insert<InstCast>(CastKind, Dest, Src); 606 return Context.insert<InstCast>(CastKind, Dest, Src);
604 }, Src0); 607 }, Src0);
605 CastInstr->setDeleted(); 608 CastInstr->setDeleted();
606 return; 609 return;
607 } 610 }
608 611
609 switch (CastKind) { 612 switch (CastKind) {
610 default: 613 default:
611 return; 614 return;
612 case InstCast::Fptosi: 615 case InstCast::Fptosi:
613 case InstCast::Fptoui: { 616 case InstCast::Fptoui: {
614 if (DestTy != IceType_i64) { 617 if (DestTy != IceType_i64) {
615 return; 618 return;
616 } 619 }
617 const bool DestIsSigned = CastKind == InstCast::Fptosi; 620 const bool DestIsSigned = CastKind == InstCast::Fptosi;
618 const bool Src0IsF32 = isFloat32Asserting32Or64(Src0->getType()); 621 const bool Src0IsF32 = isFloat32Asserting32Or64(SrcTy);
619 Operand *TargetHelper = Ctx->getConstantExternSym( 622 Operand *TargetHelper = Ctx->getConstantExternSym(
620 Src0IsF32 ? (DestIsSigned ? H_fptosi_f32_i64 : H_fptoui_f32_i64) 623 Src0IsF32 ? (DestIsSigned ? H_fptosi_f32_i64 : H_fptoui_f32_i64)
621 : (DestIsSigned ? H_fptosi_f64_i64 : H_fptoui_f64_i64)); 624 : (DestIsSigned ? H_fptosi_f64_i64 : H_fptoui_f64_i64));
622 static constexpr SizeT MaxArgs = 1; 625 static constexpr SizeT MaxArgs = 1;
623 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, 626 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper,
624 NoTailCall, IsTargetHelperCall); 627 NoTailCall, IsTargetHelperCall);
625 Call->addArg(Src0); 628 Call->addArg(Src0);
626 Instr->setDeleted(); 629 Instr->setDeleted();
627 return; 630 return;
628 } 631 }
629 case InstCast::Sitofp: 632 case InstCast::Sitofp:
630 case InstCast::Uitofp: { 633 case InstCast::Uitofp: {
631 if (Src0->getType() != IceType_i64) { 634 if (SrcTy != IceType_i64) {
632 return; 635 return;
633 } 636 }
634 const bool SourceIsSigned = CastKind == InstCast::Sitofp; 637 const bool SourceIsSigned = CastKind == InstCast::Sitofp;
635 const bool DestIsF32 = isFloat32Asserting32Or64(Dest->getType()); 638 const bool DestIsF32 = isFloat32Asserting32Or64(Dest->getType());
636 Operand *TargetHelper = Ctx->getConstantExternSym( 639 Operand *TargetHelper = Ctx->getConstantExternSym(
637 DestIsF32 ? (SourceIsSigned ? H_sitofp_i64_f32 : H_uitofp_i64_f32) 640 DestIsF32 ? (SourceIsSigned ? H_sitofp_i64_f32 : H_uitofp_i64_f32)
638 : (SourceIsSigned ? H_sitofp_i64_f64 : H_uitofp_i64_f64)); 641 : (SourceIsSigned ? H_sitofp_i64_f64 : H_uitofp_i64_f64));
639 static constexpr SizeT MaxArgs = 1; 642 static constexpr SizeT MaxArgs = 1;
640 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, 643 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper,
641 NoTailCall, IsTargetHelperCall); 644 NoTailCall, IsTargetHelperCall);
642 Call->addArg(Src0); 645 Call->addArg(Src0);
643 Instr->setDeleted(); 646 Instr->setDeleted();
644 return; 647 return;
645 } 648 }
649 case InstCast::Bitcast: {
650 if (DestTy == SrcTy) {
651 return;
652 }
653 Variable *CallDest = Dest;
654 const char *HelperName = nullptr;
655 switch (DestTy) {
656 default:
657 return;
658 case IceType_i8:
659 assert(SrcTy == IceType_v8i1);
660 HelperName = H_bitcast_8xi1_i8;
661 CallDest = Func->makeVariable(IceType_i32);
662 break;
663 case IceType_i16:
664 assert(SrcTy == IceType_v16i1);
665 HelperName = H_bitcast_16xi1_i16;
666 CallDest = Func->makeVariable(IceType_i32);
667 break;
668 case IceType_v8i1: {
669 assert(SrcTy == IceType_i8);
670 HelperName = H_bitcast_i8_8xi1;
671 Variable *Src0AsI32 = Func->makeVariable(stackSlotType());
672 // Arguments to functions are required to be at least 32 bits wide.
673 Context.insert<InstCast>(InstCast::Zext, Src0AsI32, Src0);
674 Src0 = Src0AsI32;
675 } break;
676 case IceType_v16i1: {
677 assert(SrcTy == IceType_i16);
678 HelperName = H_bitcast_i16_16xi1;
679 Variable *Src0AsI32 = Func->makeVariable(stackSlotType());
680 // Arguments to functions are required to be at least 32 bits wide.
681 Context.insert<InstCast>(InstCast::Zext, Src0AsI32, Src0);
682 Src0 = Src0AsI32;
683 } break;
684 }
685 assert(HelperName != nullptr);
686 constexpr SizeT MaxSrcs = 1;
687 InstCall *Call = makeHelperCall(HelperName, CallDest, MaxSrcs);
688 Call->addArg(Src0);
689 Context.insert(Call);
690 // The PNaCl ABI disallows i8/i16 return types, so truncate the helper
691 // call result to the appropriate type as necessary.
692 if (CallDest->getType() != Dest->getType())
693 Context.insert<InstCast>(InstCast::Trunc, Dest, CallDest);
694 Instr->setDeleted();
695 return;
696 }
646 } 697 }
647 llvm::report_fatal_error("Control flow should never have reached here."); 698 llvm::report_fatal_error("Control flow should never have reached here.");
648 } 699 }
649 case Inst::IntrinsicCall: { 700 case Inst::IntrinsicCall: {
650 Variable *Dest = Instr->getDest(); 701 Variable *Dest = Instr->getDest();
651 auto *IntrinsicCall = llvm::cast<InstIntrinsicCall>(Instr); 702 auto *IntrinsicCall = llvm::cast<InstIntrinsicCall>(Instr);
652 Intrinsics::IntrinsicID ID = IntrinsicCall->getIntrinsicInfo().ID; 703 Intrinsics::IntrinsicID ID = IntrinsicCall->getIntrinsicInfo().ID;
653 switch (ID) { 704 switch (ID) {
654 default: 705 default:
655 return; 706 return;
(...skipping 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 } 4066 }
4016 Type DestType = Dest->getType(); 4067 Type DestType = Dest->getType();
4017 switch (DestType) { 4068 switch (DestType) {
4018 case IceType_NUM: 4069 case IceType_NUM:
4019 case IceType_void: 4070 case IceType_void:
4020 llvm::report_fatal_error("Unexpected bitcast."); 4071 llvm::report_fatal_error("Unexpected bitcast.");
4021 case IceType_i1: 4072 case IceType_i1:
4022 UnimplementedLoweringError(this, Instr); 4073 UnimplementedLoweringError(this, Instr);
4023 break; 4074 break;
4024 case IceType_i8: 4075 case IceType_i8:
4025 UnimplementedLoweringError(this, Instr); 4076 assert(Src0->getType() == IceType_v8i1);
4077 llvm::report_fatal_error(
4078 "i8 to v8i1 conversion should have been prelowered.");
4026 break; 4079 break;
4027 case IceType_i16: 4080 case IceType_i16:
4028 UnimplementedLoweringError(this, Instr); 4081 assert(Src0->getType() == IceType_v16i1);
4082 llvm::report_fatal_error(
4083 "i16 to v16i1 conversion should have been prelowered.");
4029 break; 4084 break;
4030 case IceType_i32: 4085 case IceType_i32:
4031 case IceType_f32: { 4086 case IceType_f32: {
4032 Variable *Src0R = legalizeToReg(Src0); 4087 Variable *Src0R = legalizeToReg(Src0);
4033 Variable *T = makeReg(DestType); 4088 Variable *T = makeReg(DestType);
4034 _mov(T, Src0R); 4089 _mov(T, Src0R);
4035 lowerAssign(InstAssign::create(Func, Dest, T)); 4090 lowerAssign(InstAssign::create(Func, Dest, T));
4036 break; 4091 break;
4037 } 4092 }
4038 case IceType_i64: { 4093 case IceType_i64: {
(...skipping 19 matching lines...) Expand all
4058 assert(Src0->getType() == IceType_i64); 4113 assert(Src0->getType() == IceType_i64);
4059 Variable *T = makeReg(DestType); 4114 Variable *T = makeReg(DestType);
4060 auto *Src64 = llvm::cast<Variable64On32>(Func->makeVariable(IceType_i64)); 4115 auto *Src64 = llvm::cast<Variable64On32>(Func->makeVariable(IceType_i64));
4061 Src64->initHiLo(Func); 4116 Src64->initHiLo(Func);
4062 configureBitcastTemporary(Src64); 4117 configureBitcastTemporary(Src64);
4063 lowerAssign(InstAssign::create(Func, Src64, Src0)); 4118 lowerAssign(InstAssign::create(Func, Src64, Src0));
4064 _mov(T, Src64); 4119 _mov(T, Src64);
4065 lowerAssign(InstAssign::create(Func, Dest, T)); 4120 lowerAssign(InstAssign::create(Func, Dest, T));
4066 break; 4121 break;
4067 } 4122 }
4123 case IceType_v8i1:
4124 assert(Src0->getType() == IceType_i8);
4125 llvm::report_fatal_error(
4126 "v8i1 to i8 conversion should have been prelowered.");
4127 break;
4128 case IceType_v16i1:
4129 assert(Src0->getType() == IceType_i16);
4130 llvm::report_fatal_error(
4131 "v16i1 to i16 conversion should have been prelowered.");
4132 break;
4068 case IceType_v4i1: 4133 case IceType_v4i1:
4069 case IceType_v8i1:
4070 case IceType_v16i1:
4071 case IceType_v8i16: 4134 case IceType_v8i16:
4072 case IceType_v16i8: 4135 case IceType_v16i8:
4073 case IceType_v4f32: 4136 case IceType_v4f32:
4074 case IceType_v4i32: { 4137 case IceType_v4i32: {
4075 UnimplementedLoweringError(this, Instr); 4138 assert(typeWidthInBytes(DestType) == typeWidthInBytes(Src0->getType()));
4139 assert(isVectorType(DestType) == isVectorType(Src0->getType()));
4140 Variable *T = makeReg(DestType);
4141 _mov(T, Src0);
4142 _mov(Dest, T);
4076 break; 4143 break;
4077 } 4144 }
4078 } 4145 }
4079 break; 4146 break;
4080 } 4147 }
4081 } 4148 }
4082 } 4149 }
4083 4150
4084 void TargetARM32::lowerExtractElement(const InstExtractElement *Instr) { 4151 void TargetARM32::lowerExtractElement(const InstExtractElement *Instr) {
4085 Variable *Dest = Instr->getDest(); 4152 Variable *Dest = Instr->getDest();
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
6818 // However, for compatibility with current NaCl LLVM, don't claim that. 6885 // However, for compatibility with current NaCl LLVM, don't claim that.
6819 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 6886 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
6820 } 6887 }
6821 6888
6822 SmallBitVector TargetARM32::TypeToRegisterSet[RegARM32::RCARM32_NUM]; 6889 SmallBitVector TargetARM32::TypeToRegisterSet[RegARM32::RCARM32_NUM];
6823 SmallBitVector TargetARM32::TypeToRegisterSetUnfiltered[RegARM32::RCARM32_NUM]; 6890 SmallBitVector TargetARM32::TypeToRegisterSetUnfiltered[RegARM32::RCARM32_NUM];
6824 SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; 6891 SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM];
6825 6892
6826 } // end of namespace ARM32 6893 } // end of namespace ARM32
6827 } // end of namespace Ice 6894 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringARM32.h ('k') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698