Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ | 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ |
| 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ | 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ |
| 7 | 7 |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 class Truncation final { | 15 class Truncation final { |
| 16 public: | 16 public: |
| 17 // Constructors. | 17 // Constructors. |
| 18 static Truncation None() { return Truncation(TruncationKind::kNone); } | 18 static Truncation None() { return Truncation(TruncationKind::kNone); } |
| 19 static Truncation Bool() { return Truncation(TruncationKind::kBool); } | 19 static Truncation Bool() { return Truncation(TruncationKind::kBool); } |
| 20 static Truncation Word32() { return Truncation(TruncationKind::kWord32); } | 20 static Truncation Word32() { return Truncation(TruncationKind::kWord32); } |
| 21 static Truncation Word64() { return Truncation(TruncationKind::kWord64); } | 21 static Truncation Word64() { return Truncation(TruncationKind::kWord64); } |
| 22 static Truncation Float32() { return Truncation(TruncationKind::kFloat32); } | |
| 23 static Truncation Float64() { return Truncation(TruncationKind::kFloat64); } | 22 static Truncation Float64() { return Truncation(TruncationKind::kFloat64); } |
| 24 static Truncation Any() { return Truncation(TruncationKind::kAny); } | 23 static Truncation Any() { return Truncation(TruncationKind::kAny); } |
| 25 | 24 |
| 26 static Truncation Generalize(Truncation t1, Truncation t2) { | 25 static Truncation Generalize(Truncation t1, Truncation t2) { |
| 27 return Truncation(Generalize(t1.kind(), t2.kind())); | 26 return Truncation(Generalize(t1.kind(), t2.kind())); |
| 28 } | 27 } |
| 29 | 28 |
| 30 // Queries. | 29 // Queries. |
| 31 bool IsUnused() const { return kind_ == TruncationKind::kNone; } | 30 bool IsUnused() const { return kind_ == TruncationKind::kNone; } |
| 32 bool IsUsedAsBool() const { | 31 bool IsUsedAsBool() const { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 56 bool IsLessGeneralThan(Truncation other) { | 55 bool IsLessGeneralThan(Truncation other) { |
| 57 return LessGeneral(kind(), other.kind()); | 56 return LessGeneral(kind(), other.kind()); |
| 58 } | 57 } |
| 59 | 58 |
| 60 private: | 59 private: |
| 61 enum class TruncationKind : uint8_t { | 60 enum class TruncationKind : uint8_t { |
| 62 kNone, | 61 kNone, |
| 63 kBool, | 62 kBool, |
| 64 kWord32, | 63 kWord32, |
| 65 kWord64, | 64 kWord64, |
| 66 kFloat32, | |
| 67 kFloat64, | 65 kFloat64, |
| 68 kAny | 66 kAny |
| 69 }; | 67 }; |
| 70 | 68 |
| 71 explicit Truncation(TruncationKind kind) : kind_(kind) {} | 69 explicit Truncation(TruncationKind kind) : kind_(kind) {} |
| 72 TruncationKind kind() const { return kind_; } | 70 TruncationKind kind() const { return kind_; } |
| 73 | 71 |
| 74 TruncationKind kind_; | 72 TruncationKind kind_; |
| 75 | 73 |
| 76 static TruncationKind Generalize(TruncationKind rep1, TruncationKind rep2); | 74 static TruncationKind Generalize(TruncationKind rep1, TruncationKind rep2); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 minus_zero_check_(minus_zero_check) {} | 125 minus_zero_check_(minus_zero_check) {} |
| 128 static UseInfo TruncatingWord32() { | 126 static UseInfo TruncatingWord32() { |
| 129 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); | 127 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); |
| 130 } | 128 } |
| 131 static UseInfo TruncatingWord64() { | 129 static UseInfo TruncatingWord64() { |
| 132 return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); | 130 return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); |
| 133 } | 131 } |
| 134 static UseInfo Bool() { | 132 static UseInfo Bool() { |
| 135 return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); | 133 return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); |
| 136 } | 134 } |
| 137 static UseInfo TruncatingFloat32() { | 135 static UseInfo Float32() { |
| 138 return UseInfo(MachineRepresentation::kFloat32, Truncation::Float32()); | 136 return UseInfo(MachineRepresentation::kFloat32, Truncation::Any()); |
|
Jarin
2016/10/12 18:04:01
It might be better to say kFloat64; otherwise floa
mvstanton
2016/10/13 13:25:48
Per our offline discussion, I'll go ahead and land
| |
| 139 } | 137 } |
| 140 static UseInfo TruncatingFloat64() { | 138 static UseInfo TruncatingFloat64() { |
| 141 return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64()); | 139 return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64()); |
| 142 } | 140 } |
| 143 static UseInfo PointerInt() { | 141 static UseInfo PointerInt() { |
| 144 return kPointerSize == 4 ? TruncatingWord32() : TruncatingWord64(); | 142 return kPointerSize == 4 ? TruncatingWord32() : TruncatingWord64(); |
| 145 } | 143 } |
| 146 static UseInfo AnyTagged() { | 144 static UseInfo AnyTagged() { |
| 147 return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); | 145 return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); |
| 148 } | 146 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 Factory* factory() const { return isolate()->factory(); } | 294 Factory* factory() const { return isolate()->factory(); } |
| 297 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } | 295 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } |
| 298 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } | 296 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
| 299 }; | 297 }; |
| 300 | 298 |
| 301 } // namespace compiler | 299 } // namespace compiler |
| 302 } // namespace internal | 300 } // namespace internal |
| 303 } // namespace v8 | 301 } // namespace v8 |
| 304 | 302 |
| 305 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 303 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
| OLD | NEW |