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