Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ |
| 6 | #define V8_COMPILER_MACHINE_OPERATOR_H_ |
| 7 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 8 | #include "src/base/flags.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 9 | #include "src/machine-type.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | namespace compiler { |
| 14 | |
| 15 | // Forward declarations. |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 16 | struct MachineOperatorGlobalCache; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 17 | class Operator; |
| 18 | |
| 19 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 20 | // For operators that are not supported on all platforms. |
| 21 | class OptionalOperator final { |
| 22 | public: |
| 23 | explicit OptionalOperator(const Operator* op) : op_(op) {} |
| 24 | |
| 25 | bool IsSupported() const { return op_ != nullptr; } |
| 26 | const Operator* op() const { |
| 27 | DCHECK_NOT_NULL(op_); |
| 28 | return op_; |
| 29 | } |
| 30 | |
| 31 | private: |
| 32 | const Operator* const op_; |
| 33 | }; |
| 34 | |
| 35 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 36 | // A Load needs a MachineType. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 37 | typedef MachineType LoadRepresentation; |
| 38 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 39 | LoadRepresentation LoadRepresentationOf(Operator const*); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 40 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 41 | // A Store needs a MachineType and a WriteBarrierKind in order to emit the |
| 42 | // correct write barrier. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 43 | class StoreRepresentation final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 44 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 45 | StoreRepresentation(MachineRepresentation representation, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 46 | WriteBarrierKind write_barrier_kind) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 47 | : representation_(representation), |
| 48 | write_barrier_kind_(write_barrier_kind) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 49 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 50 | MachineRepresentation representation() const { return representation_; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 51 | WriteBarrierKind write_barrier_kind() const { return write_barrier_kind_; } |
| 52 | |
| 53 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 54 | MachineRepresentation representation_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 55 | WriteBarrierKind write_barrier_kind_; |
| 56 | }; |
| 57 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 58 | bool operator==(StoreRepresentation, StoreRepresentation); |
| 59 | bool operator!=(StoreRepresentation, StoreRepresentation); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 60 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 61 | size_t hash_value(StoreRepresentation); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 62 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 63 | std::ostream& operator<<(std::ostream&, StoreRepresentation); |
| 64 | |
| 65 | StoreRepresentation const& StoreRepresentationOf(Operator const*); |
| 66 | |
| 67 | |
| 68 | // A CheckedLoad needs a MachineType. |
| 69 | typedef MachineType CheckedLoadRepresentation; |
| 70 | |
| 71 | CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const*); |
| 72 | |
| 73 | |
| 74 | // A CheckedStore needs a MachineType. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 75 | typedef MachineRepresentation CheckedStoreRepresentation; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 76 | |
| 77 | CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const*); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 78 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 79 | MachineRepresentation StackSlotRepresentationOf(Operator const* op); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 80 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 81 | MachineRepresentation AtomicStoreRepresentationOf(Operator const* op); |
| 82 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 83 | // Interface for building machine-level operators. These operators are |
| 84 | // machine-level but machine-independent and thus define a language suitable |
| 85 | // for generating code to run on architectures such as ia32, x64, arm, etc. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 86 | class MachineOperatorBuilder final : public ZoneObject { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 87 | public: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 88 | // Flags that specify which operations are available. This is useful |
| 89 | // for operations that are unsupported by some back-ends. |
| 90 | enum Flag { |
| 91 | kNoFlags = 0u, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 92 | // Note that Float*Max behaves like `(b < a) ? a : b`, not like Math.max(). |
| 93 | // Note that Float*Min behaves like `(a < b) ? a : b`, not like Math.min(). |
| 94 | kFloat32Max = 1u << 0, |
| 95 | kFloat32Min = 1u << 1, |
| 96 | kFloat64Max = 1u << 2, |
| 97 | kFloat64Min = 1u << 3, |
| 98 | kFloat32RoundDown = 1u << 4, |
| 99 | kFloat64RoundDown = 1u << 5, |
| 100 | kFloat32RoundUp = 1u << 6, |
| 101 | kFloat64RoundUp = 1u << 7, |
| 102 | kFloat32RoundTruncate = 1u << 8, |
| 103 | kFloat64RoundTruncate = 1u << 9, |
| 104 | kFloat32RoundTiesEven = 1u << 10, |
| 105 | kFloat64RoundTiesEven = 1u << 11, |
| 106 | kFloat64RoundTiesAway = 1u << 12, |
| 107 | kInt32DivIsSafe = 1u << 13, |
| 108 | kUint32DivIsSafe = 1u << 14, |
| 109 | kWord32ShiftIsSafe = 1u << 15, |
| 110 | kWord32Ctz = 1u << 16, |
| 111 | kWord64Ctz = 1u << 17, |
| 112 | kWord32Popcnt = 1u << 18, |
| 113 | kWord64Popcnt = 1u << 19, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 114 | kWord32ReverseBits = 1u << 20, |
| 115 | kWord64ReverseBits = 1u << 21, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 116 | kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | |
| 117 | kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | |
| 118 | kFloat64RoundUp | kFloat32RoundTruncate | |
| 119 | kFloat64RoundTruncate | kFloat64RoundTiesAway | |
| 120 | kFloat32RoundTiesEven | kFloat64RoundTiesEven | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 121 | kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | |
| 122 | kWord32ReverseBits | kWord64ReverseBits |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 123 | }; |
| 124 | typedef base::Flags<Flag, unsigned> Flags; |
| 125 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 126 | explicit MachineOperatorBuilder( |
| 127 | Zone* zone, |
| 128 | MachineRepresentation word = MachineType::PointerRepresentation(), |
| 129 | Flags supportedOperators = kNoFlags); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 130 | |
| 131 | const Operator* Word32And(); |
| 132 | const Operator* Word32Or(); |
| 133 | const Operator* Word32Xor(); |
| 134 | const Operator* Word32Shl(); |
| 135 | const Operator* Word32Shr(); |
| 136 | const Operator* Word32Sar(); |
| 137 | const Operator* Word32Ror(); |
| 138 | const Operator* Word32Equal(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 139 | const Operator* Word32Clz(); |
| 140 | const OptionalOperator Word32Ctz(); |
| 141 | const OptionalOperator Word32Popcnt(); |
| 142 | const OptionalOperator Word64Popcnt(); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 143 | const Operator* Word64PopcntPlaceholder(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 144 | const OptionalOperator Word32ReverseBits(); |
| 145 | const OptionalOperator Word64ReverseBits(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 146 | bool Word32ShiftIsSafe() const { return flags_ & kWord32ShiftIsSafe; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 147 | |
| 148 | const Operator* Word64And(); |
| 149 | const Operator* Word64Or(); |
| 150 | const Operator* Word64Xor(); |
| 151 | const Operator* Word64Shl(); |
| 152 | const Operator* Word64Shr(); |
| 153 | const Operator* Word64Sar(); |
| 154 | const Operator* Word64Ror(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 155 | const Operator* Word64Clz(); |
| 156 | const OptionalOperator Word64Ctz(); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 157 | const Operator* Word64CtzPlaceholder(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 158 | const Operator* Word64Equal(); |
| 159 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 160 | const Operator* Int32PairAdd(); |
| 161 | const Operator* Int32PairSub(); |
| 162 | const Operator* Int32PairMul(); |
| 163 | const Operator* Word32PairShl(); |
| 164 | const Operator* Word32PairShr(); |
| 165 | const Operator* Word32PairSar(); |
| 166 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 167 | const Operator* Int32Add(); |
| 168 | const Operator* Int32AddWithOverflow(); |
| 169 | const Operator* Int32Sub(); |
| 170 | const Operator* Int32SubWithOverflow(); |
| 171 | const Operator* Int32Mul(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 172 | const Operator* Int32MulHigh(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 173 | const Operator* Int32Div(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 174 | const Operator* Int32Mod(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 175 | const Operator* Int32LessThan(); |
| 176 | const Operator* Int32LessThanOrEqual(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 177 | const Operator* Uint32Div(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 178 | const Operator* Uint32LessThan(); |
| 179 | const Operator* Uint32LessThanOrEqual(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 180 | const Operator* Uint32Mod(); |
| 181 | const Operator* Uint32MulHigh(); |
| 182 | bool Int32DivIsSafe() const { return flags_ & kInt32DivIsSafe; } |
| 183 | bool Uint32DivIsSafe() const { return flags_ & kUint32DivIsSafe; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 184 | |
| 185 | const Operator* Int64Add(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 186 | const Operator* Int64AddWithOverflow(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 187 | const Operator* Int64Sub(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 188 | const Operator* Int64SubWithOverflow(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 189 | const Operator* Int64Mul(); |
| 190 | const Operator* Int64Div(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 191 | const Operator* Int64Mod(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 192 | const Operator* Int64LessThan(); |
| 193 | const Operator* Int64LessThanOrEqual(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 194 | const Operator* Uint64Div(); |
| 195 | const Operator* Uint64LessThan(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 196 | const Operator* Uint64LessThanOrEqual(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 197 | const Operator* Uint64Mod(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 198 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 199 | // This operator reinterprets the bits of a word as tagged pointer. |
| 200 | const Operator* BitcastWordToTagged(); |
| 201 | |
| 202 | // JavaScript float64 to int32/uint32 truncation. |
| 203 | const Operator* TruncateFloat64ToWord32(); |
| 204 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 205 | // These operators change the representation of numbers while preserving the |
| 206 | // value of the number. Narrowing operators assume the input is representable |
| 207 | // in the target type and are *not* defined for other inputs. |
| 208 | // Use narrowing change operators only when there is a static guarantee that |
| 209 | // the input value is representable in the target value. |
| 210 | const Operator* ChangeFloat32ToFloat64(); |
| 211 | const Operator* ChangeFloat64ToInt32(); // narrowing |
| 212 | const Operator* ChangeFloat64ToUint32(); // narrowing |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 213 | const Operator* TruncateFloat64ToUint32(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 214 | const Operator* TruncateFloat32ToInt32(); |
| 215 | const Operator* TruncateFloat32ToUint32(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 216 | const Operator* TryTruncateFloat32ToInt64(); |
| 217 | const Operator* TryTruncateFloat64ToInt64(); |
| 218 | const Operator* TryTruncateFloat32ToUint64(); |
| 219 | const Operator* TryTruncateFloat64ToUint64(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 220 | const Operator* ChangeInt32ToFloat64(); |
| 221 | const Operator* ChangeInt32ToInt64(); |
| 222 | const Operator* ChangeUint32ToFloat64(); |
| 223 | const Operator* ChangeUint32ToUint64(); |
| 224 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 225 | // These operators truncate or round numbers, both changing the representation |
| 226 | // of the number and mapping multiple input values onto the same output value. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 227 | const Operator* TruncateFloat64ToFloat32(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 228 | const Operator* TruncateInt64ToInt32(); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 229 | const Operator* RoundFloat64ToInt32(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 230 | const Operator* RoundInt32ToFloat32(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 231 | const Operator* RoundInt64ToFloat32(); |
| 232 | const Operator* RoundInt64ToFloat64(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 233 | const Operator* RoundUint32ToFloat32(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 234 | const Operator* RoundUint64ToFloat32(); |
| 235 | const Operator* RoundUint64ToFloat64(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 236 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 237 | // These operators reinterpret the bits of a floating point number as an |
| 238 | // integer and vice versa. |
| 239 | const Operator* BitcastFloat32ToInt32(); |
| 240 | const Operator* BitcastFloat64ToInt64(); |
| 241 | const Operator* BitcastInt32ToFloat32(); |
| 242 | const Operator* BitcastInt64ToFloat64(); |
| 243 | |
| 244 | // Floating point operators always operate with IEEE 754 round-to-nearest |
| 245 | // (single-precision). |
| 246 | const Operator* Float32Add(); |
| 247 | const Operator* Float32Sub(); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 248 | const Operator* Float32SubPreserveNan(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 249 | const Operator* Float32Mul(); |
| 250 | const Operator* Float32Div(); |
| 251 | const Operator* Float32Sqrt(); |
| 252 | |
| 253 | // Floating point operators always operate with IEEE 754 round-to-nearest |
| 254 | // (double-precision). |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 255 | const Operator* Float64Add(); |
| 256 | const Operator* Float64Sub(); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 257 | const Operator* Float64SubPreserveNan(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 258 | const Operator* Float64Mul(); |
| 259 | const Operator* Float64Div(); |
| 260 | const Operator* Float64Mod(); |
| 261 | const Operator* Float64Sqrt(); |
| 262 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 263 | // Floating point comparisons complying to IEEE 754 (single-precision). |
| 264 | const Operator* Float32Equal(); |
| 265 | const Operator* Float32LessThan(); |
| 266 | const Operator* Float32LessThanOrEqual(); |
| 267 | |
| 268 | // Floating point comparisons complying to IEEE 754 (double-precision). |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 269 | const Operator* Float64Equal(); |
| 270 | const Operator* Float64LessThan(); |
| 271 | const Operator* Float64LessThanOrEqual(); |
| 272 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 273 | // Floating point min/max complying to IEEE 754 (single-precision). |
| 274 | const OptionalOperator Float32Max(); |
| 275 | const OptionalOperator Float32Min(); |
| 276 | |
| 277 | // Floating point min/max complying to IEEE 754 (double-precision). |
| 278 | const OptionalOperator Float64Max(); |
| 279 | const OptionalOperator Float64Min(); |
| 280 | |
| 281 | // Floating point abs complying to IEEE 754 (single-precision). |
| 282 | const Operator* Float32Abs(); |
| 283 | |
| 284 | // Floating point abs complying to IEEE 754 (double-precision). |
| 285 | const Operator* Float64Abs(); |
| 286 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 287 | // Floating point rounding. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 288 | const OptionalOperator Float32RoundDown(); |
| 289 | const OptionalOperator Float64RoundDown(); |
| 290 | const OptionalOperator Float32RoundUp(); |
| 291 | const OptionalOperator Float64RoundUp(); |
| 292 | const OptionalOperator Float32RoundTruncate(); |
| 293 | const OptionalOperator Float64RoundTruncate(); |
| 294 | const OptionalOperator Float64RoundTiesAway(); |
| 295 | const OptionalOperator Float32RoundTiesEven(); |
| 296 | const OptionalOperator Float64RoundTiesEven(); |
| 297 | |
| 298 | // Floating point bit representation. |
| 299 | const Operator* Float64ExtractLowWord32(); |
| 300 | const Operator* Float64ExtractHighWord32(); |
| 301 | const Operator* Float64InsertLowWord32(); |
| 302 | const Operator* Float64InsertHighWord32(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 303 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 304 | // SIMD operators. |
| 305 | const Operator* CreateFloat32x4(); |
| 306 | const Operator* Float32x4ExtractLane(); |
| 307 | const Operator* Float32x4ReplaceLane(); |
| 308 | const Operator* Float32x4Abs(); |
| 309 | const Operator* Float32x4Neg(); |
| 310 | const Operator* Float32x4Sqrt(); |
| 311 | const Operator* Float32x4RecipApprox(); |
| 312 | const Operator* Float32x4RecipSqrtApprox(); |
| 313 | const Operator* Float32x4Add(); |
| 314 | const Operator* Float32x4Sub(); |
| 315 | const Operator* Float32x4Mul(); |
| 316 | const Operator* Float32x4Div(); |
| 317 | const Operator* Float32x4Min(); |
| 318 | const Operator* Float32x4Max(); |
| 319 | const Operator* Float32x4MinNum(); |
| 320 | const Operator* Float32x4MaxNum(); |
| 321 | const Operator* Float32x4Equal(); |
| 322 | const Operator* Float32x4NotEqual(); |
| 323 | const Operator* Float32x4LessThan(); |
| 324 | const Operator* Float32x4LessThanOrEqual(); |
| 325 | const Operator* Float32x4GreaterThan(); |
| 326 | const Operator* Float32x4GreaterThanOrEqual(); |
| 327 | const Operator* Float32x4Select(); |
| 328 | const Operator* Float32x4Swizzle(); |
| 329 | const Operator* Float32x4Shuffle(); |
| 330 | const Operator* Float32x4FromInt32x4(); |
| 331 | const Operator* Float32x4FromUint32x4(); |
| 332 | |
| 333 | const Operator* CreateInt32x4(); |
| 334 | const Operator* Int32x4ExtractLane(); |
| 335 | const Operator* Int32x4ReplaceLane(); |
| 336 | const Operator* Int32x4Neg(); |
| 337 | const Operator* Int32x4Add(); |
| 338 | const Operator* Int32x4Sub(); |
| 339 | const Operator* Int32x4Mul(); |
| 340 | const Operator* Int32x4Min(); |
| 341 | const Operator* Int32x4Max(); |
| 342 | const Operator* Int32x4ShiftLeftByScalar(); |
| 343 | const Operator* Int32x4ShiftRightByScalar(); |
| 344 | const Operator* Int32x4Equal(); |
| 345 | const Operator* Int32x4NotEqual(); |
| 346 | const Operator* Int32x4LessThan(); |
| 347 | const Operator* Int32x4LessThanOrEqual(); |
| 348 | const Operator* Int32x4GreaterThan(); |
| 349 | const Operator* Int32x4GreaterThanOrEqual(); |
| 350 | const Operator* Int32x4Select(); |
| 351 | const Operator* Int32x4Swizzle(); |
| 352 | const Operator* Int32x4Shuffle(); |
| 353 | const Operator* Int32x4FromFloat32x4(); |
| 354 | |
| 355 | const Operator* Uint32x4Min(); |
| 356 | const Operator* Uint32x4Max(); |
| 357 | const Operator* Uint32x4ShiftLeftByScalar(); |
| 358 | const Operator* Uint32x4ShiftRightByScalar(); |
| 359 | const Operator* Uint32x4LessThan(); |
| 360 | const Operator* Uint32x4LessThanOrEqual(); |
| 361 | const Operator* Uint32x4GreaterThan(); |
| 362 | const Operator* Uint32x4GreaterThanOrEqual(); |
| 363 | const Operator* Uint32x4FromFloat32x4(); |
| 364 | |
| 365 | const Operator* CreateBool32x4(); |
| 366 | const Operator* Bool32x4ExtractLane(); |
| 367 | const Operator* Bool32x4ReplaceLane(); |
| 368 | const Operator* Bool32x4And(); |
| 369 | const Operator* Bool32x4Or(); |
| 370 | const Operator* Bool32x4Xor(); |
| 371 | const Operator* Bool32x4Not(); |
| 372 | const Operator* Bool32x4AnyTrue(); |
| 373 | const Operator* Bool32x4AllTrue(); |
| 374 | const Operator* Bool32x4Swizzle(); |
| 375 | const Operator* Bool32x4Shuffle(); |
| 376 | const Operator* Bool32x4Equal(); |
| 377 | const Operator* Bool32x4NotEqual(); |
| 378 | |
| 379 | const Operator* CreateInt16x8(); |
| 380 | const Operator* Int16x8ExtractLane(); |
| 381 | const Operator* Int16x8ReplaceLane(); |
| 382 | const Operator* Int16x8Neg(); |
| 383 | const Operator* Int16x8Add(); |
| 384 | const Operator* Int16x8AddSaturate(); |
| 385 | const Operator* Int16x8Sub(); |
| 386 | const Operator* Int16x8SubSaturate(); |
| 387 | const Operator* Int16x8Mul(); |
| 388 | const Operator* Int16x8Min(); |
| 389 | const Operator* Int16x8Max(); |
| 390 | const Operator* Int16x8ShiftLeftByScalar(); |
| 391 | const Operator* Int16x8ShiftRightByScalar(); |
| 392 | const Operator* Int16x8Equal(); |
| 393 | const Operator* Int16x8NotEqual(); |
| 394 | const Operator* Int16x8LessThan(); |
| 395 | const Operator* Int16x8LessThanOrEqual(); |
| 396 | const Operator* Int16x8GreaterThan(); |
| 397 | const Operator* Int16x8GreaterThanOrEqual(); |
| 398 | const Operator* Int16x8Select(); |
| 399 | const Operator* Int16x8Swizzle(); |
| 400 | const Operator* Int16x8Shuffle(); |
| 401 | |
| 402 | const Operator* Uint16x8AddSaturate(); |
| 403 | const Operator* Uint16x8SubSaturate(); |
| 404 | const Operator* Uint16x8Min(); |
| 405 | const Operator* Uint16x8Max(); |
| 406 | const Operator* Uint16x8ShiftLeftByScalar(); |
| 407 | const Operator* Uint16x8ShiftRightByScalar(); |
| 408 | const Operator* Uint16x8LessThan(); |
| 409 | const Operator* Uint16x8LessThanOrEqual(); |
| 410 | const Operator* Uint16x8GreaterThan(); |
| 411 | const Operator* Uint16x8GreaterThanOrEqual(); |
| 412 | |
| 413 | const Operator* CreateBool16x8(); |
| 414 | const Operator* Bool16x8ExtractLane(); |
| 415 | const Operator* Bool16x8ReplaceLane(); |
| 416 | const Operator* Bool16x8And(); |
| 417 | const Operator* Bool16x8Or(); |
| 418 | const Operator* Bool16x8Xor(); |
| 419 | const Operator* Bool16x8Not(); |
| 420 | const Operator* Bool16x8AnyTrue(); |
| 421 | const Operator* Bool16x8AllTrue(); |
| 422 | const Operator* Bool16x8Swizzle(); |
| 423 | const Operator* Bool16x8Shuffle(); |
| 424 | const Operator* Bool16x8Equal(); |
| 425 | const Operator* Bool16x8NotEqual(); |
| 426 | |
| 427 | const Operator* CreateInt8x16(); |
| 428 | const Operator* Int8x16ExtractLane(); |
| 429 | const Operator* Int8x16ReplaceLane(); |
| 430 | const Operator* Int8x16Neg(); |
| 431 | const Operator* Int8x16Add(); |
| 432 | const Operator* Int8x16AddSaturate(); |
| 433 | const Operator* Int8x16Sub(); |
| 434 | const Operator* Int8x16SubSaturate(); |
| 435 | const Operator* Int8x16Mul(); |
| 436 | const Operator* Int8x16Min(); |
| 437 | const Operator* Int8x16Max(); |
| 438 | const Operator* Int8x16ShiftLeftByScalar(); |
| 439 | const Operator* Int8x16ShiftRightByScalar(); |
| 440 | const Operator* Int8x16Equal(); |
| 441 | const Operator* Int8x16NotEqual(); |
| 442 | const Operator* Int8x16LessThan(); |
| 443 | const Operator* Int8x16LessThanOrEqual(); |
| 444 | const Operator* Int8x16GreaterThan(); |
| 445 | const Operator* Int8x16GreaterThanOrEqual(); |
| 446 | const Operator* Int8x16Select(); |
| 447 | const Operator* Int8x16Swizzle(); |
| 448 | const Operator* Int8x16Shuffle(); |
| 449 | |
| 450 | const Operator* Uint8x16AddSaturate(); |
| 451 | const Operator* Uint8x16SubSaturate(); |
| 452 | const Operator* Uint8x16Min(); |
| 453 | const Operator* Uint8x16Max(); |
| 454 | const Operator* Uint8x16ShiftLeftByScalar(); |
| 455 | const Operator* Uint8x16ShiftRightByScalar(); |
| 456 | const Operator* Uint8x16LessThan(); |
| 457 | const Operator* Uint8x16LessThanOrEqual(); |
| 458 | const Operator* Uint8x16GreaterThan(); |
| 459 | const Operator* Uint8x16GreaterThanOrEqual(); |
| 460 | |
| 461 | const Operator* CreateBool8x16(); |
| 462 | const Operator* Bool8x16ExtractLane(); |
| 463 | const Operator* Bool8x16ReplaceLane(); |
| 464 | const Operator* Bool8x16And(); |
| 465 | const Operator* Bool8x16Or(); |
| 466 | const Operator* Bool8x16Xor(); |
| 467 | const Operator* Bool8x16Not(); |
| 468 | const Operator* Bool8x16AnyTrue(); |
| 469 | const Operator* Bool8x16AllTrue(); |
| 470 | const Operator* Bool8x16Swizzle(); |
| 471 | const Operator* Bool8x16Shuffle(); |
| 472 | const Operator* Bool8x16Equal(); |
| 473 | const Operator* Bool8x16NotEqual(); |
| 474 | |
| 475 | const Operator* Simd128Load(); |
| 476 | const Operator* Simd128Load1(); |
| 477 | const Operator* Simd128Load2(); |
| 478 | const Operator* Simd128Load3(); |
| 479 | const Operator* Simd128Store(); |
| 480 | const Operator* Simd128Store1(); |
| 481 | const Operator* Simd128Store2(); |
| 482 | const Operator* Simd128Store3(); |
| 483 | const Operator* Simd128And(); |
| 484 | const Operator* Simd128Or(); |
| 485 | const Operator* Simd128Xor(); |
| 486 | const Operator* Simd128Not(); |
| 487 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 488 | // load [base + index] |
| 489 | const Operator* Load(LoadRepresentation rep); |
| 490 | |
| 491 | // store [base + index], value |
| 492 | const Operator* Store(StoreRepresentation rep); |
| 493 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 494 | const Operator* StackSlot(MachineRepresentation rep); |
| 495 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 496 | // Access to the machine stack. |
| 497 | const Operator* LoadStackPointer(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 498 | const Operator* LoadFramePointer(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 499 | const Operator* LoadParentFramePointer(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 500 | |
| 501 | // checked-load heap, index, length |
| 502 | const Operator* CheckedLoad(CheckedLoadRepresentation); |
| 503 | // checked-store heap, index, length, value |
| 504 | const Operator* CheckedStore(CheckedStoreRepresentation); |
| 505 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 506 | // atomic-load [base + index] |
| 507 | const Operator* AtomicLoad(LoadRepresentation rep); |
| 508 | // atomic-store [base + index], value |
| 509 | const Operator* AtomicStore(MachineRepresentation rep); |
| 510 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 511 | // Target machine word-size assumed by this builder. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 512 | bool Is32() const { return word() == MachineRepresentation::kWord32; } |
| 513 | bool Is64() const { return word() == MachineRepresentation::kWord64; } |
| 514 | MachineRepresentation word() const { return word_; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 515 | |
| 516 | // Pseudo operators that translate to 32/64-bit operators depending on the |
| 517 | // word-size of the target machine assumed by this builder. |
| 518 | #define PSEUDO_OP_LIST(V) \ |
| 519 | V(Word, And) \ |
| 520 | V(Word, Or) \ |
| 521 | V(Word, Xor) \ |
| 522 | V(Word, Shl) \ |
| 523 | V(Word, Shr) \ |
| 524 | V(Word, Sar) \ |
| 525 | V(Word, Ror) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 526 | V(Word, Clz) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 527 | V(Word, Equal) \ |
| 528 | V(Int, Add) \ |
| 529 | V(Int, Sub) \ |
| 530 | V(Int, Mul) \ |
| 531 | V(Int, Div) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 532 | V(Int, Mod) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 533 | V(Int, LessThan) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 534 | V(Int, LessThanOrEqual) \ |
| 535 | V(Uint, Div) \ |
| 536 | V(Uint, LessThan) \ |
| 537 | V(Uint, Mod) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 538 | #define PSEUDO_OP(Prefix, Suffix) \ |
| 539 | const Operator* Prefix##Suffix() { \ |
| 540 | return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
| 541 | } |
| 542 | PSEUDO_OP_LIST(PSEUDO_OP) |
| 543 | #undef PSEUDO_OP |
| 544 | #undef PSEUDO_OP_LIST |
| 545 | |
| 546 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 547 | MachineOperatorGlobalCache const& cache_; |
| 548 | MachineRepresentation const word_; |
| 549 | Flags const flags_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 550 | |
| 551 | DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 554 | |
| 555 | DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
| 556 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 557 | } // namespace compiler |
| 558 | } // namespace internal |
| 559 | } // namespace v8 |
| 560 | |
| 561 | #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |