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