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