OSDN Git Service

Subzero, MIPS32: Handling fptrunc and fpext casting
authorSrdjan Obucina <Srdjan.Obucina@imgtec.com>
Sun, 11 Sep 2016 14:08:30 +0000 (07:08 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Sun, 11 Sep 2016 14:08:30 +0000 (07:08 -0700)
Patch implements truncation and extension of FP values.

R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2324903002 .

Patch from Srdjan Obucina <Srdjan.Obucina@imgtec.com>.

src/IceTargetLoweringMIPS32.cpp
tests_lit/llvm2ice_tests/fp.convert.ll

index 19a054b..622af79 100644 (file)
@@ -2393,22 +2393,31 @@ void TargetMIPS32::lowerCast(const InstCast *Instr) {
     _mov(Dest, T);
     break;
   }
-  case InstCast::Fptrunc:
-    // Use _cvt_d_s
-    UnimplementedLoweringError(this, Instr);
+  case InstCast::Fptrunc: {
+    assert(Dest->getType() == IceType_f32);
+    assert(Src0->getType() == IceType_f64);
+    auto *DestR = legalizeToReg(Dest);
+    auto *Src0R = legalizeToReg(Src0);
+    _cvt_s_d(DestR, Src0R);
+    _mov(Dest, DestR);
     break;
+  }
   case InstCast::Fpext: {
-    // Use _cvt_s_d
-    UnimplementedLoweringError(this, Instr);
+    assert(Dest->getType() == IceType_f64);
+    assert(Src0->getType() == IceType_f32);
+    auto *DestR = legalizeToReg(Dest);
+    auto *Src0R = legalizeToReg(Src0);
+    _cvt_d_s(DestR, Src0R);
+    _mov(Dest, DestR);
     break;
   }
-  case InstCast::Fptosi:
+  case InstCast::Fptosi: //
     UnimplementedLoweringError(this, Instr);
     break;
   case InstCast::Fptoui:
     UnimplementedLoweringError(this, Instr);
     break;
-  case InstCast::Sitofp:
+  case InstCast::Sitofp: //
     UnimplementedLoweringError(this, Instr);
     break;
   case InstCast::Uitofp: {
index 4fc71f8..d1bd743 100644 (file)
 ; RUN:   | %if --need=allow_dump --need=target_ARM32 --command FileCheck %s \
 ; RUN:   --check-prefix=ARM32
 
+; RUN: %if --need=allow_dump --need=target_MIPS32 --command %p2i \
+; RUN:   --filetype=asm --target mips32 -i %s --args -Om1 --skip-unimplemented \
+; RUN:   | %if --need=allow_dump --need=target_MIPS32 --command FileCheck %s \
+; RUN:   --check-prefix=MIPS32
+
 define internal float @fptrunc(double %a) {
 entry:
   %conv = fptrunc double %a to float
@@ -26,6 +31,8 @@ entry:
 ; CHECK: fld
 ; ARM32-LABEL: fptrunc
 ; ARM32: vcvt.f32.f64 {{s[0-9]+}}, {{d[0-9]+}}
+; MIPS32-LABEL: fptrunc
+; MIPS32: cvt.s.d
 
 define internal double @fpext(float %a) {
 entry:
@@ -37,6 +44,8 @@ entry:
 ; CHECK: fld
 ; ARM32-LABEL: fpext
 ; ARM32: vcvt.f64.f32 {{d[0-9]+}}, {{s[0-9]+}}
+; MIPS32-LABEL: fpext
+; MIPS32: cvt.d.s
 
 define internal i64 @doubleToSigned64(double %a) {
 entry: