Commit 5a9f714f by Srdjan Obucina Committed by Jim Stichnoth

Subzero, MIPS32: Handling fptrunc and fpext casting

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>.
parent 53d05686
...@@ -2393,22 +2393,31 @@ void TargetMIPS32::lowerCast(const InstCast *Instr) { ...@@ -2393,22 +2393,31 @@ void TargetMIPS32::lowerCast(const InstCast *Instr) {
_mov(Dest, T); _mov(Dest, T);
break; break;
} }
case InstCast::Fptrunc: case InstCast::Fptrunc: {
// Use _cvt_d_s assert(Dest->getType() == IceType_f32);
UnimplementedLoweringError(this, Instr); assert(Src0->getType() == IceType_f64);
auto *DestR = legalizeToReg(Dest);
auto *Src0R = legalizeToReg(Src0);
_cvt_s_d(DestR, Src0R);
_mov(Dest, DestR);
break; break;
}
case InstCast::Fpext: { case InstCast::Fpext: {
// Use _cvt_s_d assert(Dest->getType() == IceType_f64);
UnimplementedLoweringError(this, Instr); assert(Src0->getType() == IceType_f32);
auto *DestR = legalizeToReg(Dest);
auto *Src0R = legalizeToReg(Src0);
_cvt_d_s(DestR, Src0R);
_mov(Dest, DestR);
break; break;
} }
case InstCast::Fptosi: case InstCast::Fptosi: //
UnimplementedLoweringError(this, Instr); UnimplementedLoweringError(this, Instr);
break; break;
case InstCast::Fptoui: case InstCast::Fptoui:
UnimplementedLoweringError(this, Instr); UnimplementedLoweringError(this, Instr);
break; break;
case InstCast::Sitofp: case InstCast::Sitofp: //
UnimplementedLoweringError(this, Instr); UnimplementedLoweringError(this, Instr);
break; break;
case InstCast::Uitofp: { case InstCast::Uitofp: {
......
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
; RUN: | %if --need=allow_dump --need=target_ARM32 --command FileCheck %s \ ; RUN: | %if --need=allow_dump --need=target_ARM32 --command FileCheck %s \
; RUN: --check-prefix=ARM32 ; 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) { define internal float @fptrunc(double %a) {
entry: entry:
%conv = fptrunc double %a to float %conv = fptrunc double %a to float
...@@ -26,6 +31,8 @@ entry: ...@@ -26,6 +31,8 @@ entry:
; CHECK: fld ; CHECK: fld
; ARM32-LABEL: fptrunc ; ARM32-LABEL: fptrunc
; ARM32: vcvt.f32.f64 {{s[0-9]+}}, {{d[0-9]+}} ; ARM32: vcvt.f32.f64 {{s[0-9]+}}, {{d[0-9]+}}
; MIPS32-LABEL: fptrunc
; MIPS32: cvt.s.d
define internal double @fpext(float %a) { define internal double @fpext(float %a) {
entry: entry:
...@@ -37,6 +44,8 @@ entry: ...@@ -37,6 +44,8 @@ entry:
; CHECK: fld ; CHECK: fld
; ARM32-LABEL: fpext ; ARM32-LABEL: fpext
; ARM32: vcvt.f64.f32 {{d[0-9]+}}, {{s[0-9]+}} ; ARM32: vcvt.f64.f32 {{d[0-9]+}}, {{s[0-9]+}}
; MIPS32-LABEL: fpext
; MIPS32: cvt.d.s
define internal i64 @doubleToSigned64(double %a) { define internal i64 @doubleToSigned64(double %a) {
entry: entry:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment