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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 6117003: ARM: Add instruction VFPCompareAndSetFlags to macro assembler (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1071
1072 Representation r = instr->hydrogen()->representation(); 1072 Representation r = instr->hydrogen()->representation();
1073 if (r.IsInteger32()) { 1073 if (r.IsInteger32()) {
1074 Register reg = ToRegister(instr->input()); 1074 Register reg = ToRegister(instr->input());
1075 __ cmp(reg, Operand(0)); 1075 __ cmp(reg, Operand(0));
1076 EmitBranch(true_block, false_block, nz); 1076 EmitBranch(true_block, false_block, nz);
1077 } else if (r.IsDouble()) { 1077 } else if (r.IsDouble()) {
1078 DoubleRegister reg = ToDoubleRegister(instr->input()); 1078 DoubleRegister reg = ToDoubleRegister(instr->input());
1079 Register scratch = scratch0(); 1079 Register scratch = scratch0();
1080 1080
1081 // Test for the double value. Zero and NaN are false. 1081 // Test the double value. Zero and NaN are false.
1082 // Clear the Invalid cumulative exception flags. 1082 __ VFPCompareAndLoadFlags(reg, 0.0, scratch);
1083 __ ClearFPSCRBits(kVFPInvalidExceptionBit, scratch);
1084 __ vcmp(reg, 0.0);
1085 // Retrieve the exception and status flags and
1086 // check for zero or an invalid exception.
1087 __ vmrs(scratch);
1088 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPInvalidExceptionBit)); 1083 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPInvalidExceptionBit));
1089 EmitBranch(true_block, false_block, ne); 1084 EmitBranch(true_block, false_block, ne);
1090 } else { 1085 } else {
1091 ASSERT(r.IsTagged()); 1086 ASSERT(r.IsTagged());
1092 Register reg = ToRegister(instr->input()); 1087 Register reg = ToRegister(instr->input());
1093 if (instr->hydrogen()->type().IsBoolean()) { 1088 if (instr->hydrogen()->type().IsBoolean()) {
1094 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 1089 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1095 __ cmp(reg, ip); 1090 __ cmp(reg, ip);
1096 EmitBranch(true_block, false_block, eq); 1091 EmitBranch(true_block, false_block, eq);
1097 } else { 1092 } else {
1098 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1093 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1099 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1094 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1100 1095
1101 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 1096 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1102 __ cmp(reg, ip); 1097 __ cmp(reg, ip);
1103 __ b(eq, false_label); 1098 __ b(eq, false_label);
1104 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 1099 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1105 __ cmp(reg, ip); 1100 __ cmp(reg, ip);
1106 __ b(eq, true_label); 1101 __ b(eq, true_label);
1107 __ LoadRoot(ip, Heap::kFalseValueRootIndex); 1102 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
1108 __ cmp(reg, ip); 1103 __ cmp(reg, ip);
1109 __ b(eq, false_label); 1104 __ b(eq, false_label);
1110 __ cmp(reg, Operand(0)); 1105 __ cmp(reg, Operand(0));
1111 __ b(eq, false_label); 1106 __ b(eq, false_label);
1112 __ tst(reg, Operand(kSmiTagMask)); 1107 __ tst(reg, Operand(kSmiTagMask));
1113 __ b(eq, true_label); 1108 __ b(eq, true_label);
1114 1109
1115 // Test for double values. Zero and NaN are false. 1110 // Test double values. Zero and NaN are false.
1116 Label call_stub; 1111 Label call_stub;
1117 DoubleRegister dbl_scratch = d0; 1112 DoubleRegister dbl_scratch = d0;
1118 Register scratch = scratch0(); 1113 Register scratch = scratch0();
1119 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); 1114 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset));
1120 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); 1115 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
1121 __ cmp(scratch, Operand(ip)); 1116 __ cmp(scratch, Operand(ip));
1122 __ b(ne, &call_stub); 1117 __ b(ne, &call_stub);
1123 __ sub(ip, reg, Operand(kHeapObjectTag)); 1118 __ sub(ip, reg, Operand(kHeapObjectTag));
1124 __ vldr(dbl_scratch, ip, HeapNumber::kValueOffset); 1119 __ vldr(dbl_scratch, ip, HeapNumber::kValueOffset);
1125 // Clear the Invalid cumulative exception flags. 1120 __ VFPCompareAndLoadFlags(dbl_scratch, 0.0, scratch);
1126 __ ClearFPSCRBits(kVFPInvalidExceptionBit, scratch);
1127 __ vcmp(dbl_scratch, 0.0);
1128 // Retrieve the exception and status flags and
1129 // check for zero or an invalid exception.
1130 __ vmrs(scratch);
1131 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPInvalidExceptionBit)); 1121 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPInvalidExceptionBit));
1132 __ b(ne, false_label); 1122 __ b(ne, false_label);
1133 __ b(true_label); 1123 __ b(true_label);
1134 1124
1135 // The conversion stub doesn't cause garbage collections so it's 1125 // The conversion stub doesn't cause garbage collections so it's
1136 // safe to not record a safepoint after the call. 1126 // safe to not record a safepoint after the call.
1137 __ bind(&call_stub); 1127 __ bind(&call_stub);
1138 ToBooleanStub stub(reg); 1128 ToBooleanStub stub(reg);
1139 RegList saved_regs = kJSCallerSaved | kCalleeSaved; 1129 RegList saved_regs = kJSCallerSaved | kCalleeSaved;
1140 __ stm(db_w, sp, saved_regs); 1130 __ stm(db_w, sp, saved_regs);
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 // conversions. 2180 // conversions.
2191 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 2181 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
2192 __ cmp(input_reg, Operand(ip)); 2182 __ cmp(input_reg, Operand(ip));
2193 DeoptimizeIf(ne, instr->environment()); 2183 DeoptimizeIf(ne, instr->environment());
2194 __ mov(input_reg, Operand(0)); 2184 __ mov(input_reg, Operand(0));
2195 __ b(&done); 2185 __ b(&done);
2196 2186
2197 __ bind(&heap_number); 2187 __ bind(&heap_number);
2198 __ sub(ip, input_reg, Operand(kHeapObjectTag)); 2188 __ sub(ip, input_reg, Operand(kHeapObjectTag));
2199 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); 2189 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset);
2200 __ vcmp(dbl_tmp, 0.0); // Sets overflow bit if NaN. 2190 __ vcmp(dbl_tmp, 0.0); // Sets overflow bit in FPSCR flags if NaN.
2201 __ vcvt_s32_f64(flt_scratch, dbl_tmp); 2191 __ vcvt_s32_f64(flt_scratch, dbl_tmp);
2202 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. 2192 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion.
2203 __ vmrs(pc); // Move vector status bits to normal status bits. 2193 __ vmrs(pc); // Move vector status bits to normal status bits.
2204 // Overflow bit is set if dbl_tmp is Nan. 2194 // Overflow bit is set if dbl_tmp is Nan.
2205 __ cmn(input_reg, Operand(1), vc); // 0x7fffffff + 1 -> overflow. 2195 __ cmn(input_reg, Operand(1), vc); // 0x7fffffff + 1 -> overflow.
2206 __ cmp(input_reg, Operand(1), vc); // 0x80000000 - 1 -> overflow. 2196 __ cmp(input_reg, Operand(1), vc); // 0x80000000 - 1 -> overflow.
2207 DeoptimizeIf(vs, instr->environment()); // Saturation may have occured. 2197 DeoptimizeIf(vs, instr->environment()); // Saturation may have occured.
2208 2198
2209 } else { 2199 } else {
2210 // Deoptimize if we don't have a heap number. 2200 // Deoptimize if we don't have a heap number.
2211 DeoptimizeIf(ne, instr->environment()); 2201 DeoptimizeIf(ne, instr->environment());
2212 2202
2213 __ sub(ip, input_reg, Operand(kHeapObjectTag)); 2203 __ sub(ip, input_reg, Operand(kHeapObjectTag));
2214 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); 2204 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset);
2215 __ vcvt_s32_f64(flt_scratch, dbl_tmp); 2205 __ vcvt_s32_f64(flt_scratch, dbl_tmp);
2216 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. 2206 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion.
2217 // Non-truncating conversion means that we cannot lose bits, so we convert 2207 // Non-truncating conversion means that we cannot lose bits, so we convert
2218 // back to check; note that using non-overlapping s and d regs would be 2208 // back to check; note that using non-overlapping s and d regs would be
2219 // slightly faster. 2209 // slightly faster.
2220 __ vcvt_f64_s32(dbl_scratch, flt_scratch); 2210 __ vcvt_f64_s32(dbl_scratch, flt_scratch);
2221 __ vcmp(dbl_scratch, dbl_tmp); 2211 __ VFPCompareAndSetFlags(dbl_scratch, dbl_tmp);
2222 __ vmrs(pc); // Move vector status bits to normal status bits.
2223 DeoptimizeIf(ne, instr->environment()); // Not equal or unordered. 2212 DeoptimizeIf(ne, instr->environment()); // Not equal or unordered.
2224 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 2213 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2225 __ tst(input_reg, Operand(input_reg)); 2214 __ tst(input_reg, Operand(input_reg));
2226 __ b(ne, &done); 2215 __ b(ne, &done);
2227 __ vmov(lr, ip, dbl_tmp); 2216 __ vmov(lr, ip, dbl_tmp);
2228 __ tst(ip, Operand(1 << 31)); // Test sign bit. 2217 __ tst(ip, Operand(1 << 31)); // Test sign bit.
2229 DeoptimizeIf(ne, instr->environment()); 2218 DeoptimizeIf(ne, instr->environment());
2230 } 2219 }
2231 } 2220 }
2232 __ bind(&done); 2221 __ bind(&done);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 2630
2642 2631
2643 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { 2632 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
2644 Abort("DoOsrEntry unimplemented."); 2633 Abort("DoOsrEntry unimplemented.");
2645 } 2634 }
2646 2635
2647 2636
2648 #undef __ 2637 #undef __
2649 2638
2650 } } // namespace v8::internal 2639 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698