f2426d0d550d0039135951c17b30eed3dac32fae
[platform/upstream/v8.git] / src / ppc / lithium-ppc.h
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_PPC_LITHIUM_PPC_H_
6 #define V8_PPC_LITHIUM_PPC_H_
7
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
13
14 namespace v8 {
15 namespace internal {
16
17 // Forward declarations.
18 class LCodeGen;
19
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21   V(AccessArgumentsAt)                       \
22   V(AddI)                                    \
23   V(Allocate)                                \
24   V(AllocateBlockContext)                    \
25   V(ApplyArguments)                          \
26   V(ArgumentsElements)                       \
27   V(ArgumentsLength)                         \
28   V(ArithmeticD)                             \
29   V(ArithmeticT)                             \
30   V(BitI)                                    \
31   V(BoundsCheck)                             \
32   V(Branch)                                  \
33   V(CallJSFunction)                          \
34   V(CallWithDescriptor)                      \
35   V(CallFunction)                            \
36   V(CallNew)                                 \
37   V(CallNewArray)                            \
38   V(CallRuntime)                             \
39   V(CallStub)                                \
40   V(CheckArrayBufferNotNeutered)             \
41   V(CheckInstanceType)                       \
42   V(CheckNonSmi)                             \
43   V(CheckMaps)                               \
44   V(CheckMapValue)                           \
45   V(CheckSmi)                                \
46   V(CheckValue)                              \
47   V(ClampDToUint8)                           \
48   V(ClampIToUint8)                           \
49   V(ClampTToUint8)                           \
50   V(ClassOfTestAndBranch)                    \
51   V(CompareMinusZeroAndBranch)               \
52   V(CompareNumericAndBranch)                 \
53   V(CmpObjectEqAndBranch)                    \
54   V(CmpHoleAndBranch)                        \
55   V(CmpMapAndBranch)                         \
56   V(CmpT)                                    \
57   V(ConstantD)                               \
58   V(ConstantE)                               \
59   V(ConstantI)                               \
60   V(ConstantS)                               \
61   V(ConstantT)                               \
62   V(ConstructDouble)                         \
63   V(Context)                                 \
64   V(DateField)                               \
65   V(DebugBreak)                              \
66   V(DeclareGlobals)                          \
67   V(Deoptimize)                              \
68   V(DivByConstI)                             \
69   V(DivByPowerOf2I)                          \
70   V(DivI)                                    \
71   V(DoubleBits)                              \
72   V(DoubleToI)                               \
73   V(DoubleToSmi)                             \
74   V(Drop)                                    \
75   V(Dummy)                                   \
76   V(DummyUse)                                \
77   V(FlooringDivByConstI)                     \
78   V(FlooringDivByPowerOf2I)                  \
79   V(FlooringDivI)                            \
80   V(ForInCacheArray)                         \
81   V(ForInPrepareMap)                         \
82   V(FunctionLiteral)                         \
83   V(GetCachedArrayIndex)                     \
84   V(Goto)                                    \
85   V(HasCachedArrayIndexAndBranch)            \
86   V(HasInstanceTypeAndBranch)                \
87   V(InnerAllocatedObject)                    \
88   V(InstanceOf)                              \
89   V(InstanceOfKnownGlobal)                   \
90   V(InstructionGap)                          \
91   V(Integer32ToDouble)                       \
92   V(InvokeFunction)                          \
93   V(IsConstructCallAndBranch)                \
94   V(IsObjectAndBranch)                       \
95   V(IsStringAndBranch)                       \
96   V(IsSmiAndBranch)                          \
97   V(IsUndetectableAndBranch)                 \
98   V(Label)                                   \
99   V(LazyBailout)                             \
100   V(LoadContextSlot)                         \
101   V(LoadRoot)                                \
102   V(LoadFieldByIndex)                        \
103   V(LoadFunctionPrototype)                   \
104   V(LoadGlobalGeneric)                       \
105   V(LoadGlobalViaContext)                    \
106   V(LoadKeyed)                               \
107   V(LoadKeyedGeneric)                        \
108   V(LoadNamedField)                          \
109   V(LoadNamedGeneric)                        \
110   V(MapEnumLength)                           \
111   V(MathAbs)                                 \
112   V(MathClz32)                               \
113   V(MathExp)                                 \
114   V(MathFloor)                               \
115   V(MathFround)                              \
116   V(MathLog)                                 \
117   V(MathMinMax)                              \
118   V(MathPowHalf)                             \
119   V(MathRound)                               \
120   V(MathSqrt)                                \
121   V(MaybeGrowElements)                       \
122   V(ModByConstI)                             \
123   V(ModByPowerOf2I)                          \
124   V(ModI)                                    \
125   V(MulI)                                    \
126   V(MultiplyAddD)                            \
127   V(MultiplySubD)                            \
128   V(NumberTagD)                              \
129   V(NumberTagI)                              \
130   V(NumberTagU)                              \
131   V(NumberUntagD)                            \
132   V(OsrEntry)                                \
133   V(Parameter)                               \
134   V(Power)                                   \
135   V(PushArgument)                            \
136   V(RegExpLiteral)                           \
137   V(Return)                                  \
138   V(SeqStringGetChar)                        \
139   V(SeqStringSetChar)                        \
140   V(ShiftI)                                  \
141   V(SmiTag)                                  \
142   V(SmiUntag)                                \
143   V(StackCheck)                              \
144   V(StoreCodeEntry)                          \
145   V(StoreContextSlot)                        \
146   V(StoreFrameContext)                       \
147   V(StoreGlobalViaContext)                   \
148   V(StoreKeyed)                              \
149   V(StoreKeyedGeneric)                       \
150   V(StoreNamedField)                         \
151   V(StoreNamedGeneric)                       \
152   V(StringAdd)                               \
153   V(StringCharCodeAt)                        \
154   V(StringCharFromCode)                      \
155   V(StringCompareAndBranch)                  \
156   V(SubI)                                    \
157   V(RSubI)                                   \
158   V(TaggedToI)                               \
159   V(ThisFunction)                            \
160   V(ToFastProperties)                        \
161   V(TransitionElementsKind)                  \
162   V(TrapAllocationMemento)                   \
163   V(Typeof)                                  \
164   V(TypeofIsAndBranch)                       \
165   V(Uint32ToDouble)                          \
166   V(UnknownOSRValue)                         \
167   V(WrapReceiver)
168
169
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)            \
171   Opcode opcode() const final { return LInstruction::k##type; } \
172   void CompileToNative(LCodeGen* generator) final;              \
173   const char* Mnemonic() const final { return mnemonic; }       \
174   static L##type* cast(LInstruction* instr) {                   \
175     DCHECK(instr->Is##type());                                  \
176     return reinterpret_cast<L##type*>(instr);                   \
177   }
178
179
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181   H##type* hydrogen() const { return H##type::cast(hydrogen_value()); }
182
183
184 class LInstruction : public ZoneObject {
185  public:
186   LInstruction()
187       : environment_(NULL),
188         hydrogen_value_(NULL),
189         bit_field_(IsCallBits::encode(false)) {}
190
191   virtual ~LInstruction() {}
192
193   virtual void CompileToNative(LCodeGen* generator) = 0;
194   virtual const char* Mnemonic() const = 0;
195   virtual void PrintTo(StringStream* stream);
196   virtual void PrintDataTo(StringStream* stream);
197   virtual void PrintOutputOperandTo(StringStream* stream);
198
199   enum Opcode {
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202     LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kNumberOfInstructions
203 #undef DECLARE_OPCODE
204   };
205
206   virtual Opcode opcode() const = 0;
207
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210   bool Is##type() const { return opcode() == k##type; }
211   LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
213
214   // Declare virtual predicates for instructions that don't have
215   // an opcode.
216   virtual bool IsGap() const { return false; }
217
218   virtual bool IsControl() const { return false; }
219
220   // Try deleting this instruction if possible.
221   virtual bool TryDelete() { return false; }
222
223   void set_environment(LEnvironment* env) { environment_ = env; }
224   LEnvironment* environment() const { return environment_; }
225   bool HasEnvironment() const { return environment_ != NULL; }
226
227   void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228   LPointerMap* pointer_map() const { return pointer_map_.get(); }
229   bool HasPointerMap() const { return pointer_map_.is_set(); }
230
231   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232   HValue* hydrogen_value() const { return hydrogen_value_; }
233
234   virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {}
235
236   void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
237   bool IsCall() const { return IsCallBits::decode(bit_field_); }
238
239   // Interface to the register allocator and iterators.
240   bool ClobbersTemps() const { return IsCall(); }
241   bool ClobbersRegisters() const { return IsCall(); }
242   virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243     return IsCall();
244   }
245
246   // Interface to the register allocator and iterators.
247   bool IsMarkedAsCall() const { return IsCall(); }
248
249   virtual bool HasResult() const = 0;
250   virtual LOperand* result() const = 0;
251
252   LOperand* FirstInput() { return InputAt(0); }
253   LOperand* Output() { return HasResult() ? result() : NULL; }
254
255   virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256
257 #ifdef DEBUG
258   void VerifyCall();
259 #endif
260
261   virtual int InputCount() = 0;
262   virtual LOperand* InputAt(int i) = 0;
263
264  private:
265   // Iterator support.
266   friend class InputIterator;
267
268   friend class TempIterator;
269   virtual int TempCount() = 0;
270   virtual LOperand* TempAt(int i) = 0;
271
272   class IsCallBits : public BitField<bool, 0, 1> {};
273
274   LEnvironment* environment_;
275   SetOncePointer<LPointerMap> pointer_map_;
276   HValue* hydrogen_value_;
277   int bit_field_;
278 };
279
280
281 // R = number of result operands (0 or 1).
282 template <int R>
283 class LTemplateResultInstruction : public LInstruction {
284  public:
285   // Allow 0 or 1 output operands.
286   STATIC_ASSERT(R == 0 || R == 1);
287   bool HasResult() const final { return R != 0 && result() != NULL; }
288   void set_result(LOperand* operand) { results_[0] = operand; }
289   LOperand* result() const override { return results_[0]; }
290
291  protected:
292   EmbeddedContainer<LOperand*, R> results_;
293 };
294
295
296 // R = number of result operands (0 or 1).
297 // I = number of input operands.
298 // T = number of temporary operands.
299 template <int R, int I, int T>
300 class LTemplateInstruction : public LTemplateResultInstruction<R> {
301  protected:
302   EmbeddedContainer<LOperand*, I> inputs_;
303   EmbeddedContainer<LOperand*, T> temps_;
304
305  private:
306   // Iterator support.
307   int InputCount() final { return I; }
308   LOperand* InputAt(int i) final { return inputs_[i]; }
309
310   int TempCount() final { return T; }
311   LOperand* TempAt(int i) final { return temps_[i]; }
312 };
313
314
315 class LGap : public LTemplateInstruction<0, 0, 0> {
316  public:
317   explicit LGap(HBasicBlock* block) : block_(block) {
318     parallel_moves_[BEFORE] = NULL;
319     parallel_moves_[START] = NULL;
320     parallel_moves_[END] = NULL;
321     parallel_moves_[AFTER] = NULL;
322   }
323
324   // Can't use the DECLARE-macro here because of sub-classes.
325   bool IsGap() const override { return true; }
326   void PrintDataTo(StringStream* stream) override;
327   static LGap* cast(LInstruction* instr) {
328     DCHECK(instr->IsGap());
329     return reinterpret_cast<LGap*>(instr);
330   }
331
332   bool IsRedundant() const;
333
334   HBasicBlock* block() const { return block_; }
335
336   enum InnerPosition {
337     BEFORE,
338     START,
339     END,
340     AFTER,
341     FIRST_INNER_POSITION = BEFORE,
342     LAST_INNER_POSITION = AFTER
343   };
344
345   LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
346     if (parallel_moves_[pos] == NULL) {
347       parallel_moves_[pos] = new (zone) LParallelMove(zone);
348     }
349     return parallel_moves_[pos];
350   }
351
352   LParallelMove* GetParallelMove(InnerPosition pos) {
353     return parallel_moves_[pos];
354   }
355
356  private:
357   LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
358   HBasicBlock* block_;
359 };
360
361
362 class LInstructionGap final : public LGap {
363  public:
364   explicit LInstructionGap(HBasicBlock* block) : LGap(block) {}
365
366   bool HasInterestingComment(LCodeGen* gen) const override {
367     return !IsRedundant();
368   }
369
370   DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
371 };
372
373
374 class LGoto final : public LTemplateInstruction<0, 0, 0> {
375  public:
376   explicit LGoto(HBasicBlock* block) : block_(block) {}
377
378   bool HasInterestingComment(LCodeGen* gen) const override;
379   DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
380   void PrintDataTo(StringStream* stream) override;
381   bool IsControl() const override { return true; }
382
383   int block_id() const { return block_->block_id(); }
384
385  private:
386   HBasicBlock* block_;
387 };
388
389
390 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
391  public:
392   LLazyBailout() : gap_instructions_size_(0) {}
393
394   DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
395
396   void set_gap_instructions_size(int gap_instructions_size) {
397     gap_instructions_size_ = gap_instructions_size;
398   }
399   int gap_instructions_size() { return gap_instructions_size_; }
400
401  private:
402   int gap_instructions_size_;
403 };
404
405
406 class LDummy final : public LTemplateInstruction<1, 0, 0> {
407  public:
408   LDummy() {}
409   DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
410 };
411
412
413 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
414  public:
415   explicit LDummyUse(LOperand* value) { inputs_[0] = value; }
416   DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
417 };
418
419
420 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
421  public:
422   bool IsControl() const override { return true; }
423   DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
424   DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
425 };
426
427
428 class LLabel final : public LGap {
429  public:
430   explicit LLabel(HBasicBlock* block) : LGap(block), replacement_(NULL) {}
431
432   bool HasInterestingComment(LCodeGen* gen) const override { return false; }
433   DECLARE_CONCRETE_INSTRUCTION(Label, "label")
434
435   void PrintDataTo(StringStream* stream) override;
436
437   int block_id() const { return block()->block_id(); }
438   bool is_loop_header() const { return block()->IsLoopHeader(); }
439   bool is_osr_entry() const { return block()->is_osr_entry(); }
440   Label* label() { return &label_; }
441   LLabel* replacement() const { return replacement_; }
442   void set_replacement(LLabel* label) { replacement_ = label; }
443   bool HasReplacement() const { return replacement_ != NULL; }
444
445  private:
446   Label label_;
447   LLabel* replacement_;
448 };
449
450
451 class LParameter final : public LTemplateInstruction<1, 0, 0> {
452  public:
453   virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
454   DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
455 };
456
457
458 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
459  public:
460   explicit LCallStub(LOperand* context) { inputs_[0] = context; }
461
462   LOperand* context() { return inputs_[0]; }
463
464   DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
465   DECLARE_HYDROGEN_ACCESSOR(CallStub)
466 };
467
468
469 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
470  public:
471   bool HasInterestingComment(LCodeGen* gen) const override { return false; }
472   DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
473 };
474
475
476 template <int I, int T>
477 class LControlInstruction : public LTemplateInstruction<0, I, T> {
478  public:
479   LControlInstruction() : false_label_(NULL), true_label_(NULL) {}
480
481   bool IsControl() const final { return true; }
482
483   int SuccessorCount() { return hydrogen()->SuccessorCount(); }
484   HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
485
486   int TrueDestination(LChunk* chunk) {
487     return chunk->LookupDestination(true_block_id());
488   }
489   int FalseDestination(LChunk* chunk) {
490     return chunk->LookupDestination(false_block_id());
491   }
492
493   Label* TrueLabel(LChunk* chunk) {
494     if (true_label_ == NULL) {
495       true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
496     }
497     return true_label_;
498   }
499   Label* FalseLabel(LChunk* chunk) {
500     if (false_label_ == NULL) {
501       false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
502     }
503     return false_label_;
504   }
505
506  protected:
507   int true_block_id() { return SuccessorAt(0)->block_id(); }
508   int false_block_id() { return SuccessorAt(1)->block_id(); }
509
510  private:
511   HControlInstruction* hydrogen() {
512     return HControlInstruction::cast(this->hydrogen_value());
513   }
514
515   Label* false_label_;
516   Label* true_label_;
517 };
518
519
520 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
521  public:
522   LWrapReceiver(LOperand* receiver, LOperand* function) {
523     inputs_[0] = receiver;
524     inputs_[1] = function;
525   }
526
527   DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
528   DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
529
530   LOperand* receiver() { return inputs_[0]; }
531   LOperand* function() { return inputs_[1]; }
532 };
533
534
535 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
536  public:
537   LApplyArguments(LOperand* function, LOperand* receiver, LOperand* length,
538                   LOperand* elements) {
539     inputs_[0] = function;
540     inputs_[1] = receiver;
541     inputs_[2] = length;
542     inputs_[3] = elements;
543   }
544
545   DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
546
547   LOperand* function() { return inputs_[0]; }
548   LOperand* receiver() { return inputs_[1]; }
549   LOperand* length() { return inputs_[2]; }
550   LOperand* elements() { return inputs_[3]; }
551 };
552
553
554 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
555  public:
556   LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
557     inputs_[0] = arguments;
558     inputs_[1] = length;
559     inputs_[2] = index;
560   }
561
562   DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
563
564   LOperand* arguments() { return inputs_[0]; }
565   LOperand* length() { return inputs_[1]; }
566   LOperand* index() { return inputs_[2]; }
567
568   void PrintDataTo(StringStream* stream) override;
569 };
570
571
572 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
573  public:
574   explicit LArgumentsLength(LOperand* elements) { inputs_[0] = elements; }
575
576   LOperand* elements() { return inputs_[0]; }
577
578   DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
579 };
580
581
582 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
583  public:
584   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
585   DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
586 };
587
588
589 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
590  public:
591   LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
592     inputs_[0] = dividend;
593     divisor_ = divisor;
594   }
595
596   LOperand* dividend() { return inputs_[0]; }
597   int32_t divisor() const { return divisor_; }
598
599   DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
600   DECLARE_HYDROGEN_ACCESSOR(Mod)
601
602  private:
603   int32_t divisor_;
604 };
605
606
607 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
608  public:
609   LModByConstI(LOperand* dividend, int32_t divisor) {
610     inputs_[0] = dividend;
611     divisor_ = divisor;
612   }
613
614   LOperand* dividend() { return inputs_[0]; }
615   int32_t divisor() const { return divisor_; }
616
617   DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
618   DECLARE_HYDROGEN_ACCESSOR(Mod)
619
620  private:
621   int32_t divisor_;
622 };
623
624
625 class LModI final : public LTemplateInstruction<1, 2, 0> {
626  public:
627   LModI(LOperand* left, LOperand* right) {
628     inputs_[0] = left;
629     inputs_[1] = right;
630   }
631
632   LOperand* left() { return inputs_[0]; }
633   LOperand* right() { return inputs_[1]; }
634
635   DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
636   DECLARE_HYDROGEN_ACCESSOR(Mod)
637 };
638
639
640 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
641  public:
642   LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
643     inputs_[0] = dividend;
644     divisor_ = divisor;
645   }
646
647   LOperand* dividend() { return inputs_[0]; }
648   int32_t divisor() const { return divisor_; }
649
650   DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
651   DECLARE_HYDROGEN_ACCESSOR(Div)
652
653  private:
654   int32_t divisor_;
655 };
656
657
658 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
659  public:
660   LDivByConstI(LOperand* dividend, int32_t divisor) {
661     inputs_[0] = dividend;
662     divisor_ = divisor;
663   }
664
665   LOperand* dividend() { return inputs_[0]; }
666   int32_t divisor() const { return divisor_; }
667
668   DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
669   DECLARE_HYDROGEN_ACCESSOR(Div)
670
671  private:
672   int32_t divisor_;
673 };
674
675
676 class LDivI final : public LTemplateInstruction<1, 2, 0> {
677  public:
678   LDivI(LOperand* dividend, LOperand* divisor) {
679     inputs_[0] = dividend;
680     inputs_[1] = divisor;
681   }
682
683   LOperand* dividend() { return inputs_[0]; }
684   LOperand* divisor() { return inputs_[1]; }
685
686   DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
687   DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
688 };
689
690
691 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
692  public:
693   LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
694     inputs_[0] = dividend;
695     divisor_ = divisor;
696   }
697
698   LOperand* dividend() { return inputs_[0]; }
699   int32_t divisor() { return divisor_; }
700
701   DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
702                                "flooring-div-by-power-of-2-i")
703   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
704
705  private:
706   int32_t divisor_;
707 };
708
709
710 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 1> {
711  public:
712   LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
713     inputs_[0] = dividend;
714     divisor_ = divisor;
715     temps_[0] = temp;
716   }
717
718   LOperand* dividend() { return inputs_[0]; }
719   int32_t divisor() const { return divisor_; }
720   LOperand* temp() { return temps_[0]; }
721
722   DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
723   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
724
725  private:
726   int32_t divisor_;
727 };
728
729
730 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
731  public:
732   LFlooringDivI(LOperand* dividend, LOperand* divisor) {
733     inputs_[0] = dividend;
734     inputs_[1] = divisor;
735   }
736
737   LOperand* dividend() { return inputs_[0]; }
738   LOperand* divisor() { return inputs_[1]; }
739
740   DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
741   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
742 };
743
744
745 class LMulI final : public LTemplateInstruction<1, 2, 0> {
746  public:
747   LMulI(LOperand* left, LOperand* right) {
748     inputs_[0] = left;
749     inputs_[1] = right;
750   }
751
752   LOperand* left() { return inputs_[0]; }
753   LOperand* right() { return inputs_[1]; }
754
755   DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
756   DECLARE_HYDROGEN_ACCESSOR(Mul)
757 };
758
759
760 // Instruction for computing multiplier * multiplicand + addend.
761 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
762  public:
763   LMultiplyAddD(LOperand* addend, LOperand* multiplier,
764                 LOperand* multiplicand) {
765     inputs_[0] = addend;
766     inputs_[1] = multiplier;
767     inputs_[2] = multiplicand;
768   }
769
770   LOperand* addend() { return inputs_[0]; }
771   LOperand* multiplier() { return inputs_[1]; }
772   LOperand* multiplicand() { return inputs_[2]; }
773
774   DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
775 };
776
777
778 // Instruction for computing minuend - multiplier * multiplicand.
779 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
780  public:
781   LMultiplySubD(LOperand* minuend, LOperand* multiplier,
782                 LOperand* multiplicand) {
783     inputs_[0] = minuend;
784     inputs_[1] = multiplier;
785     inputs_[2] = multiplicand;
786   }
787
788   LOperand* minuend() { return inputs_[0]; }
789   LOperand* multiplier() { return inputs_[1]; }
790   LOperand* multiplicand() { return inputs_[2]; }
791
792   DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
793 };
794
795
796 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
797  public:
798   DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
799 };
800
801
802 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
803  public:
804   LCompareNumericAndBranch(LOperand* left, LOperand* right) {
805     inputs_[0] = left;
806     inputs_[1] = right;
807   }
808
809   LOperand* left() { return inputs_[0]; }
810   LOperand* right() { return inputs_[1]; }
811
812   DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
813                                "compare-numeric-and-branch")
814   DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
815
816   Token::Value op() const { return hydrogen()->token(); }
817   bool is_double() const { return hydrogen()->representation().IsDouble(); }
818
819   void PrintDataTo(StringStream* stream) override;
820 };
821
822
823 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
824  public:
825   explicit LMathFloor(LOperand* value) { inputs_[0] = value; }
826
827   LOperand* value() { return inputs_[0]; }
828
829   DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
830   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
831 };
832
833
834 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
835  public:
836   LMathRound(LOperand* value, LOperand* temp) {
837     inputs_[0] = value;
838     temps_[0] = temp;
839   }
840
841   LOperand* value() { return inputs_[0]; }
842   LOperand* temp() { return temps_[0]; }
843
844   DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
845   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
846 };
847
848
849 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
850  public:
851   explicit LMathFround(LOperand* value) { inputs_[0] = value; }
852
853   LOperand* value() { return inputs_[0]; }
854
855   DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
856 };
857
858
859 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
860  public:
861   LMathAbs(LOperand* context, LOperand* value) {
862     inputs_[1] = context;
863     inputs_[0] = value;
864   }
865
866   LOperand* context() { return inputs_[1]; }
867   LOperand* value() { return inputs_[0]; }
868
869   DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
870   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
871 };
872
873
874 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
875  public:
876   explicit LMathLog(LOperand* value) { inputs_[0] = value; }
877
878   LOperand* value() { return inputs_[0]; }
879
880   DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
881 };
882
883
884 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
885  public:
886   explicit LMathClz32(LOperand* value) { inputs_[0] = value; }
887
888   LOperand* value() { return inputs_[0]; }
889
890   DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
891 };
892
893
894 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
895  public:
896   LMathExp(LOperand* value, LOperand* double_temp, LOperand* temp1,
897            LOperand* temp2) {
898     inputs_[0] = value;
899     temps_[0] = temp1;
900     temps_[1] = temp2;
901     temps_[2] = double_temp;
902     ExternalReference::InitializeMathExpData();
903   }
904
905   LOperand* value() { return inputs_[0]; }
906   LOperand* temp1() { return temps_[0]; }
907   LOperand* temp2() { return temps_[1]; }
908   LOperand* double_temp() { return temps_[2]; }
909
910   DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
911 };
912
913
914 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
915  public:
916   explicit LMathSqrt(LOperand* value) { inputs_[0] = value; }
917
918   LOperand* value() { return inputs_[0]; }
919
920   DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
921 };
922
923
924 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
925  public:
926   explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
927
928   LOperand* value() { return inputs_[0]; }
929
930   DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
931 };
932
933
934 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
935  public:
936   LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
937     inputs_[0] = left;
938     inputs_[1] = right;
939   }
940
941   LOperand* left() { return inputs_[0]; }
942   LOperand* right() { return inputs_[1]; }
943
944   DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
945   DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
946 };
947
948
949 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
950  public:
951   explicit LCmpHoleAndBranch(LOperand* object) { inputs_[0] = object; }
952
953   LOperand* object() { return inputs_[0]; }
954
955   DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
956   DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
957 };
958
959
960 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
961  public:
962   LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
963     inputs_[0] = value;
964     temps_[0] = temp;
965   }
966
967   LOperand* value() { return inputs_[0]; }
968   LOperand* temp() { return temps_[0]; }
969
970   DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
971                                "cmp-minus-zero-and-branch")
972   DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
973 };
974
975
976 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
977  public:
978   LIsObjectAndBranch(LOperand* value, LOperand* temp) {
979     inputs_[0] = value;
980     temps_[0] = temp;
981   }
982
983   LOperand* value() { return inputs_[0]; }
984   LOperand* temp() { return temps_[0]; }
985
986   DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
987   DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
988
989   void PrintDataTo(StringStream* stream) override;
990 };
991
992
993 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
994  public:
995   LIsStringAndBranch(LOperand* value, LOperand* temp) {
996     inputs_[0] = value;
997     temps_[0] = temp;
998   }
999
1000   LOperand* value() { return inputs_[0]; }
1001   LOperand* temp() { return temps_[0]; }
1002
1003   DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1004   DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1005
1006   void PrintDataTo(StringStream* stream) override;
1007 };
1008
1009
1010 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1011  public:
1012   explicit LIsSmiAndBranch(LOperand* value) { inputs_[0] = value; }
1013
1014   LOperand* value() { return inputs_[0]; }
1015
1016   DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1017   DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1018
1019   void PrintDataTo(StringStream* stream) override;
1020 };
1021
1022
1023 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1024  public:
1025   explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1026     inputs_[0] = value;
1027     temps_[0] = temp;
1028   }
1029
1030   LOperand* value() { return inputs_[0]; }
1031   LOperand* temp() { return temps_[0]; }
1032
1033   DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1034                                "is-undetectable-and-branch")
1035   DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1036
1037   void PrintDataTo(StringStream* stream) override;
1038 };
1039
1040
1041 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1042  public:
1043   LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1044     inputs_[0] = context;
1045     inputs_[1] = left;
1046     inputs_[2] = right;
1047   }
1048
1049   LOperand* context() { return inputs_[0]; }
1050   LOperand* left() { return inputs_[1]; }
1051   LOperand* right() { return inputs_[2]; }
1052
1053   DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1054                                "string-compare-and-branch")
1055   DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1056
1057   Token::Value op() const { return hydrogen()->token(); }
1058
1059   void PrintDataTo(StringStream* stream) override;
1060 };
1061
1062
1063 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1064  public:
1065   explicit LHasInstanceTypeAndBranch(LOperand* value) { inputs_[0] = value; }
1066
1067   LOperand* value() { return inputs_[0]; }
1068
1069   DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1070                                "has-instance-type-and-branch")
1071   DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1072
1073   void PrintDataTo(StringStream* stream) override;
1074 };
1075
1076
1077 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1078  public:
1079   explicit LGetCachedArrayIndex(LOperand* value) { inputs_[0] = value; }
1080
1081   LOperand* value() { return inputs_[0]; }
1082
1083   DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1084   DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1085 };
1086
1087
1088 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1089  public:
1090   explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1091     inputs_[0] = value;
1092   }
1093
1094   LOperand* value() { return inputs_[0]; }
1095
1096   DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1097                                "has-cached-array-index-and-branch")
1098   DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1099
1100   void PrintDataTo(StringStream* stream) override;
1101 };
1102
1103
1104 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1105  public:
1106   LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1107     inputs_[0] = value;
1108     temps_[0] = temp;
1109   }
1110
1111   LOperand* value() { return inputs_[0]; }
1112   LOperand* temp() { return temps_[0]; }
1113
1114   DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, "class-of-test-and-branch")
1115   DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1116
1117   void PrintDataTo(StringStream* stream) override;
1118 };
1119
1120
1121 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1122  public:
1123   LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1124     inputs_[0] = context;
1125     inputs_[1] = left;
1126     inputs_[2] = right;
1127   }
1128
1129   LOperand* context() { return inputs_[0]; }
1130   LOperand* left() { return inputs_[1]; }
1131   LOperand* right() { return inputs_[2]; }
1132
1133   DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1134   DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1135
1136   Strength strength() { return hydrogen()->strength(); }
1137
1138   Token::Value op() const { return hydrogen()->token(); }
1139 };
1140
1141
1142 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1143  public:
1144   LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1145     inputs_[0] = context;
1146     inputs_[1] = left;
1147     inputs_[2] = right;
1148   }
1149
1150   LOperand* context() { return inputs_[0]; }
1151   LOperand* left() { return inputs_[1]; }
1152   LOperand* right() { return inputs_[2]; }
1153
1154   DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1155 };
1156
1157
1158 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1159  public:
1160   LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1161     inputs_[0] = context;
1162     inputs_[1] = value;
1163     temps_[0] = temp;
1164   }
1165
1166   LOperand* context() { return inputs_[0]; }
1167   LOperand* value() { return inputs_[1]; }
1168   LOperand* temp() { return temps_[0]; }
1169
1170   DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1171                                "instance-of-known-global")
1172   DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1173
1174   Handle<JSFunction> function() const { return hydrogen()->function(); }
1175   LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1176     return lazy_deopt_env_;
1177   }
1178   virtual void SetDeferredLazyDeoptimizationEnvironment(
1179       LEnvironment* env) override {
1180     lazy_deopt_env_ = env;
1181   }
1182
1183  private:
1184   LEnvironment* lazy_deopt_env_;
1185 };
1186
1187
1188 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1189  public:
1190   LBoundsCheck(LOperand* index, LOperand* length) {
1191     inputs_[0] = index;
1192     inputs_[1] = length;
1193   }
1194
1195   LOperand* index() { return inputs_[0]; }
1196   LOperand* length() { return inputs_[1]; }
1197
1198   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1199   DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1200 };
1201
1202
1203 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1204  public:
1205   LBitI(LOperand* left, LOperand* right) {
1206     inputs_[0] = left;
1207     inputs_[1] = right;
1208   }
1209
1210   LOperand* left() { return inputs_[0]; }
1211   LOperand* right() { return inputs_[1]; }
1212
1213   Token::Value op() const { return hydrogen()->op(); }
1214
1215   DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1216   DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1217 };
1218
1219
1220 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1221  public:
1222   LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1223       : op_(op), can_deopt_(can_deopt) {
1224     inputs_[0] = left;
1225     inputs_[1] = right;
1226   }
1227
1228   Token::Value op() const { return op_; }
1229   LOperand* left() { return inputs_[0]; }
1230   LOperand* right() { return inputs_[1]; }
1231   bool can_deopt() const { return can_deopt_; }
1232
1233   DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1234
1235  private:
1236   Token::Value op_;
1237   bool can_deopt_;
1238 };
1239
1240
1241 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1242  public:
1243   LSubI(LOperand* left, LOperand* right) {
1244     inputs_[0] = left;
1245     inputs_[1] = right;
1246   }
1247
1248   LOperand* left() { return inputs_[0]; }
1249   LOperand* right() { return inputs_[1]; }
1250
1251   DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1252   DECLARE_HYDROGEN_ACCESSOR(Sub)
1253 };
1254
1255
1256 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1257  public:
1258   LRSubI(LOperand* left, LOperand* right) {
1259     inputs_[0] = left;
1260     inputs_[1] = right;
1261   }
1262
1263   LOperand* left() { return inputs_[0]; }
1264   LOperand* right() { return inputs_[1]; }
1265
1266   DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1267   DECLARE_HYDROGEN_ACCESSOR(Sub)
1268 };
1269
1270
1271 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1272  public:
1273   DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1274   DECLARE_HYDROGEN_ACCESSOR(Constant)
1275
1276   int32_t value() const { return hydrogen()->Integer32Value(); }
1277 };
1278
1279
1280 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1281  public:
1282   DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1283   DECLARE_HYDROGEN_ACCESSOR(Constant)
1284
1285   Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1286 };
1287
1288
1289 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1290  public:
1291   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1292   DECLARE_HYDROGEN_ACCESSOR(Constant)
1293
1294   double value() const { return hydrogen()->DoubleValue(); }
1295   uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1296 };
1297
1298
1299 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1300  public:
1301   DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1302   DECLARE_HYDROGEN_ACCESSOR(Constant)
1303
1304   ExternalReference value() const {
1305     return hydrogen()->ExternalReferenceValue();
1306   }
1307 };
1308
1309
1310 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1311  public:
1312   DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1313   DECLARE_HYDROGEN_ACCESSOR(Constant)
1314
1315   Handle<Object> value(Isolate* isolate) const {
1316     return hydrogen()->handle(isolate);
1317   }
1318 };
1319
1320
1321 class LBranch final : public LControlInstruction<1, 0> {
1322  public:
1323   explicit LBranch(LOperand* value) { inputs_[0] = value; }
1324
1325   LOperand* value() { return inputs_[0]; }
1326
1327   DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1328   DECLARE_HYDROGEN_ACCESSOR(Branch)
1329
1330   void PrintDataTo(StringStream* stream) override;
1331 };
1332
1333
1334 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1335  public:
1336   LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1337     inputs_[0] = value;
1338     temps_[0] = temp;
1339   }
1340
1341   LOperand* value() { return inputs_[0]; }
1342   LOperand* temp() { return temps_[0]; }
1343
1344   DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1345   DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1346
1347   Handle<Map> map() const { return hydrogen()->map().handle(); }
1348 };
1349
1350
1351 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1352  public:
1353   explicit LMapEnumLength(LOperand* value) { inputs_[0] = value; }
1354
1355   LOperand* value() { return inputs_[0]; }
1356
1357   DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1358 };
1359
1360
1361 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1362  public:
1363   LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1364     inputs_[0] = date;
1365     temps_[0] = temp;
1366   }
1367
1368   LOperand* date() { return inputs_[0]; }
1369   LOperand* temp() { return temps_[0]; }
1370   Smi* index() const { return index_; }
1371
1372   DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1373   DECLARE_HYDROGEN_ACCESSOR(DateField)
1374
1375  private:
1376   Smi* index_;
1377 };
1378
1379
1380 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1381  public:
1382   LSeqStringGetChar(LOperand* string, LOperand* index) {
1383     inputs_[0] = string;
1384     inputs_[1] = index;
1385   }
1386
1387   LOperand* string() const { return inputs_[0]; }
1388   LOperand* index() const { return inputs_[1]; }
1389
1390   DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1391   DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1392 };
1393
1394
1395 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1396  public:
1397   LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1398                     LOperand* value) {
1399     inputs_[0] = context;
1400     inputs_[1] = string;
1401     inputs_[2] = index;
1402     inputs_[3] = value;
1403   }
1404
1405   LOperand* string() { return inputs_[1]; }
1406   LOperand* index() { return inputs_[2]; }
1407   LOperand* value() { return inputs_[3]; }
1408
1409   DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1410   DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1411 };
1412
1413
1414 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1415  public:
1416   LAddI(LOperand* left, LOperand* right) {
1417     inputs_[0] = left;
1418     inputs_[1] = right;
1419   }
1420
1421   LOperand* left() { return inputs_[0]; }
1422   LOperand* right() { return inputs_[1]; }
1423
1424   DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1425   DECLARE_HYDROGEN_ACCESSOR(Add)
1426 };
1427
1428
1429 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1430  public:
1431   LMathMinMax(LOperand* left, LOperand* right) {
1432     inputs_[0] = left;
1433     inputs_[1] = right;
1434   }
1435
1436   LOperand* left() { return inputs_[0]; }
1437   LOperand* right() { return inputs_[1]; }
1438
1439   DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1440   DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1441 };
1442
1443
1444 class LPower final : public LTemplateInstruction<1, 2, 0> {
1445  public:
1446   LPower(LOperand* left, LOperand* right) {
1447     inputs_[0] = left;
1448     inputs_[1] = right;
1449   }
1450
1451   LOperand* left() { return inputs_[0]; }
1452   LOperand* right() { return inputs_[1]; }
1453
1454   DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1455   DECLARE_HYDROGEN_ACCESSOR(Power)
1456 };
1457
1458
1459 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1460  public:
1461   LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1462     inputs_[0] = left;
1463     inputs_[1] = right;
1464   }
1465
1466   Token::Value op() const { return op_; }
1467   LOperand* left() { return inputs_[0]; }
1468   LOperand* right() { return inputs_[1]; }
1469
1470   Opcode opcode() const override { return LInstruction::kArithmeticD; }
1471   void CompileToNative(LCodeGen* generator) override;
1472   const char* Mnemonic() const override;
1473
1474  private:
1475   Token::Value op_;
1476 };
1477
1478
1479 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1480  public:
1481   LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1482                LOperand* right)
1483       : op_(op) {
1484     inputs_[0] = context;
1485     inputs_[1] = left;
1486     inputs_[2] = right;
1487   }
1488
1489   LOperand* context() { return inputs_[0]; }
1490   LOperand* left() { return inputs_[1]; }
1491   LOperand* right() { return inputs_[2]; }
1492   Token::Value op() const { return op_; }
1493
1494   Opcode opcode() const override { return LInstruction::kArithmeticT; }
1495   void CompileToNative(LCodeGen* generator) override;
1496   const char* Mnemonic() const override;
1497
1498   DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1499
1500   Strength strength() { return hydrogen()->strength(); }
1501
1502  private:
1503   Token::Value op_;
1504 };
1505
1506
1507 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1508  public:
1509   LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1510     inputs_[0] = value;
1511     inputs_[1] = context;
1512     inputs_[2] = parameter_count;
1513   }
1514
1515   LOperand* value() { return inputs_[0]; }
1516
1517   bool has_constant_parameter_count() {
1518     return parameter_count()->IsConstantOperand();
1519   }
1520   LConstantOperand* constant_parameter_count() {
1521     DCHECK(has_constant_parameter_count());
1522     return LConstantOperand::cast(parameter_count());
1523   }
1524   LOperand* parameter_count() { return inputs_[2]; }
1525
1526   DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1527 };
1528
1529
1530 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1531  public:
1532   explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1533
1534   LOperand* object() { return inputs_[0]; }
1535
1536   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1537   DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1538 };
1539
1540
1541 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1542  public:
1543   LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1544     inputs_[0] = context;
1545     inputs_[1] = object;
1546     temps_[0] = vector;
1547   }
1548
1549   LOperand* context() { return inputs_[0]; }
1550   LOperand* object() { return inputs_[1]; }
1551   LOperand* temp_vector() { return temps_[0]; }
1552
1553   DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1554   DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1555
1556   Handle<Object> name() const { return hydrogen()->name(); }
1557 };
1558
1559
1560 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1561  public:
1562   explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1563
1564   LOperand* function() { return inputs_[0]; }
1565
1566   DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1567   DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1568 };
1569
1570
1571 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1572  public:
1573   DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1574   DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1575
1576   Heap::RootListIndex index() const { return hydrogen()->index(); }
1577 };
1578
1579
1580 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1581  public:
1582   LLoadKeyed(LOperand* elements, LOperand* key) {
1583     inputs_[0] = elements;
1584     inputs_[1] = key;
1585   }
1586
1587   LOperand* elements() { return inputs_[0]; }
1588   LOperand* key() { return inputs_[1]; }
1589   ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1590   bool is_external() const { return hydrogen()->is_external(); }
1591   bool is_fixed_typed_array() const {
1592     return hydrogen()->is_fixed_typed_array();
1593   }
1594   bool is_typed_elements() const {
1595     return is_external() || is_fixed_typed_array();
1596   }
1597
1598   DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1599   DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1600
1601   void PrintDataTo(StringStream* stream) override;
1602   uint32_t base_offset() const { return hydrogen()->base_offset(); }
1603 };
1604
1605
1606 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1607  public:
1608   LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1609                     LOperand* vector) {
1610     inputs_[0] = context;
1611     inputs_[1] = object;
1612     inputs_[2] = key;
1613     temps_[0] = vector;
1614   }
1615
1616   LOperand* context() { return inputs_[0]; }
1617   LOperand* object() { return inputs_[1]; }
1618   LOperand* key() { return inputs_[2]; }
1619   LOperand* temp_vector() { return temps_[0]; }
1620
1621   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1622   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1623 };
1624
1625
1626 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1627  public:
1628   LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1629                      LOperand* vector) {
1630     inputs_[0] = context;
1631     inputs_[1] = global_object;
1632     temps_[0] = vector;
1633   }
1634
1635   LOperand* context() { return inputs_[0]; }
1636   LOperand* global_object() { return inputs_[1]; }
1637   LOperand* temp_vector() { return temps_[0]; }
1638
1639   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1640   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1641
1642   Handle<Object> name() const { return hydrogen()->name(); }
1643   TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1644 };
1645
1646
1647 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1648  public:
1649   explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1650
1651   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1652   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1653
1654   void PrintDataTo(StringStream* stream) override;
1655
1656   LOperand* context() { return inputs_[0]; }
1657
1658   Handle<Object> name() const { return hydrogen()->name(); }
1659   int depth() const { return hydrogen()->depth(); }
1660   int slot_index() const { return hydrogen()->slot_index(); }
1661 };
1662
1663
1664 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1665  public:
1666   explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1667
1668   LOperand* context() { return inputs_[0]; }
1669
1670   DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1671   DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1672
1673   int slot_index() { return hydrogen()->slot_index(); }
1674
1675   void PrintDataTo(StringStream* stream) override;
1676 };
1677
1678
1679 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1680  public:
1681   LStoreContextSlot(LOperand* context, LOperand* value) {
1682     inputs_[0] = context;
1683     inputs_[1] = value;
1684   }
1685
1686   LOperand* context() { return inputs_[0]; }
1687   LOperand* value() { return inputs_[1]; }
1688
1689   DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1690   DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1691
1692   int slot_index() { return hydrogen()->slot_index(); }
1693
1694   void PrintDataTo(StringStream* stream) override;
1695 };
1696
1697
1698 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1699  public:
1700   explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1701
1702   LOperand* value() { return inputs_[0]; }
1703
1704   DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1705 };
1706
1707
1708 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1709  public:
1710   explicit LDrop(int count) : count_(count) {}
1711
1712   int count() const { return count_; }
1713
1714   DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1715
1716  private:
1717   int count_;
1718 };
1719
1720
1721 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1722  public:
1723   LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1724     inputs_[0] = function;
1725     inputs_[1] = code_object;
1726   }
1727
1728   LOperand* function() { return inputs_[0]; }
1729   LOperand* code_object() { return inputs_[1]; }
1730
1731   void PrintDataTo(StringStream* stream) override;
1732
1733   DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1734   DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1735 };
1736
1737
1738 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1739  public:
1740   LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1741     inputs_[0] = base_object;
1742     inputs_[1] = offset;
1743   }
1744
1745   LOperand* base_object() const { return inputs_[0]; }
1746   LOperand* offset() const { return inputs_[1]; }
1747
1748   void PrintDataTo(StringStream* stream) override;
1749
1750   DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1751 };
1752
1753
1754 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1755  public:
1756   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1757   DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1758 };
1759
1760
1761 class LContext final : public LTemplateInstruction<1, 0, 0> {
1762  public:
1763   DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1764   DECLARE_HYDROGEN_ACCESSOR(Context)
1765 };
1766
1767
1768 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1769  public:
1770   explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1771
1772   LOperand* context() { return inputs_[0]; }
1773
1774   DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1775   DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1776 };
1777
1778
1779 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1780  public:
1781   explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1782
1783   LOperand* function() { return inputs_[0]; }
1784
1785   DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1786   DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1787
1788   void PrintDataTo(StringStream* stream) override;
1789
1790   int arity() const { return hydrogen()->argument_count() - 1; }
1791 };
1792
1793
1794 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1795  public:
1796   LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1797                       const ZoneList<LOperand*>& operands, Zone* zone)
1798       : descriptor_(descriptor),
1799         inputs_(descriptor.GetRegisterParameterCount() +
1800                     kImplicitRegisterParameterCount,
1801                 zone) {
1802     DCHECK(descriptor.GetRegisterParameterCount() +
1803                kImplicitRegisterParameterCount ==
1804            operands.length());
1805     inputs_.AddAll(operands, zone);
1806   }
1807
1808   LOperand* target() const { return inputs_[0]; }
1809
1810   const CallInterfaceDescriptor descriptor() { return descriptor_; }
1811
1812   DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1813
1814   // The target and context are passed as implicit parameters that are not
1815   // explicitly listed in the descriptor.
1816   static const int kImplicitRegisterParameterCount = 2;
1817
1818  private:
1819   DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1820
1821   void PrintDataTo(StringStream* stream) override;
1822
1823   int arity() const { return hydrogen()->argument_count() - 1; }
1824
1825   CallInterfaceDescriptor descriptor_;
1826   ZoneList<LOperand*> inputs_;
1827
1828   // Iterator support.
1829   int InputCount() final { return inputs_.length(); }
1830   LOperand* InputAt(int i) final { return inputs_[i]; }
1831
1832   int TempCount() final { return 0; }
1833   LOperand* TempAt(int i) final { return NULL; }
1834 };
1835
1836
1837 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1838  public:
1839   LInvokeFunction(LOperand* context, LOperand* function) {
1840     inputs_[0] = context;
1841     inputs_[1] = function;
1842   }
1843
1844   LOperand* context() { return inputs_[0]; }
1845   LOperand* function() { return inputs_[1]; }
1846
1847   DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1848   DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1849
1850   void PrintDataTo(StringStream* stream) override;
1851
1852   int arity() const { return hydrogen()->argument_count() - 1; }
1853 };
1854
1855
1856 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1857  public:
1858   LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1859                 LOperand* vector) {
1860     inputs_[0] = context;
1861     inputs_[1] = function;
1862     temps_[0] = slot;
1863     temps_[1] = vector;
1864   }
1865
1866   LOperand* context() { return inputs_[0]; }
1867   LOperand* function() { return inputs_[1]; }
1868   LOperand* temp_slot() { return temps_[0]; }
1869   LOperand* temp_vector() { return temps_[1]; }
1870
1871   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1872   DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1873
1874   int arity() const { return hydrogen()->argument_count() - 1; }
1875   void PrintDataTo(StringStream* stream) override;
1876 };
1877
1878
1879 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1880  public:
1881   LCallNew(LOperand* context, LOperand* constructor) {
1882     inputs_[0] = context;
1883     inputs_[1] = constructor;
1884   }
1885
1886   LOperand* context() { return inputs_[0]; }
1887   LOperand* constructor() { return inputs_[1]; }
1888
1889   DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1890   DECLARE_HYDROGEN_ACCESSOR(CallNew)
1891
1892   void PrintDataTo(StringStream* stream) override;
1893
1894   int arity() const { return hydrogen()->argument_count() - 1; }
1895 };
1896
1897
1898 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1899  public:
1900   LCallNewArray(LOperand* context, LOperand* constructor) {
1901     inputs_[0] = context;
1902     inputs_[1] = constructor;
1903   }
1904
1905   LOperand* context() { return inputs_[0]; }
1906   LOperand* constructor() { return inputs_[1]; }
1907
1908   DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1909   DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1910
1911   void PrintDataTo(StringStream* stream) override;
1912
1913   int arity() const { return hydrogen()->argument_count() - 1; }
1914 };
1915
1916
1917 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1918  public:
1919   explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1920
1921   LOperand* context() { return inputs_[0]; }
1922
1923   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1924   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1925
1926   bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1927     return save_doubles() == kDontSaveFPRegs;
1928   }
1929
1930   const Runtime::Function* function() const { return hydrogen()->function(); }
1931   int arity() const { return hydrogen()->argument_count(); }
1932   SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1933 };
1934
1935
1936 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1937  public:
1938   explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1939
1940   LOperand* value() { return inputs_[0]; }
1941
1942   DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1943 };
1944
1945
1946 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1947  public:
1948   explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1949
1950   LOperand* value() { return inputs_[0]; }
1951
1952   DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1953 };
1954
1955
1956 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1957  public:
1958   LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1959     inputs_[0] = value;
1960     temps_[0] = temp1;
1961     temps_[1] = temp2;
1962   }
1963
1964   LOperand* value() { return inputs_[0]; }
1965   LOperand* temp1() { return temps_[0]; }
1966   LOperand* temp2() { return temps_[1]; }
1967
1968   DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1969 };
1970
1971
1972 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1973  public:
1974   LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1975     inputs_[0] = value;
1976     temps_[0] = temp1;
1977     temps_[1] = temp2;
1978   }
1979
1980   LOperand* value() { return inputs_[0]; }
1981   LOperand* temp1() { return temps_[0]; }
1982   LOperand* temp2() { return temps_[1]; }
1983
1984   DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1985 };
1986
1987
1988 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1989  public:
1990   LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1991     inputs_[0] = value;
1992     temps_[0] = temp;
1993     temps_[1] = temp2;
1994   }
1995
1996   LOperand* value() { return inputs_[0]; }
1997   LOperand* temp() { return temps_[0]; }
1998   LOperand* temp2() { return temps_[1]; }
1999
2000   DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2001   DECLARE_HYDROGEN_ACCESSOR(Change)
2002 };
2003
2004
2005 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2006  public:
2007   explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
2008
2009   LOperand* value() { return inputs_[0]; }
2010
2011   DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2012   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2013
2014   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2015 };
2016
2017
2018 // Sometimes truncating conversion from a tagged value to an int32.
2019 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2020  public:
2021   explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
2022
2023   LOperand* value() { return inputs_[0]; }
2024
2025   DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2026   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2027
2028   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2029 };
2030
2031
2032 // Truncating conversion from a tagged value to an int32.
2033 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2034  public:
2035   LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2036     inputs_[0] = value;
2037     temps_[0] = temp;
2038     temps_[1] = temp2;
2039   }
2040
2041   LOperand* value() { return inputs_[0]; }
2042   LOperand* temp() { return temps_[0]; }
2043   LOperand* temp2() { return temps_[1]; }
2044
2045   DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2046   DECLARE_HYDROGEN_ACCESSOR(Change)
2047
2048   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2049 };
2050
2051
2052 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2053  public:
2054   explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2055
2056   LOperand* value() { return inputs_[0]; }
2057
2058   DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2059   DECLARE_HYDROGEN_ACCESSOR(Change)
2060 };
2061
2062
2063 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2064  public:
2065   explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2066
2067   LOperand* value() { return inputs_[0]; }
2068
2069   DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2070   DECLARE_HYDROGEN_ACCESSOR(Change)
2071 };
2072
2073
2074 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2075  public:
2076   LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2077     inputs_[0] = value;
2078   }
2079
2080   LOperand* value() { return inputs_[0]; }
2081   bool needs_check() const { return needs_check_; }
2082
2083   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2084
2085  private:
2086   bool needs_check_;
2087 };
2088
2089
2090 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2091  public:
2092   LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2093     inputs_[0] = object;
2094     inputs_[1] = value;
2095     temps_[0] = temp;
2096   }
2097
2098   LOperand* object() { return inputs_[0]; }
2099   LOperand* value() { return inputs_[1]; }
2100   LOperand* temp() { return temps_[0]; }
2101
2102   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2103   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2104
2105   void PrintDataTo(StringStream* stream) override;
2106
2107   Representation representation() const {
2108     return hydrogen()->field_representation();
2109   }
2110 };
2111
2112
2113 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2114  public:
2115   LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2116                      LOperand* slot, LOperand* vector) {
2117     inputs_[0] = context;
2118     inputs_[1] = object;
2119     inputs_[2] = value;
2120     temps_[0] = slot;
2121     temps_[1] = vector;
2122   }
2123
2124   LOperand* context() { return inputs_[0]; }
2125   LOperand* object() { return inputs_[1]; }
2126   LOperand* value() { return inputs_[2]; }
2127   LOperand* temp_slot() { return temps_[0]; }
2128   LOperand* temp_vector() { return temps_[1]; }
2129
2130   DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2131   DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2132
2133   void PrintDataTo(StringStream* stream) override;
2134
2135   Handle<Object> name() const { return hydrogen()->name(); }
2136   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2137 };
2138
2139
2140 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2141  public:
2142   LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2143     inputs_[0] = context;
2144     inputs_[1] = value;
2145   }
2146
2147   LOperand* context() { return inputs_[0]; }
2148   LOperand* value() { return inputs_[1]; }
2149
2150   DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2151                                "store-global-via-context")
2152   DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2153
2154   void PrintDataTo(StringStream* stream) override;
2155
2156   Handle<Object> name() const { return hydrogen()->name(); }
2157   int depth() { return hydrogen()->depth(); }
2158   int slot_index() { return hydrogen()->slot_index(); }
2159   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2160 };
2161
2162
2163 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2164  public:
2165   LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2166     inputs_[0] = object;
2167     inputs_[1] = key;
2168     inputs_[2] = value;
2169   }
2170
2171   bool is_external() const { return hydrogen()->is_external(); }
2172   bool is_fixed_typed_array() const {
2173     return hydrogen()->is_fixed_typed_array();
2174   }
2175   bool is_typed_elements() const {
2176     return is_external() || is_fixed_typed_array();
2177   }
2178   LOperand* elements() { return inputs_[0]; }
2179   LOperand* key() { return inputs_[1]; }
2180   LOperand* value() { return inputs_[2]; }
2181   ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2182
2183   DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2184   DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2185
2186   void PrintDataTo(StringStream* stream) override;
2187   bool NeedsCanonicalization() {
2188     if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2189         hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2190       return false;
2191     }
2192     return hydrogen()->NeedsCanonicalization();
2193   }
2194   uint32_t base_offset() const { return hydrogen()->base_offset(); }
2195 };
2196
2197
2198 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2199  public:
2200   LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2201                      LOperand* value, LOperand* slot, LOperand* vector) {
2202     inputs_[0] = context;
2203     inputs_[1] = object;
2204     inputs_[2] = key;
2205     inputs_[3] = value;
2206     temps_[0] = slot;
2207     temps_[1] = vector;
2208   }
2209
2210   LOperand* context() { return inputs_[0]; }
2211   LOperand* object() { return inputs_[1]; }
2212   LOperand* key() { return inputs_[2]; }
2213   LOperand* value() { return inputs_[3]; }
2214   LOperand* temp_slot() { return temps_[0]; }
2215   LOperand* temp_vector() { return temps_[1]; }
2216
2217   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2218   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2219
2220   void PrintDataTo(StringStream* stream) override;
2221
2222   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2223 };
2224
2225
2226 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2227  public:
2228   LTransitionElementsKind(LOperand* object, LOperand* context,
2229                           LOperand* new_map_temp) {
2230     inputs_[0] = object;
2231     inputs_[1] = context;
2232     temps_[0] = new_map_temp;
2233   }
2234
2235   LOperand* context() { return inputs_[1]; }
2236   LOperand* object() { return inputs_[0]; }
2237   LOperand* new_map_temp() { return temps_[0]; }
2238
2239   DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2240                                "transition-elements-kind")
2241   DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2242
2243   void PrintDataTo(StringStream* stream) override;
2244
2245   Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2246   Handle<Map> transitioned_map() {
2247     return hydrogen()->transitioned_map().handle();
2248   }
2249   ElementsKind from_kind() { return hydrogen()->from_kind(); }
2250   ElementsKind to_kind() { return hydrogen()->to_kind(); }
2251 };
2252
2253
2254 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2255  public:
2256   LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2257     inputs_[0] = object;
2258     temps_[0] = temp;
2259   }
2260
2261   LOperand* object() { return inputs_[0]; }
2262   LOperand* temp() { return temps_[0]; }
2263
2264   DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2265 };
2266
2267
2268 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2269  public:
2270   LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2271                      LOperand* key, LOperand* current_capacity) {
2272     inputs_[0] = context;
2273     inputs_[1] = object;
2274     inputs_[2] = elements;
2275     inputs_[3] = key;
2276     inputs_[4] = current_capacity;
2277   }
2278
2279   LOperand* context() { return inputs_[0]; }
2280   LOperand* object() { return inputs_[1]; }
2281   LOperand* elements() { return inputs_[2]; }
2282   LOperand* key() { return inputs_[3]; }
2283   LOperand* current_capacity() { return inputs_[4]; }
2284
2285   DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2286   DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2287 };
2288
2289
2290 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2291  public:
2292   LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2293     inputs_[0] = context;
2294     inputs_[1] = left;
2295     inputs_[2] = right;
2296   }
2297
2298   LOperand* context() { return inputs_[0]; }
2299   LOperand* left() { return inputs_[1]; }
2300   LOperand* right() { return inputs_[2]; }
2301
2302   DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2303   DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2304 };
2305
2306
2307 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2308  public:
2309   LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2310     inputs_[0] = context;
2311     inputs_[1] = string;
2312     inputs_[2] = index;
2313   }
2314
2315   LOperand* context() { return inputs_[0]; }
2316   LOperand* string() { return inputs_[1]; }
2317   LOperand* index() { return inputs_[2]; }
2318
2319   DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2320   DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2321 };
2322
2323
2324 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2325  public:
2326   explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2327     inputs_[0] = context;
2328     inputs_[1] = char_code;
2329   }
2330
2331   LOperand* context() { return inputs_[0]; }
2332   LOperand* char_code() { return inputs_[1]; }
2333
2334   DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2335   DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2336 };
2337
2338
2339 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2340  public:
2341   explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2342
2343   LOperand* value() { return inputs_[0]; }
2344
2345   DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2346   DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2347 };
2348
2349
2350 class LCheckArrayBufferNotNeutered final
2351     : public LTemplateInstruction<0, 1, 0> {
2352  public:
2353   explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2354
2355   LOperand* view() { return inputs_[0]; }
2356
2357   DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2358                                "check-array-buffer-not-neutered")
2359   DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2360 };
2361
2362
2363 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2364  public:
2365   explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2366
2367   LOperand* value() { return inputs_[0]; }
2368
2369   DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2370   DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2371 };
2372
2373
2374 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2375  public:
2376   explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2377     inputs_[0] = value;
2378     temps_[0] = temp;
2379   }
2380
2381   LOperand* value() { return inputs_[0]; }
2382   LOperand* temp() { return temps_[0]; }
2383
2384   DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2385   DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2386 };
2387
2388
2389 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2390  public:
2391   explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2392
2393   LOperand* value() { return inputs_[0]; }
2394
2395   DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2396 };
2397
2398
2399 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2400  public:
2401   explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2402
2403   LOperand* value() { return inputs_[0]; }
2404
2405   DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2406   DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2407 };
2408
2409
2410 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2411  public:
2412   explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2413
2414   LOperand* unclamped() { return inputs_[0]; }
2415
2416   DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2417 };
2418
2419
2420 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2421  public:
2422   explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2423
2424   LOperand* unclamped() { return inputs_[0]; }
2425
2426   DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2427 };
2428
2429
2430 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2431  public:
2432   LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2433     inputs_[0] = unclamped;
2434     temps_[0] = temp;
2435   }
2436
2437   LOperand* unclamped() { return inputs_[0]; }
2438   LOperand* temp() { return temps_[0]; }
2439
2440   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2441 };
2442
2443
2444 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2445  public:
2446   explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2447
2448   LOperand* value() { return inputs_[0]; }
2449
2450   DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2451   DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2452 };
2453
2454
2455 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2456  public:
2457   LConstructDouble(LOperand* hi, LOperand* lo) {
2458     inputs_[0] = hi;
2459     inputs_[1] = lo;
2460   }
2461
2462   LOperand* hi() { return inputs_[0]; }
2463   LOperand* lo() { return inputs_[1]; }
2464
2465   DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2466 };
2467
2468
2469 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2470  public:
2471   LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2472             LOperand* temp2) {
2473     inputs_[0] = context;
2474     inputs_[1] = size;
2475     temps_[0] = temp1;
2476     temps_[1] = temp2;
2477   }
2478
2479   LOperand* context() { return inputs_[0]; }
2480   LOperand* size() { return inputs_[1]; }
2481   LOperand* temp1() { return temps_[0]; }
2482   LOperand* temp2() { return temps_[1]; }
2483
2484   DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2485   DECLARE_HYDROGEN_ACCESSOR(Allocate)
2486 };
2487
2488
2489 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2490  public:
2491   explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2492
2493   LOperand* context() { return inputs_[0]; }
2494
2495   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2496   DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2497 };
2498
2499
2500 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2501  public:
2502   explicit LFunctionLiteral(LOperand* context) { inputs_[0] = context; }
2503
2504   LOperand* context() { return inputs_[0]; }
2505
2506   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2507   DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2508 };
2509
2510
2511 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2512  public:
2513   explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2514
2515   LOperand* value() { return inputs_[0]; }
2516
2517   DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2518   DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2519 };
2520
2521
2522 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2523  public:
2524   LTypeof(LOperand* context, LOperand* value) {
2525     inputs_[0] = context;
2526     inputs_[1] = value;
2527   }
2528
2529   LOperand* context() { return inputs_[0]; }
2530   LOperand* value() { return inputs_[1]; }
2531
2532   DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2533 };
2534
2535
2536 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2537  public:
2538   explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2539
2540   LOperand* value() { return inputs_[0]; }
2541
2542   DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2543   DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2544
2545   Handle<String> type_literal() { return hydrogen()->type_literal(); }
2546
2547   void PrintDataTo(StringStream* stream) override;
2548 };
2549
2550
2551 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2552  public:
2553   explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2554
2555   LOperand* temp() { return temps_[0]; }
2556
2557   DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2558                                "is-construct-call-and-branch")
2559 };
2560
2561
2562 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2563  public:
2564   LOsrEntry() {}
2565
2566   bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2567   DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2568 };
2569
2570
2571 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2572  public:
2573   explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2574
2575   LOperand* context() { return inputs_[0]; }
2576
2577   DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2578   DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2579
2580   Label* done_label() { return &done_label_; }
2581
2582  private:
2583   Label done_label_;
2584 };
2585
2586
2587 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2588  public:
2589   LForInPrepareMap(LOperand* context, LOperand* object) {
2590     inputs_[0] = context;
2591     inputs_[1] = object;
2592   }
2593
2594   LOperand* context() { return inputs_[0]; }
2595   LOperand* object() { return inputs_[1]; }
2596
2597   DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2598 };
2599
2600
2601 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2602  public:
2603   explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2604
2605   LOperand* map() { return inputs_[0]; }
2606
2607   DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2608
2609   int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2610 };
2611
2612
2613 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2614  public:
2615   LCheckMapValue(LOperand* value, LOperand* map) {
2616     inputs_[0] = value;
2617     inputs_[1] = map;
2618   }
2619
2620   LOperand* value() { return inputs_[0]; }
2621   LOperand* map() { return inputs_[1]; }
2622
2623   DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2624 };
2625
2626
2627 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2628  public:
2629   LLoadFieldByIndex(LOperand* object, LOperand* index) {
2630     inputs_[0] = object;
2631     inputs_[1] = index;
2632   }
2633
2634   LOperand* object() { return inputs_[0]; }
2635   LOperand* index() { return inputs_[1]; }
2636
2637   DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2638 };
2639
2640
2641 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2642  public:
2643   explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2644
2645   LOperand* context() { return inputs_[0]; }
2646
2647   DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2648 };
2649
2650
2651 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2652  public:
2653   LAllocateBlockContext(LOperand* context, LOperand* function) {
2654     inputs_[0] = context;
2655     inputs_[1] = function;
2656   }
2657
2658   LOperand* context() { return inputs_[0]; }
2659   LOperand* function() { return inputs_[1]; }
2660
2661   Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2662
2663   DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2664   DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2665 };
2666
2667
2668 class LChunkBuilder;
2669 class LPlatformChunk final : public LChunk {
2670  public:
2671   LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2672
2673   int GetNextSpillIndex(RegisterKind kind);
2674   LOperand* GetNextSpillSlot(RegisterKind kind);
2675 };
2676
2677
2678 class LChunkBuilder final : public LChunkBuilderBase {
2679  public:
2680   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2681       : LChunkBuilderBase(info, graph),
2682         current_instruction_(NULL),
2683         current_block_(NULL),
2684         next_block_(NULL),
2685         allocator_(allocator) {}
2686
2687   // Build the sequence for the graph.
2688   LPlatformChunk* Build();
2689
2690 // Declare methods that deal with the individual node types.
2691 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2692   HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2693 #undef DECLARE_DO
2694
2695   LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2696   LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2697   LInstruction* DoRSub(HSub* instr);
2698
2699   static bool HasMagicNumberForDivisor(int32_t divisor);
2700
2701   LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2702   LInstruction* DoMathRound(HUnaryMathOperation* instr);
2703   LInstruction* DoMathFround(HUnaryMathOperation* instr);
2704   LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2705   LInstruction* DoMathLog(HUnaryMathOperation* instr);
2706   LInstruction* DoMathExp(HUnaryMathOperation* instr);
2707   LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2708   LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2709   LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2710   LInstruction* DoDivByPowerOf2I(HDiv* instr);
2711   LInstruction* DoDivByConstI(HDiv* instr);
2712   LInstruction* DoDivI(HDiv* instr);
2713   LInstruction* DoModByPowerOf2I(HMod* instr);
2714   LInstruction* DoModByConstI(HMod* instr);
2715   LInstruction* DoModI(HMod* instr);
2716   LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2717   LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2718   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2719
2720  private:
2721   // Methods for getting operands for Use / Define / Temp.
2722   LUnallocated* ToUnallocated(Register reg);
2723   LUnallocated* ToUnallocated(DoubleRegister reg);
2724
2725   // Methods for setting up define-use relationships.
2726   MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2727   MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2728   MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2729                                            DoubleRegister fixed_register);
2730
2731   // A value that is guaranteed to be allocated to a register.
2732   // Operand created by UseRegister is guaranteed to be live until the end of
2733   // instruction. This means that register allocator will not reuse it's
2734   // register for any other operand inside instruction.
2735   // Operand created by UseRegisterAtStart is guaranteed to be live only at
2736   // instruction start. Register allocator is free to assign the same register
2737   // to some other operand used inside instruction (i.e. temporary or
2738   // output).
2739   MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2740   MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2741
2742   // An input operand in a register that may be trashed.
2743   MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2744
2745   // An input operand in a register or stack slot.
2746   MUST_USE_RESULT LOperand* Use(HValue* value);
2747   MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2748
2749   // An input operand in a register, stack slot or a constant operand.
2750   MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2751   MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2752
2753   // An input operand in a register or a constant operand.
2754   MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2755   MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2756
2757   // An input operand in a constant operand.
2758   MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2759
2760   // An input operand in register, stack slot or a constant operand.
2761   // Will not be moved to a register even if one is freely available.
2762   MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2763
2764   // Temporary operand that must be in a register.
2765   MUST_USE_RESULT LUnallocated* TempRegister();
2766   MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2767   MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2768   MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2769
2770   // Methods for setting up define-use relationships.
2771   // Return the same instruction that they are passed.
2772   LInstruction* Define(LTemplateResultInstruction<1>* instr,
2773                        LUnallocated* result);
2774   LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2775   LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2776                                 int index);
2777   LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2778   LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2779   LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2780                                   DoubleRegister reg);
2781   LInstruction* AssignEnvironment(LInstruction* instr);
2782   LInstruction* AssignPointerMap(LInstruction* instr);
2783
2784   enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2785
2786   // By default we assume that instruction sequences generated for calls
2787   // cannot deoptimize eagerly and we do not attach environment to this
2788   // instruction.
2789   LInstruction* MarkAsCall(
2790       LInstruction* instr, HInstruction* hinstr,
2791       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2792
2793   void VisitInstruction(HInstruction* current);
2794   void AddInstruction(LInstruction* instr, HInstruction* current);
2795
2796   void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2797   LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2798   LInstruction* DoArithmeticD(Token::Value op,
2799                               HArithmeticBinaryOperation* instr);
2800   LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2801
2802   HInstruction* current_instruction_;
2803   HBasicBlock* current_block_;
2804   HBasicBlock* next_block_;
2805   LAllocator* allocator_;
2806
2807   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2808 };
2809
2810 #undef DECLARE_HYDROGEN_ACCESSOR
2811 #undef DECLARE_CONCRETE_INSTRUCTION
2812 }
2813 }  // namespace v8::internal
2814
2815 #endif  // V8_PPC_LITHIUM_PPC_H_