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

Side by Side Diff: src/compiler/representation-change.cc

Issue 2159373004: [turbofan] Properly handle bit->tagged representation changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/representation-change.h" 5 #include "src/compiler/representation-change.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 case IrOpcode::kNumberConstant: 177 case IrOpcode::kNumberConstant:
178 case IrOpcode::kHeapConstant: 178 case IrOpcode::kHeapConstant:
179 return node; // No change necessary. 179 return node; // No change necessary.
180 case IrOpcode::kInt32Constant: 180 case IrOpcode::kInt32Constant:
181 if (output_type->Is(Type::Signed32())) { 181 if (output_type->Is(Type::Signed32())) {
182 int32_t value = OpParameter<int32_t>(node); 182 int32_t value = OpParameter<int32_t>(node);
183 return jsgraph()->Constant(value); 183 return jsgraph()->Constant(value);
184 } else if (output_type->Is(Type::Unsigned32())) { 184 } else if (output_type->Is(Type::Unsigned32())) {
185 uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node)); 185 uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
186 return jsgraph()->Constant(static_cast<double>(value)); 186 return jsgraph()->Constant(static_cast<double>(value));
187 } else if (output_rep == MachineRepresentation::kBit) { 187 } else if (output_type->Is(Type::Boolean())) {
188 return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant() 188 return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant()
189 : jsgraph()->TrueConstant(); 189 : jsgraph()->TrueConstant();
190 } else { 190 } else {
191 return TypeError(node, output_rep, output_type, 191 return TypeError(node, output_rep, output_type,
192 MachineRepresentation::kTagged); 192 MachineRepresentation::kTagged);
193 } 193 }
194 case IrOpcode::kFloat64Constant: 194 case IrOpcode::kFloat64Constant:
195 return jsgraph()->Constant(OpParameter<double>(node)); 195 return jsgraph()->Constant(OpParameter<double>(node));
196 case IrOpcode::kFloat32Constant: 196 case IrOpcode::kFloat32Constant:
197 return jsgraph()->Constant(OpParameter<float>(node)); 197 return jsgraph()->Constant(OpParameter<float>(node));
198 default: 198 default:
199 break; 199 break;
200 } 200 }
201 // Select the correct X -> Tagged operator. 201 // Select the correct X -> Tagged operator.
202 const Operator* op; 202 const Operator* op;
203 if (output_rep == MachineRepresentation::kBit) { 203 if (output_rep == MachineRepresentation::kBit) {
204 op = simplified()->ChangeBitToTagged(); 204 if (output_type->Is(Type::Boolean())) {
205 op = simplified()->ChangeBitToTagged();
206 } else {
207 return TypeError(node, output_rep, output_type,
208 MachineRepresentation::kTagged);
209 }
205 } else if (IsWord(output_rep)) { 210 } else if (IsWord(output_rep)) {
206 if (output_type->Is(Type::Signed31())) { 211 if (output_type->Is(Type::Signed31())) {
207 op = simplified()->ChangeInt31ToTaggedSigned(); 212 op = simplified()->ChangeInt31ToTaggedSigned();
208 } else if (output_type->Is(Type::Signed32())) { 213 } else if (output_type->Is(Type::Signed32())) {
209 op = simplified()->ChangeInt32ToTagged(); 214 op = simplified()->ChangeInt32ToTagged();
210 } else if (output_type->Is(Type::Unsigned32())) { 215 } else if (output_type->Is(Type::Unsigned32())) {
211 op = simplified()->ChangeUint32ToTagged(); 216 op = simplified()->ChangeUint32ToTagged();
212 } else { 217 } else {
213 return TypeError(node, output_rep, output_type, 218 return TypeError(node, output_rep, output_type,
214 MachineRepresentation::kTagged); 219 MachineRepresentation::kTagged);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 826 }
822 827
823 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 828 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
824 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 829 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
825 node); 830 node);
826 } 831 }
827 832
828 } // namespace compiler 833 } // namespace compiler
829 } // namespace internal 834 } // namespace internal
830 } // namespace v8 835 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698