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