| 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(); |
| 66 const Operator* Word32Or() const WARN_UNUSED_RESULT; | 66 const Operator* Word32Or(); |
| 67 const Operator* Word32Xor() const WARN_UNUSED_RESULT; | 67 const Operator* Word32Xor(); |
| 68 const Operator* Word32Shl() const WARN_UNUSED_RESULT; | 68 const Operator* Word32Shl(); |
| 69 const Operator* Word32Shr() const WARN_UNUSED_RESULT; | 69 const Operator* Word32Shr(); |
| 70 const Operator* Word32Sar() const WARN_UNUSED_RESULT; | 70 const Operator* Word32Sar(); |
| 71 const Operator* Word32Ror() const WARN_UNUSED_RESULT; | 71 const Operator* Word32Ror(); |
| 72 const Operator* Word32Equal() const WARN_UNUSED_RESULT; | 72 const Operator* Word32Equal(); |
| 73 | 73 |
| 74 const Operator* Word64And() const WARN_UNUSED_RESULT; | 74 const Operator* Word64And(); |
| 75 const Operator* Word64Or() const WARN_UNUSED_RESULT; | 75 const Operator* Word64Or(); |
| 76 const Operator* Word64Xor() const WARN_UNUSED_RESULT; | 76 const Operator* Word64Xor(); |
| 77 const Operator* Word64Shl() const WARN_UNUSED_RESULT; | 77 const Operator* Word64Shl(); |
| 78 const Operator* Word64Shr() const WARN_UNUSED_RESULT; | 78 const Operator* Word64Shr(); |
| 79 const Operator* Word64Sar() const WARN_UNUSED_RESULT; | 79 const Operator* Word64Sar(); |
| 80 const Operator* Word64Ror() const WARN_UNUSED_RESULT; | 80 const Operator* Word64Ror(); |
| 81 const Operator* Word64Equal() const WARN_UNUSED_RESULT; | 81 const Operator* Word64Equal(); |
| 82 | 82 |
| 83 const Operator* Int32Add() const WARN_UNUSED_RESULT; | 83 const Operator* Int32Add(); |
| 84 const Operator* Int32AddWithOverflow() const WARN_UNUSED_RESULT; | 84 const Operator* Int32AddWithOverflow(); |
| 85 const Operator* Int32Sub() const WARN_UNUSED_RESULT; | 85 const Operator* Int32Sub(); |
| 86 const Operator* Int32SubWithOverflow() const WARN_UNUSED_RESULT; | 86 const Operator* Int32SubWithOverflow(); |
| 87 const Operator* Int32Mul() const WARN_UNUSED_RESULT; | 87 const Operator* Int32Mul(); |
| 88 const Operator* Int32Div() const WARN_UNUSED_RESULT; | 88 const Operator* Int32Div(); |
| 89 const Operator* Int32UDiv() const WARN_UNUSED_RESULT; | 89 const Operator* Int32UDiv(); |
| 90 const Operator* Int32Mod() const WARN_UNUSED_RESULT; | 90 const Operator* Int32Mod(); |
| 91 const Operator* Int32UMod() const WARN_UNUSED_RESULT; | 91 const Operator* Int32UMod(); |
| 92 const Operator* Int32LessThan() const WARN_UNUSED_RESULT; | 92 const Operator* Int32LessThan(); |
| 93 const Operator* Int32LessThanOrEqual() const WARN_UNUSED_RESULT; | 93 const Operator* Int32LessThanOrEqual(); |
| 94 const Operator* Uint32LessThan() const WARN_UNUSED_RESULT; | 94 const Operator* Uint32LessThan(); |
| 95 const Operator* Uint32LessThanOrEqual() const WARN_UNUSED_RESULT; | 95 const Operator* Uint32LessThanOrEqual(); |
| 96 | 96 |
| 97 const Operator* Int64Add() const WARN_UNUSED_RESULT; | 97 const Operator* Int64Add(); |
| 98 const Operator* Int64Sub() const WARN_UNUSED_RESULT; | 98 const Operator* Int64Sub(); |
| 99 const Operator* Int64Mul() const WARN_UNUSED_RESULT; | 99 const Operator* Int64Mul(); |
| 100 const Operator* Int64Div() const WARN_UNUSED_RESULT; | 100 const Operator* Int64Div(); |
| 101 const Operator* Int64UDiv() const WARN_UNUSED_RESULT; | 101 const Operator* Int64UDiv(); |
| 102 const Operator* Int64Mod() const WARN_UNUSED_RESULT; | 102 const Operator* Int64Mod(); |
| 103 const Operator* Int64UMod() const WARN_UNUSED_RESULT; | 103 const Operator* Int64UMod(); |
| 104 const Operator* Int64LessThan() const WARN_UNUSED_RESULT; | 104 const Operator* Int64LessThan(); |
| 105 const Operator* Int64LessThanOrEqual() const WARN_UNUSED_RESULT; | 105 const Operator* Int64LessThanOrEqual(); |
| 106 | 106 |
| 107 // Convert representation of integers between float64 and int32/uint32. | 107 // Convert representation of integers between float64 and int32/uint32. |
| 108 // The precise rounding mode and handling of out of range inputs are *not* | 108 // The precise rounding mode and handling of out of range inputs are *not* |
| 109 // defined for these operators, since they are intended only for use with | 109 // defined for these operators, since they are intended only for use with |
| 110 // integers. | 110 // integers. |
| 111 const Operator* ChangeInt32ToFloat64() const WARN_UNUSED_RESULT; | 111 const Operator* ChangeInt32ToFloat64(); |
| 112 const Operator* ChangeUint32ToFloat64() const WARN_UNUSED_RESULT; | 112 const Operator* ChangeUint32ToFloat64(); |
| 113 const Operator* ChangeFloat64ToInt32() const WARN_UNUSED_RESULT; | 113 const Operator* ChangeFloat64ToInt32(); |
| 114 const Operator* ChangeFloat64ToUint32() const WARN_UNUSED_RESULT; | 114 const Operator* ChangeFloat64ToUint32(); |
| 115 | 115 |
| 116 // Sign/zero extend int32/uint32 to int64/uint64. | 116 // Sign/zero extend int32/uint32 to int64/uint64. |
| 117 const Operator* ChangeInt32ToInt64() const WARN_UNUSED_RESULT; | 117 const Operator* ChangeInt32ToInt64(); |
| 118 const Operator* ChangeUint32ToUint64() const WARN_UNUSED_RESULT; | 118 const Operator* ChangeUint32ToUint64(); |
| 119 | 119 |
| 120 // Truncate double to int32 using JavaScript semantics. | 120 // Truncate double to int32 using JavaScript semantics. |
| 121 const Operator* TruncateFloat64ToInt32() const WARN_UNUSED_RESULT; | 121 const Operator* TruncateFloat64ToInt32(); |
| 122 | 122 |
| 123 // Truncate the high order bits and convert the remaining bits to int32. | 123 // Truncate the high order bits and convert the remaining bits to int32. |
| 124 const Operator* TruncateInt64ToInt32() const WARN_UNUSED_RESULT; | 124 const Operator* TruncateInt64ToInt32(); |
| 125 | 125 |
| 126 // Floating point operators always operate with IEEE 754 round-to-nearest. | 126 // Floating point operators always operate with IEEE 754 round-to-nearest. |
| 127 const Operator* Float64Add() const WARN_UNUSED_RESULT; | 127 const Operator* Float64Add(); |
| 128 const Operator* Float64Sub() const WARN_UNUSED_RESULT; | 128 const Operator* Float64Sub(); |
| 129 const Operator* Float64Mul() const WARN_UNUSED_RESULT; | 129 const Operator* Float64Mul(); |
| 130 const Operator* Float64Div() const WARN_UNUSED_RESULT; | 130 const Operator* Float64Div(); |
| 131 const Operator* Float64Mod() const WARN_UNUSED_RESULT; | 131 const Operator* Float64Mod(); |
| 132 | 132 |
| 133 // Floating point comparisons complying to IEEE 754. | 133 // Floating point comparisons complying to IEEE 754. |
| 134 const Operator* Float64Equal() const WARN_UNUSED_RESULT; | 134 const Operator* Float64Equal(); |
| 135 const Operator* Float64LessThan() const WARN_UNUSED_RESULT; | 135 const Operator* Float64LessThan(); |
| 136 const Operator* Float64LessThanOrEqual() const WARN_UNUSED_RESULT; | 136 const Operator* Float64LessThanOrEqual(); |
| 137 | 137 |
| 138 // load [base + index] | 138 // load [base + index] |
| 139 const Operator* Load(LoadRepresentation rep) const WARN_UNUSED_RESULT; | 139 const Operator* Load(LoadRepresentation rep); |
| 140 | 140 |
| 141 // store [base + index], value | 141 // store [base + index], value |
| 142 const Operator* Store(StoreRepresentation rep) const WARN_UNUSED_RESULT; | 142 const Operator* Store(StoreRepresentation rep); |
| 143 | 143 |
| 144 // Target machine word-size assumed by this builder. | 144 // Target machine word-size assumed by this builder. |
| 145 bool Is32() const { return word() == kRepWord32; } | 145 bool Is32() const { return word() == kRepWord32; } |
| 146 bool Is64() const { return word() == kRepWord64; } | 146 bool Is64() const { return word() == kRepWord64; } |
| 147 MachineType word() const { return word_; } | 147 MachineType word() const { return word_; } |
| 148 | 148 |
| 149 // Pseudo operators that translate to 32/64-bit operators depending on the | 149 // Pseudo operators that translate to 32/64-bit operators depending on the |
| 150 // word-size of the target machine assumed by this builder. | 150 // word-size of the target machine assumed by this builder. |
| 151 #define PSEUDO_OP_LIST(V) \ | 151 #define PSEUDO_OP_LIST(V) \ |
| 152 V(Word, And) \ | 152 V(Word, And) \ |
| 153 V(Word, Or) \ | 153 V(Word, Or) \ |
| 154 V(Word, Xor) \ | 154 V(Word, Xor) \ |
| 155 V(Word, Shl) \ | 155 V(Word, Shl) \ |
| 156 V(Word, Shr) \ | 156 V(Word, Shr) \ |
| 157 V(Word, Sar) \ | 157 V(Word, Sar) \ |
| 158 V(Word, Ror) \ | 158 V(Word, Ror) \ |
| 159 V(Word, Equal) \ | 159 V(Word, Equal) \ |
| 160 V(Int, Add) \ | 160 V(Int, Add) \ |
| 161 V(Int, Sub) \ | 161 V(Int, Sub) \ |
| 162 V(Int, Mul) \ | 162 V(Int, Mul) \ |
| 163 V(Int, Div) \ | 163 V(Int, Div) \ |
| 164 V(Int, UDiv) \ | 164 V(Int, UDiv) \ |
| 165 V(Int, Mod) \ | 165 V(Int, Mod) \ |
| 166 V(Int, UMod) \ | 166 V(Int, UMod) \ |
| 167 V(Int, LessThan) \ | 167 V(Int, LessThan) \ |
| 168 V(Int, LessThanOrEqual) | 168 V(Int, LessThanOrEqual) |
| 169 #define PSEUDO_OP(Prefix, Suffix) \ | 169 #define PSEUDO_OP(Prefix, Suffix) \ |
| 170 const Operator* Prefix##Suffix() const { \ | 170 const Operator* Prefix##Suffix() { \ |
| 171 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 171 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
| 172 } | 172 } |
| 173 PSEUDO_OP_LIST(PSEUDO_OP) | 173 PSEUDO_OP_LIST(PSEUDO_OP) |
| 174 #undef PSEUDO_OP | 174 #undef PSEUDO_OP |
| 175 #undef PSEUDO_OP_LIST | 175 #undef PSEUDO_OP_LIST |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 const MachineOperatorBuilderImpl& impl_; | 178 const MachineOperatorBuilderImpl& impl_; |
| 179 const MachineType word_; | 179 const MachineType word_; |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 } // namespace compiler | 182 } // namespace compiler |
| 183 } // namespace internal | 183 } // namespace internal |
| 184 } // namespace v8 | 184 } // namespace v8 |
| 185 | 185 |
| 186 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 186 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |