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