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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 550723002: Subzero: Use cvttss2si and similar instead of cvtss2si for fp->int casts. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use truncating conversion instruction for fp to int conversions Created 6 years, 3 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/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/fp.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/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 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 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 _cvt(T, Src0RM); 2050 _cvt(T, Src0RM);
2051 _mov(Dest, T); 2051 _mov(Dest, T);
2052 break; 2052 break;
2053 } 2053 }
2054 case InstCast::Fptosi: 2054 case InstCast::Fptosi:
2055 if (isVectorType(Dest->getType())) { 2055 if (isVectorType(Dest->getType())) {
2056 assert(Dest->getType() == IceType_v4i32 && 2056 assert(Dest->getType() == IceType_v4i32 &&
2057 Inst->getSrc(0)->getType() == IceType_v4f32); 2057 Inst->getSrc(0)->getType() == IceType_v4f32);
2058 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2058 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2059 Variable *T = makeReg(Dest->getType()); 2059 Variable *T = makeReg(Dest->getType());
2060 _cvt(T, Src0RM); 2060 _cvtt(T, Src0RM);
2061 _movp(Dest, T); 2061 _movp(Dest, T);
2062 } else if (Dest->getType() == IceType_i64) { 2062 } else if (Dest->getType() == IceType_i64) {
2063 // Use a helper for converting floating-point values to 64-bit 2063 // Use a helper for converting floating-point values to 64-bit
2064 // integers. SSE2 appears to have no way to convert from xmm 2064 // integers. SSE2 appears to have no way to convert from xmm
2065 // registers to something like the edx:eax register pair, and 2065 // registers to something like the edx:eax register pair, and
2066 // gcc and clang both want to use x87 instructions complete with 2066 // gcc and clang both want to use x87 instructions complete with
2067 // temporary manipulation of the status word. This helper is 2067 // temporary manipulation of the status word. This helper is
2068 // not needed for x86-64. 2068 // not needed for x86-64.
2069 split64(Dest); 2069 split64(Dest);
2070 const SizeT MaxSrcs = 1; 2070 const SizeT MaxSrcs = 1;
2071 Type SrcType = Inst->getSrc(0)->getType(); 2071 Type SrcType = Inst->getSrc(0)->getType();
2072 InstCall *Call = makeHelperCall( 2072 InstCall *Call = makeHelperCall(
2073 SrcType == IceType_f32 ? "cvtftosi64" : "cvtdtosi64", Dest, MaxSrcs); 2073 SrcType == IceType_f32 ? "cvtftosi64" : "cvtdtosi64", Dest, MaxSrcs);
2074 // TODO: Call the correct compiler-rt helper function. 2074 // TODO: Call the correct compiler-rt helper function.
2075 Call->addArg(Inst->getSrc(0)); 2075 Call->addArg(Inst->getSrc(0));
2076 lowerCall(Call); 2076 lowerCall(Call);
2077 } else { 2077 } else {
2078 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2078 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2079 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2079 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2080 Variable *T_1 = makeReg(IceType_i32); 2080 Variable *T_1 = makeReg(IceType_i32);
2081 Variable *T_2 = makeReg(Dest->getType()); 2081 Variable *T_2 = makeReg(Dest->getType());
2082 _cvt(T_1, Src0RM); 2082 _cvtt(T_1, Src0RM);
2083 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2083 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2084 _mov(Dest, T_2); 2084 _mov(Dest, T_2);
2085 T_2->setPreferredRegister(T_1, true); 2085 T_2->setPreferredRegister(T_1, true);
2086 } 2086 }
2087 break; 2087 break;
2088 case InstCast::Fptoui: 2088 case InstCast::Fptoui:
2089 if (isVectorType(Dest->getType())) { 2089 if (isVectorType(Dest->getType())) {
2090 assert(Dest->getType() == IceType_v4i32 && 2090 assert(Dest->getType() == IceType_v4i32 &&
2091 Inst->getSrc(0)->getType() == IceType_v4f32); 2091 Inst->getSrc(0)->getType() == IceType_v4f32);
2092 const SizeT MaxSrcs = 1; 2092 const SizeT MaxSrcs = 1;
(...skipping 14 matching lines...) Expand all
2107 // TODO: Call the correct compiler-rt helper function. 2107 // TODO: Call the correct compiler-rt helper function.
2108 InstCall *Call = makeHelperCall(TargetString, Dest, MaxSrcs); 2108 InstCall *Call = makeHelperCall(TargetString, Dest, MaxSrcs);
2109 Call->addArg(Inst->getSrc(0)); 2109 Call->addArg(Inst->getSrc(0));
2110 lowerCall(Call); 2110 lowerCall(Call);
2111 return; 2111 return;
2112 } else { 2112 } else {
2113 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2113 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2114 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2114 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2115 Variable *T_1 = makeReg(IceType_i32); 2115 Variable *T_1 = makeReg(IceType_i32);
2116 Variable *T_2 = makeReg(Dest->getType()); 2116 Variable *T_2 = makeReg(Dest->getType());
2117 _cvt(T_1, Src0RM); 2117 _cvtt(T_1, Src0RM);
2118 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2118 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2119 _mov(Dest, T_2); 2119 _mov(Dest, T_2);
2120 T_2->setPreferredRegister(T_1, true); 2120 T_2->setPreferredRegister(T_1, true);
2121 } 2121 }
2122 break; 2122 break;
2123 case InstCast::Sitofp: 2123 case InstCast::Sitofp:
2124 if (isVectorType(Dest->getType())) { 2124 if (isVectorType(Dest->getType())) {
2125 assert(Dest->getType() == IceType_v4f32 && 2125 assert(Dest->getType() == IceType_v4f32 &&
2126 Inst->getSrc(0)->getType() == IceType_v4i32); 2126 Inst->getSrc(0)->getType() == IceType_v4i32);
2127 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2127 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after
4439 Str << "\t.align\t" << Align << "\n"; 4439 Str << "\t.align\t" << Align << "\n";
4440 Str << MangledName << ":\n"; 4440 Str << MangledName << ":\n";
4441 for (SizeT i = 0; i < Size; ++i) { 4441 for (SizeT i = 0; i < Size; ++i) {
4442 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4442 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4443 } 4443 }
4444 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4444 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4445 } 4445 }
4446 } 4446 }
4447 4447
4448 } // end of namespace Ice 4448 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/fp.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698