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