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

Side by Side Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2363333002: Subzero, MIPS32: Add missing functions for genTargetHelperCallFor (Closed)
Patch Set: Add missing functions for genTargetHelperCallFor and some casts Created 4 years, 2 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/IceInstMIPS32.cpp ('k') | tests_lit/llvm2ice_tests/fp.convert.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 // 1 //
2 // The Subzero Code Generator 2 // The Subzero Code Generator
3 // 3 //
4 // This file is distributed under the University of Illinois Open Source 4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details. 5 // License. See LICENSE.TXT for details.
6 // 6 //
7 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
8 /// 8 ///
9 /// \file 9 /// \file
10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 const Type DestTy = Dest->getType(); 302 const Type DestTy = Dest->getType();
303 const Type SrcTy = Src0->getType(); 303 const Type SrcTy = Src0->getType();
304 auto *CastInstr = llvm::cast<InstCast>(Instr); 304 auto *CastInstr = llvm::cast<InstCast>(Instr);
305 const InstCast::OpKind CastKind = CastInstr->getCastKind(); 305 const InstCast::OpKind CastKind = CastInstr->getCastKind();
306 306
307 switch (CastKind) { 307 switch (CastKind) {
308 default: 308 default:
309 return; 309 return;
310 case InstCast::Fptosi: 310 case InstCast::Fptosi:
311 case InstCast::Fptoui: { 311 case InstCast::Fptoui: {
312 if (DestTy != IceType_i64) { 312 if ((DestTy != IceType_i32) && (DestTy != IceType_i64)) {
313 return; 313 return;
314 } 314 }
315 const bool DestIs32 = DestTy == IceType_i32;
315 const bool DestIsSigned = CastKind == InstCast::Fptosi; 316 const bool DestIsSigned = CastKind == InstCast::Fptosi;
316 const bool Src0IsF32 = isFloat32Asserting32Or64(SrcTy); 317 const bool Src0IsF32 = isFloat32Asserting32Or64(SrcTy);
317 Operand *TargetHelper = Ctx->getRuntimeHelperFunc( 318 RuntimeHelper RTHFunc = RuntimeHelper::H_Num;
318 Src0IsF32 ? (DestIsSigned ? RuntimeHelper::H_fptosi_f32_i64 319 if (DestIsSigned) {
319 : RuntimeHelper::H_fptoui_f32_i64) 320 if (DestIs32) {
320 : (DestIsSigned ? RuntimeHelper::H_fptosi_f64_i64 321 return;
321 : RuntimeHelper::H_fptoui_f64_i64)); 322 }
323 RTHFunc = Src0IsF32 ? RuntimeHelper::H_fptosi_f32_i64
324 : RuntimeHelper::H_fptosi_f64_i64;
325 } else {
326 RTHFunc = Src0IsF32 ? (DestIs32 ? RuntimeHelper::H_fptoui_f32_i32
327 : RuntimeHelper::H_fptoui_f32_i64)
328 : (DestIs32 ? RuntimeHelper::H_fptoui_f64_i32
329 : RuntimeHelper::H_fptoui_f64_i64);
330 }
331 Operand *TargetHelper = Ctx->getRuntimeHelperFunc(RTHFunc);
322 static constexpr SizeT MaxArgs = 1; 332 static constexpr SizeT MaxArgs = 1;
323 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, 333 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper,
324 NoTailCall, IsTargetHelperCall); 334 NoTailCall, IsTargetHelperCall);
325 Call->addArg(Src0); 335 Call->addArg(Src0);
326 Instr->setDeleted(); 336 Instr->setDeleted();
327 return; 337 return;
328 } 338 }
329 case InstCast::Sitofp: 339 case InstCast::Sitofp:
330 case InstCast::Uitofp: { 340 case InstCast::Uitofp: {
331 if (SrcTy != IceType_i64) { 341 if ((SrcTy != IceType_i32) && (SrcTy != IceType_i64)) {
332 return; 342 return;
333 } 343 }
344 const bool SourceIs32 = SrcTy == IceType_i32;
334 const bool SourceIsSigned = CastKind == InstCast::Sitofp; 345 const bool SourceIsSigned = CastKind == InstCast::Sitofp;
335 const bool DestIsF32 = isFloat32Asserting32Or64(Dest->getType()); 346 const bool DestIsF32 = isFloat32Asserting32Or64(Dest->getType());
336 Operand *TargetHelper = Ctx->getRuntimeHelperFunc( 347 RuntimeHelper RTHFunc = RuntimeHelper::H_Num;
337 DestIsF32 ? (SourceIsSigned ? RuntimeHelper::H_sitofp_i64_f32 348 if (SourceIsSigned) {
338 : RuntimeHelper::H_uitofp_i64_f32) 349 if (SourceIs32) {
339 : (SourceIsSigned ? RuntimeHelper::H_sitofp_i64_f64 350 return;
340 : RuntimeHelper::H_uitofp_i64_f64)); 351 }
352 RTHFunc = DestIsF32 ? RuntimeHelper::H_sitofp_i64_f32
353 : RuntimeHelper::H_sitofp_i64_f64;
354 } else {
355 RTHFunc = DestIsF32 ? (SourceIs32 ? RuntimeHelper::H_uitofp_i32_f32
356 : RuntimeHelper::H_uitofp_i64_f32)
357 : (SourceIs32 ? RuntimeHelper::H_uitofp_i32_f64
358 : RuntimeHelper::H_uitofp_i64_f64);
359 }
360 Operand *TargetHelper = Ctx->getRuntimeHelperFunc(RTHFunc);
341 static constexpr SizeT MaxArgs = 1; 361 static constexpr SizeT MaxArgs = 1;
342 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, 362 auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper,
343 NoTailCall, IsTargetHelperCall); 363 NoTailCall, IsTargetHelperCall);
344 Call->addArg(Src0); 364 Call->addArg(Src0);
345 Instr->setDeleted(); 365 Instr->setDeleted();
346 return; 366 return;
347 } 367 }
348 case InstCast::Bitcast: { 368 case InstCast::Bitcast: {
349 if (DestTy == SrcTy) { 369 if (DestTy == SrcTy) {
350 return; 370 return;
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 } 2597 }
2578 case InstCast::Fpext: { 2598 case InstCast::Fpext: {
2579 assert(Dest->getType() == IceType_f64); 2599 assert(Dest->getType() == IceType_f64);
2580 assert(Src0->getType() == IceType_f32); 2600 assert(Src0->getType() == IceType_f32);
2581 auto *DestR = legalizeToReg(Dest); 2601 auto *DestR = legalizeToReg(Dest);
2582 auto *Src0R = legalizeToReg(Src0); 2602 auto *Src0R = legalizeToReg(Src0);
2583 _cvt_d_s(DestR, Src0R); 2603 _cvt_d_s(DestR, Src0R);
2584 _mov(Dest, DestR); 2604 _mov(Dest, DestR);
2585 break; 2605 break;
2586 } 2606 }
2587 case InstCast::Fptosi: { 2607 case InstCast::Fptosi:
2608 case InstCast::Fptoui: {
2588 if (llvm::isa<Variable64On32>(Dest)) { 2609 if (llvm::isa<Variable64On32>(Dest)) {
2589 llvm::report_fatal_error("fp-to-i64 should have been prelowered."); 2610 llvm::report_fatal_error("fp-to-i64 should have been prelowered.");
2590 return; 2611 return;
2591 } 2612 }
2592 if (Src0Ty == IceType_f32 && DestTy == IceType_i32) { 2613 if (DestTy != IceType_i64) {
2593 Variable *Src0R = legalizeToReg(Src0); 2614 if (Src0Ty == IceType_f32 && isScalarIntegerType(DestTy)) {
2594 Variable *FTmp = makeReg(IceType_f32); 2615 Variable *Src0R = legalizeToReg(Src0);
2595 _trunc_w_s(FTmp, Src0R); 2616 Variable *FTmp = makeReg(IceType_f32);
2596 _mov(Dest, FTmp); 2617 _trunc_w_s(FTmp, Src0R);
2597 } else { 2618 _mov(Dest, FTmp);
2598 UnimplementedLoweringError(this, Instr); 2619 return;
2599 } 2620 }
2600 break; 2621 if (Src0Ty == IceType_f64 && isScalarIntegerType(DestTy)) {
2601 } 2622 Variable *Src0R = legalizeToReg(Src0);
2602 case InstCast::Fptoui: 2623 Variable *FTmp = makeReg(IceType_f64);
2603 if (llvm::isa<Variable64On32>(Dest)) { 2624 _trunc_w_d(FTmp, Src0R);
2604 llvm::report_fatal_error("fp-to-i64 should have been prelowered."); 2625 _mov(Dest, FTmp);
2605 return; 2626 return;
2627 }
2606 } 2628 }
2607 UnimplementedLoweringError(this, Instr); 2629 UnimplementedLoweringError(this, Instr);
2608 break; 2630 break;
2609 case InstCast::Sitofp: {
2610 if (llvm::isa<Variable64On32>(Dest)) {
2611 llvm::report_fatal_error("i64-to-fp should have been prelowered.");
2612 return;
2613 }
2614 if (Src0Ty == IceType_i32 && DestTy == IceType_f32) {
2615 Variable *Src0R = legalizeToReg(Src0);
2616 Variable *FTmp1 = makeReg(IceType_f32);
2617 Variable *FTmp2 = makeReg(IceType_f32);
2618 _mov(FTmp1, Src0R);
2619 _cvt_s_w(FTmp2, FTmp1);
2620 _mov(Dest, FTmp2);
2621 } else {
2622 UnimplementedLoweringError(this, Instr);
2623 }
2624 break;
2625 } 2631 }
2632 case InstCast::Sitofp:
2626 case InstCast::Uitofp: { 2633 case InstCast::Uitofp: {
2627 if (llvm::isa<Variable64On32>(Dest)) { 2634 if (llvm::isa<Variable64On32>(Dest)) {
2628 llvm::report_fatal_error("i64-to-fp should have been prelowered."); 2635 llvm::report_fatal_error("i64-to-fp should have been prelowered.");
2629 return; 2636 return;
2630 } 2637 }
2638 if (Src0Ty != IceType_i64) {
2639 if (isScalarIntegerType(Src0Ty) && DestTy == IceType_f32) {
2640 Variable *Src0R = legalizeToReg(Src0);
2641 Variable *FTmp1 = makeReg(IceType_f32);
2642 Variable *FTmp2 = makeReg(IceType_f32);
2643 _mtc1(FTmp1, Src0R);
2644 _cvt_s_w(FTmp2, FTmp1);
2645 _mov(Dest, FTmp2);
2646 return;
2647 }
2648 if (isScalarIntegerType(Src0Ty) && DestTy == IceType_f64) {
2649 Variable *Src0R = legalizeToReg(Src0);
2650 Variable *FTmp1 = makeReg(IceType_f64);
2651 Variable *FTmp2 = makeReg(IceType_f64);
2652 _mtc1(FTmp1, Src0R);
2653 _cvt_d_w(FTmp2, FTmp1);
2654 _mov(Dest, FTmp2);
2655 return;
2656 }
2657 }
2631 UnimplementedLoweringError(this, Instr); 2658 UnimplementedLoweringError(this, Instr);
2632 break; 2659 break;
2633 } 2660 }
2634 case InstCast::Bitcast: { 2661 case InstCast::Bitcast: {
2662 Operand *Src0 = Instr->getSrc(0);
2663 if (DestTy == Src0->getType()) {
2664 auto *Assign = InstAssign::create(Func, Dest, Src0);
2665 lowerAssign(Assign);
2666 return;
2667 }
2635 switch (DestTy) { 2668 switch (DestTy) {
2636 case IceType_NUM: 2669 case IceType_NUM:
2637 case IceType_void: 2670 case IceType_void:
2638 llvm::report_fatal_error("Unexpected bitcast."); 2671 llvm::report_fatal_error("Unexpected bitcast.");
2639 case IceType_i1: 2672 case IceType_i1:
2640 UnimplementedLoweringError(this, Instr); 2673 UnimplementedLoweringError(this, Instr);
2641 break; 2674 break;
2642 case IceType_i8: 2675 case IceType_i8:
2643 assert(Src0->getType() == IceType_v8i1); 2676 assert(Src0->getType() == IceType_v8i1);
2644 llvm::report_fatal_error( 2677 llvm::report_fatal_error(
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 Str << "\t.set\t" 4013 Str << "\t.set\t"
3981 << "nomips16\n"; 4014 << "nomips16\n";
3982 } 4015 }
3983 4016
3984 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 4017 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
3985 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 4018 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
3986 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 4019 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
3987 4020
3988 } // end of namespace MIPS32 4021 } // end of namespace MIPS32
3989 } // end of namespace Ice 4022 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstMIPS32.cpp ('k') | tests_lit/llvm2ice_tests/fp.convert.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698