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