Correctify instanceof and make it optimizable.
[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(HasInPrototypeChainAndBranch)            \
87   V(HasInstanceTypeAndBranch)                \
88   V(InnerAllocatedObject)                    \
89   V(InstanceOf)                              \
90   V(InstructionGap)                          \
91   V(Integer32ToDouble)                       \
92   V(InvokeFunction)                          \
93   V(IsConstructCallAndBranch)                \
94   V(IsObjectAndBranch)                       \
95   V(IsStringAndBranch)                       \
96   V(IsSmiAndBranch)                          \
97   V(IsUndetectableAndBranch)                 \
98   V(Label)                                   \
99   V(LazyBailout)                             \
100   V(LoadContextSlot)                         \
101   V(LoadRoot)                                \
102   V(LoadFieldByIndex)                        \
103   V(LoadFunctionPrototype)                   \
104   V(LoadGlobalGeneric)                       \
105   V(LoadGlobalViaContext)                    \
106   V(LoadKeyed)                               \
107   V(LoadKeyedGeneric)                        \
108   V(LoadNamedField)                          \
109   V(LoadNamedGeneric)                        \
110   V(MapEnumLength)                           \
111   V(MathAbs)                                 \
112   V(MathExp)                                 \
113   V(MathClz32)                               \
114   V(MathFloor)                               \
115   V(MathFround)                              \
116   V(MathLog)                                 \
117   V(MathMinMax)                              \
118   V(MathPowHalf)                             \
119   V(MathRound)                               \
120   V(MathSqrt)                                \
121   V(MaybeGrowElements)                       \
122   V(ModByConstI)                             \
123   V(ModByPowerOf2I)                          \
124   V(ModI)                                    \
125   V(MulI)                                    \
126   V(MultiplyAddD)                            \
127   V(NumberTagD)                              \
128   V(NumberTagI)                              \
129   V(NumberTagU)                              \
130   V(NumberUntagD)                            \
131   V(OsrEntry)                                \
132   V(Parameter)                               \
133   V(Power)                                   \
134   V(PushArgument)                            \
135   V(RegExpLiteral)                           \
136   V(Return)                                  \
137   V(SeqStringGetChar)                        \
138   V(SeqStringSetChar)                        \
139   V(ShiftI)                                  \
140   V(SmiTag)                                  \
141   V(SmiUntag)                                \
142   V(StackCheck)                              \
143   V(StoreCodeEntry)                          \
144   V(StoreContextSlot)                        \
145   V(StoreFrameContext)                       \
146   V(StoreGlobalViaContext)                   \
147   V(StoreKeyed)                              \
148   V(StoreKeyedGeneric)                       \
149   V(StoreNamedField)                         \
150   V(StoreNamedGeneric)                       \
151   V(StringAdd)                               \
152   V(StringCharCodeAt)                        \
153   V(StringCharFromCode)                      \
154   V(StringCompareAndBranch)                  \
155   V(SubI)                                    \
156   V(TaggedToI)                               \
157   V(ThisFunction)                            \
158   V(ToFastProperties)                        \
159   V(TransitionElementsKind)                  \
160   V(TrapAllocationMemento)                   \
161   V(Typeof)                                  \
162   V(TypeofIsAndBranch)                       \
163   V(Uint32ToDouble)                          \
164   V(UnknownOSRValue)                         \
165   V(WrapReceiver)
166
167 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)            \
168   Opcode opcode() const final { return LInstruction::k##type; } \
169   void CompileToNative(LCodeGen* generator) final;              \
170   const char* Mnemonic() const final { return mnemonic; }       \
171   static L##type* cast(LInstruction* instr) {                   \
172     DCHECK(instr->Is##type());                                  \
173     return reinterpret_cast<L##type*>(instr);                   \
174   }
175
176
177 #define DECLARE_HYDROGEN_ACCESSOR(type)     \
178   H##type* hydrogen() const {               \
179     return H##type::cast(hydrogen_value()); \
180   }
181
182
183 class LInstruction : public ZoneObject {
184  public:
185   LInstruction()
186       : environment_(NULL),
187         hydrogen_value_(NULL),
188         bit_field_(IsCallBits::encode(false)) {
189   }
190
191   virtual ~LInstruction() {}
192
193   virtual void CompileToNative(LCodeGen* generator) = 0;
194   virtual const char* Mnemonic() const = 0;
195   virtual void PrintTo(StringStream* stream);
196   virtual void PrintDataTo(StringStream* stream);
197   virtual void PrintOutputOperandTo(StringStream* stream);
198
199   enum Opcode {
200     // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202     LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203     kNumberOfInstructions
204 #undef DECLARE_OPCODE
205   };
206
207   virtual Opcode opcode() const = 0;
208
209   // Declare non-virtual type testers for all leaf IR classes.
210 #define DECLARE_PREDICATE(type) \
211   bool Is##type() const { return opcode() == k##type; }
212   LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
214
215   // Declare virtual predicates for instructions that don't have
216   // an opcode.
217   virtual bool IsGap() const { return false; }
218
219   virtual bool IsControl() const { return false; }
220
221   // Try deleting this instruction if possible.
222   virtual bool TryDelete() { return false; }
223
224   void set_environment(LEnvironment* env) { environment_ = env; }
225   LEnvironment* environment() const { return environment_; }
226   bool HasEnvironment() const { return environment_ != NULL; }
227
228   void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
229   LPointerMap* pointer_map() const { return pointer_map_.get(); }
230   bool HasPointerMap() const { return pointer_map_.is_set(); }
231
232   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
233   HValue* hydrogen_value() const { return hydrogen_value_; }
234
235   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   Strength strength() { return hydrogen()->strength(); }
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() const { return inputs_[0]; }
1172   LOperand* left() const { return inputs_[1]; }
1173   LOperand* right() const { return inputs_[2]; }
1174
1175   DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1176 };
1177
1178
1179 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1180  public:
1181   LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1182     inputs_[0] = object;
1183     inputs_[1] = prototype;
1184   }
1185
1186   LOperand* object() const { return inputs_[0]; }
1187   LOperand* prototype() const { return inputs_[1]; }
1188
1189   DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1190                                "has-in-prototype-chain-and-branch")
1191   DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1192 };
1193
1194
1195 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1196  public:
1197   LBoundsCheck(LOperand* index, LOperand* length) {
1198     inputs_[0] = index;
1199     inputs_[1] = length;
1200   }
1201
1202   LOperand* index() { return inputs_[0]; }
1203   LOperand* length() { return inputs_[1]; }
1204
1205   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1206   DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1207 };
1208
1209
1210 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1211  public:
1212   LBitI(LOperand* left, LOperand* right) {
1213     inputs_[0] = left;
1214     inputs_[1] = right;
1215   }
1216
1217   LOperand* left() { return inputs_[0]; }
1218   LOperand* right() { return inputs_[1]; }
1219
1220   Token::Value op() const { return hydrogen()->op(); }
1221
1222   DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1223   DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1224 };
1225
1226
1227 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1228  public:
1229   LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1230       : op_(op), can_deopt_(can_deopt) {
1231     inputs_[0] = left;
1232     inputs_[1] = right;
1233   }
1234
1235   Token::Value op() const { return op_; }
1236   LOperand* left() { return inputs_[0]; }
1237   LOperand* right() { return inputs_[1]; }
1238   bool can_deopt() const { return can_deopt_; }
1239
1240   DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1241
1242  private:
1243   Token::Value op_;
1244   bool can_deopt_;
1245 };
1246
1247
1248 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1249  public:
1250   LSubI(LOperand* left, LOperand* right) {
1251     inputs_[0] = left;
1252     inputs_[1] = right;
1253   }
1254
1255   LOperand* left() { return inputs_[0]; }
1256   LOperand* right() { return inputs_[1]; }
1257
1258   DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1259   DECLARE_HYDROGEN_ACCESSOR(Sub)
1260 };
1261
1262
1263 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1264  public:
1265   DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1266   DECLARE_HYDROGEN_ACCESSOR(Constant)
1267
1268   int32_t value() const { return hydrogen()->Integer32Value(); }
1269 };
1270
1271
1272 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1273  public:
1274   DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1275   DECLARE_HYDROGEN_ACCESSOR(Constant)
1276
1277   Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1278 };
1279
1280
1281 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1282  public:
1283   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1284   DECLARE_HYDROGEN_ACCESSOR(Constant)
1285
1286   double value() const { return hydrogen()->DoubleValue(); }
1287   uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1288 };
1289
1290
1291 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1292  public:
1293   DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1294   DECLARE_HYDROGEN_ACCESSOR(Constant)
1295
1296   ExternalReference value() const {
1297     return hydrogen()->ExternalReferenceValue();
1298   }
1299 };
1300
1301
1302 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1303  public:
1304   DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1305   DECLARE_HYDROGEN_ACCESSOR(Constant)
1306
1307   Handle<Object> value(Isolate* isolate) const {
1308     return hydrogen()->handle(isolate);
1309   }
1310 };
1311
1312
1313 class LBranch final : public LControlInstruction<1, 0> {
1314  public:
1315   explicit LBranch(LOperand* value) {
1316     inputs_[0] = value;
1317   }
1318
1319   LOperand* value() { return inputs_[0]; }
1320
1321   DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1322   DECLARE_HYDROGEN_ACCESSOR(Branch)
1323
1324   void PrintDataTo(StringStream* stream) override;
1325 };
1326
1327
1328 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1329  public:
1330   LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1331     inputs_[0] = value;
1332     temps_[0] = temp;
1333   }
1334
1335   LOperand* value() { return inputs_[0]; }
1336   LOperand* temp() { return temps_[0]; }
1337
1338   DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1339   DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1340
1341   Handle<Map> map() const { return hydrogen()->map().handle(); }
1342 };
1343
1344
1345 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1346  public:
1347   explicit LMapEnumLength(LOperand* value) {
1348     inputs_[0] = value;
1349   }
1350
1351   LOperand* value() { return inputs_[0]; }
1352
1353   DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1354 };
1355
1356
1357 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1358  public:
1359   LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1360     inputs_[0] = date;
1361     temps_[0] = temp;
1362   }
1363
1364   LOperand* date() { return inputs_[0]; }
1365   LOperand* temp() { return temps_[0]; }
1366   Smi* index() const { return index_; }
1367
1368   DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1369   DECLARE_HYDROGEN_ACCESSOR(DateField)
1370
1371  private:
1372   Smi* index_;
1373 };
1374
1375
1376 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1377  public:
1378   LSeqStringGetChar(LOperand* string, LOperand* index) {
1379     inputs_[0] = string;
1380     inputs_[1] = index;
1381   }
1382
1383   LOperand* string() const { return inputs_[0]; }
1384   LOperand* index() const { return inputs_[1]; }
1385
1386   DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1387   DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1388 };
1389
1390
1391 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1392  public:
1393   LSeqStringSetChar(LOperand* context,
1394                     LOperand* string,
1395                     LOperand* index,
1396                     LOperand* value) {
1397     inputs_[0] = context;
1398     inputs_[1] = string;
1399     inputs_[2] = index;
1400     inputs_[3] = value;
1401   }
1402
1403   LOperand* string() { return inputs_[1]; }
1404   LOperand* index() { return inputs_[2]; }
1405   LOperand* value() { return inputs_[3]; }
1406
1407   DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1408   DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1409 };
1410
1411
1412 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1413  public:
1414   LAddI(LOperand* left, LOperand* right) {
1415     inputs_[0] = left;
1416     inputs_[1] = right;
1417   }
1418
1419   LOperand* left() { return inputs_[0]; }
1420   LOperand* right() { return inputs_[1]; }
1421
1422   DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1423   DECLARE_HYDROGEN_ACCESSOR(Add)
1424 };
1425
1426
1427 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1428  public:
1429   LMathMinMax(LOperand* left, LOperand* right) {
1430     inputs_[0] = left;
1431     inputs_[1] = right;
1432   }
1433
1434   LOperand* left() { return inputs_[0]; }
1435   LOperand* right() { return inputs_[1]; }
1436
1437   DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1438   DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1439 };
1440
1441
1442 class LPower final : public LTemplateInstruction<1, 2, 0> {
1443  public:
1444   LPower(LOperand* left, LOperand* right) {
1445     inputs_[0] = left;
1446     inputs_[1] = right;
1447   }
1448
1449   LOperand* left() { return inputs_[0]; }
1450   LOperand* right() { return inputs_[1]; }
1451
1452   DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1453   DECLARE_HYDROGEN_ACCESSOR(Power)
1454 };
1455
1456
1457 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1458  public:
1459   LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1460       : op_(op) {
1461     inputs_[0] = left;
1462     inputs_[1] = right;
1463   }
1464
1465   Token::Value op() const { return op_; }
1466   LOperand* left() { return inputs_[0]; }
1467   LOperand* right() { return inputs_[1]; }
1468
1469   Opcode opcode() const override { return LInstruction::kArithmeticD; }
1470   void CompileToNative(LCodeGen* generator) override;
1471   const char* Mnemonic() const override;
1472
1473  private:
1474   Token::Value op_;
1475 };
1476
1477
1478 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1479  public:
1480   LArithmeticT(Token::Value op,
1481                LOperand* context,
1482                LOperand* left,
1483                LOperand* right)
1484       : op_(op) {
1485     inputs_[0] = context;
1486     inputs_[1] = left;
1487     inputs_[2] = right;
1488   }
1489
1490   LOperand* context() { return inputs_[0]; }
1491   LOperand* left() { return inputs_[1]; }
1492   LOperand* right() { return inputs_[2]; }
1493   Token::Value op() const { return op_; }
1494
1495   Opcode opcode() const final { return LInstruction::kArithmeticT; }
1496   void CompileToNative(LCodeGen* generator) override;
1497   const char* Mnemonic() const override;
1498
1499   DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1500
1501   Strength strength() { return hydrogen()->strength(); }
1502
1503  private:
1504   Token::Value op_;
1505 };
1506
1507
1508 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1509  public:
1510   LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1511     inputs_[0] = value;
1512     inputs_[1] = context;
1513     inputs_[2] = parameter_count;
1514   }
1515
1516   LOperand* value() { return inputs_[0]; }
1517
1518   bool has_constant_parameter_count() {
1519     return parameter_count()->IsConstantOperand();
1520   }
1521   LConstantOperand* constant_parameter_count() {
1522     DCHECK(has_constant_parameter_count());
1523     return LConstantOperand::cast(parameter_count());
1524   }
1525   LOperand* parameter_count() { return inputs_[2]; }
1526
1527   DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1528 };
1529
1530
1531 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1532  public:
1533   explicit LLoadNamedField(LOperand* object) {
1534     inputs_[0] = object;
1535   }
1536
1537   LOperand* object() { return inputs_[0]; }
1538
1539   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1540   DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1541 };
1542
1543
1544 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1545  public:
1546   LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1547     inputs_[0] = context;
1548     inputs_[1] = object;
1549     temps_[0] = vector;
1550   }
1551
1552   LOperand* context() { return inputs_[0]; }
1553   LOperand* object() { return inputs_[1]; }
1554   LOperand* temp_vector() { return temps_[0]; }
1555
1556   DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1557   DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1558
1559   Handle<Object> name() const { return hydrogen()->name(); }
1560 };
1561
1562
1563 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1564  public:
1565   explicit LLoadFunctionPrototype(LOperand* function) {
1566     inputs_[0] = function;
1567   }
1568
1569   LOperand* function() { return inputs_[0]; }
1570
1571   DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1572   DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1573 };
1574
1575
1576 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1577  public:
1578   DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1579   DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1580
1581   Heap::RootListIndex index() const { return hydrogen()->index(); }
1582 };
1583
1584
1585 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1586  public:
1587   LLoadKeyed(LOperand* elements, LOperand* key) {
1588     inputs_[0] = elements;
1589     inputs_[1] = key;
1590   }
1591
1592   LOperand* elements() { return inputs_[0]; }
1593   LOperand* key() { return inputs_[1]; }
1594   ElementsKind elements_kind() const {
1595     return hydrogen()->elements_kind();
1596   }
1597   bool is_fixed_typed_array() const {
1598     return hydrogen()->is_fixed_typed_array();
1599   }
1600
1601   DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1602   DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1603
1604   void PrintDataTo(StringStream* stream) override;
1605   uint32_t base_offset() const { return hydrogen()->base_offset(); }
1606 };
1607
1608
1609 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1610  public:
1611   LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1612                     LOperand* vector) {
1613     inputs_[0] = context;
1614     inputs_[1] = object;
1615     inputs_[2] = key;
1616     temps_[0] = vector;
1617   }
1618
1619   LOperand* context() { return inputs_[0]; }
1620   LOperand* object() { return inputs_[1]; }
1621   LOperand* key() { return inputs_[2]; }
1622   LOperand* temp_vector() { return temps_[0]; }
1623
1624   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1625   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1626 };
1627
1628
1629 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1630  public:
1631   LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1632                      LOperand* vector) {
1633     inputs_[0] = context;
1634     inputs_[1] = global_object;
1635     temps_[0] = vector;
1636   }
1637
1638   LOperand* context() { return inputs_[0]; }
1639   LOperand* global_object() { return inputs_[1]; }
1640   LOperand* temp_vector() { return temps_[0]; }
1641
1642   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1643   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1644
1645   Handle<Object> name() const { return hydrogen()->name(); }
1646   TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1647 };
1648
1649
1650 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1651  public:
1652   explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1653
1654   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1655   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1656
1657   void PrintDataTo(StringStream* stream) override;
1658
1659   LOperand* context() { return inputs_[0]; }
1660
1661   int depth() const { return hydrogen()->depth(); }
1662   int slot_index() const { return hydrogen()->slot_index(); }
1663 };
1664
1665
1666 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1667  public:
1668   explicit LLoadContextSlot(LOperand* context) {
1669     inputs_[0] = context;
1670   }
1671
1672   LOperand* context() { return inputs_[0]; }
1673
1674   DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1675   DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1676
1677   int slot_index() { return hydrogen()->slot_index(); }
1678
1679   void PrintDataTo(StringStream* stream) override;
1680 };
1681
1682
1683 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1684  public:
1685   LStoreContextSlot(LOperand* context, LOperand* value) {
1686     inputs_[0] = context;
1687     inputs_[1] = value;
1688   }
1689
1690   LOperand* context() { return inputs_[0]; }
1691   LOperand* value() { return inputs_[1]; }
1692
1693   DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1694   DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1695
1696   int slot_index() { return hydrogen()->slot_index(); }
1697
1698   void PrintDataTo(StringStream* stream) override;
1699 };
1700
1701
1702 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1703  public:
1704   explicit LPushArgument(LOperand* value) {
1705     inputs_[0] = value;
1706   }
1707
1708   LOperand* value() { return inputs_[0]; }
1709
1710   DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1711 };
1712
1713
1714 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1715  public:
1716   explicit LDrop(int count) : count_(count) { }
1717
1718   int count() const { return count_; }
1719
1720   DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1721
1722  private:
1723   int count_;
1724 };
1725
1726
1727 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1728  public:
1729   LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1730     inputs_[0] = function;
1731     inputs_[1] = code_object;
1732   }
1733
1734   LOperand* function() { return inputs_[0]; }
1735   LOperand* code_object() { return inputs_[1]; }
1736
1737   void PrintDataTo(StringStream* stream) override;
1738
1739   DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1740   DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1741 };
1742
1743
1744 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1745  public:
1746   LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1747     inputs_[0] = base_object;
1748     inputs_[1] = offset;
1749   }
1750
1751   LOperand* base_object() const { return inputs_[0]; }
1752   LOperand* offset() const { return inputs_[1]; }
1753
1754   void PrintDataTo(StringStream* stream) override;
1755
1756   DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1757 };
1758
1759
1760 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1761  public:
1762   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1763   DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1764 };
1765
1766
1767 class LContext final : public LTemplateInstruction<1, 0, 0> {
1768  public:
1769   DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1770   DECLARE_HYDROGEN_ACCESSOR(Context)
1771 };
1772
1773
1774 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1775  public:
1776   explicit LDeclareGlobals(LOperand* context) {
1777     inputs_[0] = context;
1778   }
1779
1780   LOperand* context() { return inputs_[0]; }
1781
1782   DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1783   DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1784 };
1785
1786
1787 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1788  public:
1789   explicit LCallJSFunction(LOperand* function) {
1790     inputs_[0] = function;
1791   }
1792
1793   LOperand* function() { return inputs_[0]; }
1794
1795   DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1796   DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1797
1798   void PrintDataTo(StringStream* stream) override;
1799
1800   int arity() const { return hydrogen()->argument_count() - 1; }
1801 };
1802
1803
1804 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1805  public:
1806   LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1807                       const ZoneList<LOperand*>& operands, Zone* zone)
1808       : descriptor_(descriptor),
1809         inputs_(descriptor.GetRegisterParameterCount() +
1810                     kImplicitRegisterParameterCount,
1811                 zone) {
1812     DCHECK(descriptor.GetRegisterParameterCount() +
1813                kImplicitRegisterParameterCount ==
1814            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   // The target and context are passed as implicit parameters that are not
1825   // explicitly listed in the descriptor.
1826   static const int kImplicitRegisterParameterCount = 2;
1827
1828  private:
1829   DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1830
1831   void PrintDataTo(StringStream* stream) override;
1832
1833   int arity() const { return hydrogen()->argument_count() - 1; }
1834
1835   CallInterfaceDescriptor descriptor_;
1836   ZoneList<LOperand*> inputs_;
1837
1838   // Iterator support.
1839   int InputCount() final { return inputs_.length(); }
1840   LOperand* InputAt(int i) final { return inputs_[i]; }
1841
1842   int TempCount() final { return 0; }
1843   LOperand* TempAt(int i) final { return NULL; }
1844 };
1845
1846
1847 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1848  public:
1849   LInvokeFunction(LOperand* context, LOperand* function) {
1850     inputs_[0] = context;
1851     inputs_[1] = function;
1852   }
1853
1854   LOperand* context() { return inputs_[0]; }
1855   LOperand* function() { return inputs_[1]; }
1856
1857   DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1858   DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1859
1860   void PrintDataTo(StringStream* stream) override;
1861
1862   int arity() const { return hydrogen()->argument_count() - 1; }
1863 };
1864
1865
1866 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1867  public:
1868   LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1869                 LOperand* vector) {
1870     inputs_[0] = context;
1871     inputs_[1] = function;
1872     temps_[0] = slot;
1873     temps_[1] = vector;
1874   }
1875
1876   LOperand* context() { return inputs_[0]; }
1877   LOperand* function() { return inputs_[1]; }
1878   LOperand* temp_slot() { return temps_[0]; }
1879   LOperand* temp_vector() { return temps_[1]; }
1880
1881   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1882   DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1883
1884   int arity() const { return hydrogen()->argument_count() - 1; }
1885   void PrintDataTo(StringStream* stream) override;
1886 };
1887
1888
1889 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1890  public:
1891   LCallNew(LOperand* context, LOperand* constructor) {
1892     inputs_[0] = context;
1893     inputs_[1] = constructor;
1894   }
1895
1896   LOperand* context() { return inputs_[0]; }
1897   LOperand* constructor() { return inputs_[1]; }
1898
1899   DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1900   DECLARE_HYDROGEN_ACCESSOR(CallNew)
1901
1902   void PrintDataTo(StringStream* stream) override;
1903
1904   int arity() const { return hydrogen()->argument_count() - 1; }
1905 };
1906
1907
1908 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1909  public:
1910   LCallNewArray(LOperand* context, LOperand* constructor) {
1911     inputs_[0] = context;
1912     inputs_[1] = constructor;
1913   }
1914
1915   LOperand* context() { return inputs_[0]; }
1916   LOperand* constructor() { return inputs_[1]; }
1917
1918   DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1919   DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1920
1921   void PrintDataTo(StringStream* stream) override;
1922
1923   int arity() const { return hydrogen()->argument_count() - 1; }
1924 };
1925
1926
1927 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1928  public:
1929   explicit LCallRuntime(LOperand* context) {
1930     inputs_[0] = context;
1931   }
1932
1933   LOperand* context() { return inputs_[0]; }
1934
1935   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1936   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1937
1938   bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1939     return save_doubles() == kDontSaveFPRegs;
1940   }
1941
1942   const Runtime::Function* function() const { return hydrogen()->function(); }
1943   int arity() const { return hydrogen()->argument_count(); }
1944   SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1945 };
1946
1947
1948 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1949  public:
1950   explicit LInteger32ToDouble(LOperand* value) {
1951     inputs_[0] = value;
1952   }
1953
1954   LOperand* value() { return inputs_[0]; }
1955
1956   DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1957 };
1958
1959
1960 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1961  public:
1962   explicit LUint32ToDouble(LOperand* value) {
1963     inputs_[0] = value;
1964   }
1965
1966   LOperand* value() { return inputs_[0]; }
1967
1968   DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1969 };
1970
1971
1972 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1973  public:
1974   LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1975     inputs_[0] = value;
1976     temps_[0] = temp1;
1977     temps_[1] = temp2;
1978   }
1979
1980   LOperand* value() { return inputs_[0]; }
1981   LOperand* temp1() { return temps_[0]; }
1982   LOperand* temp2() { return temps_[1]; }
1983
1984   DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1985 };
1986
1987
1988 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1989  public:
1990   LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1991     inputs_[0] = value;
1992     temps_[0] = temp1;
1993     temps_[1] = temp2;
1994   }
1995
1996   LOperand* value() { return inputs_[0]; }
1997   LOperand* temp1() { return temps_[0]; }
1998   LOperand* temp2() { return temps_[1]; }
1999
2000   DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2001 };
2002
2003
2004 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2005  public:
2006   LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2007     inputs_[0] = value;
2008     temps_[0] = temp;
2009     temps_[1] = temp2;
2010   }
2011
2012   LOperand* value() { return inputs_[0]; }
2013   LOperand* temp() { return temps_[0]; }
2014   LOperand* temp2() { return temps_[1]; }
2015
2016   DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2017   DECLARE_HYDROGEN_ACCESSOR(Change)
2018 };
2019
2020
2021 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2022  public:
2023   explicit LDoubleToSmi(LOperand* value) {
2024     inputs_[0] = value;
2025   }
2026
2027   LOperand* value() { return inputs_[0]; }
2028
2029   DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2030   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2031
2032   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2033 };
2034
2035
2036 // Sometimes truncating conversion from a tagged value to an int32.
2037 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2038  public:
2039   explicit LDoubleToI(LOperand* value) {
2040     inputs_[0] = value;
2041   }
2042
2043   LOperand* value() { return inputs_[0]; }
2044
2045   DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2046   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2047
2048   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2049 };
2050
2051
2052 // Truncating conversion from a tagged value to an int32.
2053 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2054  public:
2055   LTaggedToI(LOperand* value,
2056              LOperand* temp,
2057              LOperand* temp2) {
2058     inputs_[0] = value;
2059     temps_[0] = temp;
2060     temps_[1] = temp2;
2061   }
2062
2063   LOperand* value() { return inputs_[0]; }
2064   LOperand* temp() { return temps_[0]; }
2065   LOperand* temp2() { return temps_[1]; }
2066
2067   DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2068   DECLARE_HYDROGEN_ACCESSOR(Change)
2069
2070   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2071 };
2072
2073
2074 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2075  public:
2076   explicit LSmiTag(LOperand* value) {
2077     inputs_[0] = value;
2078   }
2079
2080   LOperand* value() { return inputs_[0]; }
2081
2082   DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2083   DECLARE_HYDROGEN_ACCESSOR(Change)
2084 };
2085
2086
2087 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2088  public:
2089   explicit LNumberUntagD(LOperand* value) {
2090     inputs_[0] = value;
2091   }
2092
2093   LOperand* value() { return inputs_[0]; }
2094
2095   DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2096   DECLARE_HYDROGEN_ACCESSOR(Change)
2097 };
2098
2099
2100 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2101  public:
2102   LSmiUntag(LOperand* value, bool needs_check)
2103       : needs_check_(needs_check) {
2104     inputs_[0] = value;
2105   }
2106
2107   LOperand* value() { return inputs_[0]; }
2108   bool needs_check() const { return needs_check_; }
2109
2110   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2111
2112  private:
2113   bool needs_check_;
2114 };
2115
2116
2117 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2118  public:
2119   LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2120     inputs_[0] = object;
2121     inputs_[1] = value;
2122     temps_[0] = temp;
2123   }
2124
2125   LOperand* object() { return inputs_[0]; }
2126   LOperand* value() { return inputs_[1]; }
2127   LOperand* temp() { return temps_[0]; }
2128
2129   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2130   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2131
2132   void PrintDataTo(StringStream* stream) override;
2133
2134   Representation representation() const {
2135     return hydrogen()->field_representation();
2136   }
2137 };
2138
2139
2140 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2141  public:
2142   LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2143                      LOperand* slot, LOperand* vector) {
2144     inputs_[0] = context;
2145     inputs_[1] = object;
2146     inputs_[2] = value;
2147     temps_[0] = slot;
2148     temps_[1] = vector;
2149   }
2150
2151   LOperand* context() { return inputs_[0]; }
2152   LOperand* object() { return inputs_[1]; }
2153   LOperand* value() { return inputs_[2]; }
2154   LOperand* temp_slot() { return temps_[0]; }
2155   LOperand* temp_vector() { return temps_[1]; }
2156
2157   DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2158   DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2159
2160   void PrintDataTo(StringStream* stream) override;
2161
2162   Handle<Object> name() const { return hydrogen()->name(); }
2163   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2164 };
2165
2166
2167 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2168  public:
2169   LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2170     inputs_[0] = context;
2171     inputs_[1] = value;
2172   }
2173
2174   LOperand* context() { return inputs_[0]; }
2175   LOperand* value() { return inputs_[1]; }
2176
2177   DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2178                                "store-global-via-context")
2179   DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2180
2181   void PrintDataTo(StringStream* stream) override;
2182
2183   int depth() { return hydrogen()->depth(); }
2184   int slot_index() { return hydrogen()->slot_index(); }
2185   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2186 };
2187
2188
2189 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2190  public:
2191   LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2192     inputs_[0] = object;
2193     inputs_[1] = key;
2194     inputs_[2] = value;
2195   }
2196
2197   bool is_fixed_typed_array() const {
2198     return hydrogen()->is_fixed_typed_array();
2199   }
2200   LOperand* elements() { return inputs_[0]; }
2201   LOperand* key() { return inputs_[1]; }
2202   LOperand* value() { return inputs_[2]; }
2203   ElementsKind elements_kind() const {
2204     return hydrogen()->elements_kind();
2205   }
2206
2207   DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2208   DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2209
2210   void PrintDataTo(StringStream* stream) override;
2211   bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2212   uint32_t base_offset() const { return hydrogen()->base_offset(); }
2213 };
2214
2215
2216 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2217  public:
2218   LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2219                      LOperand* value, LOperand* slot, LOperand* vector) {
2220     inputs_[0] = context;
2221     inputs_[1] = object;
2222     inputs_[2] = key;
2223     inputs_[3] = value;
2224     temps_[0] = slot;
2225     temps_[1] = vector;
2226   }
2227
2228   LOperand* context() { return inputs_[0]; }
2229   LOperand* object() { return inputs_[1]; }
2230   LOperand* key() { return inputs_[2]; }
2231   LOperand* value() { return inputs_[3]; }
2232   LOperand* temp_slot() { return temps_[0]; }
2233   LOperand* temp_vector() { return temps_[1]; }
2234
2235   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2236   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2237
2238   void PrintDataTo(StringStream* stream) override;
2239
2240   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2241 };
2242
2243
2244 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2245  public:
2246   LTransitionElementsKind(LOperand* object,
2247                           LOperand* context,
2248                           LOperand* new_map_temp) {
2249     inputs_[0] = object;
2250     inputs_[1] = context;
2251     temps_[0] = new_map_temp;
2252   }
2253
2254   LOperand* context() { return inputs_[1]; }
2255   LOperand* object() { return inputs_[0]; }
2256   LOperand* new_map_temp() { return temps_[0]; }
2257
2258   DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2259                                "transition-elements-kind")
2260   DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2261
2262   void PrintDataTo(StringStream* stream) override;
2263
2264   Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2265   Handle<Map> transitioned_map() {
2266     return hydrogen()->transitioned_map().handle();
2267   }
2268   ElementsKind from_kind() { return hydrogen()->from_kind(); }
2269   ElementsKind to_kind() { return hydrogen()->to_kind(); }
2270 };
2271
2272
2273 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2274  public:
2275   LTrapAllocationMemento(LOperand* object,
2276                          LOperand* temp) {
2277     inputs_[0] = object;
2278     temps_[0] = temp;
2279   }
2280
2281   LOperand* object() { return inputs_[0]; }
2282   LOperand* temp() { return temps_[0]; }
2283
2284   DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2285                                "trap-allocation-memento")
2286 };
2287
2288
2289 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2290  public:
2291   LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2292                      LOperand* key, LOperand* current_capacity) {
2293     inputs_[0] = context;
2294     inputs_[1] = object;
2295     inputs_[2] = elements;
2296     inputs_[3] = key;
2297     inputs_[4] = current_capacity;
2298   }
2299
2300   LOperand* context() { return inputs_[0]; }
2301   LOperand* object() { return inputs_[1]; }
2302   LOperand* elements() { return inputs_[2]; }
2303   LOperand* key() { return inputs_[3]; }
2304   LOperand* current_capacity() { return inputs_[4]; }
2305
2306   DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2307   DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2308 };
2309
2310
2311 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2312  public:
2313   LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2314     inputs_[0] = context;
2315     inputs_[1] = left;
2316     inputs_[2] = right;
2317   }
2318
2319   LOperand* context() { return inputs_[0]; }
2320   LOperand* left() { return inputs_[1]; }
2321   LOperand* right() { return inputs_[2]; }
2322
2323   DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2324   DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2325 };
2326
2327
2328 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2329  public:
2330   LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2331     inputs_[0] = context;
2332     inputs_[1] = string;
2333     inputs_[2] = index;
2334   }
2335
2336   LOperand* context() { return inputs_[0]; }
2337   LOperand* string() { return inputs_[1]; }
2338   LOperand* index() { return inputs_[2]; }
2339
2340   DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2341   DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2342 };
2343
2344
2345 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2346  public:
2347   explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2348     inputs_[0] = context;
2349     inputs_[1] = char_code;
2350   }
2351
2352   LOperand* context() { return inputs_[0]; }
2353   LOperand* char_code() { return inputs_[1]; }
2354
2355   DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2356   DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2357 };
2358
2359
2360 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2361  public:
2362   explicit LCheckValue(LOperand* value) {
2363     inputs_[0] = value;
2364   }
2365
2366   LOperand* value() { return inputs_[0]; }
2367
2368   DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2369   DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2370 };
2371
2372
2373 class LCheckArrayBufferNotNeutered final
2374     : public LTemplateInstruction<0, 1, 0> {
2375  public:
2376   explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2377
2378   LOperand* view() { return inputs_[0]; }
2379
2380   DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2381                                "check-array-buffer-not-neutered")
2382   DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2383 };
2384
2385
2386 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2387  public:
2388   explicit LCheckInstanceType(LOperand* value) {
2389     inputs_[0] = value;
2390   }
2391
2392   LOperand* value() { return inputs_[0]; }
2393
2394   DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2395   DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2396 };
2397
2398
2399 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2400  public:
2401   explicit LCheckMaps(LOperand* value = NULL) {
2402     inputs_[0] = value;
2403   }
2404
2405   LOperand* value() { return inputs_[0]; }
2406
2407   DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2408   DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2409 };
2410
2411
2412 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2413  public:
2414   explicit LCheckSmi(LOperand* value) {
2415     inputs_[0] = value;
2416   }
2417
2418   LOperand* value() { return inputs_[0]; }
2419
2420   DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2421 };
2422
2423
2424 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2425  public:
2426   explicit LCheckNonSmi(LOperand* value) {
2427     inputs_[0] = value;
2428   }
2429
2430   LOperand* value() { return inputs_[0]; }
2431
2432   DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2433   DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2434 };
2435
2436
2437 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2438  public:
2439   LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2440     inputs_[0] = unclamped;
2441     temps_[0] = temp;
2442   }
2443
2444   LOperand* unclamped() { return inputs_[0]; }
2445   LOperand* temp() { return temps_[0]; }
2446
2447   DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2448 };
2449
2450
2451 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2452  public:
2453   explicit LClampIToUint8(LOperand* unclamped) {
2454     inputs_[0] = unclamped;
2455   }
2456
2457   LOperand* unclamped() { return inputs_[0]; }
2458
2459   DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2460 };
2461
2462
2463 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2464  public:
2465   LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2466     inputs_[0] = unclamped;
2467     temps_[0] = temp;
2468   }
2469
2470   LOperand* unclamped() { return inputs_[0]; }
2471   LOperand* temp() { return temps_[0]; }
2472
2473   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2474 };
2475
2476
2477 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2478  public:
2479   explicit LDoubleBits(LOperand* value) {
2480     inputs_[0] = value;
2481   }
2482
2483   LOperand* value() { return inputs_[0]; }
2484
2485   DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2486   DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2487 };
2488
2489
2490 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2491  public:
2492   LConstructDouble(LOperand* hi, LOperand* lo) {
2493     inputs_[0] = hi;
2494     inputs_[1] = lo;
2495   }
2496
2497   LOperand* hi() { return inputs_[0]; }
2498   LOperand* lo() { return inputs_[1]; }
2499
2500   DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2501 };
2502
2503
2504 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2505  public:
2506   LAllocate(LOperand* context,
2507             LOperand* size,
2508             LOperand* temp1,
2509             LOperand* temp2) {
2510     inputs_[0] = context;
2511     inputs_[1] = size;
2512     temps_[0] = temp1;
2513     temps_[1] = temp2;
2514   }
2515
2516   LOperand* context() { return inputs_[0]; }
2517   LOperand* size() { return inputs_[1]; }
2518   LOperand* temp1() { return temps_[0]; }
2519   LOperand* temp2() { return temps_[1]; }
2520
2521   DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2522   DECLARE_HYDROGEN_ACCESSOR(Allocate)
2523 };
2524
2525
2526 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2527  public:
2528   explicit LRegExpLiteral(LOperand* context) {
2529     inputs_[0] = context;
2530   }
2531
2532   LOperand* context() { return inputs_[0]; }
2533
2534   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2535   DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2536 };
2537
2538
2539 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2540  public:
2541   explicit LFunctionLiteral(LOperand* context) {
2542     inputs_[0] = context;
2543   }
2544
2545   LOperand* context() { return inputs_[0]; }
2546
2547   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2548   DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2549 };
2550
2551
2552 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2553  public:
2554   explicit LToFastProperties(LOperand* value) {
2555     inputs_[0] = value;
2556   }
2557
2558   LOperand* value() { return inputs_[0]; }
2559
2560   DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2561   DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2562 };
2563
2564
2565 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2566  public:
2567   LTypeof(LOperand* context, LOperand* value) {
2568     inputs_[0] = context;
2569     inputs_[1] = value;
2570   }
2571
2572   LOperand* context() { return inputs_[0]; }
2573   LOperand* value() { return inputs_[1]; }
2574
2575   DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2576 };
2577
2578
2579 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2580  public:
2581   explicit LTypeofIsAndBranch(LOperand* value) {
2582     inputs_[0] = value;
2583   }
2584
2585   LOperand* value() { return inputs_[0]; }
2586
2587   DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2588   DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2589
2590   Handle<String> type_literal() { return hydrogen()->type_literal(); }
2591
2592   void PrintDataTo(StringStream* stream) override;
2593 };
2594
2595
2596 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2597  public:
2598   explicit LIsConstructCallAndBranch(LOperand* temp) {
2599     temps_[0] = temp;
2600   }
2601
2602   LOperand* temp() { return temps_[0]; }
2603
2604   DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2605                                "is-construct-call-and-branch")
2606 };
2607
2608
2609 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2610  public:
2611   LOsrEntry() {}
2612
2613   bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2614   DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2615 };
2616
2617
2618 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2619  public:
2620   explicit LStackCheck(LOperand* context) {
2621     inputs_[0] = context;
2622   }
2623
2624   LOperand* context() { return inputs_[0]; }
2625
2626   DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2627   DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2628
2629   Label* done_label() { return &done_label_; }
2630
2631  private:
2632   Label done_label_;
2633 };
2634
2635
2636 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2637  public:
2638   LForInPrepareMap(LOperand* context, LOperand* object) {
2639     inputs_[0] = context;
2640     inputs_[1] = object;
2641   }
2642
2643   LOperand* context() { return inputs_[0]; }
2644   LOperand* object() { return inputs_[1]; }
2645
2646   DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2647 };
2648
2649
2650 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2651  public:
2652   explicit LForInCacheArray(LOperand* map) {
2653     inputs_[0] = map;
2654   }
2655
2656   LOperand* map() { return inputs_[0]; }
2657
2658   DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2659
2660   int idx() {
2661     return HForInCacheArray::cast(this->hydrogen_value())->idx();
2662   }
2663 };
2664
2665
2666 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2667  public:
2668   LCheckMapValue(LOperand* value, LOperand* map) {
2669     inputs_[0] = value;
2670     inputs_[1] = map;
2671   }
2672
2673   LOperand* value() { return inputs_[0]; }
2674   LOperand* map() { return inputs_[1]; }
2675
2676   DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2677 };
2678
2679
2680 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2681  public:
2682   LLoadFieldByIndex(LOperand* object, LOperand* index) {
2683     inputs_[0] = object;
2684     inputs_[1] = index;
2685   }
2686
2687   LOperand* object() { return inputs_[0]; }
2688   LOperand* index() { return inputs_[1]; }
2689
2690   DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2691 };
2692
2693
2694 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2695  public:
2696   explicit LStoreFrameContext(LOperand* context) {
2697     inputs_[0] = context;
2698   }
2699
2700   LOperand* context() { return inputs_[0]; }
2701
2702   DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2703 };
2704
2705
2706 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2707  public:
2708   LAllocateBlockContext(LOperand* context, LOperand* function) {
2709     inputs_[0] = context;
2710     inputs_[1] = function;
2711   }
2712
2713   LOperand* context() { return inputs_[0]; }
2714   LOperand* function() { return inputs_[1]; }
2715
2716   Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2717
2718   DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2719   DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2720 };
2721
2722
2723 class LChunkBuilder;
2724 class LPlatformChunk final : public LChunk {
2725  public:
2726   LPlatformChunk(CompilationInfo* info, HGraph* graph)
2727       : LChunk(info, graph) { }
2728
2729   int GetNextSpillIndex(RegisterKind kind);
2730   LOperand* GetNextSpillSlot(RegisterKind kind);
2731 };
2732
2733
2734 class LChunkBuilder final : public LChunkBuilderBase {
2735  public:
2736   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2737       : LChunkBuilderBase(info, graph),
2738         current_instruction_(NULL),
2739         current_block_(NULL),
2740         next_block_(NULL),
2741         allocator_(allocator) {}
2742
2743   // Build the sequence for the graph.
2744   LPlatformChunk* Build();
2745
2746   // Declare methods that deal with the individual node types.
2747 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2748   HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2749 #undef DECLARE_DO
2750
2751   LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2752
2753   static bool HasMagicNumberForDivisor(int32_t divisor);
2754
2755   LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2756   LInstruction* DoMathRound(HUnaryMathOperation* instr);
2757   LInstruction* DoMathFround(HUnaryMathOperation* instr);
2758   LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2759   LInstruction* DoMathLog(HUnaryMathOperation* instr);
2760   LInstruction* DoMathExp(HUnaryMathOperation* instr);
2761   LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2762   LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2763   LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2764   LInstruction* DoDivByPowerOf2I(HDiv* instr);
2765   LInstruction* DoDivByConstI(HDiv* instr);
2766   LInstruction* DoDivI(HDiv* instr);
2767   LInstruction* DoModByPowerOf2I(HMod* instr);
2768   LInstruction* DoModByConstI(HMod* instr);
2769   LInstruction* DoModI(HMod* instr);
2770   LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2771   LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2772   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2773
2774  private:
2775   // Methods for getting operands for Use / Define / Temp.
2776   LUnallocated* ToUnallocated(Register reg);
2777   LUnallocated* ToUnallocated(DoubleRegister reg);
2778
2779   // Methods for setting up define-use relationships.
2780   MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2781   MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2782   MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2783                                            DoubleRegister fixed_register);
2784
2785   // A value that is guaranteed to be allocated to a register.
2786   // Operand created by UseRegister is guaranteed to be live until the end of
2787   // instruction. This means that register allocator will not reuse it's
2788   // register for any other operand inside instruction.
2789   // Operand created by UseRegisterAtStart is guaranteed to be live only at
2790   // instruction start. Register allocator is free to assign the same register
2791   // to some other operand used inside instruction (i.e. temporary or
2792   // output).
2793   MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2794   MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2795
2796   // An input operand in a register that may be trashed.
2797   MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2798
2799   // An input operand in a register or stack slot.
2800   MUST_USE_RESULT LOperand* Use(HValue* value);
2801   MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2802
2803   // An input operand in a register, stack slot or a constant operand.
2804   MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2805   MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2806
2807   // An input operand in a register or a constant operand.
2808   MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2809   MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2810
2811   // An input operand in a constant operand.
2812   MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2813
2814   // An input operand in register, stack slot or a constant operand.
2815   // Will not be moved to a register even if one is freely available.
2816   MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2817
2818   // Temporary operand that must be in a register.
2819   MUST_USE_RESULT LUnallocated* TempRegister();
2820   MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2821   MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2822   MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2823
2824   // Methods for setting up define-use relationships.
2825   // Return the same instruction that they are passed.
2826   LInstruction* Define(LTemplateResultInstruction<1>* instr,
2827                        LUnallocated* result);
2828   LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2829   LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2830                                 int index);
2831   LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2832   LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2833                             Register reg);
2834   LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2835                                   DoubleRegister reg);
2836   LInstruction* AssignEnvironment(LInstruction* instr);
2837   LInstruction* AssignPointerMap(LInstruction* instr);
2838
2839   enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2840
2841   // By default we assume that instruction sequences generated for calls
2842   // cannot deoptimize eagerly and we do not attach environment to this
2843   // instruction.
2844   LInstruction* MarkAsCall(
2845       LInstruction* instr,
2846       HInstruction* hinstr,
2847       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2848
2849   void VisitInstruction(HInstruction* current);
2850   void AddInstruction(LInstruction* instr, HInstruction* current);
2851
2852   void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2853   LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2854   LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2855   LInstruction* DoArithmeticD(Token::Value op,
2856                               HArithmeticBinaryOperation* instr);
2857   LInstruction* DoArithmeticT(Token::Value op,
2858                               HBinaryOperation* instr);
2859
2860   HInstruction* current_instruction_;
2861   HBasicBlock* current_block_;
2862   HBasicBlock* next_block_;
2863   LAllocator* allocator_;
2864
2865   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2866 };
2867
2868 #undef DECLARE_HYDROGEN_ACCESSOR
2869 #undef DECLARE_CONCRETE_INSTRUCTION
2870
2871 } }  // namespace v8::internal
2872
2873 #endif  // V8_MIPS_LITHIUM_MIPS_H_