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