1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_PPC_LITHIUM_PPC_H_
6 #define V8_PPC_LITHIUM_PPC_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInPrototypeChainAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsStringAndBranch) \
95 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
102 V(LoadGlobalGeneric) \
103 V(LoadGlobalViaContext) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
119 V(MaybeGrowElements) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
146 V(StoreGlobalViaContext) \
148 V(StoreKeyedGeneric) \
150 V(StoreNamedGeneric) \
152 V(StringCharCodeAt) \
153 V(StringCharFromCode) \
154 V(StringCompareAndBranch) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const final { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) final; \
172 const char* Mnemonic() const final { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { return H##type::cast(hydrogen_value()); }
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {}
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kNumberOfInstructions
202 #undef DECLARE_OPCODE
205 virtual Opcode opcode() const = 0;
207 // Declare non-virtual type testers for all leaf IR classes.
208 #define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211 #undef DECLARE_PREDICATE
213 // Declare virtual predicates for instructions that don't have
215 virtual bool IsGap() const { return false; }
217 virtual bool IsControl() const { return false; }
219 // Try deleting this instruction if possible.
220 virtual bool TryDelete() { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 // Interface to the register allocator and iterators.
244 bool IsMarkedAsCall() const { return IsCall(); }
246 virtual bool HasResult() const = 0;
247 virtual LOperand* result() const = 0;
249 LOperand* FirstInput() { return InputAt(0); }
250 LOperand* Output() { return HasResult() ? result() : NULL; }
252 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
258 virtual int InputCount() = 0;
259 virtual LOperand* InputAt(int i) = 0;
263 friend class InputIterator;
265 friend class TempIterator;
266 virtual int TempCount() = 0;
267 virtual LOperand* TempAt(int i) = 0;
269 class IsCallBits : public BitField<bool, 0, 1> {};
271 LEnvironment* environment_;
272 SetOncePointer<LPointerMap> pointer_map_;
273 HValue* hydrogen_value_;
278 // R = number of result operands (0 or 1).
280 class LTemplateResultInstruction : public LInstruction {
282 // Allow 0 or 1 output operands.
283 STATIC_ASSERT(R == 0 || R == 1);
284 bool HasResult() const final { return R != 0 && result() != NULL; }
285 void set_result(LOperand* operand) { results_[0] = operand; }
286 LOperand* result() const override { return results_[0]; }
289 EmbeddedContainer<LOperand*, R> results_;
293 // R = number of result operands (0 or 1).
294 // I = number of input operands.
295 // T = number of temporary operands.
296 template <int R, int I, int T>
297 class LTemplateInstruction : public LTemplateResultInstruction<R> {
299 EmbeddedContainer<LOperand*, I> inputs_;
300 EmbeddedContainer<LOperand*, T> temps_;
304 int InputCount() final { return I; }
305 LOperand* InputAt(int i) final { return inputs_[i]; }
307 int TempCount() final { return T; }
308 LOperand* TempAt(int i) final { return temps_[i]; }
312 class LGap : public LTemplateInstruction<0, 0, 0> {
314 explicit LGap(HBasicBlock* block) : block_(block) {
315 parallel_moves_[BEFORE] = NULL;
316 parallel_moves_[START] = NULL;
317 parallel_moves_[END] = NULL;
318 parallel_moves_[AFTER] = NULL;
321 // Can't use the DECLARE-macro here because of sub-classes.
322 bool IsGap() const override { return true; }
323 void PrintDataTo(StringStream* stream) override;
324 static LGap* cast(LInstruction* instr) {
325 DCHECK(instr->IsGap());
326 return reinterpret_cast<LGap*>(instr);
329 bool IsRedundant() const;
331 HBasicBlock* block() const { return block_; }
338 FIRST_INNER_POSITION = BEFORE,
339 LAST_INNER_POSITION = AFTER
342 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
343 if (parallel_moves_[pos] == NULL) {
344 parallel_moves_[pos] = new (zone) LParallelMove(zone);
346 return parallel_moves_[pos];
349 LParallelMove* GetParallelMove(InnerPosition pos) {
350 return parallel_moves_[pos];
354 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
359 class LInstructionGap final : public LGap {
361 explicit LInstructionGap(HBasicBlock* block) : LGap(block) {}
363 bool HasInterestingComment(LCodeGen* gen) const override {
364 return !IsRedundant();
367 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
371 class LGoto final : public LTemplateInstruction<0, 0, 0> {
373 explicit LGoto(HBasicBlock* block) : block_(block) {}
375 bool HasInterestingComment(LCodeGen* gen) const override;
376 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
377 void PrintDataTo(StringStream* stream) override;
378 bool IsControl() const override { return true; }
380 int block_id() const { return block_->block_id(); }
387 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
389 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
393 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
395 LLazyBailout() : gap_instructions_size_(0) {}
397 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
399 void set_gap_instructions_size(int gap_instructions_size) {
400 gap_instructions_size_ = gap_instructions_size;
402 int gap_instructions_size() { return gap_instructions_size_; }
405 int gap_instructions_size_;
409 class LDummy final : public LTemplateInstruction<1, 0, 0> {
412 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
416 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
418 explicit LDummyUse(LOperand* value) { inputs_[0] = value; }
419 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
423 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
425 bool IsControl() const override { return true; }
426 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
427 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
431 class LLabel final : public LGap {
433 explicit LLabel(HBasicBlock* block) : LGap(block), replacement_(NULL) {}
435 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
436 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
438 void PrintDataTo(StringStream* stream) override;
440 int block_id() const { return block()->block_id(); }
441 bool is_loop_header() const { return block()->IsLoopHeader(); }
442 bool is_osr_entry() const { return block()->is_osr_entry(); }
443 Label* label() { return &label_; }
444 LLabel* replacement() const { return replacement_; }
445 void set_replacement(LLabel* label) { replacement_ = label; }
446 bool HasReplacement() const { return replacement_ != NULL; }
450 LLabel* replacement_;
454 class LParameter final : public LTemplateInstruction<1, 0, 0> {
456 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
457 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
463 explicit LCallStub(LOperand* context) { inputs_[0] = context; }
465 LOperand* context() { return inputs_[0]; }
467 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
468 DECLARE_HYDROGEN_ACCESSOR(CallStub)
472 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
474 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
475 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
479 template <int I, int T>
480 class LControlInstruction : public LTemplateInstruction<0, I, T> {
482 LControlInstruction() : false_label_(NULL), true_label_(NULL) {}
484 bool IsControl() const final { return true; }
486 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
487 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
489 int TrueDestination(LChunk* chunk) {
490 return chunk->LookupDestination(true_block_id());
492 int FalseDestination(LChunk* chunk) {
493 return chunk->LookupDestination(false_block_id());
496 Label* TrueLabel(LChunk* chunk) {
497 if (true_label_ == NULL) {
498 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
502 Label* FalseLabel(LChunk* chunk) {
503 if (false_label_ == NULL) {
504 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
510 int true_block_id() { return SuccessorAt(0)->block_id(); }
511 int false_block_id() { return SuccessorAt(1)->block_id(); }
514 HControlInstruction* hydrogen() {
515 return HControlInstruction::cast(this->hydrogen_value());
523 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
525 LWrapReceiver(LOperand* receiver, LOperand* function) {
526 inputs_[0] = receiver;
527 inputs_[1] = function;
530 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
531 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
533 LOperand* receiver() { return inputs_[0]; }
534 LOperand* function() { return inputs_[1]; }
538 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
540 LApplyArguments(LOperand* function, LOperand* receiver, LOperand* length,
541 LOperand* elements) {
542 inputs_[0] = function;
543 inputs_[1] = receiver;
545 inputs_[3] = elements;
548 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
550 LOperand* function() { return inputs_[0]; }
551 LOperand* receiver() { return inputs_[1]; }
552 LOperand* length() { return inputs_[2]; }
553 LOperand* elements() { return inputs_[3]; }
557 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
559 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
560 inputs_[0] = arguments;
565 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
567 LOperand* arguments() { return inputs_[0]; }
568 LOperand* length() { return inputs_[1]; }
569 LOperand* index() { return inputs_[2]; }
571 void PrintDataTo(StringStream* stream) override;
575 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
577 explicit LArgumentsLength(LOperand* elements) { inputs_[0] = elements; }
579 LOperand* elements() { return inputs_[0]; }
581 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
585 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
587 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
588 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
592 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
594 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
595 inputs_[0] = dividend;
599 LOperand* dividend() { return inputs_[0]; }
600 int32_t divisor() const { return divisor_; }
602 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
603 DECLARE_HYDROGEN_ACCESSOR(Mod)
610 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
612 LModByConstI(LOperand* dividend, int32_t divisor) {
613 inputs_[0] = dividend;
617 LOperand* dividend() { return inputs_[0]; }
618 int32_t divisor() const { return divisor_; }
620 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
621 DECLARE_HYDROGEN_ACCESSOR(Mod)
628 class LModI final : public LTemplateInstruction<1, 2, 0> {
630 LModI(LOperand* left, LOperand* right) {
635 LOperand* left() { return inputs_[0]; }
636 LOperand* right() { return inputs_[1]; }
638 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
639 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
645 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
646 inputs_[0] = dividend;
650 LOperand* dividend() { return inputs_[0]; }
651 int32_t divisor() const { return divisor_; }
653 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
654 DECLARE_HYDROGEN_ACCESSOR(Div)
661 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
663 LDivByConstI(LOperand* dividend, int32_t divisor) {
664 inputs_[0] = dividend;
668 LOperand* dividend() { return inputs_[0]; }
669 int32_t divisor() const { return divisor_; }
671 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
672 DECLARE_HYDROGEN_ACCESSOR(Div)
679 class LDivI final : public LTemplateInstruction<1, 2, 0> {
681 LDivI(LOperand* dividend, LOperand* divisor) {
682 inputs_[0] = dividend;
683 inputs_[1] = divisor;
686 LOperand* dividend() { return inputs_[0]; }
687 LOperand* divisor() { return inputs_[1]; }
689 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
690 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
694 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
696 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
697 inputs_[0] = dividend;
701 LOperand* dividend() { return inputs_[0]; }
702 int32_t divisor() { return divisor_; }
704 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
705 "flooring-div-by-power-of-2-i")
706 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
713 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 1> {
715 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
716 inputs_[0] = dividend;
721 LOperand* dividend() { return inputs_[0]; }
722 int32_t divisor() const { return divisor_; }
723 LOperand* temp() { return temps_[0]; }
725 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
726 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
733 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
735 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
736 inputs_[0] = dividend;
737 inputs_[1] = divisor;
740 LOperand* dividend() { return inputs_[0]; }
741 LOperand* divisor() { return inputs_[1]; }
743 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
744 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
748 class LMulI final : public LTemplateInstruction<1, 2, 0> {
750 LMulI(LOperand* left, LOperand* right) {
755 LOperand* left() { return inputs_[0]; }
756 LOperand* right() { return inputs_[1]; }
758 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
759 DECLARE_HYDROGEN_ACCESSOR(Mul)
763 // Instruction for computing multiplier * multiplicand + addend.
764 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
766 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
767 LOperand* multiplicand) {
769 inputs_[1] = multiplier;
770 inputs_[2] = multiplicand;
773 LOperand* addend() { return inputs_[0]; }
774 LOperand* multiplier() { return inputs_[1]; }
775 LOperand* multiplicand() { return inputs_[2]; }
777 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
781 // Instruction for computing minuend - multiplier * multiplicand.
782 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
784 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
785 LOperand* multiplicand) {
786 inputs_[0] = minuend;
787 inputs_[1] = multiplier;
788 inputs_[2] = multiplicand;
791 LOperand* minuend() { return inputs_[0]; }
792 LOperand* multiplier() { return inputs_[1]; }
793 LOperand* multiplicand() { return inputs_[2]; }
795 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
799 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
801 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
805 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
807 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
812 LOperand* left() { return inputs_[0]; }
813 LOperand* right() { return inputs_[1]; }
815 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
816 "compare-numeric-and-branch")
817 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
819 Token::Value op() const { return hydrogen()->token(); }
820 bool is_double() const { return hydrogen()->representation().IsDouble(); }
822 void PrintDataTo(StringStream* stream) override;
826 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
828 explicit LMathFloor(LOperand* value) { inputs_[0] = value; }
830 LOperand* value() { return inputs_[0]; }
832 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
833 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
837 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
839 LMathRound(LOperand* value, LOperand* temp) {
844 LOperand* value() { return inputs_[0]; }
845 LOperand* temp() { return temps_[0]; }
847 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
848 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
852 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
854 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
856 LOperand* value() { return inputs_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
862 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
864 LMathAbs(LOperand* context, LOperand* value) {
865 inputs_[1] = context;
869 LOperand* context() { return inputs_[1]; }
870 LOperand* value() { return inputs_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
879 explicit LMathLog(LOperand* value) { inputs_[0] = value; }
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
887 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
889 explicit LMathClz32(LOperand* value) { inputs_[0] = value; }
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
897 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
899 LMathExp(LOperand* value, LOperand* double_temp, LOperand* temp1,
904 temps_[2] = double_temp;
905 ExternalReference::InitializeMathExpData();
908 LOperand* value() { return inputs_[0]; }
909 LOperand* temp1() { return temps_[0]; }
910 LOperand* temp2() { return temps_[1]; }
911 LOperand* double_temp() { return temps_[2]; }
913 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
917 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
919 explicit LMathSqrt(LOperand* value) { inputs_[0] = value; }
921 LOperand* value() { return inputs_[0]; }
923 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
927 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
929 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
931 LOperand* value() { return inputs_[0]; }
933 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
937 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
939 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
944 LOperand* left() { return inputs_[0]; }
945 LOperand* right() { return inputs_[1]; }
947 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
948 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
952 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
954 explicit LCmpHoleAndBranch(LOperand* object) { inputs_[0] = object; }
956 LOperand* object() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
959 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
963 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
965 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
970 LOperand* value() { return inputs_[0]; }
971 LOperand* temp() { return temps_[0]; }
973 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
974 "cmp-minus-zero-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
979 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
981 LIsStringAndBranch(LOperand* value, LOperand* temp) {
986 LOperand* value() { return inputs_[0]; }
987 LOperand* temp() { return temps_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
992 void PrintDataTo(StringStream* stream) override;
996 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
998 explicit LIsSmiAndBranch(LOperand* value) { inputs_[0] = value; }
1000 LOperand* value() { return inputs_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1005 void PrintDataTo(StringStream* stream) override;
1009 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1011 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1016 LOperand* value() { return inputs_[0]; }
1017 LOperand* temp() { return temps_[0]; }
1019 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1020 "is-undetectable-and-branch")
1021 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1023 void PrintDataTo(StringStream* stream) override;
1027 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1029 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1030 inputs_[0] = context;
1035 LOperand* context() { return inputs_[0]; }
1036 LOperand* left() { return inputs_[1]; }
1037 LOperand* right() { return inputs_[2]; }
1039 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1040 "string-compare-and-branch")
1041 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1043 Token::Value op() const { return hydrogen()->token(); }
1045 void PrintDataTo(StringStream* stream) override;
1049 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1051 explicit LHasInstanceTypeAndBranch(LOperand* value) { inputs_[0] = value; }
1053 LOperand* value() { return inputs_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1056 "has-instance-type-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1059 void PrintDataTo(StringStream* stream) override;
1063 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1065 explicit LGetCachedArrayIndex(LOperand* value) { inputs_[0] = value; }
1067 LOperand* value() { return inputs_[0]; }
1069 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1070 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1074 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1076 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1080 LOperand* value() { return inputs_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1083 "has-cached-array-index-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1086 void PrintDataTo(StringStream* stream) override;
1090 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1092 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1097 LOperand* value() { return inputs_[0]; }
1098 LOperand* temp() { return temps_[0]; }
1100 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, "class-of-test-and-branch")
1101 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1103 void PrintDataTo(StringStream* stream) override;
1107 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1109 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1110 inputs_[0] = context;
1115 LOperand* context() { return inputs_[0]; }
1116 LOperand* left() { return inputs_[1]; }
1117 LOperand* right() { return inputs_[2]; }
1119 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1120 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1122 Strength strength() { return hydrogen()->strength(); }
1124 Token::Value op() const { return hydrogen()->token(); }
1128 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1130 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1131 inputs_[0] = context;
1136 LOperand* context() const { return inputs_[0]; }
1137 LOperand* left() const { return inputs_[1]; }
1138 LOperand* right() const { return inputs_[2]; }
1140 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1144 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1146 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1147 inputs_[0] = object;
1148 inputs_[1] = prototype;
1151 LOperand* object() const { return inputs_[0]; }
1152 LOperand* prototype() const { return inputs_[1]; }
1154 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1155 "has-in-prototype-chain-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1160 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1162 LBoundsCheck(LOperand* index, LOperand* length) {
1164 inputs_[1] = length;
1167 LOperand* index() { return inputs_[0]; }
1168 LOperand* length() { return inputs_[1]; }
1170 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1171 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1175 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1177 LBitI(LOperand* left, LOperand* right) {
1182 LOperand* left() { return inputs_[0]; }
1183 LOperand* right() { return inputs_[1]; }
1185 Token::Value op() const { return hydrogen()->op(); }
1187 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1188 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1192 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1194 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1195 : op_(op), can_deopt_(can_deopt) {
1200 Token::Value op() const { return op_; }
1201 LOperand* left() { return inputs_[0]; }
1202 LOperand* right() { return inputs_[1]; }
1203 bool can_deopt() const { return can_deopt_; }
1205 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1213 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1215 LSubI(LOperand* left, LOperand* right) {
1220 LOperand* left() { return inputs_[0]; }
1221 LOperand* right() { return inputs_[1]; }
1223 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1224 DECLARE_HYDROGEN_ACCESSOR(Sub)
1228 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1230 LRSubI(LOperand* left, LOperand* right) {
1235 LOperand* left() { return inputs_[0]; }
1236 LOperand* right() { return inputs_[1]; }
1238 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1239 DECLARE_HYDROGEN_ACCESSOR(Sub)
1243 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1245 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1246 DECLARE_HYDROGEN_ACCESSOR(Constant)
1248 int32_t value() const { return hydrogen()->Integer32Value(); }
1252 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1254 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1255 DECLARE_HYDROGEN_ACCESSOR(Constant)
1257 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1261 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1263 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1264 DECLARE_HYDROGEN_ACCESSOR(Constant)
1266 double value() const { return hydrogen()->DoubleValue(); }
1267 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1271 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1273 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1274 DECLARE_HYDROGEN_ACCESSOR(Constant)
1276 ExternalReference value() const {
1277 return hydrogen()->ExternalReferenceValue();
1282 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1284 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1285 DECLARE_HYDROGEN_ACCESSOR(Constant)
1287 Handle<Object> value(Isolate* isolate) const {
1288 return hydrogen()->handle(isolate);
1293 class LBranch final : public LControlInstruction<1, 0> {
1295 explicit LBranch(LOperand* value) { inputs_[0] = value; }
1297 LOperand* value() { return inputs_[0]; }
1299 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1300 DECLARE_HYDROGEN_ACCESSOR(Branch)
1302 void PrintDataTo(StringStream* stream) override;
1306 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1308 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1313 LOperand* value() { return inputs_[0]; }
1314 LOperand* temp() { return temps_[0]; }
1316 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1317 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1319 Handle<Map> map() const { return hydrogen()->map().handle(); }
1323 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1325 explicit LMapEnumLength(LOperand* value) { inputs_[0] = value; }
1327 LOperand* value() { return inputs_[0]; }
1329 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1333 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1335 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1340 LOperand* date() { return inputs_[0]; }
1341 LOperand* temp() { return temps_[0]; }
1342 Smi* index() const { return index_; }
1344 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1345 DECLARE_HYDROGEN_ACCESSOR(DateField)
1352 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1354 LSeqStringGetChar(LOperand* string, LOperand* index) {
1355 inputs_[0] = string;
1359 LOperand* string() const { return inputs_[0]; }
1360 LOperand* index() const { return inputs_[1]; }
1362 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1363 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1367 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1369 LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1371 inputs_[0] = context;
1372 inputs_[1] = string;
1377 LOperand* string() { return inputs_[1]; }
1378 LOperand* index() { return inputs_[2]; }
1379 LOperand* value() { return inputs_[3]; }
1381 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1382 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1386 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1388 LAddI(LOperand* left, LOperand* right) {
1393 LOperand* left() { return inputs_[0]; }
1394 LOperand* right() { return inputs_[1]; }
1396 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1397 DECLARE_HYDROGEN_ACCESSOR(Add)
1401 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1403 LMathMinMax(LOperand* left, LOperand* right) {
1408 LOperand* left() { return inputs_[0]; }
1409 LOperand* right() { return inputs_[1]; }
1411 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1412 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1416 class LPower final : public LTemplateInstruction<1, 2, 0> {
1418 LPower(LOperand* left, LOperand* right) {
1423 LOperand* left() { return inputs_[0]; }
1424 LOperand* right() { return inputs_[1]; }
1426 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1427 DECLARE_HYDROGEN_ACCESSOR(Power)
1431 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1433 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1438 Token::Value op() const { return op_; }
1439 LOperand* left() { return inputs_[0]; }
1440 LOperand* right() { return inputs_[1]; }
1442 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1443 void CompileToNative(LCodeGen* generator) override;
1444 const char* Mnemonic() const override;
1451 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1453 LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1456 inputs_[0] = context;
1461 LOperand* context() { return inputs_[0]; }
1462 LOperand* left() { return inputs_[1]; }
1463 LOperand* right() { return inputs_[2]; }
1464 Token::Value op() const { return op_; }
1466 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1467 void CompileToNative(LCodeGen* generator) override;
1468 const char* Mnemonic() const override;
1470 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1472 Strength strength() { return hydrogen()->strength(); }
1479 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1481 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1483 inputs_[1] = context;
1484 inputs_[2] = parameter_count;
1487 LOperand* value() { return inputs_[0]; }
1489 bool has_constant_parameter_count() {
1490 return parameter_count()->IsConstantOperand();
1492 LConstantOperand* constant_parameter_count() {
1493 DCHECK(has_constant_parameter_count());
1494 return LConstantOperand::cast(parameter_count());
1496 LOperand* parameter_count() { return inputs_[2]; }
1498 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1502 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1504 explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1506 LOperand* object() { return inputs_[0]; }
1508 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1509 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1513 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1515 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1516 inputs_[0] = context;
1517 inputs_[1] = object;
1521 LOperand* context() { return inputs_[0]; }
1522 LOperand* object() { return inputs_[1]; }
1523 LOperand* temp_vector() { return temps_[0]; }
1525 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1526 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1528 Handle<Object> name() const { return hydrogen()->name(); }
1532 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1534 explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1536 LOperand* function() { return inputs_[0]; }
1538 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1539 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1543 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1545 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1546 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1548 Heap::RootListIndex index() const { return hydrogen()->index(); }
1552 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1554 LLoadKeyed(LOperand* elements, LOperand* key) {
1555 inputs_[0] = elements;
1559 LOperand* elements() { return inputs_[0]; }
1560 LOperand* key() { return inputs_[1]; }
1561 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1562 bool is_fixed_typed_array() const {
1563 return hydrogen()->is_fixed_typed_array();
1566 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1569 void PrintDataTo(StringStream* stream) override;
1570 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1574 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1576 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1578 inputs_[0] = context;
1579 inputs_[1] = object;
1584 LOperand* context() { return inputs_[0]; }
1585 LOperand* object() { return inputs_[1]; }
1586 LOperand* key() { return inputs_[2]; }
1587 LOperand* temp_vector() { return temps_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1594 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1596 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1598 inputs_[0] = context;
1599 inputs_[1] = global_object;
1603 LOperand* context() { return inputs_[0]; }
1604 LOperand* global_object() { return inputs_[1]; }
1605 LOperand* temp_vector() { return temps_[0]; }
1607 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1608 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1610 Handle<Object> name() const { return hydrogen()->name(); }
1611 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1615 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1617 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1619 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1622 void PrintDataTo(StringStream* stream) override;
1624 LOperand* context() { return inputs_[0]; }
1626 int depth() const { return hydrogen()->depth(); }
1627 int slot_index() const { return hydrogen()->slot_index(); }
1631 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1633 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1635 LOperand* context() { return inputs_[0]; }
1637 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1638 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1640 int slot_index() { return hydrogen()->slot_index(); }
1642 void PrintDataTo(StringStream* stream) override;
1646 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1648 LStoreContextSlot(LOperand* context, LOperand* value) {
1649 inputs_[0] = context;
1653 LOperand* context() { return inputs_[0]; }
1654 LOperand* value() { return inputs_[1]; }
1656 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1657 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1659 int slot_index() { return hydrogen()->slot_index(); }
1661 void PrintDataTo(StringStream* stream) override;
1665 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1667 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1669 LOperand* value() { return inputs_[0]; }
1671 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1675 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1677 explicit LDrop(int count) : count_(count) {}
1679 int count() const { return count_; }
1681 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1688 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1690 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1691 inputs_[0] = function;
1692 inputs_[1] = code_object;
1695 LOperand* function() { return inputs_[0]; }
1696 LOperand* code_object() { return inputs_[1]; }
1698 void PrintDataTo(StringStream* stream) override;
1700 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1701 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1705 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1707 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1708 inputs_[0] = base_object;
1709 inputs_[1] = offset;
1712 LOperand* base_object() const { return inputs_[0]; }
1713 LOperand* offset() const { return inputs_[1]; }
1715 void PrintDataTo(StringStream* stream) override;
1717 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1721 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1723 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1724 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1728 class LContext final : public LTemplateInstruction<1, 0, 0> {
1730 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1731 DECLARE_HYDROGEN_ACCESSOR(Context)
1735 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1737 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1739 LOperand* context() { return inputs_[0]; }
1741 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1742 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1746 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1748 explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1750 LOperand* function() { return inputs_[0]; }
1752 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1753 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1755 void PrintDataTo(StringStream* stream) override;
1757 int arity() const { return hydrogen()->argument_count() - 1; }
1761 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1763 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1764 const ZoneList<LOperand*>& operands, Zone* zone)
1765 : descriptor_(descriptor),
1766 inputs_(descriptor.GetRegisterParameterCount() +
1767 kImplicitRegisterParameterCount,
1769 DCHECK(descriptor.GetRegisterParameterCount() +
1770 kImplicitRegisterParameterCount ==
1772 inputs_.AddAll(operands, zone);
1775 LOperand* target() const { return inputs_[0]; }
1777 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1779 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1781 // The target and context are passed as implicit parameters that are not
1782 // explicitly listed in the descriptor.
1783 static const int kImplicitRegisterParameterCount = 2;
1786 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1788 void PrintDataTo(StringStream* stream) override;
1790 int arity() const { return hydrogen()->argument_count() - 1; }
1792 CallInterfaceDescriptor descriptor_;
1793 ZoneList<LOperand*> inputs_;
1795 // Iterator support.
1796 int InputCount() final { return inputs_.length(); }
1797 LOperand* InputAt(int i) final { return inputs_[i]; }
1799 int TempCount() final { return 0; }
1800 LOperand* TempAt(int i) final { return NULL; }
1804 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1806 LInvokeFunction(LOperand* context, LOperand* function) {
1807 inputs_[0] = context;
1808 inputs_[1] = function;
1811 LOperand* context() { return inputs_[0]; }
1812 LOperand* function() { return inputs_[1]; }
1814 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1815 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1817 void PrintDataTo(StringStream* stream) override;
1819 int arity() const { return hydrogen()->argument_count() - 1; }
1823 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1825 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1827 inputs_[0] = context;
1828 inputs_[1] = function;
1833 LOperand* context() { return inputs_[0]; }
1834 LOperand* function() { return inputs_[1]; }
1835 LOperand* temp_slot() { return temps_[0]; }
1836 LOperand* temp_vector() { return temps_[1]; }
1838 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1839 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1841 int arity() const { return hydrogen()->argument_count() - 1; }
1842 void PrintDataTo(StringStream* stream) override;
1846 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1848 LCallNew(LOperand* context, LOperand* constructor) {
1849 inputs_[0] = context;
1850 inputs_[1] = constructor;
1853 LOperand* context() { return inputs_[0]; }
1854 LOperand* constructor() { return inputs_[1]; }
1856 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1857 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1859 void PrintDataTo(StringStream* stream) override;
1861 int arity() const { return hydrogen()->argument_count() - 1; }
1865 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1867 LCallNewArray(LOperand* context, LOperand* constructor) {
1868 inputs_[0] = context;
1869 inputs_[1] = constructor;
1872 LOperand* context() { return inputs_[0]; }
1873 LOperand* constructor() { return inputs_[1]; }
1875 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1876 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1878 void PrintDataTo(StringStream* stream) override;
1880 int arity() const { return hydrogen()->argument_count() - 1; }
1884 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1886 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1888 LOperand* context() { return inputs_[0]; }
1890 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1891 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1893 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1894 return save_doubles() == kDontSaveFPRegs;
1897 const Runtime::Function* function() const { return hydrogen()->function(); }
1898 int arity() const { return hydrogen()->argument_count(); }
1899 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1903 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1905 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1907 LOperand* value() { return inputs_[0]; }
1909 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1913 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1915 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1917 LOperand* value() { return inputs_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1923 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1925 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1931 LOperand* value() { return inputs_[0]; }
1932 LOperand* temp1() { return temps_[0]; }
1933 LOperand* temp2() { return temps_[1]; }
1935 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1939 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1941 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1947 LOperand* value() { return inputs_[0]; }
1948 LOperand* temp1() { return temps_[0]; }
1949 LOperand* temp2() { return temps_[1]; }
1951 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1955 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1957 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1963 LOperand* value() { return inputs_[0]; }
1964 LOperand* temp() { return temps_[0]; }
1965 LOperand* temp2() { return temps_[1]; }
1967 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1968 DECLARE_HYDROGEN_ACCESSOR(Change)
1972 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
1974 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
1976 LOperand* value() { return inputs_[0]; }
1978 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1979 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1981 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1985 // Sometimes truncating conversion from a tagged value to an int32.
1986 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
1988 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
1990 LOperand* value() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1993 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1995 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1999 // Truncating conversion from a tagged value to an int32.
2000 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2002 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2008 LOperand* value() { return inputs_[0]; }
2009 LOperand* temp() { return temps_[0]; }
2010 LOperand* temp2() { return temps_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2013 DECLARE_HYDROGEN_ACCESSOR(Change)
2015 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2019 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2021 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2023 LOperand* value() { return inputs_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2026 DECLARE_HYDROGEN_ACCESSOR(Change)
2030 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2032 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2034 LOperand* value() { return inputs_[0]; }
2036 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2037 DECLARE_HYDROGEN_ACCESSOR(Change)
2041 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2043 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2047 LOperand* value() { return inputs_[0]; }
2048 bool needs_check() const { return needs_check_; }
2050 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2057 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2059 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2060 inputs_[0] = object;
2065 LOperand* object() { return inputs_[0]; }
2066 LOperand* value() { return inputs_[1]; }
2067 LOperand* temp() { return temps_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2070 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2072 void PrintDataTo(StringStream* stream) override;
2074 Representation representation() const {
2075 return hydrogen()->field_representation();
2080 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2082 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2083 LOperand* slot, LOperand* vector) {
2084 inputs_[0] = context;
2085 inputs_[1] = object;
2091 LOperand* context() { return inputs_[0]; }
2092 LOperand* object() { return inputs_[1]; }
2093 LOperand* value() { return inputs_[2]; }
2094 LOperand* temp_slot() { return temps_[0]; }
2095 LOperand* temp_vector() { return temps_[1]; }
2097 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2098 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2100 void PrintDataTo(StringStream* stream) override;
2102 Handle<Object> name() const { return hydrogen()->name(); }
2103 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2107 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2109 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2110 inputs_[0] = context;
2114 LOperand* context() { return inputs_[0]; }
2115 LOperand* value() { return inputs_[1]; }
2117 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2118 "store-global-via-context")
2119 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2121 void PrintDataTo(StringStream* stream) override;
2123 int depth() { return hydrogen()->depth(); }
2124 int slot_index() { return hydrogen()->slot_index(); }
2125 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2129 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2131 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2132 inputs_[0] = object;
2137 bool is_fixed_typed_array() const {
2138 return hydrogen()->is_fixed_typed_array();
2140 LOperand* elements() { return inputs_[0]; }
2141 LOperand* key() { return inputs_[1]; }
2142 LOperand* value() { return inputs_[2]; }
2143 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2145 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2146 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2148 void PrintDataTo(StringStream* stream) override;
2149 bool NeedsCanonicalization() {
2150 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2151 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2154 return hydrogen()->NeedsCanonicalization();
2156 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2160 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2162 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2163 LOperand* value, LOperand* slot, LOperand* vector) {
2164 inputs_[0] = context;
2165 inputs_[1] = object;
2172 LOperand* context() { return inputs_[0]; }
2173 LOperand* object() { return inputs_[1]; }
2174 LOperand* key() { return inputs_[2]; }
2175 LOperand* value() { return inputs_[3]; }
2176 LOperand* temp_slot() { return temps_[0]; }
2177 LOperand* temp_vector() { return temps_[1]; }
2179 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2180 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2182 void PrintDataTo(StringStream* stream) override;
2184 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2188 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2190 LTransitionElementsKind(LOperand* object, LOperand* context,
2191 LOperand* new_map_temp) {
2192 inputs_[0] = object;
2193 inputs_[1] = context;
2194 temps_[0] = new_map_temp;
2197 LOperand* context() { return inputs_[1]; }
2198 LOperand* object() { return inputs_[0]; }
2199 LOperand* new_map_temp() { return temps_[0]; }
2201 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2202 "transition-elements-kind")
2203 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2205 void PrintDataTo(StringStream* stream) override;
2207 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2208 Handle<Map> transitioned_map() {
2209 return hydrogen()->transitioned_map().handle();
2211 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2212 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2216 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2218 LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2219 inputs_[0] = object;
2223 LOperand* object() { return inputs_[0]; }
2224 LOperand* temp() { return temps_[0]; }
2226 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2230 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2232 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2233 LOperand* key, LOperand* current_capacity) {
2234 inputs_[0] = context;
2235 inputs_[1] = object;
2236 inputs_[2] = elements;
2238 inputs_[4] = current_capacity;
2241 LOperand* context() { return inputs_[0]; }
2242 LOperand* object() { return inputs_[1]; }
2243 LOperand* elements() { return inputs_[2]; }
2244 LOperand* key() { return inputs_[3]; }
2245 LOperand* current_capacity() { return inputs_[4]; }
2247 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2248 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2252 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2254 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2255 inputs_[0] = context;
2260 LOperand* context() { return inputs_[0]; }
2261 LOperand* left() { return inputs_[1]; }
2262 LOperand* right() { return inputs_[2]; }
2264 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2265 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2269 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2271 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2272 inputs_[0] = context;
2273 inputs_[1] = string;
2277 LOperand* context() { return inputs_[0]; }
2278 LOperand* string() { return inputs_[1]; }
2279 LOperand* index() { return inputs_[2]; }
2281 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2282 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2286 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2288 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2289 inputs_[0] = context;
2290 inputs_[1] = char_code;
2293 LOperand* context() { return inputs_[0]; }
2294 LOperand* char_code() { return inputs_[1]; }
2296 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2297 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2301 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2303 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2305 LOperand* value() { return inputs_[0]; }
2307 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2308 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2312 class LCheckArrayBufferNotNeutered final
2313 : public LTemplateInstruction<0, 1, 0> {
2315 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2317 LOperand* view() { return inputs_[0]; }
2319 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2320 "check-array-buffer-not-neutered")
2321 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2325 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2327 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2329 LOperand* value() { return inputs_[0]; }
2331 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2332 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2336 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2338 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2343 LOperand* value() { return inputs_[0]; }
2344 LOperand* temp() { return temps_[0]; }
2346 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2347 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2351 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2353 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2355 LOperand* value() { return inputs_[0]; }
2357 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2361 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2363 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2365 LOperand* value() { return inputs_[0]; }
2367 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2368 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2372 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2374 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2376 LOperand* unclamped() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2382 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2384 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2386 LOperand* unclamped() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2392 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2394 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2395 inputs_[0] = unclamped;
2399 LOperand* unclamped() { return inputs_[0]; }
2400 LOperand* temp() { return temps_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2406 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2408 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2410 LOperand* value() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2413 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2417 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2419 LConstructDouble(LOperand* hi, LOperand* lo) {
2424 LOperand* hi() { return inputs_[0]; }
2425 LOperand* lo() { return inputs_[1]; }
2427 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2431 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2433 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2435 inputs_[0] = context;
2441 LOperand* context() { return inputs_[0]; }
2442 LOperand* size() { return inputs_[1]; }
2443 LOperand* temp1() { return temps_[0]; }
2444 LOperand* temp2() { return temps_[1]; }
2446 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2447 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2451 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2453 explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2455 LOperand* context() { return inputs_[0]; }
2457 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2458 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2462 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2464 explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2466 LOperand* value() { return inputs_[0]; }
2468 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2469 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2473 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2475 LTypeof(LOperand* context, LOperand* value) {
2476 inputs_[0] = context;
2480 LOperand* context() { return inputs_[0]; }
2481 LOperand* value() { return inputs_[1]; }
2483 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2487 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2489 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2491 LOperand* value() { return inputs_[0]; }
2493 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2494 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2496 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2498 void PrintDataTo(StringStream* stream) override;
2502 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2504 explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2506 LOperand* temp() { return temps_[0]; }
2508 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2509 "is-construct-call-and-branch")
2513 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2517 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2518 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2522 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2524 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2526 LOperand* context() { return inputs_[0]; }
2528 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2529 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2531 Label* done_label() { return &done_label_; }
2538 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2540 LForInPrepareMap(LOperand* context, LOperand* object) {
2541 inputs_[0] = context;
2542 inputs_[1] = object;
2545 LOperand* context() { return inputs_[0]; }
2546 LOperand* object() { return inputs_[1]; }
2548 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2552 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2554 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2556 LOperand* map() { return inputs_[0]; }
2558 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2560 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2564 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2566 LCheckMapValue(LOperand* value, LOperand* map) {
2571 LOperand* value() { return inputs_[0]; }
2572 LOperand* map() { return inputs_[1]; }
2574 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2578 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2580 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2581 inputs_[0] = object;
2585 LOperand* object() { return inputs_[0]; }
2586 LOperand* index() { return inputs_[1]; }
2588 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2592 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2594 explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2596 LOperand* context() { return inputs_[0]; }
2598 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2602 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2604 LAllocateBlockContext(LOperand* context, LOperand* function) {
2605 inputs_[0] = context;
2606 inputs_[1] = function;
2609 LOperand* context() { return inputs_[0]; }
2610 LOperand* function() { return inputs_[1]; }
2612 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2614 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2615 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2619 class LChunkBuilder;
2620 class LPlatformChunk final : public LChunk {
2622 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2624 int GetNextSpillIndex(RegisterKind kind);
2625 LOperand* GetNextSpillSlot(RegisterKind kind);
2629 class LChunkBuilder final : public LChunkBuilderBase {
2631 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2632 : LChunkBuilderBase(info, graph),
2633 current_instruction_(NULL),
2634 current_block_(NULL),
2636 allocator_(allocator) {}
2638 // Build the sequence for the graph.
2639 LPlatformChunk* Build();
2641 // Declare methods that deal with the individual node types.
2642 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2643 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2646 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2647 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2648 LInstruction* DoRSub(HSub* instr);
2650 static bool HasMagicNumberForDivisor(int32_t divisor);
2652 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2653 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2654 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2655 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2656 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2657 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2658 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2659 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2660 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2661 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2662 LInstruction* DoDivByConstI(HDiv* instr);
2663 LInstruction* DoDivI(HDiv* instr);
2664 LInstruction* DoModByPowerOf2I(HMod* instr);
2665 LInstruction* DoModByConstI(HMod* instr);
2666 LInstruction* DoModI(HMod* instr);
2667 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2668 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2669 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2672 // Methods for getting operands for Use / Define / Temp.
2673 LUnallocated* ToUnallocated(Register reg);
2674 LUnallocated* ToUnallocated(DoubleRegister reg);
2676 // Methods for setting up define-use relationships.
2677 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2678 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2679 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2680 DoubleRegister fixed_register);
2682 // A value that is guaranteed to be allocated to a register.
2683 // Operand created by UseRegister is guaranteed to be live until the end of
2684 // instruction. This means that register allocator will not reuse it's
2685 // register for any other operand inside instruction.
2686 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2687 // instruction start. Register allocator is free to assign the same register
2688 // to some other operand used inside instruction (i.e. temporary or
2690 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2691 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2693 // An input operand in a register that may be trashed.
2694 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2696 // An input operand in a register or stack slot.
2697 MUST_USE_RESULT LOperand* Use(HValue* value);
2698 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2700 // An input operand in a register, stack slot or a constant operand.
2701 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2702 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2704 // An input operand in a register or a constant operand.
2705 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2706 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2708 // An input operand in a constant operand.
2709 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2711 // An input operand in register, stack slot or a constant operand.
2712 // Will not be moved to a register even if one is freely available.
2713 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2715 // Temporary operand that must be in a register.
2716 MUST_USE_RESULT LUnallocated* TempRegister();
2717 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2718 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2719 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2721 // Methods for setting up define-use relationships.
2722 // Return the same instruction that they are passed.
2723 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2724 LUnallocated* result);
2725 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2726 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2728 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2729 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2730 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2731 DoubleRegister reg);
2732 LInstruction* AssignEnvironment(LInstruction* instr);
2733 LInstruction* AssignPointerMap(LInstruction* instr);
2735 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2737 // By default we assume that instruction sequences generated for calls
2738 // cannot deoptimize eagerly and we do not attach environment to this
2740 LInstruction* MarkAsCall(
2741 LInstruction* instr, HInstruction* hinstr,
2742 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2744 void VisitInstruction(HInstruction* current);
2745 void AddInstruction(LInstruction* instr, HInstruction* current);
2747 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2748 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2749 LInstruction* DoArithmeticD(Token::Value op,
2750 HArithmeticBinaryOperation* instr);
2751 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2753 HInstruction* current_instruction_;
2754 HBasicBlock* current_block_;
2755 HBasicBlock* next_block_;
2756 LAllocator* allocator_;
2758 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2761 #undef DECLARE_HYDROGEN_ACCESSOR
2762 #undef DECLARE_CONCRETE_INSTRUCTION
2763 } // namespace internal
2766 #endif // V8_PPC_LITHIUM_PPC_H_