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