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

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

Issue 142473006: A64: Do not sign-extend constant operand of bitwise operation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/a64/lithium-codegen-a64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 } else if (op->IsDoubleRegister()) { 1080 } else if (op->IsDoubleRegister()) {
1081 Abort("ToOperand IsDoubleRegister unimplemented"); 1081 Abort("ToOperand IsDoubleRegister unimplemented");
1082 return Operand(0); 1082 return Operand(0);
1083 } 1083 }
1084 // Stack slots not implemented, use ToMemOperand instead. 1084 // Stack slots not implemented, use ToMemOperand instead.
1085 UNREACHABLE(); 1085 UNREACHABLE();
1086 return Operand(0); 1086 return Operand(0);
1087 } 1087 }
1088 1088
1089 1089
1090 Operand LCodeGen::ToOperand32(LOperand* op) { 1090 Operand LCodeGen::ToOperand32I(LOperand* op) {
1091 return ToOperand32(op, SIGNED_INT32);
1092 }
1093
1094
1095 Operand LCodeGen::ToOperand32U(LOperand* op) {
1096 return ToOperand32(op, UNSIGNED_INT32);
1097 }
1098
1099
1100 Operand LCodeGen::ToOperand32(LOperand* op, IntegerSignedness signedness) {
1091 ASSERT(op != NULL); 1101 ASSERT(op != NULL);
1092 if (op->IsRegister()) { 1102 if (op->IsRegister()) {
1093 return Operand(ToRegister32(op)); 1103 return Operand(ToRegister32(op));
1094 } else if (op->IsConstantOperand()) { 1104 } else if (op->IsConstantOperand()) {
1095 LConstantOperand* const_op = LConstantOperand::cast(op); 1105 LConstantOperand* const_op = LConstantOperand::cast(op);
1096 HConstant* constant = chunk()->LookupConstant(const_op); 1106 HConstant* constant = chunk()->LookupConstant(const_op);
1097 Representation r = chunk_->LookupLiteralRepresentation(const_op); 1107 Representation r = chunk_->LookupLiteralRepresentation(const_op);
1098 if (r.IsInteger32()) { 1108 if (r.IsInteger32()) {
1099 ASSERT(constant->HasInteger32Value()); 1109 ASSERT(constant->HasInteger32Value());
1100 return Operand(constant->Integer32Value()); 1110 return Operand(signedness == SIGNED_INT32
1111 ? constant->Integer32Value()
1112 : static_cast<uint32_t>(constant->Integer32Value()));
1101 } else { 1113 } else {
1102 // Other constants not implemented. 1114 // Other constants not implemented.
1103 Abort("ToOperand32 unsupported immediate."); 1115 Abort("ToOperand32 unsupported immediate.");
1104 } 1116 }
1105 } 1117 }
1106 // Other cases are not implemented. 1118 // Other cases are not implemented.
1107 UNREACHABLE(); 1119 UNREACHABLE();
1108 return Operand(0); 1120 return Operand(0);
1109 } 1121 }
1110 1122
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 instr->index()->IsConstantOperand()) { 1278 instr->index()->IsConstantOperand()) {
1267 ASSERT(instr->temp() == NULL); 1279 ASSERT(instr->temp() == NULL);
1268 int index = ToInteger32(LConstantOperand::cast(instr->index())); 1280 int index = ToInteger32(LConstantOperand::cast(instr->index()));
1269 int length = ToInteger32(LConstantOperand::cast(instr->length())); 1281 int length = ToInteger32(LConstantOperand::cast(instr->length()));
1270 int offset = ((length - index) + 1) * kPointerSize; 1282 int offset = ((length - index) + 1) * kPointerSize;
1271 __ Ldr(result, MemOperand(arguments, offset)); 1283 __ Ldr(result, MemOperand(arguments, offset));
1272 } else { 1284 } else {
1273 ASSERT(instr->temp() != NULL); 1285 ASSERT(instr->temp() != NULL);
1274 Register temp = ToRegister32(instr->temp()); 1286 Register temp = ToRegister32(instr->temp());
1275 Register length = ToRegister32(instr->length()); 1287 Register length = ToRegister32(instr->length());
1276 Operand index = ToOperand32(instr->index()); 1288 Operand index = ToOperand32I(instr->index());
1277 // There are two words between the frame pointer and the last arguments. 1289 // There are two words between the frame pointer and the last arguments.
1278 // Subtracting from length accounts for only one, so we add one more. 1290 // Subtracting from length accounts for only one, so we add one more.
1279 __ Sub(temp, length, index); 1291 __ Sub(temp, length, index);
1280 __ Add(temp, temp, 1); 1292 __ Add(temp, temp, 1);
1281 __ Ldr(result, MemOperand(arguments, temp, UXTW, kPointerSizeLog2)); 1293 __ Ldr(result, MemOperand(arguments, temp, UXTW, kPointerSizeLog2));
1282 } 1294 }
1283 } 1295 }
1284 1296
1285 1297
1286 void LCodeGen::DoAddI(LAddI* instr) { 1298 void LCodeGen::DoAddI(LAddI* instr) {
1287 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); 1299 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
1288 Register result = ToRegister32(instr->result()); 1300 Register result = ToRegister32(instr->result());
1289 Register left = ToRegister32(instr->left()); 1301 Register left = ToRegister32(instr->left());
1290 Operand right = ToOperand32(instr->right()); 1302 Operand right = ToOperand32I(instr->right());
1291 if (can_overflow) { 1303 if (can_overflow) {
1292 __ Adds(result, left, right); 1304 __ Adds(result, left, right);
1293 DeoptimizeIf(vs, instr->environment()); 1305 DeoptimizeIf(vs, instr->environment());
1294 } else { 1306 } else {
1295 __ Add(result, left, right); 1307 __ Add(result, left, right);
1296 } 1308 }
1297 } 1309 }
1298 1310
1299 1311
1300 void LCodeGen::DoAddS(LAddS* instr) { 1312 void LCodeGen::DoAddS(LAddS* instr) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 ASSERT(ToRegister(instr->result()).is(x0)); 1557 ASSERT(ToRegister(instr->result()).is(x0));
1546 1558
1547 BinaryOpStub stub(instr->op(), NO_OVERWRITE); 1559 BinaryOpStub stub(instr->op(), NO_OVERWRITE);
1548 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 1560 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1549 } 1561 }
1550 1562
1551 1563
1552 void LCodeGen::DoBitI(LBitI* instr) { 1564 void LCodeGen::DoBitI(LBitI* instr) {
1553 Register result = ToRegister32(instr->result()); 1565 Register result = ToRegister32(instr->result());
1554 Register left = ToRegister32(instr->left()); 1566 Register left = ToRegister32(instr->left());
1555 Operand right = ToOperand32(instr->right()); 1567 Operand right = ToOperand32U(instr->right());
1556 1568
1557 switch (instr->op()) { 1569 switch (instr->op()) {
1558 case Token::BIT_AND: __ And(result, left, right); break; 1570 case Token::BIT_AND: __ And(result, left, right); break;
1559 case Token::BIT_OR: __ Orr(result, left, right); break; 1571 case Token::BIT_OR: __ Orr(result, left, right); break;
1560 case Token::BIT_XOR: __ Eor(result, left, right); break; 1572 case Token::BIT_XOR: __ Eor(result, left, right); break;
1561 default: 1573 default:
1562 UNREACHABLE(); 1574 UNREACHABLE();
1563 break; 1575 break;
1564 } 1576 }
1565 } 1577 }
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 // If a NaN is involved, i.e. the result is unordered (V set), 2212 // If a NaN is involved, i.e. the result is unordered (V set),
2201 // jump to false block label. 2213 // jump to false block label.
2202 __ B(vs, instr->FalseLabel(chunk_)); 2214 __ B(vs, instr->FalseLabel(chunk_));
2203 EmitBranch(instr, cond); 2215 EmitBranch(instr, cond);
2204 } else { 2216 } else {
2205 if (instr->hydrogen_value()->representation().IsInteger32()) { 2217 if (instr->hydrogen_value()->representation().IsInteger32()) {
2206 if (right->IsConstantOperand()) { 2218 if (right->IsConstantOperand()) {
2207 EmitCompareAndBranch(instr, 2219 EmitCompareAndBranch(instr,
2208 cond, 2220 cond,
2209 ToRegister32(left), 2221 ToRegister32(left),
2210 ToOperand32(right)); 2222 ToOperand32I(right));
2211 } else { 2223 } else {
2212 // Transpose the operands and reverse the condition. 2224 // Transpose the operands and reverse the condition.
2213 EmitCompareAndBranch(instr, 2225 EmitCompareAndBranch(instr,
2214 ReverseConditionForCmp(cond), 2226 ReverseConditionForCmp(cond),
2215 ToRegister32(right), 2227 ToRegister32(right),
2216 ToOperand32(left)); 2228 ToOperand32I(left));
2217 } 2229 }
2218 } else { 2230 } else {
2219 ASSERT(instr->hydrogen_value()->representation().IsSmi()); 2231 ASSERT(instr->hydrogen_value()->representation().IsSmi());
2220 if (right->IsConstantOperand()) { 2232 if (right->IsConstantOperand()) {
2221 int32_t value = ToInteger32(LConstantOperand::cast(right)); 2233 int32_t value = ToInteger32(LConstantOperand::cast(right));
2222 EmitCompareAndBranch(instr, 2234 EmitCompareAndBranch(instr,
2223 cond, 2235 cond,
2224 ToRegister(left), 2236 ToRegister(left),
2225 Operand(Smi::FromInt(value))); 2237 Operand(Smi::FromInt(value)));
2226 } else if (left->IsConstantOperand()) { 2238 } else if (left->IsConstantOperand()) {
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 4013 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
4002 ASSERT(ToDoubleRegister(instr->result()).Is(d0)); 4014 ASSERT(ToDoubleRegister(instr->result()).Is(d0));
4003 } 4015 }
4004 4016
4005 4017
4006 void LCodeGen::DoMathMinMax(LMathMinMax* instr) { 4018 void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
4007 HMathMinMax::Operation op = instr->hydrogen()->operation(); 4019 HMathMinMax::Operation op = instr->hydrogen()->operation();
4008 if (instr->hydrogen()->representation().IsInteger32()) { 4020 if (instr->hydrogen()->representation().IsInteger32()) {
4009 Register result = ToRegister32(instr->result()); 4021 Register result = ToRegister32(instr->result());
4010 Register left = ToRegister32(instr->left()); 4022 Register left = ToRegister32(instr->left());
4011 Operand right = ToOperand32(instr->right()); 4023 Operand right = ToOperand32I(instr->right());
4012 4024
4013 __ Cmp(left, right); 4025 __ Cmp(left, right);
4014 __ Csel(result, left, right, (op == HMathMinMax::kMathMax) ? ge : le); 4026 __ Csel(result, left, right, (op == HMathMinMax::kMathMax) ? ge : le);
4015 } else if (instr->hydrogen()->representation().IsSmi()) { 4027 } else if (instr->hydrogen()->representation().IsSmi()) {
4016 Register result = ToRegister(instr->result()); 4028 Register result = ToRegister(instr->result());
4017 Register left = ToRegister(instr->left()); 4029 Register left = ToRegister(instr->left());
4018 Operand right = ToOperand(instr->right()); 4030 Operand right = ToOperand(instr->right());
4019 4031
4020 __ Cmp(left, right); 4032 __ Cmp(left, right);
4021 __ Csel(result, left, right, (op == HMathMinMax::kMathMax) ? ge : le); 4033 __ Csel(result, left, right, (op == HMathMinMax::kMathMax) ? ge : le);
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
5174 Register string = ToRegister(instr->string()); 5186 Register string = ToRegister(instr->string());
5175 Register result = ToRegister(instr->result()); 5187 Register result = ToRegister(instr->result());
5176 __ Ldr(result, FieldMemOperand(string, String::kLengthOffset)); 5188 __ Ldr(result, FieldMemOperand(string, String::kLengthOffset));
5177 } 5189 }
5178 5190
5179 5191
5180 void LCodeGen::DoSubI(LSubI* instr) { 5192 void LCodeGen::DoSubI(LSubI* instr) {
5181 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); 5193 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
5182 Register result = ToRegister32(instr->result()); 5194 Register result = ToRegister32(instr->result());
5183 Register left = ToRegister32(instr->left()); 5195 Register left = ToRegister32(instr->left());
5184 Operand right = ToOperand32(instr->right()); 5196 Operand right = ToOperand32I(instr->right());
5185 if (can_overflow) { 5197 if (can_overflow) {
5186 __ Subs(result, left, right); 5198 __ Subs(result, left, right);
5187 DeoptimizeIf(vs, instr->environment()); 5199 DeoptimizeIf(vs, instr->environment());
5188 } else { 5200 } else {
5189 __ Sub(result, left, right); 5201 __ Sub(result, left, right);
5190 } 5202 }
5191 } 5203 }
5192 5204
5193 5205
5194 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, 5206 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr,
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 __ Bind(&out_of_object); 5618 __ Bind(&out_of_object);
5607 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 5619 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
5608 // Index is equal to negated out of object property index plus 1. 5620 // Index is equal to negated out of object property index plus 1.
5609 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 5621 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2));
5610 __ Ldr(result, FieldMemOperand(result, 5622 __ Ldr(result, FieldMemOperand(result,
5611 FixedArray::kHeaderSize - kPointerSize)); 5623 FixedArray::kHeaderSize - kPointerSize));
5612 __ Bind(&done); 5624 __ Bind(&done);
5613 } 5625 }
5614 5626
5615 } } // namespace v8::internal 5627 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/a64/lithium-codegen-a64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698