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