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