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