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