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