blob: 68541a48c45455a876e1ebd6cf1ac56b5b08eee1 [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) \
74 V(FlooringDivByConstI) \
75 V(FlooringDivByPowerOf2I) \
76 V(FlooringDivI) \
77 V(ForInCacheArray) \
78 V(ForInPrepareMap) \
79 V(GetCachedArrayIndex) \
80 V(Goto) \
81 V(HasCachedArrayIndexAndBranch) \
82 V(HasInPrototypeChainAndBranch) \
83 V(HasInstanceTypeAndBranch) \
84 V(InnerAllocatedObject) \
85 V(InstanceOf) \
86 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
1142class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1143 public:
1144 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1145 inputs_[0] = context;
1146 inputs_[1] = left;
1147 inputs_[2] = right;
1148 }
1149
1150 LOperand* context() const { return inputs_[0]; }
1151 LOperand* left() const { return inputs_[1]; }
1152 LOperand* right() const { return inputs_[2]; }
1153
1154 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1155};
1156
1157
1158class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 1> {
1159 public:
1160 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype,
1161 LOperand* scratch) {
1162 inputs_[0] = object;
1163 inputs_[1] = prototype;
1164 temps_[0] = scratch;
1165 }
1166
1167 LOperand* object() const { return inputs_[0]; }
1168 LOperand* prototype() const { return inputs_[1]; }
1169 LOperand* scratch() const { return temps_[0]; }
1170
1171 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1172 "has-in-prototype-chain-and-branch")
1173 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1174};
1175
1176
1177class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1178 public:
1179 LBoundsCheck(LOperand* index, LOperand* length) {
1180 inputs_[0] = index;
1181 inputs_[1] = length;
1182 }
1183
1184 LOperand* index() { return inputs_[0]; }
1185 LOperand* length() { return inputs_[1]; }
1186
1187 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1188 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1189};
1190
1191
1192class LBitI final : public LTemplateInstruction<1, 2, 0> {
1193 public:
1194 LBitI(LOperand* left, LOperand* right) {
1195 inputs_[0] = left;
1196 inputs_[1] = right;
1197 }
1198
1199 LOperand* left() { return inputs_[0]; }
1200 LOperand* right() { return inputs_[1]; }
1201
1202 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1203 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1204
1205 Token::Value op() const { return hydrogen()->op(); }
1206};
1207
1208
1209class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1210 public:
1211 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1212 : op_(op), can_deopt_(can_deopt) {
1213 inputs_[0] = left;
1214 inputs_[1] = right;
1215 }
1216
1217 LOperand* left() { return inputs_[0]; }
1218 LOperand* right() { return inputs_[1]; }
1219
1220 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1221
1222 Token::Value op() const { return op_; }
1223 bool can_deopt() const { return can_deopt_; }
1224
1225 private:
1226 Token::Value op_;
1227 bool can_deopt_;
1228};
1229
1230
1231class LSubI final : public LTemplateInstruction<1, 2, 0> {
1232 public:
1233 LSubI(LOperand* left, LOperand* right) {
1234 inputs_[0] = left;
1235 inputs_[1] = right;
1236 }
1237
1238 LOperand* left() { return inputs_[0]; }
1239 LOperand* right() { return inputs_[1]; }
1240
1241 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1242 DECLARE_HYDROGEN_ACCESSOR(Sub)
1243};
1244
1245
1246class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1247 public:
1248 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1249 DECLARE_HYDROGEN_ACCESSOR(Constant)
1250
1251 int32_t value() const { return hydrogen()->Integer32Value(); }
1252};
1253
1254
1255class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1256 public:
1257 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1258 DECLARE_HYDROGEN_ACCESSOR(Constant)
1259
1260 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1261};
1262
1263
1264class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1265 public:
1266 explicit LConstantD(LOperand* temp) {
1267 temps_[0] = temp;
1268 }
1269
1270 LOperand* temp() { return temps_[0]; }
1271
1272 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1273 DECLARE_HYDROGEN_ACCESSOR(Constant)
1274
1275 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1276};
1277
1278
1279class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1280 public:
1281 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1282 DECLARE_HYDROGEN_ACCESSOR(Constant)
1283
1284 ExternalReference value() const {
1285 return hydrogen()->ExternalReferenceValue();
1286 }
1287};
1288
1289
1290class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1291 public:
1292 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1293 DECLARE_HYDROGEN_ACCESSOR(Constant)
1294
1295 Handle<Object> value(Isolate* isolate) const {
1296 return hydrogen()->handle(isolate);
1297 }
1298};
1299
1300
1301class LBranch final : public LControlInstruction<1, 1> {
1302 public:
1303 LBranch(LOperand* value, LOperand* temp) {
1304 inputs_[0] = value;
1305 temps_[0] = temp;
1306 }
1307
1308 LOperand* value() { return inputs_[0]; }
1309 LOperand* temp() { return temps_[0]; }
1310
1311 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1312 DECLARE_HYDROGEN_ACCESSOR(Branch)
1313
1314 void PrintDataTo(StringStream* stream) override;
1315};
1316
1317
1318class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1319 public:
1320 explicit LCmpMapAndBranch(LOperand* value) {
1321 inputs_[0] = value;
1322 }
1323
1324 LOperand* value() { return inputs_[0]; }
1325
1326 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1327 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1328
1329 Handle<Map> map() const { return hydrogen()->map().handle(); }
1330};
1331
1332
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001333class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1334 public:
1335 LSeqStringGetChar(LOperand* string, LOperand* index) {
1336 inputs_[0] = string;
1337 inputs_[1] = index;
1338 }
1339
1340 LOperand* string() const { return inputs_[0]; }
1341 LOperand* index() const { return inputs_[1]; }
1342
1343 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1344 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1345};
1346
1347
1348class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1349 public:
1350 LSeqStringSetChar(LOperand* context,
1351 LOperand* string,
1352 LOperand* index,
1353 LOperand* value) {
1354 inputs_[0] = context;
1355 inputs_[1] = string;
1356 inputs_[2] = index;
1357 inputs_[3] = value;
1358 }
1359
1360 LOperand* string() { return inputs_[1]; }
1361 LOperand* index() { return inputs_[2]; }
1362 LOperand* value() { return inputs_[3]; }
1363
1364 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1365 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1366};
1367
1368
1369class LAddI final : public LTemplateInstruction<1, 2, 0> {
1370 public:
1371 LAddI(LOperand* left, LOperand* right) {
1372 inputs_[0] = left;
1373 inputs_[1] = right;
1374 }
1375
1376 LOperand* left() { return inputs_[0]; }
1377 LOperand* right() { return inputs_[1]; }
1378
1379 static bool UseLea(HAdd* add) {
1380 return !add->CheckFlag(HValue::kCanOverflow) &&
1381 add->BetterLeftOperand()->UseCount() > 1;
1382 }
1383
1384 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1385 DECLARE_HYDROGEN_ACCESSOR(Add)
1386};
1387
1388
1389class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1390 public:
1391 LMathMinMax(LOperand* left, LOperand* right) {
1392 inputs_[0] = left;
1393 inputs_[1] = right;
1394 }
1395
1396 LOperand* left() { return inputs_[0]; }
1397 LOperand* right() { return inputs_[1]; }
1398
1399 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1400 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1401};
1402
1403
1404class LPower final : public LTemplateInstruction<1, 2, 0> {
1405 public:
1406 LPower(LOperand* left, LOperand* right) {
1407 inputs_[0] = left;
1408 inputs_[1] = right;
1409 }
1410
1411 LOperand* left() { return inputs_[0]; }
1412 LOperand* right() { return inputs_[1]; }
1413
1414 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1415 DECLARE_HYDROGEN_ACCESSOR(Power)
1416};
1417
1418
1419class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1420 public:
1421 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1422 : op_(op) {
1423 inputs_[0] = left;
1424 inputs_[1] = right;
1425 }
1426
1427 LOperand* left() { return inputs_[0]; }
1428 LOperand* right() { return inputs_[1]; }
1429
1430 Token::Value op() const { return op_; }
1431
1432 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1433 void CompileToNative(LCodeGen* generator) override;
1434 const char* Mnemonic() const override;
1435
1436 private:
1437 Token::Value op_;
1438};
1439
1440
1441class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1442 public:
1443 LArithmeticT(Token::Value op,
1444 LOperand* context,
1445 LOperand* left,
1446 LOperand* right)
1447 : op_(op) {
1448 inputs_[0] = context;
1449 inputs_[1] = left;
1450 inputs_[2] = right;
1451 }
1452
1453 LOperand* context() { return inputs_[0]; }
1454 LOperand* left() { return inputs_[1]; }
1455 LOperand* right() { return inputs_[2]; }
1456 Token::Value op() const { return op_; }
1457
1458 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1459 void CompileToNative(LCodeGen* generator) override;
1460 const char* Mnemonic() const override;
1461
1462 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1463
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001464 private:
1465 Token::Value op_;
1466};
1467
1468
1469class LReturn final : public LTemplateInstruction<0, 3, 0> {
1470 public:
1471 explicit LReturn(LOperand* value,
1472 LOperand* context,
1473 LOperand* parameter_count) {
1474 inputs_[0] = value;
1475 inputs_[1] = context;
1476 inputs_[2] = parameter_count;
1477 }
1478
1479 bool has_constant_parameter_count() {
1480 return parameter_count()->IsConstantOperand();
1481 }
1482 LConstantOperand* constant_parameter_count() {
1483 DCHECK(has_constant_parameter_count());
1484 return LConstantOperand::cast(parameter_count());
1485 }
1486 LOperand* parameter_count() { return inputs_[2]; }
1487
1488 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1489 DECLARE_HYDROGEN_ACCESSOR(Return)
1490};
1491
1492
1493class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1494 public:
1495 explicit LLoadNamedField(LOperand* object) {
1496 inputs_[0] = object;
1497 }
1498
1499 LOperand* object() { return inputs_[0]; }
1500
1501 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1502 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1503};
1504
1505
1506class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1507 public:
1508 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1509 inputs_[0] = context;
1510 inputs_[1] = object;
1511 temps_[0] = vector;
1512 }
1513
1514 LOperand* context() { return inputs_[0]; }
1515 LOperand* object() { return inputs_[1]; }
1516 LOperand* temp_vector() { return temps_[0]; }
1517
1518 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1519 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1520
1521 Handle<Object> name() const { return hydrogen()->name(); }
1522};
1523
1524
1525class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1526 public:
1527 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1528 inputs_[0] = function;
1529 temps_[0] = temp;
1530 }
1531
1532 LOperand* function() { return inputs_[0]; }
1533 LOperand* temp() { return temps_[0]; }
1534
1535 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1536 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1537};
1538
1539
1540class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1541 public:
1542 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1543 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1544
1545 Heap::RootListIndex index() const { return hydrogen()->index(); }
1546};
1547
1548
1549class LLoadKeyed final : public LTemplateInstruction<1, 3, 0> {
1550 public:
1551 LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
1552 inputs_[0] = elements;
1553 inputs_[1] = key;
1554 inputs_[2] = backing_store_owner;
1555 }
1556 LOperand* elements() { return inputs_[0]; }
1557 LOperand* key() { return inputs_[1]; }
1558 LOperand* backing_store_owner() { return inputs_[2]; }
1559 ElementsKind elements_kind() const {
1560 return hydrogen()->elements_kind();
1561 }
1562 bool is_fixed_typed_array() const {
1563 return hydrogen()->is_fixed_typed_array();
1564 }
1565
1566 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1568
1569 void PrintDataTo(StringStream* stream) override;
1570 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1571 bool key_is_smi() {
1572 return hydrogen()->key()->representation().IsTagged();
1573 }
1574};
1575
1576
1577inline static bool ExternalArrayOpRequiresTemp(
1578 Representation key_representation,
1579 ElementsKind elements_kind) {
1580 // Operations that require the key to be divided by two to be converted into
1581 // an index cannot fold the scale operation into a load and need an extra
1582 // temp register to do the work.
1583 return key_representation.IsSmi() &&
1584 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1585 elements_kind == UINT8_CLAMPED_ELEMENTS);
1586}
1587
1588
1589class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1590 public:
1591 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1592 LOperand* vector) {
1593 inputs_[0] = context;
1594 inputs_[1] = obj;
1595 inputs_[2] = key;
1596 temps_[0] = vector;
1597 }
1598
1599 LOperand* context() { return inputs_[0]; }
1600 LOperand* object() { return inputs_[1]; }
1601 LOperand* key() { return inputs_[2]; }
1602 LOperand* temp_vector() { return temps_[0]; }
1603
1604 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1606};
1607
1608
1609class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1610 public:
1611 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1612 LOperand* vector) {
1613 inputs_[0] = context;
1614 inputs_[1] = global_object;
1615 temps_[0] = vector;
1616 }
1617
1618 LOperand* context() { return inputs_[0]; }
1619 LOperand* global_object() { return inputs_[1]; }
1620 LOperand* temp_vector() { return temps_[0]; }
1621
1622 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1623 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1624
1625 Handle<Object> name() const { return hydrogen()->name(); }
1626 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1627};
1628
1629
1630class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1631 public:
1632 explicit LLoadContextSlot(LOperand* context) {
1633 inputs_[0] = context;
1634 }
1635
1636 LOperand* context() { return inputs_[0]; }
1637
1638 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1639 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1640
1641 int slot_index() { return hydrogen()->slot_index(); }
1642
1643 void PrintDataTo(StringStream* stream) override;
1644};
1645
1646
1647class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1648 public:
1649 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1650 inputs_[0] = context;
1651 inputs_[1] = value;
1652 temps_[0] = temp;
1653 }
1654
1655 LOperand* context() { return inputs_[0]; }
1656 LOperand* value() { return inputs_[1]; }
1657 LOperand* temp() { return temps_[0]; }
1658
1659 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1660 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1661
1662 int slot_index() { return hydrogen()->slot_index(); }
1663
1664 void PrintDataTo(StringStream* stream) override;
1665};
1666
1667
1668class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1669 public:
1670 explicit LPushArgument(LOperand* value) {
1671 inputs_[0] = value;
1672 }
1673
1674 LOperand* value() { return inputs_[0]; }
1675
1676 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1677};
1678
1679
1680class LDrop final : public LTemplateInstruction<0, 0, 0> {
1681 public:
1682 explicit LDrop(int count) : count_(count) { }
1683
1684 int count() const { return count_; }
1685
1686 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1687
1688 private:
1689 int count_;
1690};
1691
1692
1693class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1694 public:
1695 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1696 inputs_[0] = function;
1697 inputs_[1] = code_object;
1698 }
1699
1700 LOperand* function() { return inputs_[0]; }
1701 LOperand* code_object() { return inputs_[1]; }
1702
1703 void PrintDataTo(StringStream* stream) override;
1704
1705 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1706 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1707};
1708
1709
1710class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1711 public:
1712 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1713 inputs_[0] = base_object;
1714 inputs_[1] = offset;
1715 }
1716
1717 LOperand* base_object() const { return inputs_[0]; }
1718 LOperand* offset() const { return inputs_[1]; }
1719
1720 void PrintDataTo(StringStream* stream) override;
1721
1722 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1723};
1724
1725
1726class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1727 public:
1728 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1729 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1730};
1731
1732
1733class LContext final : public LTemplateInstruction<1, 0, 0> {
1734 public:
1735 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1736 DECLARE_HYDROGEN_ACCESSOR(Context)
1737};
1738
1739
1740class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1741 public:
1742 explicit LDeclareGlobals(LOperand* context) {
1743 inputs_[0] = context;
1744 }
1745
1746 LOperand* context() { return inputs_[0]; }
1747
1748 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1749 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1750};
1751
1752
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001753class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1754 public:
1755 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1756 const ZoneList<LOperand*>& operands, Zone* zone)
1757 : inputs_(descriptor.GetRegisterParameterCount() +
1758 kImplicitRegisterParameterCount,
1759 zone) {
1760 DCHECK(descriptor.GetRegisterParameterCount() +
1761 kImplicitRegisterParameterCount ==
1762 operands.length());
1763 inputs_.AddAll(operands, zone);
1764 }
1765
1766 LOperand* target() const { return inputs_[0]; }
1767
1768 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1769
1770 // The target and context are passed as implicit parameters that are not
1771 // explicitly listed in the descriptor.
1772 static const int kImplicitRegisterParameterCount = 2;
1773
1774 private:
1775 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1776
1777 void PrintDataTo(StringStream* stream) override;
1778
1779 int arity() const { return hydrogen()->argument_count() - 1; }
1780
1781 ZoneList<LOperand*> inputs_;
1782
1783 // Iterator support.
1784 int InputCount() final { return inputs_.length(); }
1785 LOperand* InputAt(int i) final { return inputs_[i]; }
1786
1787 int TempCount() final { return 0; }
1788 LOperand* TempAt(int i) final { return NULL; }
1789};
1790
1791
1792class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1793 public:
1794 LInvokeFunction(LOperand* context, LOperand* function) {
1795 inputs_[0] = context;
1796 inputs_[1] = function;
1797 }
1798
1799 LOperand* context() { return inputs_[0]; }
1800 LOperand* function() { return inputs_[1]; }
1801
1802 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1803 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1804
1805 void PrintDataTo(StringStream* stream) override;
1806
1807 int arity() const { return hydrogen()->argument_count() - 1; }
1808};
1809
1810
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001811class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1812 public:
1813 LCallNewArray(LOperand* context, LOperand* constructor) {
1814 inputs_[0] = context;
1815 inputs_[1] = constructor;
1816 }
1817
1818 LOperand* context() { return inputs_[0]; }
1819 LOperand* constructor() { return inputs_[1]; }
1820
1821 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1822 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1823
1824 void PrintDataTo(StringStream* stream) override;
1825
1826 int arity() const { return hydrogen()->argument_count() - 1; }
1827};
1828
1829
1830class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1831 public:
1832 explicit LCallRuntime(LOperand* context) {
1833 inputs_[0] = context;
1834 }
1835
1836 LOperand* context() { return inputs_[0]; }
1837
1838 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1839 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1840
1841 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1842 return save_doubles() == kDontSaveFPRegs;
1843 }
1844
1845 const Runtime::Function* function() const { return hydrogen()->function(); }
1846 int arity() const { return hydrogen()->argument_count(); }
1847 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1848};
1849
1850
1851class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1852 public:
1853 explicit LInteger32ToDouble(LOperand* value) {
1854 inputs_[0] = value;
1855 }
1856
1857 LOperand* value() { return inputs_[0]; }
1858
1859 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1860};
1861
1862
1863class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1864 public:
1865 explicit LUint32ToDouble(LOperand* value) {
1866 inputs_[0] = value;
1867 }
1868
1869 LOperand* value() { return inputs_[0]; }
1870
1871 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1872};
1873
1874
1875class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
1876 public:
1877 LNumberTagI(LOperand* value, LOperand* temp) {
1878 inputs_[0] = value;
1879 temps_[0] = temp;
1880 }
1881
1882 LOperand* value() { return inputs_[0]; }
1883 LOperand* temp() { return temps_[0]; }
1884
1885 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1886};
1887
1888
1889class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
1890 public:
1891 LNumberTagU(LOperand* value, LOperand* temp) {
1892 inputs_[0] = value;
1893 temps_[0] = temp;
1894 }
1895
1896 LOperand* value() { return inputs_[0]; }
1897 LOperand* temp() { return temps_[0]; }
1898
1899 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1900};
1901
1902
1903class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
1904 public:
1905 LNumberTagD(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(NumberTagD, "number-tag-d")
1914 DECLARE_HYDROGEN_ACCESSOR(Change)
1915};
1916
1917
1918// Sometimes truncating conversion from a tagged value to an int32.
1919class LDoubleToI final : public LTemplateInstruction<1, 1, 1> {
1920 public:
1921 LDoubleToI(LOperand* value, LOperand* temp) {
1922 inputs_[0] = value;
1923 temps_[0] = temp;
1924 }
1925
1926 LOperand* value() { return inputs_[0]; }
1927 LOperand* temp() { return temps_[0]; }
1928
1929 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1930 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1931
1932 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1933};
1934
1935
1936class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
1937 public:
1938 explicit LDoubleToSmi(LOperand* value) {
1939 inputs_[0] = value;
1940 }
1941
1942 LOperand* value() { return inputs_[0]; }
1943
1944 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1945 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1946};
1947
1948
1949// Truncating conversion from a tagged value to an int32.
1950class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
1951 public:
1952 LTaggedToI(LOperand* value, LOperand* temp) {
1953 inputs_[0] = value;
1954 temps_[0] = temp;
1955 }
1956
1957 LOperand* value() { return inputs_[0]; }
1958 LOperand* temp() { return temps_[0]; }
1959
1960 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1961 DECLARE_HYDROGEN_ACCESSOR(Change)
1962
1963 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1964};
1965
1966
1967class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
1968 public:
1969 explicit LSmiTag(LOperand* value) {
1970 inputs_[0] = value;
1971 }
1972
1973 LOperand* value() { return inputs_[0]; }
1974
1975 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1976 DECLARE_HYDROGEN_ACCESSOR(Change)
1977};
1978
1979
1980class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
1981 public:
1982 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
1983 inputs_[0] = value;
1984 temps_[0] = temp;
1985 }
1986
1987 LOperand* value() { return inputs_[0]; }
1988 LOperand* temp() { return temps_[0]; }
1989
1990 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1991 DECLARE_HYDROGEN_ACCESSOR(Change);
1992};
1993
1994
1995class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
1996 public:
1997 LSmiUntag(LOperand* value, bool needs_check)
1998 : needs_check_(needs_check) {
1999 inputs_[0] = value;
2000 }
2001
2002 LOperand* value() { return inputs_[0]; }
2003
2004 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2005
2006 bool needs_check() const { return needs_check_; }
2007
2008 private:
2009 bool needs_check_;
2010};
2011
2012
2013class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2014 public:
2015 LStoreNamedField(LOperand* obj,
2016 LOperand* val,
2017 LOperand* temp,
2018 LOperand* temp_map) {
2019 inputs_[0] = obj;
2020 inputs_[1] = val;
2021 temps_[0] = temp;
2022 temps_[1] = temp_map;
2023 }
2024
2025 LOperand* object() { return inputs_[0]; }
2026 LOperand* value() { return inputs_[1]; }
2027 LOperand* temp() { return temps_[0]; }
2028 LOperand* temp_map() { return temps_[1]; }
2029
2030 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2031 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2032
2033 void PrintDataTo(StringStream* stream) override;
2034};
2035
2036
2037class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2038 public:
2039 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2040 LOperand* slot, LOperand* vector) {
2041 inputs_[0] = context;
2042 inputs_[1] = object;
2043 inputs_[2] = value;
2044 temps_[0] = slot;
2045 temps_[1] = vector;
2046 }
2047
2048 LOperand* context() { return inputs_[0]; }
2049 LOperand* object() { return inputs_[1]; }
2050 LOperand* value() { return inputs_[2]; }
2051 LOperand* temp_slot() { return temps_[0]; }
2052 LOperand* temp_vector() { return temps_[1]; }
2053
2054 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2055 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2056
2057 void PrintDataTo(StringStream* stream) override;
2058 Handle<Object> name() const { return hydrogen()->name(); }
2059 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2060};
2061
2062
2063class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> {
2064 public:
2065 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val,
2066 LOperand* backing_store_owner) {
2067 inputs_[0] = obj;
2068 inputs_[1] = key;
2069 inputs_[2] = val;
2070 inputs_[3] = backing_store_owner;
2071 }
2072
2073 bool is_fixed_typed_array() const {
2074 return hydrogen()->is_fixed_typed_array();
2075 }
2076 LOperand* elements() { return inputs_[0]; }
2077 LOperand* key() { return inputs_[1]; }
2078 LOperand* value() { return inputs_[2]; }
2079 LOperand* backing_store_owner() { return inputs_[3]; }
2080 ElementsKind elements_kind() const {
2081 return hydrogen()->elements_kind();
2082 }
2083
2084 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2085 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2086
2087 void PrintDataTo(StringStream* stream) override;
2088 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2089 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2090};
2091
2092
2093class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2094 public:
2095 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2096 LOperand* value, LOperand* slot, LOperand* vector) {
2097 inputs_[0] = context;
2098 inputs_[1] = object;
2099 inputs_[2] = key;
2100 inputs_[3] = value;
2101 temps_[0] = slot;
2102 temps_[1] = vector;
2103 }
2104
2105 LOperand* context() { return inputs_[0]; }
2106 LOperand* object() { return inputs_[1]; }
2107 LOperand* key() { return inputs_[2]; }
2108 LOperand* value() { return inputs_[3]; }
2109 LOperand* temp_slot() { return temps_[0]; }
2110 LOperand* temp_vector() { return temps_[1]; }
2111
2112 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2113 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2114
2115 void PrintDataTo(StringStream* stream) override;
2116
2117 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2118};
2119
2120
2121class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2122 public:
2123 LTransitionElementsKind(LOperand* object,
2124 LOperand* context,
2125 LOperand* new_map_temp,
2126 LOperand* temp) {
2127 inputs_[0] = object;
2128 inputs_[1] = context;
2129 temps_[0] = new_map_temp;
2130 temps_[1] = temp;
2131 }
2132
2133 LOperand* context() { return inputs_[1]; }
2134 LOperand* object() { return inputs_[0]; }
2135 LOperand* new_map_temp() { return temps_[0]; }
2136 LOperand* temp() { return temps_[1]; }
2137
2138 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2139 "transition-elements-kind")
2140 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2141
2142 void PrintDataTo(StringStream* stream) override;
2143
2144 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2145 Handle<Map> transitioned_map() {
2146 return hydrogen()->transitioned_map().handle();
2147 }
2148 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2149 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2150};
2151
2152
2153class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2154 public:
2155 LTrapAllocationMemento(LOperand* object,
2156 LOperand* temp) {
2157 inputs_[0] = object;
2158 temps_[0] = temp;
2159 }
2160
2161 LOperand* object() { return inputs_[0]; }
2162 LOperand* temp() { return temps_[0]; }
2163
2164 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2165 "trap-allocation-memento")
2166};
2167
2168
2169class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2170 public:
2171 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2172 LOperand* key, LOperand* current_capacity) {
2173 inputs_[0] = context;
2174 inputs_[1] = object;
2175 inputs_[2] = elements;
2176 inputs_[3] = key;
2177 inputs_[4] = current_capacity;
2178 }
2179
2180 LOperand* context() { return inputs_[0]; }
2181 LOperand* object() { return inputs_[1]; }
2182 LOperand* elements() { return inputs_[2]; }
2183 LOperand* key() { return inputs_[3]; }
2184 LOperand* current_capacity() { return inputs_[4]; }
2185
2186 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2187 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2188};
2189
2190
2191class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2192 public:
2193 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2194 inputs_[0] = context;
2195 inputs_[1] = left;
2196 inputs_[2] = right;
2197 }
2198
2199 LOperand* context() { return inputs_[0]; }
2200 LOperand* left() { return inputs_[1]; }
2201 LOperand* right() { return inputs_[2]; }
2202
2203 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2204 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2205};
2206
2207
2208class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2209 public:
2210 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2211 inputs_[0] = context;
2212 inputs_[1] = string;
2213 inputs_[2] = index;
2214 }
2215
2216 LOperand* context() { return inputs_[0]; }
2217 LOperand* string() { return inputs_[1]; }
2218 LOperand* index() { return inputs_[2]; }
2219
2220 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2221 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2222};
2223
2224
2225class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2226 public:
2227 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2228 inputs_[0] = context;
2229 inputs_[1] = char_code;
2230 }
2231
2232 LOperand* context() { return inputs_[0]; }
2233 LOperand* char_code() { return inputs_[1]; }
2234
2235 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2236 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2237};
2238
2239
2240class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2241 public:
2242 explicit LCheckValue(LOperand* value) {
2243 inputs_[0] = value;
2244 }
2245
2246 LOperand* value() { return inputs_[0]; }
2247
2248 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2249 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2250};
2251
2252
2253class LCheckArrayBufferNotNeutered final
2254 : public LTemplateInstruction<0, 1, 1> {
2255 public:
2256 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2257 inputs_[0] = view;
2258 temps_[0] = scratch;
2259 }
2260
2261 LOperand* view() { return inputs_[0]; }
2262 LOperand* scratch() { return temps_[0]; }
2263
2264 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2265 "check-array-buffer-not-neutered")
2266 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2267};
2268
2269
2270class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2271 public:
2272 LCheckInstanceType(LOperand* value, LOperand* temp) {
2273 inputs_[0] = value;
2274 temps_[0] = temp;
2275 }
2276
2277 LOperand* value() { return inputs_[0]; }
2278 LOperand* temp() { return temps_[0]; }
2279
2280 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2281 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2282};
2283
2284
2285class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2286 public:
2287 explicit LCheckMaps(LOperand* value = NULL) {
2288 inputs_[0] = value;
2289 }
2290
2291 LOperand* value() { return inputs_[0]; }
2292
2293 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2294 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2295};
2296
2297
2298class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2299 public:
2300 explicit LCheckSmi(LOperand* value) {
2301 inputs_[0] = value;
2302 }
2303
2304 LOperand* value() { return inputs_[0]; }
2305
2306 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2307};
2308
2309
2310class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2311 public:
2312 explicit LClampDToUint8(LOperand* value) {
2313 inputs_[0] = value;
2314 }
2315
2316 LOperand* unclamped() { return inputs_[0]; }
2317
2318 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2319};
2320
2321
2322class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2323 public:
2324 explicit LClampIToUint8(LOperand* value) {
2325 inputs_[0] = value;
2326 }
2327
2328 LOperand* unclamped() { return inputs_[0]; }
2329
2330 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2331};
2332
2333
2334class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2335 public:
2336 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2337 inputs_[0] = value;
2338 temps_[0] = temp_xmm;
2339 }
2340
2341 LOperand* unclamped() { return inputs_[0]; }
2342 LOperand* temp_xmm() { return temps_[0]; }
2343
2344 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2345};
2346
2347
2348class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2349 public:
2350 explicit LCheckNonSmi(LOperand* value) {
2351 inputs_[0] = value;
2352 }
2353
2354 LOperand* value() { return inputs_[0]; }
2355
2356 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2357 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2358};
2359
2360
2361class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2362 public:
2363 explicit LDoubleBits(LOperand* value) {
2364 inputs_[0] = value;
2365 }
2366
2367 LOperand* value() { return inputs_[0]; }
2368
2369 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2370 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2371};
2372
2373
2374class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2375 public:
2376 LConstructDouble(LOperand* hi, LOperand* lo) {
2377 inputs_[0] = hi;
2378 inputs_[1] = lo;
2379 }
2380
2381 LOperand* hi() { return inputs_[0]; }
2382 LOperand* lo() { return inputs_[1]; }
2383
2384 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2385};
2386
2387
2388class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2389 public:
2390 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2391 inputs_[0] = context;
2392 inputs_[1] = size;
2393 temps_[0] = temp;
2394 }
2395
2396 LOperand* context() { return inputs_[0]; }
2397 LOperand* size() { return inputs_[1]; }
2398 LOperand* temp() { return temps_[0]; }
2399
2400 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2401 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2402};
2403
2404
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002405class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2406 public:
2407 LTypeof(LOperand* context, LOperand* value) {
2408 inputs_[0] = context;
2409 inputs_[1] = value;
2410 }
2411
2412 LOperand* context() { return inputs_[0]; }
2413 LOperand* value() { return inputs_[1]; }
2414
2415 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2416};
2417
2418
2419class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2420 public:
2421 explicit LTypeofIsAndBranch(LOperand* value) {
2422 inputs_[0] = value;
2423 }
2424
2425 LOperand* value() { return inputs_[0]; }
2426
2427 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2428 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2429
2430 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2431
2432 void PrintDataTo(StringStream* stream) override;
2433};
2434
2435
2436class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2437 public:
2438 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2439 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2440};
2441
2442
2443class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2444 public:
2445 explicit LStackCheck(LOperand* context) {
2446 inputs_[0] = context;
2447 }
2448
2449 LOperand* context() { return inputs_[0]; }
2450
2451 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2452 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2453
2454 Label* done_label() { return &done_label_; }
2455
2456 private:
2457 Label done_label_;
2458};
2459
2460
2461class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2462 public:
2463 LForInPrepareMap(LOperand* context, LOperand* object) {
2464 inputs_[0] = context;
2465 inputs_[1] = object;
2466 }
2467
2468 LOperand* context() { return inputs_[0]; }
2469 LOperand* object() { return inputs_[1]; }
2470
2471 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2472};
2473
2474
2475class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2476 public:
2477 explicit LForInCacheArray(LOperand* map) {
2478 inputs_[0] = map;
2479 }
2480
2481 LOperand* map() { return inputs_[0]; }
2482
2483 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2484
2485 int idx() {
2486 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2487 }
2488};
2489
2490
2491class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2492 public:
2493 LCheckMapValue(LOperand* value, LOperand* map) {
2494 inputs_[0] = value;
2495 inputs_[1] = map;
2496 }
2497
2498 LOperand* value() { return inputs_[0]; }
2499 LOperand* map() { return inputs_[1]; }
2500
2501 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2502};
2503
2504
2505class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2506 public:
2507 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2508 inputs_[0] = object;
2509 inputs_[1] = index;
2510 }
2511
2512 LOperand* object() { return inputs_[0]; }
2513 LOperand* index() { return inputs_[1]; }
2514
2515 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2516};
2517
2518
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002519class LChunkBuilder;
2520class LPlatformChunk final : public LChunk {
2521 public:
2522 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2523 : LChunk(info, graph),
2524 num_double_slots_(0) { }
2525
2526 int GetNextSpillIndex(RegisterKind kind);
2527 LOperand* GetNextSpillSlot(RegisterKind kind);
2528
2529 int num_double_slots() const { return num_double_slots_; }
2530
2531 private:
2532 int num_double_slots_;
2533};
2534
2535
2536class LChunkBuilder final : public LChunkBuilderBase {
2537 public:
2538 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2539 : LChunkBuilderBase(info, graph),
2540 current_instruction_(NULL),
2541 current_block_(NULL),
2542 next_block_(NULL),
2543 allocator_(allocator) {}
2544
2545 // Build the sequence for the graph.
2546 LPlatformChunk* Build();
2547
2548 // Declare methods that deal with the individual node types.
2549#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2550 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2551#undef DECLARE_DO
2552
2553 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2554 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2555 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2556 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2557 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2558 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2559 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2560 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2561 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2562 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2563 LInstruction* DoDivByConstI(HDiv* instr);
2564 LInstruction* DoDivI(HDiv* instr);
2565 LInstruction* DoModByPowerOf2I(HMod* instr);
2566 LInstruction* DoModByConstI(HMod* instr);
2567 LInstruction* DoModI(HMod* instr);
2568 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2569 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2570 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2571
2572 private:
2573 // Methods for getting operands for Use / Define / Temp.
2574 LUnallocated* ToUnallocated(Register reg);
2575 LUnallocated* ToUnallocated(XMMRegister reg);
2576
2577 // Methods for setting up define-use relationships.
2578 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2579 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2580 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2581 XMMRegister fixed_register);
2582
2583 // A value that is guaranteed to be allocated to a register.
2584 // Operand created by UseRegister is guaranteed to be live until the end of
2585 // instruction. This means that register allocator will not reuse it's
2586 // register for any other operand inside instruction.
2587 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2588 // instruction start. Register allocator is free to assign the same register
2589 // to some other operand used inside instruction (i.e. temporary or
2590 // output).
2591 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2592 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2593
2594 // An input operand in a register that may be trashed.
2595 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2596
2597 // An input operand in a register or stack slot.
2598 MUST_USE_RESULT LOperand* Use(HValue* value);
2599 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2600
2601 // An input operand in a register, stack slot or a constant operand.
2602 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2603 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2604
2605 // An input operand in a fixed register or a constant operand.
2606 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2607 Register fixed_register);
2608
2609 // An input operand in a register or a constant operand.
2610 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2611 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2612
2613 // An input operand in a constant operand.
2614 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2615
2616 // An input operand in register, stack slot or a constant operand.
2617 // Will not be moved to a register even if one is freely available.
2618 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2619
2620 // Temporary operand that must be in a register.
2621 MUST_USE_RESULT LUnallocated* TempRegister();
2622 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2623 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2624
2625 // Methods for setting up define-use relationships.
2626 // Return the same instruction that they are passed.
2627 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2628 LUnallocated* result);
2629 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2630 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2631 int index);
2632 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2633 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2634 Register reg);
2635 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2636 XMMRegister reg);
2637 // Assigns an environment to an instruction. An instruction which can
2638 // deoptimize must have an environment.
2639 LInstruction* AssignEnvironment(LInstruction* instr);
2640 // Assigns a pointer map to an instruction. An instruction which can
2641 // trigger a GC or a lazy deoptimization must have a pointer map.
2642 LInstruction* AssignPointerMap(LInstruction* instr);
2643
2644 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2645
2646 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2647
2648 // Marks a call for the register allocator. Assigns a pointer map to
2649 // support GC and lazy deoptimization. Assigns an environment to support
2650 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2651 LInstruction* MarkAsCall(
2652 LInstruction* instr,
2653 HInstruction* hinstr,
2654 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2655
2656 void VisitInstruction(HInstruction* current);
2657 void AddInstruction(LInstruction* instr, HInstruction* current);
2658
2659 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2660 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2661 LInstruction* DoArithmeticD(Token::Value op,
2662 HArithmeticBinaryOperation* instr);
2663 LInstruction* DoArithmeticT(Token::Value op,
2664 HBinaryOperation* instr);
2665
2666 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2667
2668 HInstruction* current_instruction_;
2669 HBasicBlock* current_block_;
2670 HBasicBlock* next_block_;
2671 LAllocator* allocator_;
2672
2673 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2674};
2675
2676#undef DECLARE_HYDROGEN_ACCESSOR
2677#undef DECLARE_CONCRETE_INSTRUCTION
2678
2679} // namespace internal
2680} // namespace v8
2681
2682#endif // V8_CRANKSHAFT_IA32_LITHIUM_IA32_H_