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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 547033002: Subzero: Be more strict about i1 calculations. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Revert what turned out to be unnecessary changes 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
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 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 _mov(T_Hi, T_Lo); 1958 _mov(T_Hi, T_Lo);
1959 _sar(T_Hi, Shift); 1959 _sar(T_Hi, Shift);
1960 _mov(DestHi, T_Hi); 1960 _mov(DestHi, T_Hi);
1961 } else if (Src0RM->getType() == IceType_i1) { 1961 } else if (Src0RM->getType() == IceType_i1) {
1962 // t1 = src 1962 // t1 = src
1963 // shl t1, dst_bitwidth - 1 1963 // shl t1, dst_bitwidth - 1
1964 // sar t1, dst_bitwidth - 1 1964 // sar t1, dst_bitwidth - 1
1965 // dst = t1 1965 // dst = t1
1966 size_t DestBits = X86_CHAR_BIT * typeWidthInBytes(Dest->getType()); 1966 size_t DestBits = X86_CHAR_BIT * typeWidthInBytes(Dest->getType());
1967 Constant *ShiftAmount = Ctx->getConstantInt(IceType_i32, DestBits - 1); 1967 Constant *ShiftAmount = Ctx->getConstantInt(IceType_i32, DestBits - 1);
1968 Variable *T = NULL; 1968 Variable *T = makeReg(Dest->getType());
1969 _mov(T, Src0RM); 1969 if (typeWidthInBytes(Dest->getType()) <=
1970 typeWidthInBytes(Src0RM->getType())) {
1971 _mov(T, Src0RM);
1972 } else {
1973 _movzx(T, Src0RM);
jvoung (off chromium) 2014/09/06 17:53:02 Not sure I understand why it's movzx (for a sign-e
Jim Stichnoth 2014/09/06 21:57:27 Clarified in a comment. Movsx/movzx are only need
1974 }
1970 _shl(T, ShiftAmount); 1975 _shl(T, ShiftAmount);
1971 _sar(T, ShiftAmount); 1976 _sar(T, ShiftAmount);
1972 _mov(Dest, T); 1977 _mov(Dest, T);
1973 } else { 1978 } else {
1974 // t1 = movsx src; dst = t1 1979 // t1 = movsx src; dst = t1
1975 Variable *T = makeReg(Dest->getType()); 1980 Variable *T = makeReg(Dest->getType());
1976 _movsx(T, Src0RM); 1981 _movsx(T, Src0RM);
1977 _mov(Dest, T); 1982 _mov(Dest, T);
1978 } 1983 }
1979 break; 1984 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 _pand(T, OneMask); 2036 _pand(T, OneMask);
2032 _movp(Dest, T); 2037 _movp(Dest, T);
2033 } else { 2038 } else {
2034 Operand *Src0 = Inst->getSrc(0); 2039 Operand *Src0 = Inst->getSrc(0);
2035 if (Src0->getType() == IceType_i64) 2040 if (Src0->getType() == IceType_i64)
2036 Src0 = loOperand(Src0); 2041 Src0 = loOperand(Src0);
2037 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); 2042 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem);
2038 // t1 = trunc Src0RM; Dest = t1 2043 // t1 = trunc Src0RM; Dest = t1
2039 Variable *T = NULL; 2044 Variable *T = NULL;
2040 _mov(T, Src0RM); 2045 _mov(T, Src0RM);
2046 if (Dest->getType() == IceType_i1)
2047 _and(T, Ctx->getConstantInt(IceType_i1, 1));
2041 _mov(Dest, T); 2048 _mov(Dest, T);
2042 } 2049 }
2043 break; 2050 break;
2044 } 2051 }
2045 case InstCast::Fptrunc: 2052 case InstCast::Fptrunc:
2046 case InstCast::Fpext: { 2053 case InstCast::Fpext: {
2047 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2054 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2048 // t1 = cvt Src0RM; Dest = t1 2055 // t1 = cvt Src0RM; Dest = t1
2049 Variable *T = makeReg(Dest->getType()); 2056 Variable *T = makeReg(Dest->getType());
2050 _cvt(T, Src0RM); 2057 _cvt(T, Src0RM);
(...skipping 23 matching lines...) Expand all
2074 // TODO: Call the correct compiler-rt helper function. 2081 // TODO: Call the correct compiler-rt helper function.
2075 Call->addArg(Inst->getSrc(0)); 2082 Call->addArg(Inst->getSrc(0));
2076 lowerCall(Call); 2083 lowerCall(Call);
2077 } else { 2084 } else {
2078 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2085 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2079 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2086 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2080 Variable *T_1 = makeReg(IceType_i32); 2087 Variable *T_1 = makeReg(IceType_i32);
2081 Variable *T_2 = makeReg(Dest->getType()); 2088 Variable *T_2 = makeReg(Dest->getType());
2082 _cvt(T_1, Src0RM); 2089 _cvt(T_1, Src0RM);
2083 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2090 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2091 if (Dest->getType() == IceType_i1)
2092 _and(T_2, Ctx->getConstantInt(IceType_i1, 1));
2084 _mov(Dest, T_2); 2093 _mov(Dest, T_2);
2085 T_2->setPreferredRegister(T_1, true); 2094 T_2->setPreferredRegister(T_1, true);
2086 } 2095 }
2087 break; 2096 break;
2088 case InstCast::Fptoui: 2097 case InstCast::Fptoui:
2089 if (isVectorType(Dest->getType())) { 2098 if (isVectorType(Dest->getType())) {
2090 assert(Dest->getType() == IceType_v4i32 && 2099 assert(Dest->getType() == IceType_v4i32 &&
2091 Inst->getSrc(0)->getType() == IceType_v4f32); 2100 Inst->getSrc(0)->getType() == IceType_v4f32);
2092 const SizeT MaxSrcs = 1; 2101 const SizeT MaxSrcs = 1;
2093 InstCall *Call = makeHelperCall("Sz_fptoui_v4f32", Dest, MaxSrcs); 2102 InstCall *Call = makeHelperCall("Sz_fptoui_v4f32", Dest, MaxSrcs);
(...skipping 15 matching lines...) Expand all
2109 Call->addArg(Inst->getSrc(0)); 2118 Call->addArg(Inst->getSrc(0));
2110 lowerCall(Call); 2119 lowerCall(Call);
2111 return; 2120 return;
2112 } else { 2121 } else {
2113 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2122 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2114 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2123 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2115 Variable *T_1 = makeReg(IceType_i32); 2124 Variable *T_1 = makeReg(IceType_i32);
2116 Variable *T_2 = makeReg(Dest->getType()); 2125 Variable *T_2 = makeReg(Dest->getType());
2117 _cvt(T_1, Src0RM); 2126 _cvt(T_1, Src0RM);
2118 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2127 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2128 if (Dest->getType() == IceType_i1)
2129 _and(T_2, Ctx->getConstantInt(IceType_i1, 1));
2119 _mov(Dest, T_2); 2130 _mov(Dest, T_2);
2120 T_2->setPreferredRegister(T_1, true); 2131 T_2->setPreferredRegister(T_1, true);
2121 } 2132 }
2122 break; 2133 break;
2123 case InstCast::Sitofp: 2134 case InstCast::Sitofp:
2124 if (isVectorType(Dest->getType())) { 2135 if (isVectorType(Dest->getType())) {
2125 assert(Dest->getType() == IceType_v4f32 && 2136 assert(Dest->getType() == IceType_v4f32 &&
2126 Inst->getSrc(0)->getType() == IceType_v4i32); 2137 Inst->getSrc(0)->getType() == IceType_v4i32);
2127 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2138 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2128 Variable *T = makeReg(Dest->getType()); 2139 Variable *T = makeReg(Dest->getType());
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4439 Str << "\t.align\t" << Align << "\n"; 4450 Str << "\t.align\t" << Align << "\n";
4440 Str << MangledName << ":\n"; 4451 Str << MangledName << ":\n";
4441 for (SizeT i = 0; i < Size; ++i) { 4452 for (SizeT i = 0; i < Size; ++i) {
4442 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4453 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4443 } 4454 }
4444 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4455 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4445 } 4456 }
4446 } 4457 }
4447 4458
4448 } // end of namespace Ice 4459 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698