| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_MACHINE_OPERATOR_H_ | 5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ |
| 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ | 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 OStream& operator<<(OStream& os, const StoreRepresentation& rep); | 55 OStream& operator<<(OStream& os, const StoreRepresentation& rep); |
| 56 | 56 |
| 57 | 57 |
| 58 // Interface for building machine-level operators. These operators are | 58 // Interface for building machine-level operators. These operators are |
| 59 // machine-level but machine-independent and thus define a language suitable | 59 // machine-level but machine-independent and thus define a language suitable |
| 60 // for generating code to run on architectures such as ia32, x64, arm, etc. | 60 // for generating code to run on architectures such as ia32, x64, arm, etc. |
| 61 class MachineOperatorBuilder FINAL { | 61 class MachineOperatorBuilder FINAL { |
| 62 public: | 62 public: |
| 63 explicit MachineOperatorBuilder(MachineType word = kMachPtr); | 63 explicit MachineOperatorBuilder(MachineType word = kMachPtr); |
| 64 | 64 |
| 65 const Operator* Word32And() const WARN_UNUSED_RESULT; | 65 const Operator* Word32And() const; |
| 66 const Operator* Word32Or() const WARN_UNUSED_RESULT; | 66 const Operator* Word32Or() const; |
| 67 const Operator* Word32Xor() const WARN_UNUSED_RESULT; | 67 const Operator* Word32Xor() const; |
| 68 const Operator* Word32Shl() const WARN_UNUSED_RESULT; | 68 const Operator* Word32Shl() const; |
| 69 const Operator* Word32Shr() const WARN_UNUSED_RESULT; | 69 const Operator* Word32Shr() const; |
| 70 const Operator* Word32Sar() const WARN_UNUSED_RESULT; | 70 const Operator* Word32Sar() const; |
| 71 const Operator* Word32Ror() const WARN_UNUSED_RESULT; | 71 const Operator* Word32Ror() const; |
| 72 const Operator* Word32Equal() const WARN_UNUSED_RESULT; | 72 const Operator* Word32Equal() const; |
| 73 | 73 |
| 74 const Operator* Word64And() const WARN_UNUSED_RESULT; | 74 const Operator* Word64And() const; |
| 75 const Operator* Word64Or() const WARN_UNUSED_RESULT; | 75 const Operator* Word64Or() const; |
| 76 const Operator* Word64Xor() const WARN_UNUSED_RESULT; | 76 const Operator* Word64Xor() const; |
| 77 const Operator* Word64Shl() const WARN_UNUSED_RESULT; | 77 const Operator* Word64Shl() const; |
| 78 const Operator* Word64Shr() const WARN_UNUSED_RESULT; | 78 const Operator* Word64Shr() const; |
| 79 const Operator* Word64Sar() const WARN_UNUSED_RESULT; | 79 const Operator* Word64Sar() const; |
| 80 const Operator* Word64Ror() const WARN_UNUSED_RESULT; | 80 const Operator* Word64Ror() const; |
| 81 const Operator* Word64Equal() const WARN_UNUSED_RESULT; | 81 const Operator* Word64Equal() const; |
| 82 | 82 |
| 83 const Operator* Int32Add() const WARN_UNUSED_RESULT; | 83 const Operator* Int32Add() const; |
| 84 const Operator* Int32AddWithOverflow() const WARN_UNUSED_RESULT; | 84 const Operator* Int32AddWithOverflow() const; |
| 85 const Operator* Int32Sub() const WARN_UNUSED_RESULT; | 85 const Operator* Int32Sub() const; |
| 86 const Operator* Int32SubWithOverflow() const WARN_UNUSED_RESULT; | 86 const Operator* Int32SubWithOverflow() const; |
| 87 const Operator* Int32Mul() const WARN_UNUSED_RESULT; | 87 const Operator* Int32Mul() const; |
| 88 const Operator* Int32Div() const WARN_UNUSED_RESULT; | 88 const Operator* Int32Div() const; |
| 89 const Operator* Int32UDiv() const WARN_UNUSED_RESULT; | 89 const Operator* Int32UDiv() const; |
| 90 const Operator* Int32Mod() const WARN_UNUSED_RESULT; | 90 const Operator* Int32Mod() const; |
| 91 const Operator* Int32UMod() const WARN_UNUSED_RESULT; | 91 const Operator* Int32UMod() const; |
| 92 const Operator* Int32LessThan() const WARN_UNUSED_RESULT; | 92 const Operator* Int32LessThan() const; |
| 93 const Operator* Int32LessThanOrEqual() const WARN_UNUSED_RESULT; | 93 const Operator* Int32LessThanOrEqual() const; |
| 94 const Operator* Uint32LessThan() const WARN_UNUSED_RESULT; | 94 const Operator* Uint32LessThan() const; |
| 95 const Operator* Uint32LessThanOrEqual() const WARN_UNUSED_RESULT; | 95 const Operator* Uint32LessThanOrEqual() const; |
| 96 | 96 |
| 97 const Operator* Int64Add() const WARN_UNUSED_RESULT; | 97 const Operator* Int64Add() const; |
| 98 const Operator* Int64Sub() const WARN_UNUSED_RESULT; | 98 const Operator* Int64Sub() const; |
| 99 const Operator* Int64Mul() const WARN_UNUSED_RESULT; | 99 const Operator* Int64Mul() const; |
| 100 const Operator* Int64Div() const WARN_UNUSED_RESULT; | 100 const Operator* Int64Div() const; |
| 101 const Operator* Int64UDiv() const WARN_UNUSED_RESULT; | 101 const Operator* Int64UDiv() const; |
| 102 const Operator* Int64Mod() const WARN_UNUSED_RESULT; | 102 const Operator* Int64Mod() const; |
| 103 const Operator* Int64UMod() const WARN_UNUSED_RESULT; | 103 const Operator* Int64UMod() const; |
| 104 const Operator* Int64LessThan() const WARN_UNUSED_RESULT; | 104 const Operator* Int64LessThan() const; |
| 105 const Operator* Int64LessThanOrEqual() const WARN_UNUSED_RESULT; | 105 const Operator* Int64LessThanOrEqual() const; |
| 106 | 106 |
| 107 // Convert representation of integers between float64 and int32/uint32. | 107 // These operators change the representation of numbers while preserving the |
| 108 // The precise rounding mode and handling of out of range inputs are *not* | 108 // value of the number. Narrowing operators assume the input is representable |
| 109 // defined for these operators, since they are intended only for use with | 109 // in the target type and are *not* defined for other inputs. |
| 110 // integers. | 110 // Use narrowing change operators only when there is a static guarantee that |
| 111 const Operator* ChangeInt32ToFloat64() const WARN_UNUSED_RESULT; | 111 // the input value is representable in the target value. |
| 112 const Operator* ChangeUint32ToFloat64() const WARN_UNUSED_RESULT; | 112 const Operator* ChangeFloat32ToFloat64() const; |
| 113 const Operator* ChangeFloat64ToInt32() const WARN_UNUSED_RESULT; | 113 const Operator* ChangeFloat64ToFloat32() const; // narrowing |
| 114 const Operator* ChangeFloat64ToUint32() const WARN_UNUSED_RESULT; | 114 const Operator* ChangeFloat64ToInt32() const; // narrowing |
| 115 const Operator* ChangeFloat64ToUint32() const; // narrowing |
| 116 const Operator* ChangeInt32ToFloat64() const; |
| 117 const Operator* ChangeInt32ToInt64() const; |
| 118 const Operator* ChangeUint32ToFloat64() const; |
| 119 const Operator* ChangeUint32ToUint64() const; |
| 115 | 120 |
| 116 // Sign/zero extend int32/uint32 to int64/uint64. | 121 // These operators truncate numbers, both changing the representation of |
| 117 const Operator* ChangeInt32ToInt64() const WARN_UNUSED_RESULT; | 122 // the number and mapping multiple input values onto the same output value. |
| 118 const Operator* ChangeUint32ToUint64() const WARN_UNUSED_RESULT; | 123 const Operator* TruncateFloat64ToFloat32() const; |
| 119 | 124 const Operator* TruncateFloat64ToInt32() const; // JavaScript semantics. |
| 120 // Truncate double to int32 using JavaScript semantics. | 125 const Operator* TruncateInt64ToInt32() const; |
| 121 const Operator* TruncateFloat64ToInt32() const WARN_UNUSED_RESULT; | |
| 122 | |
| 123 // Truncate the high order bits and convert the remaining bits to int32. | |
| 124 const Operator* TruncateInt64ToInt32() const WARN_UNUSED_RESULT; | |
| 125 | 126 |
| 126 // Floating point operators always operate with IEEE 754 round-to-nearest. | 127 // Floating point operators always operate with IEEE 754 round-to-nearest. |
| 127 const Operator* Float64Add() const WARN_UNUSED_RESULT; | 128 const Operator* Float64Add() const; |
| 128 const Operator* Float64Sub() const WARN_UNUSED_RESULT; | 129 const Operator* Float64Sub() const; |
| 129 const Operator* Float64Mul() const WARN_UNUSED_RESULT; | 130 const Operator* Float64Mul() const; |
| 130 const Operator* Float64Div() const WARN_UNUSED_RESULT; | 131 const Operator* Float64Div() const; |
| 131 const Operator* Float64Mod() const WARN_UNUSED_RESULT; | 132 const Operator* Float64Mod() const; |
| 132 | 133 |
| 133 // Floating point comparisons complying to IEEE 754. | 134 // Floating point comparisons complying to IEEE 754. |
| 134 const Operator* Float64Equal() const WARN_UNUSED_RESULT; | 135 const Operator* Float64Equal() const; |
| 135 const Operator* Float64LessThan() const WARN_UNUSED_RESULT; | 136 const Operator* Float64LessThan() const; |
| 136 const Operator* Float64LessThanOrEqual() const WARN_UNUSED_RESULT; | 137 const Operator* Float64LessThanOrEqual() const; |
| 137 | 138 |
| 138 // load [base + index] | 139 // load [base + index] |
| 139 const Operator* Load(LoadRepresentation rep) const WARN_UNUSED_RESULT; | 140 const Operator* Load(LoadRepresentation rep) const; |
| 140 | 141 |
| 141 // store [base + index], value | 142 // store [base + index], value |
| 142 const Operator* Store(StoreRepresentation rep) const WARN_UNUSED_RESULT; | 143 const Operator* Store(StoreRepresentation rep) const; |
| 143 | 144 |
| 144 // Target machine word-size assumed by this builder. | 145 // Target machine word-size for this builder. |
| 145 bool Is32() const { return word() == kRepWord32; } | 146 bool Is32() const { return word() == kRepWord32; } |
| 146 bool Is64() const { return word() == kRepWord64; } | 147 bool Is64() const { return word() == kRepWord64; } |
| 147 MachineType word() const { return word_; } | 148 MachineType word() const { return word_; } |
| 148 | 149 |
| 149 // Pseudo operators that translate to 32/64-bit operators depending on the | 150 // Pseudo operators that translate to 32/64-bit operators depending on the |
| 150 // word-size of the target machine assumed by this builder. | 151 // word-size of the target machine assumed by this builder. |
| 151 #define PSEUDO_OP_LIST(V) \ | 152 #define PSEUDO_OP_LIST(V) \ |
| 152 V(Word, And) \ | 153 V(Word, And) \ |
| 153 V(Word, Or) \ | 154 V(Word, Or) \ |
| 154 V(Word, Xor) \ | 155 V(Word, Xor) \ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 177 private: | 178 private: |
| 178 const MachineOperatorBuilderImpl& impl_; | 179 const MachineOperatorBuilderImpl& impl_; |
| 179 const MachineType word_; | 180 const MachineType word_; |
| 180 }; | 181 }; |
| 181 | 182 |
| 182 } // namespace compiler | 183 } // namespace compiler |
| 183 } // namespace internal | 184 } // namespace internal |
| 184 } // namespace v8 | 185 } // namespace v8 |
| 185 | 186 |
| 186 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 187 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |