machine-operator.cc 73.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler/machine-operator.h"

#include "src/base/lazy-instance.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"

namespace v8 {
namespace internal {
namespace compiler {

15
bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) {
16
  return lhs.representation() == rhs.representation() &&
17
         lhs.write_barrier_kind() == rhs.write_barrier_kind();
18 19 20
}


21 22 23
bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) {
  return !(lhs == rhs);
}
24 25


26
size_t hash_value(StoreRepresentation rep) {
27
  return base::hash_combine(rep.representation(), rep.write_barrier_kind());
28 29 30 31
}


std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) {
32
  return os << rep.representation() << ", " << rep.write_barrier_kind();
33
}
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
size_t hash_value(LoadKind kind) { return static_cast<size_t>(kind); }

std::ostream& operator<<(std::ostream& os, LoadKind kind) {
  switch (kind) {
    case LoadKind::kNormal:
      return os << "kNormal";
    case LoadKind::kUnaligned:
      return os << "kUnaligned";
    case LoadKind::kProtected:
      return os << "kProtected";
  }
  UNREACHABLE();
}

size_t hash_value(LoadTransformation rep) { return static_cast<size_t>(rep); }

std::ostream& operator<<(std::ostream& os, LoadTransformation rep) {
  switch (rep) {
    case LoadTransformation::kS8x16LoadSplat:
      return os << "kS8x16LoadSplat";
    case LoadTransformation::kS16x8LoadSplat:
      return os << "kS16x8LoadSplat";
57 58 59 60
    case LoadTransformation::kS32x4LoadSplat:
      return os << "kS32x4LoadSplat";
    case LoadTransformation::kS64x2LoadSplat:
      return os << "kS64x2LoadSplat";
61 62 63 64
    case LoadTransformation::kI16x8Load8x8S:
      return os << "kI16x8Load8x8S";
    case LoadTransformation::kI16x8Load8x8U:
      return os << "kI16x8Load8x8U";
65 66 67 68 69 70 71 72
    case LoadTransformation::kI32x4Load16x4S:
      return os << "kI32x4Load16x4S";
    case LoadTransformation::kI32x4Load16x4U:
      return os << "kI32x4Load16x4U";
    case LoadTransformation::kI64x2Load32x2S:
      return os << "kI64x2Load32x2S";
    case LoadTransformation::kI64x2Load32x2U:
      return os << "kI64x2Load32x2U";
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  }
  UNREACHABLE();
}

size_t hash_value(LoadTransformParameters params) {
  return base::hash_combine(params.kind, params.transformation);
}

std::ostream& operator<<(std::ostream& os, LoadTransformParameters params) {
  return os << "(" << params.kind << " " << params.transformation << ")";
}

LoadTransformParameters const& LoadTransformParametersOf(Operator const* op) {
  DCHECK_EQ(IrOpcode::kLoadTransform, op->opcode());
  return OpParameter<LoadTransformParameters>(op);
}

bool operator==(LoadTransformParameters lhs, LoadTransformParameters rhs) {
  return lhs.transformation == rhs.transformation && lhs.kind == rhs.kind;
}

bool operator!=(LoadTransformParameters lhs, LoadTransformParameters rhs) {
  return !(lhs == rhs);
}
97

98
LoadRepresentation LoadRepresentationOf(Operator const* op) {
99
  DCHECK(IrOpcode::kLoad == op->opcode() ||
100
         IrOpcode::kProtectedLoad == op->opcode() ||
101
         IrOpcode::kWord32AtomicLoad == op->opcode() ||
102
         IrOpcode::kWord64AtomicLoad == op->opcode() ||
103
         IrOpcode::kWord32AtomicPairLoad == op->opcode() ||
104
         IrOpcode::kPoisonedLoad == op->opcode() ||
105
         IrOpcode::kUnalignedLoad == op->opcode());
106 107 108 109
  return OpParameter<LoadRepresentation>(op);
}


110
StoreRepresentation const& StoreRepresentationOf(Operator const* op) {
111 112
  DCHECK(IrOpcode::kStore == op->opcode() ||
         IrOpcode::kProtectedStore == op->opcode());
113 114 115
  return OpParameter<StoreRepresentation>(op);
}

116 117 118 119 120
UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
    Operator const* op) {
  DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode());
  return OpParameter<UnalignedStoreRepresentation>(op);
}
121

122 123 124 125 126 127 128 129 130 131 132 133 134
bool operator==(StackSlotRepresentation lhs, StackSlotRepresentation rhs) {
  return lhs.size() == rhs.size() && lhs.alignment() == rhs.alignment();
}

bool operator!=(StackSlotRepresentation lhs, StackSlotRepresentation rhs) {
  return !(lhs == rhs);
}

size_t hash_value(StackSlotRepresentation rep) {
  return base::hash_combine(rep.size(), rep.alignment());
}

std::ostream& operator<<(std::ostream& os, StackSlotRepresentation rep) {
135
  return os << rep.size() << ", " << rep.alignment();
136 137 138
}

StackSlotRepresentation const& StackSlotRepresentationOf(Operator const* op) {
139
  DCHECK_EQ(IrOpcode::kStackSlot, op->opcode());
140
  return OpParameter<StackSlotRepresentation>(op);
141
}
142

143
MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) {
144
  DCHECK(IrOpcode::kWord32AtomicStore == op->opcode() ||
145
         IrOpcode::kWord64AtomicStore == op->opcode());
146 147 148
  return OpParameter<MachineRepresentation>(op);
}

149
MachineType AtomicOpType(Operator const* op) {
150 151 152
  return OpParameter<MachineType>(op);
}

153 154
// The format is:
// V(Name, properties, value_input_count, control_input_count, output_count)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
#define PURE_BINARY_OP_LIST_32(V)                                           \
  V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)    \
  V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
  V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)    \
  V(Word32Shl, Operator::kNoProperties, 2, 0, 1)                            \
  V(Word32Shr, Operator::kNoProperties, 2, 0, 1)                            \
  V(Word32Sar, Operator::kNoProperties, 2, 0, 1)                            \
  V(Word32Ror, Operator::kNoProperties, 2, 0, 1)                            \
  V(Word32Equal, Operator::kCommutative, 2, 0, 1)                           \
  V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
  V(Int32Sub, Operator::kNoProperties, 2, 0, 1)                             \
  V(Int32Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
  V(Int32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
  V(Int32Div, Operator::kNoProperties, 2, 1, 1)                             \
  V(Int32Mod, Operator::kNoProperties, 2, 1, 1)                             \
  V(Int32LessThan, Operator::kNoProperties, 2, 0, 1)                        \
  V(Int32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)                 \
  V(Uint32Div, Operator::kNoProperties, 2, 1, 1)                            \
  V(Uint32LessThan, Operator::kNoProperties, 2, 0, 1)                       \
  V(Uint32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)                \
  V(Uint32Mod, Operator::kNoProperties, 2, 1, 1)                            \
  V(Uint32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)

178 179
// The format is:
// V(Name, properties, value_input_count, control_input_count, output_count)
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
#define PURE_BINARY_OP_LIST_64(V)                                        \
  V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
  V(Word64Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Word64Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
  V(Word64Shl, Operator::kNoProperties, 2, 0, 1)                         \
  V(Word64Shr, Operator::kNoProperties, 2, 0, 1)                         \
  V(Word64Sar, Operator::kNoProperties, 2, 0, 1)                         \
  V(Word64Ror, Operator::kNoProperties, 2, 0, 1)                         \
  V(Word64Equal, Operator::kCommutative, 2, 0, 1)                        \
  V(Int64Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Int64Sub, Operator::kNoProperties, 2, 0, 1)                          \
  V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Int64Div, Operator::kNoProperties, 2, 1, 1)                          \
  V(Int64Mod, Operator::kNoProperties, 2, 1, 1)                          \
  V(Int64LessThan, Operator::kNoProperties, 2, 0, 1)                     \
  V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
  V(Uint64Div, Operator::kNoProperties, 2, 1, 1)                         \
  V(Uint64Mod, Operator::kNoProperties, 2, 1, 1)                         \
  V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1)                    \
  V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)

201 202
// The format is:
// V(Name, properties, value_input_count, control_input_count, output_count)
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
#define MACHINE_PURE_OP_LIST(V)                                            \
  PURE_BINARY_OP_LIST_32(V)                                                \
  PURE_BINARY_OP_LIST_64(V)                                                \
  V(Word32Clz, Operator::kNoProperties, 1, 0, 1)                           \
  V(Word64Clz, Operator::kNoProperties, 1, 0, 1)                           \
  V(Word32ReverseBytes, Operator::kNoProperties, 1, 0, 1)                  \
  V(Word64ReverseBytes, Operator::kNoProperties, 1, 0, 1)                  \
  V(Simd128ReverseBytes, Operator::kNoProperties, 1, 0, 1)                 \
  V(BitcastTaggedToWordForTagAndSmiBits, Operator::kNoProperties, 1, 0, 1) \
  V(BitcastWordToTaggedSigned, Operator::kNoProperties, 1, 0, 1)           \
  V(TruncateFloat64ToWord32, Operator::kNoProperties, 1, 0, 1)             \
  V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1)              \
  V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1)                \
  V(ChangeFloat64ToInt64, Operator::kNoProperties, 1, 0, 1)                \
  V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1)               \
  V(ChangeFloat64ToUint64, Operator::kNoProperties, 1, 0, 1)               \
  V(TruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 1)              \
  V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1)             \
  V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1)              \
  V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1)             \
  V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2)           \
  V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2)           \
  V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2)          \
  V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2)          \
  V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1)                \
  V(ChangeInt64ToFloat64, Operator::kNoProperties, 1, 0, 1)                \
  V(Float64SilenceNaN, Operator::kNoProperties, 1, 0, 1)                   \
  V(RoundFloat64ToInt32, Operator::kNoProperties, 1, 0, 1)                 \
  V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1)                 \
  V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1)                 \
  V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1)                 \
  V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1)                \
  V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1)                \
  V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1)                \
  V(BitcastWord32ToWord64, Operator::kNoProperties, 1, 0, 1)               \
  V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1)                  \
  V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1)               \
  V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1)                \
  V(ChangeTaggedToCompressed, Operator::kNoProperties, 1, 0, 1)            \
  V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1)            \
  V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1)                \
  V(BitcastFloat32ToInt32, Operator::kNoProperties, 1, 0, 1)               \
  V(BitcastFloat64ToInt64, Operator::kNoProperties, 1, 0, 1)               \
  V(BitcastInt32ToFloat32, Operator::kNoProperties, 1, 0, 1)               \
  V(BitcastInt64ToFloat64, Operator::kNoProperties, 1, 0, 1)               \
  V(SignExtendWord8ToInt32, Operator::kNoProperties, 1, 0, 1)              \
  V(SignExtendWord16ToInt32, Operator::kNoProperties, 1, 0, 1)             \
  V(SignExtendWord8ToInt64, Operator::kNoProperties, 1, 0, 1)              \
  V(SignExtendWord16ToInt64, Operator::kNoProperties, 1, 0, 1)             \
  V(SignExtendWord32ToInt64, Operator::kNoProperties, 1, 0, 1)             \
  V(Float32Abs, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float32Add, Operator::kCommutative, 2, 0, 1)                           \
  V(Float32Sub, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float32Mul, Operator::kCommutative, 2, 0, 1)                           \
  V(Float32Div, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float32Neg, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float32Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Float32Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Float64Abs, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Acos, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Acosh, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Asin, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Asinh, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Atan, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Atan2, Operator::kNoProperties, 2, 0, 1)                        \
  V(Float64Atanh, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Cbrt, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Cos, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Cosh, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Exp, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Expm1, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Log, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Log1p, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Log2, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Log10, Operator::kNoProperties, 1, 0, 1)                        \
  V(Float64Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Float64Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
  V(Float64Neg, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Add, Operator::kCommutative, 2, 0, 1)                           \
  V(Float64Sub, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float64Mul, Operator::kCommutative, 2, 0, 1)                           \
  V(Float64Div, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float64Mod, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float64Pow, Operator::kNoProperties, 2, 0, 1)                          \
  V(Float64Sin, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Sinh, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float64Tan, Operator::kNoProperties, 1, 0, 1)                          \
  V(Float64Tanh, Operator::kNoProperties, 1, 0, 1)                         \
  V(Float32Equal, Operator::kCommutative, 2, 0, 1)                         \
  V(Float32LessThan, Operator::kNoProperties, 2, 0, 1)                     \
  V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
  V(Float64Equal, Operator::kCommutative, 2, 0, 1)                         \
  V(Float64LessThan, Operator::kNoProperties, 2, 0, 1)                     \
  V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
  V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1)             \
  V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1)            \
  V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1)              \
  V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1)             \
  V(LoadStackCheckOffset, Operator::kNoProperties, 0, 0, 1)                \
  V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1)                    \
  V(LoadParentFramePointer, Operator::kNoProperties, 0, 0, 1)              \
  V(Int32PairAdd, Operator::kNoProperties, 4, 0, 2)                        \
  V(Int32PairSub, Operator::kNoProperties, 4, 0, 2)                        \
  V(Int32PairMul, Operator::kNoProperties, 4, 0, 2)                        \
  V(Word32PairShl, Operator::kNoProperties, 3, 0, 2)                       \
  V(Word32PairShr, Operator::kNoProperties, 3, 0, 2)                       \
  V(Word32PairSar, Operator::kNoProperties, 3, 0, 2)                       \
  V(F64x2Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(F64x2SConvertI64x2, Operator::kNoProperties, 1, 0, 1)                  \
  V(F64x2UConvertI64x2, Operator::kNoProperties, 1, 0, 1)                  \
  V(F64x2Abs, Operator::kNoProperties, 1, 0, 1)                            \
  V(F64x2Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(F64x2Sqrt, Operator::kNoProperties, 1, 0, 1)                           \
  V(F64x2Add, Operator::kCommutative, 2, 0, 1)                             \
  V(F64x2Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(F64x2Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(F64x2Div, Operator::kNoProperties, 2, 0, 1)                            \
  V(F64x2Min, Operator::kCommutative, 2, 0, 1)                             \
  V(F64x2Max, Operator::kCommutative, 2, 0, 1)                             \
  V(F64x2Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(F64x2Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(F64x2Lt, Operator::kNoProperties, 2, 0, 1)                             \
  V(F64x2Le, Operator::kNoProperties, 2, 0, 1)                             \
  V(F64x2Qfma, Operator::kNoProperties, 3, 0, 1)                           \
  V(F64x2Qfms, Operator::kNoProperties, 3, 0, 1)                           \
  V(F32x4Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(F32x4SConvertI32x4, Operator::kNoProperties, 1, 0, 1)                  \
  V(F32x4UConvertI32x4, Operator::kNoProperties, 1, 0, 1)                  \
  V(F32x4Abs, Operator::kNoProperties, 1, 0, 1)                            \
  V(F32x4Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(F32x4Sqrt, Operator::kNoProperties, 1, 0, 1)                           \
  V(F32x4RecipApprox, Operator::kNoProperties, 1, 0, 1)                    \
  V(F32x4RecipSqrtApprox, Operator::kNoProperties, 1, 0, 1)                \
  V(F32x4Add, Operator::kCommutative, 2, 0, 1)                             \
  V(F32x4AddHoriz, Operator::kNoProperties, 2, 0, 1)                       \
  V(F32x4Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(F32x4Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(F32x4Div, Operator::kNoProperties, 2, 0, 1)                            \
  V(F32x4Min, Operator::kCommutative, 2, 0, 1)                             \
  V(F32x4Max, Operator::kCommutative, 2, 0, 1)                             \
  V(F32x4Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(F32x4Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(F32x4Lt, Operator::kNoProperties, 2, 0, 1)                             \
  V(F32x4Le, Operator::kNoProperties, 2, 0, 1)                             \
  V(F32x4Qfma, Operator::kNoProperties, 3, 0, 1)                           \
  V(F32x4Qfms, Operator::kNoProperties, 3, 0, 1)                           \
  V(I64x2Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(I64x2SplatI32Pair, Operator::kNoProperties, 2, 0, 1)                   \
  V(I64x2Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(I64x2Shl, Operator::kNoProperties, 2, 0, 1)                            \
  V(I64x2ShrS, Operator::kNoProperties, 2, 0, 1)                           \
  V(I64x2Add, Operator::kCommutative, 2, 0, 1)                             \
  V(I64x2Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(I64x2Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(I64x2MinS, Operator::kCommutative, 2, 0, 1)                            \
  V(I64x2MaxS, Operator::kCommutative, 2, 0, 1)                            \
  V(I64x2Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(I64x2Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(I64x2GtS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I64x2GeS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I64x2ShrU, Operator::kNoProperties, 2, 0, 1)                           \
  V(I64x2MinU, Operator::kCommutative, 2, 0, 1)                            \
  V(I64x2MaxU, Operator::kCommutative, 2, 0, 1)                            \
  V(I64x2GtU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I64x2GeU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(I32x4SConvertF32x4, Operator::kNoProperties, 1, 0, 1)                  \
  V(I32x4SConvertI16x8Low, Operator::kNoProperties, 1, 0, 1)               \
  V(I32x4SConvertI16x8High, Operator::kNoProperties, 1, 0, 1)              \
  V(I32x4Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(I32x4Shl, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4ShrS, Operator::kNoProperties, 2, 0, 1)                           \
  V(I32x4Add, Operator::kCommutative, 2, 0, 1)                             \
  V(I32x4AddHoriz, Operator::kNoProperties, 2, 0, 1)                       \
  V(I32x4Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(I32x4MinS, Operator::kCommutative, 2, 0, 1)                            \
  V(I32x4MaxS, Operator::kCommutative, 2, 0, 1)                            \
  V(I32x4Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(I32x4Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(I32x4GtS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4GeS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4UConvertF32x4, Operator::kNoProperties, 1, 0, 1)                  \
  V(I32x4UConvertI16x8Low, Operator::kNoProperties, 1, 0, 1)               \
  V(I32x4UConvertI16x8High, Operator::kNoProperties, 1, 0, 1)              \
  V(I32x4ShrU, Operator::kNoProperties, 2, 0, 1)                           \
  V(I32x4MinU, Operator::kCommutative, 2, 0, 1)                            \
  V(I32x4MaxU, Operator::kCommutative, 2, 0, 1)                            \
  V(I32x4GtU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I32x4GeU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(I16x8SConvertI8x16Low, Operator::kNoProperties, 1, 0, 1)               \
  V(I16x8SConvertI8x16High, Operator::kNoProperties, 1, 0, 1)              \
  V(I16x8Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(I16x8Shl, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8ShrS, Operator::kNoProperties, 2, 0, 1)                           \
  V(I16x8SConvertI32x4, Operator::kNoProperties, 2, 0, 1)                  \
  V(I16x8Add, Operator::kCommutative, 2, 0, 1)                             \
  V(I16x8AddSaturateS, Operator::kCommutative, 2, 0, 1)                    \
  V(I16x8AddHoriz, Operator::kNoProperties, 2, 0, 1)                       \
  V(I16x8Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8SubSaturateS, Operator::kNoProperties, 2, 0, 1)                   \
  V(I16x8Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(I16x8MinS, Operator::kCommutative, 2, 0, 1)                            \
  V(I16x8MaxS, Operator::kCommutative, 2, 0, 1)                            \
  V(I16x8Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(I16x8Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(I16x8GtS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8GeS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8UConvertI8x16Low, Operator::kNoProperties, 1, 0, 1)               \
  V(I16x8UConvertI8x16High, Operator::kNoProperties, 1, 0, 1)              \
  V(I16x8ShrU, Operator::kNoProperties, 2, 0, 1)                           \
  V(I16x8UConvertI32x4, Operator::kNoProperties, 2, 0, 1)                  \
  V(I16x8AddSaturateU, Operator::kCommutative, 2, 0, 1)                    \
  V(I16x8SubSaturateU, Operator::kNoProperties, 2, 0, 1)                   \
  V(I16x8MinU, Operator::kCommutative, 2, 0, 1)                            \
  V(I16x8MaxU, Operator::kCommutative, 2, 0, 1)                            \
  V(I16x8GtU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I16x8GeU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16Splat, Operator::kNoProperties, 1, 0, 1)                          \
  V(I8x16Neg, Operator::kNoProperties, 1, 0, 1)                            \
  V(I8x16Shl, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16ShrS, Operator::kNoProperties, 2, 0, 1)                           \
  V(I8x16SConvertI16x8, Operator::kNoProperties, 2, 0, 1)                  \
  V(I8x16Add, Operator::kCommutative, 2, 0, 1)                             \
  V(I8x16AddSaturateS, Operator::kCommutative, 2, 0, 1)                    \
  V(I8x16Sub, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16SubSaturateS, Operator::kNoProperties, 2, 0, 1)                   \
  V(I8x16Mul, Operator::kCommutative, 2, 0, 1)                             \
  V(I8x16MinS, Operator::kCommutative, 2, 0, 1)                            \
  V(I8x16MaxS, Operator::kCommutative, 2, 0, 1)                            \
  V(I8x16Eq, Operator::kCommutative, 2, 0, 1)                              \
  V(I8x16Ne, Operator::kCommutative, 2, 0, 1)                              \
  V(I8x16GtS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16GeS, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16ShrU, Operator::kNoProperties, 2, 0, 1)                           \
  V(I8x16UConvertI16x8, Operator::kNoProperties, 2, 0, 1)                  \
  V(I8x16AddSaturateU, Operator::kCommutative, 2, 0, 1)                    \
  V(I8x16SubSaturateU, Operator::kNoProperties, 2, 0, 1)                   \
  V(I8x16MinU, Operator::kCommutative, 2, 0, 1)                            \
  V(I8x16MaxU, Operator::kCommutative, 2, 0, 1)                            \
  V(I8x16GtU, Operator::kNoProperties, 2, 0, 1)                            \
  V(I8x16GeU, Operator::kNoProperties, 2, 0, 1)                            \
  V(S128Load, Operator::kNoProperties, 2, 0, 1)                            \
  V(S128Store, Operator::kNoProperties, 3, 0, 1)                           \
  V(S128Zero, Operator::kNoProperties, 0, 0, 1)                            \
  V(S128And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
  V(S128Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)      \
  V(S128Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
  V(S128Not, Operator::kNoProperties, 1, 0, 1)                             \
  V(S128Select, Operator::kNoProperties, 3, 0, 1)                          \
  V(S1x2AnyTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x2AllTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x4AnyTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x4AllTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x8AnyTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x8AllTrue, Operator::kNoProperties, 1, 0, 1)                         \
  V(S1x16AnyTrue, Operator::kNoProperties, 1, 0, 1)                        \
  V(S1x16AllTrue, Operator::kNoProperties, 1, 0, 1)                        \
464
  V(S8x16Swizzle, Operator::kNoProperties, 2, 0, 1)
465

466 467
// The format is:
// V(Name, properties, value_input_count, control_input_count, output_count)
468
#define PURE_OPTIONAL_OP_LIST(V)                            \
469
  V(Word32Ctz, Operator::kNoProperties, 1, 0, 1)            \
470
  V(Word64Ctz, Operator::kNoProperties, 1, 0, 1)            \
471 472
  V(Word32ReverseBits, Operator::kNoProperties, 1, 0, 1)    \
  V(Word64ReverseBits, Operator::kNoProperties, 1, 0, 1)    \
473 474
  V(Int32AbsWithOverflow, Operator::kNoProperties, 1, 0, 2) \
  V(Int64AbsWithOverflow, Operator::kNoProperties, 1, 0, 2) \
475
  V(Word32Popcnt, Operator::kNoProperties, 1, 0, 1)         \
476
  V(Word64Popcnt, Operator::kNoProperties, 1, 0, 1)         \
477
  V(Float32RoundDown, Operator::kNoProperties, 1, 0, 1)     \
478
  V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1)     \
479
  V(Float32RoundUp, Operator::kNoProperties, 1, 0, 1)       \
480
  V(Float64RoundUp, Operator::kNoProperties, 1, 0, 1)       \
481
  V(Float32RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
482
  V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
483
  V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) \
484
  V(Float32RoundTiesEven, Operator::kNoProperties, 1, 0, 1) \
485
  V(Float64RoundTiesEven, Operator::kNoProperties, 1, 0, 1)
486

487 488
// The format is:
// V(Name, properties, value_input_count, control_input_count, output_count)
489 490 491
#define OVERFLOW_OP_LIST(V)                                                \
  V(Int32AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
  V(Int32SubWithOverflow, Operator::kNoProperties)                         \
492
  V(Int32MulWithOverflow, Operator::kAssociative | Operator::kCommutative) \
493 494 495
  V(Int64AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
  V(Int64SubWithOverflow, Operator::kNoProperties)

496
#define MACHINE_TYPE_LIST(V) \
497 498
  V(Float32)                 \
  V(Float64)                 \
499
  V(Simd128)                 \
500 501 502 503 504 505 506 507 508
  V(Int8)                    \
  V(Uint8)                   \
  V(Int16)                   \
  V(Uint16)                  \
  V(Int32)                   \
  V(Uint32)                  \
  V(Int64)                   \
  V(Uint64)                  \
  V(Pointer)                 \
509 510
  V(TaggedSigned)            \
  V(TaggedPointer)           \
511 512 513
  V(AnyTagged)               \
  V(CompressedPointer)       \
  V(AnyCompressed)
514

515 516 517
#define MACHINE_REPRESENTATION_LIST(V) \
  V(kFloat32)                          \
  V(kFloat64)                          \
518
  V(kSimd128)                          \
519 520 521 522
  V(kWord8)                            \
  V(kWord16)                           \
  V(kWord32)                           \
  V(kWord64)                           \
523 524
  V(kTaggedSigned)                     \
  V(kTaggedPointer)                    \
525 526 527
  V(kTagged)                           \
  V(kCompressedPointer)                \
  V(kCompressed)
528

529 530 531
#define LOAD_TRANSFORM_LIST(V) \
  V(S8x16LoadSplat)            \
  V(S16x8LoadSplat)            \
532 533
  V(S32x4LoadSplat)            \
  V(S64x2LoadSplat)            \
534
  V(I16x8Load8x8S)             \
535 536 537 538 539
  V(I16x8Load8x8U)             \
  V(I32x4Load16x4S)            \
  V(I32x4Load16x4U)            \
  V(I64x2Load32x2S)            \
  V(I64x2Load32x2U)
540

541 542 543 544 545
#define ATOMIC_U32_TYPE_LIST(V) \
  V(Uint8)                      \
  V(Uint16)                     \
  V(Uint32)

546
#define ATOMIC_TYPE_LIST(V) \
547
  ATOMIC_U32_TYPE_LIST(V)   \
548 549
  V(Int8)                   \
  V(Int16)                  \
550
  V(Int32)
551

552 553
#define ATOMIC_U64_TYPE_LIST(V) \
  ATOMIC_U32_TYPE_LIST(V)       \
554 555
  V(Uint64)

556 557 558 559 560
#define ATOMIC_REPRESENTATION_LIST(V) \
  V(kWord8)                           \
  V(kWord16)                          \
  V(kWord32)

561 562 563 564
#define ATOMIC64_REPRESENTATION_LIST(V) \
  ATOMIC_REPRESENTATION_LIST(V)         \
  V(kWord64)

565 566 567 568 569
#define ATOMIC_PAIR_BINOP_LIST(V) \
  V(Add)                          \
  V(Sub)                          \
  V(And)                          \
  V(Or)                           \
570 571
  V(Xor)                          \
  V(Exchange)
572

573
#define SIMD_LANE_OP_LIST(V) \
574
  V(F64x2, 2)                \
575
  V(F32x4, 4)                \
576
  V(I64x2, 2)                \
577 578 579
  V(I32x4, 4)                \
  V(I16x8, 8)                \
  V(I8x16, 16)
580

581 582
#define STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(V) \
  V(4, 0) V(8, 0) V(16, 0) V(4, 4) V(8, 8) V(16, 16)
583

584 585 586 587 588 589
struct StackSlotOperator : public Operator1<StackSlotRepresentation> {
  explicit StackSlotOperator(int size, int alignment)
      : Operator1<StackSlotRepresentation>(
            IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow,
            "StackSlot", 0, 0, 0, 1, 0, 0,
            StackSlotRepresentation(size, alignment)) {}
590 591
};

592 593 594
struct MachineOperatorGlobalCache {
#define PURE(Name, properties, value_input_count, control_input_count,         \
             output_count)                                                     \
595
  struct Name##Operator final : public Operator {                              \
596 597 598 599 600
    Name##Operator()                                                           \
        : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name,     \
                   value_input_count, 0, control_input_count, output_count, 0, \
                   0) {}                                                       \
  };                                                                           \
601
  Name##Operator k##Name;
602
  MACHINE_PURE_OP_LIST(PURE)
603
  PURE_OPTIONAL_OP_LIST(PURE)
604 605
#undef PURE

606 607 608 609 610 611 612 613 614 615 616
#define OVERFLOW_OP(Name, properties)                                        \
  struct Name##Operator final : public Operator {                            \
    Name##Operator()                                                         \
        : Operator(IrOpcode::k##Name,                                        \
                   Operator::kEliminatable | Operator::kNoRead | properties, \
                   #Name, 2, 0, 1, 2, 0, 0) {}                               \
  };                                                                         \
  Name##Operator k##Name;
  OVERFLOW_OP_LIST(OVERFLOW_OP)
#undef OVERFLOW_OP

617 618 619 620 621 622 623 624
#define LOAD(Type)                                                            \
  struct Load##Type##Operator final : public Operator1<LoadRepresentation> {  \
    Load##Type##Operator()                                                    \
        : Operator1<LoadRepresentation>(                                      \
              IrOpcode::kLoad,                                                \
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,   \
              "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}               \
  };                                                                          \
625 626 627 628 629 630 631 632
  struct PoisonedLoad##Type##Operator final                                   \
      : public Operator1<LoadRepresentation> {                                \
    PoisonedLoad##Type##Operator()                                            \
        : Operator1<LoadRepresentation>(                                      \
              IrOpcode::kPoisonedLoad,                                        \
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,   \
              "PoisonedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}       \
  };                                                                          \
633
  struct UnalignedLoad##Type##Operator final                                  \
634
      : public Operator1<LoadRepresentation> {                                \
635
    UnalignedLoad##Type##Operator()                                           \
636
        : Operator1<LoadRepresentation>(                                      \
637 638 639 640 641 642 643 644 645
              IrOpcode::kUnalignedLoad,                                       \
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,   \
              "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}      \
  };                                                                          \
  struct ProtectedLoad##Type##Operator final                                  \
      : public Operator1<LoadRepresentation> {                                \
    ProtectedLoad##Type##Operator()                                           \
        : Operator1<LoadRepresentation>(                                      \
              IrOpcode::kProtectedLoad,                                       \
646
              Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 2, 1, \
647 648 649
              1, 1, 1, 0, MachineType::Type()) {}                             \
  };                                                                          \
  Load##Type##Operator kLoad##Type;                                           \
650
  PoisonedLoad##Type##Operator kPoisonedLoad##Type;                           \
651
  UnalignedLoad##Type##Operator kUnalignedLoad##Type;                         \
652
  ProtectedLoad##Type##Operator kProtectedLoad##Type;
653 654 655
  MACHINE_TYPE_LIST(LOAD)
#undef LOAD

656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
#define LOAD_TRANSFORM_KIND(TYPE, KIND)                                     \
  struct KIND##LoadTransform##TYPE##Operator final                          \
      : public Operator1<LoadTransformParameters> {                         \
    KIND##LoadTransform##TYPE##Operator()                                   \
        : Operator1<LoadTransformParameters>(                               \
              IrOpcode::kLoadTransform,                                     \
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
              #KIND "LoadTransform", 2, 1, 1, 1, 1, 0,                      \
              LoadTransformParameters{LoadKind::k##KIND,                    \
                                      LoadTransformation::k##TYPE}) {}      \
  };                                                                        \
  KIND##LoadTransform##TYPE##Operator k##KIND##LoadTransform##TYPE;

#define LOAD_TRANSFORM(TYPE)           \
  LOAD_TRANSFORM_KIND(TYPE, Normal)    \
  LOAD_TRANSFORM_KIND(TYPE, Unaligned) \
  LOAD_TRANSFORM_KIND(TYPE, Protected)

  LOAD_TRANSFORM_LIST(LOAD_TRANSFORM)
#undef LOAD_TRANSFORM
#undef LOAD_TRANSFORM_KIND

678 679 680 681 682 683 684 685 686
#define STACKSLOT(Size, Alignment)                                     \
  struct StackSlotOfSize##Size##OfAlignment##Alignment##Operator final \
      : public StackSlotOperator {                                     \
    StackSlotOfSize##Size##OfAlignment##Alignment##Operator()          \
        : StackSlotOperator(Size, Alignment) {}                        \
  };                                                                   \
  StackSlotOfSize##Size##OfAlignment##Alignment##Operator              \
      kStackSlotOfSize##Size##OfAlignment##Alignment;
  STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(STACKSLOT)
687 688
#undef STACKSLOT

689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
#define STORE(Type)                                                        \
  struct Store##Type##Operator : public Operator1<StoreRepresentation> {   \
    explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind)    \
        : Operator1<StoreRepresentation>(                                  \
              IrOpcode::kStore,                                            \
              Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
              "Store", 3, 1, 1, 0, 1, 0,                                   \
              StoreRepresentation(MachineRepresentation::Type,             \
                                  write_barrier_kind)) {}                  \
  };                                                                       \
  struct Store##Type##NoWriteBarrier##Operator final                       \
      : public Store##Type##Operator {                                     \
    Store##Type##NoWriteBarrier##Operator()                                \
        : Store##Type##Operator(kNoWriteBarrier) {}                        \
  };                                                                       \
704 705 706 707 708
  struct Store##Type##AssertNoWriteBarrier##Operator final                 \
      : public Store##Type##Operator {                                     \
    Store##Type##AssertNoWriteBarrier##Operator()                          \
        : Store##Type##Operator(kAssertNoWriteBarrier) {}                  \
  };                                                                       \
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
  struct Store##Type##MapWriteBarrier##Operator final                      \
      : public Store##Type##Operator {                                     \
    Store##Type##MapWriteBarrier##Operator()                               \
        : Store##Type##Operator(kMapWriteBarrier) {}                       \
  };                                                                       \
  struct Store##Type##PointerWriteBarrier##Operator final                  \
      : public Store##Type##Operator {                                     \
    Store##Type##PointerWriteBarrier##Operator()                           \
        : Store##Type##Operator(kPointerWriteBarrier) {}                   \
  };                                                                       \
  struct Store##Type##EphemeronKeyWriteBarrier##Operator final             \
      : public Store##Type##Operator {                                     \
    Store##Type##EphemeronKeyWriteBarrier##Operator()                      \
        : Store##Type##Operator(kEphemeronKeyWriteBarrier) {}              \
  };                                                                       \
  struct Store##Type##FullWriteBarrier##Operator final                     \
      : public Store##Type##Operator {                                     \
    Store##Type##FullWriteBarrier##Operator()                              \
        : Store##Type##Operator(kFullWriteBarrier) {}                      \
  };                                                                       \
  struct UnalignedStore##Type##Operator final                              \
      : public Operator1<UnalignedStoreRepresentation> {                   \
    UnalignedStore##Type##Operator()                                       \
        : Operator1<UnalignedStoreRepresentation>(                         \
              IrOpcode::kUnalignedStore,                                   \
              Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
              "UnalignedStore", 3, 1, 1, 0, 1, 0,                          \
              MachineRepresentation::Type) {}                              \
  };                                                                       \
  struct ProtectedStore##Type##Operator                                    \
      : public Operator1<StoreRepresentation> {                            \
    explicit ProtectedStore##Type##Operator()                              \
        : Operator1<StoreRepresentation>(                                  \
              IrOpcode::kProtectedStore,                                   \
              Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
              "Store", 3, 1, 1, 0, 1, 0,                                   \
              StoreRepresentation(MachineRepresentation::Type,             \
                                  kNoWriteBarrier)) {}                     \
  };                                                                       \
  Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier;      \
749 750
  Store##Type##AssertNoWriteBarrier##Operator                              \
      kStore##Type##AssertNoWriteBarrier;                                  \
751 752 753 754 755 756 757
  Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier;    \
  Store##Type##PointerWriteBarrier##Operator                               \
      kStore##Type##PointerWriteBarrier;                                   \
  Store##Type##EphemeronKeyWriteBarrier##Operator                          \
      kStore##Type##EphemeronKeyWriteBarrier;                              \
  Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier;  \
  UnalignedStore##Type##Operator kUnalignedStore##Type;                    \
758
  ProtectedStore##Type##Operator kProtectedStore##Type;
759
  MACHINE_REPRESENTATION_LIST(STORE)
760
#undef STORE
761

762
#define ATOMIC_LOAD(Type)                                                   \
763
  struct Word32AtomicLoad##Type##Operator final                             \
764
      : public Operator1<LoadRepresentation> {                              \
765
    Word32AtomicLoad##Type##Operator()                                      \
766
        : Operator1<LoadRepresentation>(                                    \
767
              IrOpcode::kWord32AtomicLoad,                                  \
768
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
769
              "Word32AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
770
  };                                                                        \
771
  Word32AtomicLoad##Type##Operator kWord32AtomicLoad##Type;
772 773 774
  ATOMIC_TYPE_LIST(ATOMIC_LOAD)
#undef ATOMIC_LOAD

775 776 777 778 779 780 781 782 783 784
#define ATOMIC_LOAD(Type)                                                   \
  struct Word64AtomicLoad##Type##Operator final                             \
      : public Operator1<LoadRepresentation> {                              \
    Word64AtomicLoad##Type##Operator()                                      \
        : Operator1<LoadRepresentation>(                                    \
              IrOpcode::kWord64AtomicLoad,                                  \
              Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
              "Word64AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
  };                                                                        \
  Word64AtomicLoad##Type##Operator kWord64AtomicLoad##Type;
785
  ATOMIC_U64_TYPE_LIST(ATOMIC_LOAD)
786 787
#undef ATOMIC_LOAD

788 789 790 791 792 793 794 795 796 797 798
#define ATOMIC_STORE(Type)                                                 \
  struct Word32AtomicStore##Type##Operator                                 \
      : public Operator1<MachineRepresentation> {                          \
    Word32AtomicStore##Type##Operator()                                    \
        : Operator1<MachineRepresentation>(                                \
              IrOpcode::kWord32AtomicStore,                                \
              Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
              "Word32AtomicStore", 3, 1, 1, 0, 1, 0,                       \
              MachineRepresentation::Type) {}                              \
  };                                                                       \
  Word32AtomicStore##Type##Operator kWord32AtomicStore##Type;
799
  ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
800
#undef ATOMIC_STORE
801

802 803 804 805 806 807 808 809 810 811 812 813 814 815
#define ATOMIC_STORE(Type)                                                 \
  struct Word64AtomicStore##Type##Operator                                 \
      : public Operator1<MachineRepresentation> {                          \
    Word64AtomicStore##Type##Operator()                                    \
        : Operator1<MachineRepresentation>(                                \
              IrOpcode::kWord64AtomicStore,                                \
              Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
              "Word64AtomicStore", 3, 1, 1, 0, 1, 0,                       \
              MachineRepresentation::Type) {}                              \
  };                                                                       \
  Word64AtomicStore##Type##Operator kWord64AtomicStore##Type;
  ATOMIC64_REPRESENTATION_LIST(ATOMIC_STORE)
#undef ATOMIC_STORE

816 817 818 819 820 821 822 823
#define ATOMIC_OP(op, type)                                                    \
  struct op##type##Operator : public Operator1<MachineType> {                  \
    op##type##Operator()                                                       \
        : Operator1<MachineType>(IrOpcode::k##op,                              \
                                 Operator::kNoDeopt | Operator::kNoThrow, #op, \
                                 3, 1, 1, 1, 1, 0, MachineType::type()) {}     \
  };                                                                           \
  op##type##Operator k##op##type;
824 825 826 827 828 829 830
#define ATOMIC_OP_LIST(type)       \
  ATOMIC_OP(Word32AtomicAdd, type) \
  ATOMIC_OP(Word32AtomicSub, type) \
  ATOMIC_OP(Word32AtomicAnd, type) \
  ATOMIC_OP(Word32AtomicOr, type)  \
  ATOMIC_OP(Word32AtomicXor, type) \
  ATOMIC_OP(Word32AtomicExchange, type)
831 832
  ATOMIC_TYPE_LIST(ATOMIC_OP_LIST)
#undef ATOMIC_OP_LIST
833 834 835 836 837
#define ATOMIC64_OP_LIST(type)     \
  ATOMIC_OP(Word64AtomicAdd, type) \
  ATOMIC_OP(Word64AtomicSub, type) \
  ATOMIC_OP(Word64AtomicAnd, type) \
  ATOMIC_OP(Word64AtomicOr, type)  \
838 839
  ATOMIC_OP(Word64AtomicXor, type) \
  ATOMIC_OP(Word64AtomicExchange, type)
840
  ATOMIC_U64_TYPE_LIST(ATOMIC64_OP_LIST)
841
#undef ATOMIC64_OP_LIST
842
#undef ATOMIC_OP
843

844 845 846 847 848 849 850 851 852 853 854
#define ATOMIC_COMPARE_EXCHANGE(Type)                                          \
  struct Word32AtomicCompareExchange##Type##Operator                           \
      : public Operator1<MachineType> {                                        \
    Word32AtomicCompareExchange##Type##Operator()                              \
        : Operator1<MachineType>(IrOpcode::kWord32AtomicCompareExchange,       \
                                 Operator::kNoDeopt | Operator::kNoThrow,      \
                                 "Word32AtomicCompareExchange", 4, 1, 1, 1, 1, \
                                 0, MachineType::Type()) {}                    \
  };                                                                           \
  Word32AtomicCompareExchange##Type##Operator                                  \
      kWord32AtomicCompareExchange##Type;
855 856 857
  ATOMIC_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE)
#undef ATOMIC_COMPARE_EXCHANGE

858 859 860 861 862 863 864 865 866 867 868
#define ATOMIC_COMPARE_EXCHANGE(Type)                                          \
  struct Word64AtomicCompareExchange##Type##Operator                           \
      : public Operator1<MachineType> {                                        \
    Word64AtomicCompareExchange##Type##Operator()                              \
        : Operator1<MachineType>(IrOpcode::kWord64AtomicCompareExchange,       \
                                 Operator::kNoDeopt | Operator::kNoThrow,      \
                                 "Word64AtomicCompareExchange", 4, 1, 1, 1, 1, \
                                 0, MachineType::Type()) {}                    \
  };                                                                           \
  Word64AtomicCompareExchange##Type##Operator                                  \
      kWord64AtomicCompareExchange##Type;
869
  ATOMIC_U64_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE)
870 871
#undef ATOMIC_COMPARE_EXCHANGE

872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
  struct Word32AtomicPairLoadOperator : public Operator {
    Word32AtomicPairLoadOperator()
        : Operator(IrOpcode::kWord32AtomicPairLoad,
                   Operator::kNoDeopt | Operator::kNoThrow,
                   "Word32AtomicPairLoad", 2, 1, 1, 2, 1, 0) {}
  };
  Word32AtomicPairLoadOperator kWord32AtomicPairLoad;

  struct Word32AtomicPairStoreOperator : public Operator {
    Word32AtomicPairStoreOperator()
        : Operator(IrOpcode::kWord32AtomicPairStore,
                   Operator::kNoDeopt | Operator::kNoThrow,
                   "Word32AtomicPairStore", 4, 1, 1, 0, 1, 0) {}
  };
  Word32AtomicPairStoreOperator kWord32AtomicPairStore;

888 889 890 891 892 893 894 895 896 897 898 899
#define ATOMIC_PAIR_OP(op)                                      \
  struct Word32AtomicPair##op##Operator : public Operator {     \
    Word32AtomicPair##op##Operator()                            \
        : Operator(IrOpcode::kWord32AtomicPair##op,             \
                   Operator::kNoDeopt | Operator::kNoThrow,     \
                   "Word32AtomicPair##op", 4, 1, 1, 2, 1, 0) {} \
  };                                                            \
  Word32AtomicPair##op##Operator kWord32AtomicPair##op;
  ATOMIC_PAIR_BINOP_LIST(ATOMIC_PAIR_OP)
#undef ATOMIC_PAIR_OP
#undef ATOMIC_PAIR_BINOP_LIST

900 901 902 903 904 905 906 907
  struct Word32AtomicPairCompareExchangeOperator : public Operator {
    Word32AtomicPairCompareExchangeOperator()
        : Operator(IrOpcode::kWord32AtomicPairCompareExchange,
                   Operator::kNoDeopt | Operator::kNoThrow,
                   "Word32AtomicPairCompareExchange", 6, 1, 1, 2, 1, 0) {}
  };
  Word32AtomicPairCompareExchangeOperator kWord32AtomicPairCompareExchange;

908 909 910 911 912 913 914 915
  struct MemoryBarrierOperator : public Operator {
    MemoryBarrierOperator()
        : Operator(IrOpcode::kMemoryBarrier,
                   Operator::kNoDeopt | Operator::kNoThrow, "MemoryBarrier", 0,
                   1, 1, 0, 1, 0) {}
  };
  MemoryBarrierOperator kMemoryBarrier;

916 917 918 919 920 921 922 923 924
  // The {BitcastWordToTagged} operator must not be marked as pure (especially
  // not idempotent), because otherwise the splitting logic in the Scheduler
  // might decide to split these operators, thus potentially creating live
  // ranges of allocation top across calls or other things that might allocate.
  // See https://bugs.chromium.org/p/v8/issues/detail?id=6059 for more details.
  struct BitcastWordToTaggedOperator : public Operator {
    BitcastWordToTaggedOperator()
        : Operator(IrOpcode::kBitcastWordToTagged,
                   Operator::kEliminatable | Operator::kNoWrite,
925
                   "BitcastWordToTagged", 1, 1, 1, 1, 1, 0) {}
926 927 928
  };
  BitcastWordToTaggedOperator kBitcastWordToTagged;

929 930 931 932 933 934 935 936
  struct BitcastTaggedToWordOperator : public Operator {
    BitcastTaggedToWordOperator()
        : Operator(IrOpcode::kBitcastTaggedToWord,
                   Operator::kEliminatable | Operator::kNoWrite,
                   "BitcastTaggedToWord", 1, 1, 1, 1, 1, 0) {}
  };
  BitcastTaggedToWordOperator kBitcastTaggedToWord;

937 938 939 940 941 942 943 944
  struct BitcastMaybeObjectToWordOperator : public Operator {
    BitcastMaybeObjectToWordOperator()
        : Operator(IrOpcode::kBitcastTaggedToWord,
                   Operator::kEliminatable | Operator::kNoWrite,
                   "BitcastMaybeObjectToWord", 1, 1, 1, 1, 1, 0) {}
  };
  BitcastMaybeObjectToWordOperator kBitcastMaybeObjectToWord;

945 946 947
  struct TaggedPoisonOnSpeculation : public Operator {
    TaggedPoisonOnSpeculation()
        : Operator(IrOpcode::kTaggedPoisonOnSpeculation,
948
                   Operator::kEliminatable | Operator::kNoWrite,
949
                   "TaggedPoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
950
  };
951
  TaggedPoisonOnSpeculation kTaggedPoisonOnSpeculation;
952

953 954 955
  struct Word32PoisonOnSpeculation : public Operator {
    Word32PoisonOnSpeculation()
        : Operator(IrOpcode::kWord32PoisonOnSpeculation,
956
                   Operator::kEliminatable | Operator::kNoWrite,
957
                   "Word32PoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
958
  };
959 960 961 962 963 964 965 966 967
  Word32PoisonOnSpeculation kWord32PoisonOnSpeculation;

  struct Word64PoisonOnSpeculation : public Operator {
    Word64PoisonOnSpeculation()
        : Operator(IrOpcode::kWord64PoisonOnSpeculation,
                   Operator::kEliminatable | Operator::kNoWrite,
                   "Word64PoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
  };
  Word64PoisonOnSpeculation kWord64PoisonOnSpeculation;
968

969 970 971 972
  struct AbortCSAAssertOperator : public Operator {
    AbortCSAAssertOperator()
        : Operator(IrOpcode::kAbortCSAAssert, Operator::kNoThrow,
                   "AbortCSAAssert", 1, 1, 1, 0, 1, 0) {}
973
  };
974
  AbortCSAAssertOperator kAbortCSAAssert;
975

976 977 978
  struct DebugBreakOperator : public Operator {
    DebugBreakOperator()
        : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0,
979
                   1, 1, 0, 1, 0) {}
980 981
  };
  DebugBreakOperator kDebugBreak;
982 983 984 985 986 987 988

  struct UnsafePointerAddOperator final : public Operator {
    UnsafePointerAddOperator()
        : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol,
                   "UnsafePointerAdd", 2, 1, 1, 1, 1, 0) {}
  };
  UnsafePointerAddOperator kUnsafePointerAdd;
989

990 991 992 993 994
  struct StackPointerGreaterThanOperator : public Operator1<StackCheckKind> {
    explicit StackPointerGreaterThanOperator(StackCheckKind kind)
        : Operator1<StackCheckKind>(
              IrOpcode::kStackPointerGreaterThan, Operator::kEliminatable,
              "StackPointerGreaterThan", 1, 1, 0, 1, 1, 0, kind) {}
995
  };
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
#define STACK_POINTER_GREATER_THAN(Kind)                              \
  struct StackPointerGreaterThan##Kind##Operator final                \
      : public StackPointerGreaterThanOperator {                      \
    StackPointerGreaterThan##Kind##Operator()                         \
        : StackPointerGreaterThanOperator(StackCheckKind::k##Kind) {} \
  };                                                                  \
  StackPointerGreaterThan##Kind##Operator kStackPointerGreaterThan##Kind;

  STACK_POINTER_GREATER_THAN(JSFunctionEntry)
  STACK_POINTER_GREATER_THAN(JSIterationBody)
  STACK_POINTER_GREATER_THAN(CodeStubAssembler)
  STACK_POINTER_GREATER_THAN(Wasm)
#undef STACK_POINTER_GREATER_THAN
1009 1010
};

1011 1012 1013
struct CommentOperator : public Operator1<const char*> {
  explicit CommentOperator(const char* msg)
      : Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
1014
                               "Comment", 0, 1, 1, 0, 1, 0, msg) {}
1015
};
1016

1017 1018
namespace {
DEFINE_LAZY_LEAKY_OBJECT_GETTER(MachineOperatorGlobalCache,
1019
                                GetMachineOperatorGlobalCache)
1020
}
1021

1022 1023 1024
MachineOperatorBuilder::MachineOperatorBuilder(
    Zone* zone, MachineRepresentation word, Flags flags,
    AlignmentRequirements alignmentRequirements)
1025
    : zone_(zone),
1026
      cache_(*GetMachineOperatorGlobalCache()),
1027 1028 1029
      word_(word),
      flags_(flags),
      alignment_requirements_(alignmentRequirements) {
1030 1031
  DCHECK(word == MachineRepresentation::kWord32 ||
         word == MachineRepresentation::kWord64);
1032 1033
}

1034
const Operator* MachineOperatorBuilder::UnalignedLoad(LoadRepresentation rep) {
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
#define LOAD(Type)                       \
  if (rep == MachineType::Type()) {      \
    return &cache_.kUnalignedLoad##Type; \
  }
  MACHINE_TYPE_LIST(LOAD)
#undef LOAD
  UNREACHABLE();
}

const Operator* MachineOperatorBuilder::UnalignedStore(
    UnalignedStoreRepresentation rep) {
  switch (rep) {
#define STORE(kRep)                 \
  case MachineRepresentation::kRep: \
    return &cache_.kUnalignedStore##kRep;
    MACHINE_REPRESENTATION_LIST(STORE)
#undef STORE
    case MachineRepresentation::kBit:
    case MachineRepresentation::kNone:
      break;
  }
  UNREACHABLE();
}
1058

1059 1060 1061
#define PURE(Name, properties, value_input_count, control_input_count, \
             output_count)                                             \
  const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
1062
MACHINE_PURE_OP_LIST(PURE)
1063 1064
#undef PURE

1065 1066 1067 1068
#define PURE(Name, properties, value_input_count, control_input_count, \
             output_count)                                             \
  const OptionalOperator MachineOperatorBuilder::Name() {              \
    return OptionalOperator(flags_ & k##Name, &cache_.k##Name);        \
1069 1070 1071
  }
PURE_OPTIONAL_OP_LIST(PURE)
#undef PURE
1072

1073 1074 1075 1076
#define OVERFLOW_OP(Name, properties) \
  const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
OVERFLOW_OP_LIST(OVERFLOW_OP)
#undef OVERFLOW_OP
1077

1078
const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
1079 1080 1081 1082
#define LOAD(Type)                  \
  if (rep == MachineType::Type()) { \
    return &cache_.kLoad##Type;     \
  }
1083 1084
    MACHINE_TYPE_LIST(LOAD)
#undef LOAD
1085
  UNREACHABLE();
1086 1087
}

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
const Operator* MachineOperatorBuilder::PoisonedLoad(LoadRepresentation rep) {
#define LOAD(Type)                      \
  if (rep == MachineType::Type()) {     \
    return &cache_.kPoisonedLoad##Type; \
  }
  MACHINE_TYPE_LIST(LOAD)
#undef LOAD
  UNREACHABLE();
}

1098 1099 1100 1101 1102 1103 1104 1105
const Operator* MachineOperatorBuilder::ProtectedLoad(LoadRepresentation rep) {
#define LOAD(Type)                       \
  if (rep == MachineType::Type()) {      \
    return &cache_.kProtectedLoad##Type; \
  }
  MACHINE_TYPE_LIST(LOAD)
#undef LOAD
  UNREACHABLE();
1106 1107
}

1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
const Operator* MachineOperatorBuilder::LoadTransform(
    LoadKind kind, LoadTransformation transform) {
#define LOAD_TRANSFORM_KIND(TYPE, KIND)                                        \
  if (kind == LoadKind::k##KIND && transform == LoadTransformation::k##TYPE) { \
    return &cache_.k##KIND##LoadTransform##TYPE;                               \
  }
#define LOAD_TRANSFORM(TYPE)           \
  LOAD_TRANSFORM_KIND(TYPE, Normal)    \
  LOAD_TRANSFORM_KIND(TYPE, Unaligned) \
  LOAD_TRANSFORM_KIND(TYPE, Protected)

  LOAD_TRANSFORM_LIST(LOAD_TRANSFORM)
#undef LOAD_TRANSFORM
#undef LOAD_TRANSFORM_KIND
  UNREACHABLE();
}

1125
const Operator* MachineOperatorBuilder::StackSlot(int size, int alignment) {
1126
  DCHECK_LE(0, size);
1127 1128 1129 1130
  DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || alignment == 16);
#define CASE_CACHED_SIZE(Size, Alignment)                          \
  if (size == Size && alignment == Alignment) {                    \
    return &cache_.kStackSlotOfSize##Size##OfAlignment##Alignment; \
1131
  }
1132 1133 1134

  STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(CASE_CACHED_SIZE)

1135
#undef CASE_CACHED_SIZE
1136
  return new (zone_) StackSlotOperator(size, alignment);
1137 1138
}

1139 1140 1141
const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep,
                                                  int alignment) {
  return StackSlot(1 << ElementSizeLog2Of(rep), alignment);
1142
}
1143

1144
const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
1145
  switch (store_rep.representation()) {
1146 1147 1148 1149 1150
#define STORE(kRep)                                              \
  case MachineRepresentation::kRep:                              \
    switch (store_rep.write_barrier_kind()) {                    \
      case kNoWriteBarrier:                                      \
        return &cache_.k##Store##kRep##NoWriteBarrier;           \
1151 1152
      case kAssertNoWriteBarrier:                                \
        return &cache_.k##Store##kRep##AssertNoWriteBarrier;     \
1153 1154 1155 1156 1157 1158 1159 1160 1161
      case kMapWriteBarrier:                                     \
        return &cache_.k##Store##kRep##MapWriteBarrier;          \
      case kPointerWriteBarrier:                                 \
        return &cache_.k##Store##kRep##PointerWriteBarrier;      \
      case kEphemeronKeyWriteBarrier:                            \
        return &cache_.k##Store##kRep##EphemeronKeyWriteBarrier; \
      case kFullWriteBarrier:                                    \
        return &cache_.k##Store##kRep##FullWriteBarrier;         \
    }                                                            \
1162 1163
    break;
    MACHINE_REPRESENTATION_LIST(STORE)
1164
#undef STORE
1165 1166
    case MachineRepresentation::kBit:
    case MachineRepresentation::kNone:
1167 1168
      break;
  }
1169
  UNREACHABLE();
1170
}
1171

1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
const Operator* MachineOperatorBuilder::ProtectedStore(
    MachineRepresentation rep) {
  switch (rep) {
#define STORE(kRep)                       \
  case MachineRepresentation::kRep:       \
    return &cache_.kProtectedStore##kRep; \
    break;
    MACHINE_REPRESENTATION_LIST(STORE)
#undef STORE
    case MachineRepresentation::kBit:
    case MachineRepresentation::kNone:
      break;
  }
  UNREACHABLE();
}

1188 1189 1190 1191
const Operator* MachineOperatorBuilder::UnsafePointerAdd() {
  return &cache_.kUnsafePointerAdd;
}

1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
const Operator* MachineOperatorBuilder::StackPointerGreaterThan(
    StackCheckKind kind) {
  switch (kind) {
    case StackCheckKind::kJSFunctionEntry:
      return &cache_.kStackPointerGreaterThanJSFunctionEntry;
    case StackCheckKind::kJSIterationBody:
      return &cache_.kStackPointerGreaterThanJSIterationBody;
    case StackCheckKind::kCodeStubAssembler:
      return &cache_.kStackPointerGreaterThanCodeStubAssembler;
    case StackCheckKind::kWasm:
      return &cache_.kStackPointerGreaterThanWasm;
  }
  UNREACHABLE();
1205 1206
}

1207 1208 1209 1210
const Operator* MachineOperatorBuilder::BitcastWordToTagged() {
  return &cache_.kBitcastWordToTagged;
}

1211 1212 1213 1214
const Operator* MachineOperatorBuilder::BitcastTaggedToWord() {
  return &cache_.kBitcastTaggedToWord;
}

1215 1216 1217 1218
const Operator* MachineOperatorBuilder::BitcastMaybeObjectToWord() {
  return &cache_.kBitcastMaybeObjectToWord;
}

1219 1220
const Operator* MachineOperatorBuilder::AbortCSAAssert() {
  return &cache_.kAbortCSAAssert;
1221 1222
}

1223 1224 1225
const Operator* MachineOperatorBuilder::DebugBreak() {
  return &cache_.kDebugBreak;
}
1226

1227 1228 1229 1230
const Operator* MachineOperatorBuilder::Comment(const char* msg) {
  return new (zone_) CommentOperator(msg);
}

1231 1232 1233 1234
const Operator* MachineOperatorBuilder::MemBarrier() {
  return &cache_.kMemoryBarrier;
}

1235 1236 1237 1238 1239
const Operator* MachineOperatorBuilder::Word32AtomicLoad(
    LoadRepresentation rep) {
#define LOAD(Type)                          \
  if (rep == MachineType::Type()) {         \
    return &cache_.kWord32AtomicLoad##Type; \
1240 1241 1242 1243 1244 1245
  }
  ATOMIC_TYPE_LIST(LOAD)
#undef LOAD
  UNREACHABLE();
}

1246 1247 1248 1249 1250
const Operator* MachineOperatorBuilder::Word32AtomicStore(
    MachineRepresentation rep) {
#define STORE(kRep)                          \
  if (rep == MachineRepresentation::kRep) {  \
    return &cache_.kWord32AtomicStore##kRep; \
1251 1252 1253 1254 1255 1256
  }
  ATOMIC_REPRESENTATION_LIST(STORE)
#undef STORE
  UNREACHABLE();
}

1257 1258 1259 1260
const Operator* MachineOperatorBuilder::Word32AtomicExchange(MachineType type) {
#define EXCHANGE(kType)                          \
  if (type == MachineType::kType()) {            \
    return &cache_.kWord32AtomicExchange##kType; \
1261 1262 1263 1264 1265 1266
  }
  ATOMIC_TYPE_LIST(EXCHANGE)
#undef EXCHANGE
  UNREACHABLE();
}

1267
const Operator* MachineOperatorBuilder::Word32AtomicCompareExchange(
1268 1269 1270 1271
    MachineType type) {
#define COMPARE_EXCHANGE(kType)                         \
  if (type == MachineType::kType()) {                   \
    return &cache_.kWord32AtomicCompareExchange##kType; \
1272 1273 1274 1275 1276 1277
  }
  ATOMIC_TYPE_LIST(COMPARE_EXCHANGE)
#undef COMPARE_EXCHANGE
  UNREACHABLE();
}

1278 1279 1280 1281
const Operator* MachineOperatorBuilder::Word32AtomicAdd(MachineType type) {
#define ADD(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord32AtomicAdd##kType; \
1282 1283 1284 1285 1286 1287
  }
  ATOMIC_TYPE_LIST(ADD)
#undef ADD
  UNREACHABLE();
}

1288 1289 1290 1291
const Operator* MachineOperatorBuilder::Word32AtomicSub(MachineType type) {
#define SUB(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord32AtomicSub##kType; \
1292 1293 1294 1295 1296 1297
  }
  ATOMIC_TYPE_LIST(SUB)
#undef SUB
  UNREACHABLE();
}

1298 1299 1300 1301
const Operator* MachineOperatorBuilder::Word32AtomicAnd(MachineType type) {
#define AND(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord32AtomicAnd##kType; \
1302 1303 1304 1305 1306 1307
  }
  ATOMIC_TYPE_LIST(AND)
#undef AND
  UNREACHABLE();
}

1308 1309 1310 1311
const Operator* MachineOperatorBuilder::Word32AtomicOr(MachineType type) {
#define OR(kType)                          \
  if (type == MachineType::kType()) {      \
    return &cache_.kWord32AtomicOr##kType; \
1312 1313 1314 1315 1316 1317
  }
  ATOMIC_TYPE_LIST(OR)
#undef OR
  UNREACHABLE();
}

1318 1319 1320 1321
const Operator* MachineOperatorBuilder::Word32AtomicXor(MachineType type) {
#define XOR(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord32AtomicXor##kType; \
1322 1323 1324 1325 1326 1327
  }
  ATOMIC_TYPE_LIST(XOR)
#undef XOR
  UNREACHABLE();
}

1328 1329 1330 1331 1332 1333
const Operator* MachineOperatorBuilder::Word64AtomicLoad(
    LoadRepresentation rep) {
#define LOAD(Type)                          \
  if (rep == MachineType::Type()) {         \
    return &cache_.kWord64AtomicLoad##Type; \
  }
1334
  ATOMIC_U64_TYPE_LIST(LOAD)
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
#undef LOAD
  UNREACHABLE();
}

const Operator* MachineOperatorBuilder::Word64AtomicStore(
    MachineRepresentation rep) {
#define STORE(kRep)                          \
  if (rep == MachineRepresentation::kRep) {  \
    return &cache_.kWord64AtomicStore##kRep; \
  }
  ATOMIC64_REPRESENTATION_LIST(STORE)
#undef STORE
  UNREACHABLE();
}

1350 1351 1352 1353
const Operator* MachineOperatorBuilder::Word64AtomicAdd(MachineType type) {
#define ADD(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord64AtomicAdd##kType; \
1354
  }
1355
  ATOMIC_U64_TYPE_LIST(ADD)
1356 1357 1358 1359
#undef ADD
  UNREACHABLE();
}

1360 1361 1362 1363
const Operator* MachineOperatorBuilder::Word64AtomicSub(MachineType type) {
#define SUB(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord64AtomicSub##kType; \
1364
  }
1365
  ATOMIC_U64_TYPE_LIST(SUB)
1366 1367 1368 1369
#undef SUB
  UNREACHABLE();
}

1370 1371 1372 1373
const Operator* MachineOperatorBuilder::Word64AtomicAnd(MachineType type) {
#define AND(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord64AtomicAnd##kType; \
1374
  }
1375
  ATOMIC_U64_TYPE_LIST(AND)
1376 1377 1378 1379
#undef AND
  UNREACHABLE();
}

1380 1381 1382 1383
const Operator* MachineOperatorBuilder::Word64AtomicOr(MachineType type) {
#define OR(kType)                          \
  if (type == MachineType::kType()) {      \
    return &cache_.kWord64AtomicOr##kType; \
1384
  }
1385
  ATOMIC_U64_TYPE_LIST(OR)
1386 1387 1388 1389
#undef OR
  UNREACHABLE();
}

1390 1391 1392 1393
const Operator* MachineOperatorBuilder::Word64AtomicXor(MachineType type) {
#define XOR(kType)                          \
  if (type == MachineType::kType()) {       \
    return &cache_.kWord64AtomicXor##kType; \
1394
  }
1395
  ATOMIC_U64_TYPE_LIST(XOR)
1396 1397 1398 1399
#undef XOR
  UNREACHABLE();
}

1400 1401 1402 1403
const Operator* MachineOperatorBuilder::Word64AtomicExchange(MachineType type) {
#define EXCHANGE(kType)                          \
  if (type == MachineType::kType()) {            \
    return &cache_.kWord64AtomicExchange##kType; \
1404
  }
1405
  ATOMIC_U64_TYPE_LIST(EXCHANGE)
1406 1407 1408 1409 1410
#undef EXCHANGE
  UNREACHABLE();
}

const Operator* MachineOperatorBuilder::Word64AtomicCompareExchange(
1411 1412 1413 1414
    MachineType type) {
#define COMPARE_EXCHANGE(kType)                         \
  if (type == MachineType::kType()) {                   \
    return &cache_.kWord64AtomicCompareExchange##kType; \
1415
  }
1416
  ATOMIC_U64_TYPE_LIST(COMPARE_EXCHANGE)
1417 1418 1419 1420
#undef COMPARE_EXCHANGE
  UNREACHABLE();
}

1421 1422 1423 1424 1425 1426 1427 1428
const Operator* MachineOperatorBuilder::Word32AtomicPairLoad() {
  return &cache_.kWord32AtomicPairLoad;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairStore() {
  return &cache_.kWord32AtomicPairStore;
}

1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
const Operator* MachineOperatorBuilder::Word32AtomicPairAdd() {
  return &cache_.kWord32AtomicPairAdd;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairSub() {
  return &cache_.kWord32AtomicPairSub;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairAnd() {
  return &cache_.kWord32AtomicPairAnd;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairOr() {
  return &cache_.kWord32AtomicPairOr;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairXor() {
  return &cache_.kWord32AtomicPairXor;
}

1449 1450 1451 1452 1453 1454 1455 1456
const Operator* MachineOperatorBuilder::Word32AtomicPairExchange() {
  return &cache_.kWord32AtomicPairExchange;
}

const Operator* MachineOperatorBuilder::Word32AtomicPairCompareExchange() {
  return &cache_.kWord32AtomicPairCompareExchange;
}

1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
const Operator* MachineOperatorBuilder::TaggedPoisonOnSpeculation() {
  return &cache_.kTaggedPoisonOnSpeculation;
}

const Operator* MachineOperatorBuilder::Word32PoisonOnSpeculation() {
  return &cache_.kWord32PoisonOnSpeculation;
}

const Operator* MachineOperatorBuilder::Word64PoisonOnSpeculation() {
  return &cache_.kWord64PoisonOnSpeculation;
}

1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487
#define EXTRACT_LANE_OP(Type, Sign, lane_count)                                \
  const Operator* MachineOperatorBuilder::Type##ExtractLane##Sign(             \
      int32_t lane_index) {                                                    \
    DCHECK(0 <= lane_index && lane_index < lane_count);                        \
    return new (zone_) Operator1<int32_t>(                                     \
        IrOpcode::k##Type##ExtractLane##Sign, Operator::kPure, "Extract lane", \
        1, 0, 0, 1, 0, 0, lane_index);                                         \
  }
EXTRACT_LANE_OP(F64x2, , 2)
EXTRACT_LANE_OP(F32x4, , 4)
EXTRACT_LANE_OP(I64x2, , 2)
EXTRACT_LANE_OP(I32x4, , 4)
EXTRACT_LANE_OP(I16x8, U, 8)
EXTRACT_LANE_OP(I16x8, S, 8)
EXTRACT_LANE_OP(I8x16, U, 16)
EXTRACT_LANE_OP(I8x16, S, 16)
#undef EXTRACT_LANE_OP

#define REPLACE_LANE_OP(Type, lane_count)                                   \
1488 1489 1490 1491 1492 1493 1494
  const Operator* MachineOperatorBuilder::Type##ReplaceLane(                \
      int32_t lane_index) {                                                 \
    DCHECK(0 <= lane_index && lane_index < lane_count);                     \
    return new (zone_)                                                      \
        Operator1<int32_t>(IrOpcode::k##Type##ReplaceLane, Operator::kPure, \
                           "Replace lane", 2, 0, 0, 1, 0, 0, lane_index);   \
  }
1495 1496
SIMD_LANE_OP_LIST(REPLACE_LANE_OP)
#undef REPLACE_LANE_OP
1497

1498 1499 1500 1501 1502 1503 1504 1505
const Operator* MachineOperatorBuilder::I64x2ReplaceLaneI32Pair(
    int32_t lane_index) {
  DCHECK(0 <= lane_index && lane_index < 2);
  return new (zone_)
      Operator1<int32_t>(IrOpcode::kI64x2ReplaceLaneI32Pair, Operator::kPure,
                         "Replace lane", 3, 0, 0, 1, 0, 0, lane_index);
}

1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
bool operator==(S8x16ShuffleParameter const& lhs,
                S8x16ShuffleParameter const& rhs) {
  return (lhs.shuffle() == rhs.shuffle());
}

bool operator!=(S8x16ShuffleParameter const& lhs,
                S8x16ShuffleParameter const& rhs) {
  return !(lhs == rhs);
}

size_t hash_value(S8x16ShuffleParameter const& p) {
  return base::hash_range(p.shuffle().begin(), p.shuffle().end());
1518
}
1519

1520 1521 1522 1523 1524 1525 1526 1527 1528
std::ostream& operator<<(std::ostream& os, S8x16ShuffleParameter const& p) {
  for (int i = 0; i < 16; i++) {
    const char* separator = (i < 15) ? "," : "";
    os << static_cast<uint32_t>(p[i]) << separator;
  }
  return os;
}

S8x16ShuffleParameter const& S8x16ShuffleParameterOf(Operator const* op) {
1529
  DCHECK_EQ(IrOpcode::kS8x16Shuffle, op->opcode());
1530 1531 1532 1533 1534 1535 1536 1537
  return OpParameter<S8x16ShuffleParameter>(op);
}

const Operator* MachineOperatorBuilder::S8x16Shuffle(
    const uint8_t shuffle[16]) {
  return new (zone_) Operator1<S8x16ShuffleParameter>(
      IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle", 2, 0, 0, 1, 0, 0,
      S8x16ShuffleParameter(shuffle));
1538 1539
}

1540 1541 1542 1543 1544
StackCheckKind StackCheckKindOf(Operator const* op) {
  DCHECK_EQ(IrOpcode::kStackPointerGreaterThan, op->opcode());
  return OpParameter<StackCheckKind>(op);
}

1545 1546 1547 1548 1549 1550 1551 1552
#undef PURE_BINARY_OP_LIST_32
#undef PURE_BINARY_OP_LIST_64
#undef MACHINE_PURE_OP_LIST
#undef PURE_OPTIONAL_OP_LIST
#undef OVERFLOW_OP_LIST
#undef MACHINE_TYPE_LIST
#undef MACHINE_REPRESENTATION_LIST
#undef ATOMIC_TYPE_LIST
1553 1554
#undef ATOMIC_U64_TYPE_LIST
#undef ATOMIC_U32_TYPE_LIST
1555
#undef ATOMIC_REPRESENTATION_LIST
1556
#undef ATOMIC64_REPRESENTATION_LIST
1557 1558
#undef SIMD_LANE_OP_LIST
#undef STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST
1559
#undef LOAD_TRANSFORM_LIST
1560

1561 1562 1563
}  // namespace compiler
}  // namespace internal
}  // namespace v8