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) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
105 V(LoadGlobalViaContext) \
107 V(LoadKeyedGeneric) \
109 V(LoadNamedGeneric) \
121 V(MaybeGrowElements) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
147 V(StoreGlobalViaContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
160 V(ToFastProperties) \
161 V(TransitionElementsKind) \
162 V(TrapAllocationMemento) \
164 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 Opcode opcode() const final { return LInstruction::k##type; } \
172 void CompileToNative(LCodeGen* generator) final; \
173 const char* Mnemonic() const final { return mnemonic; } \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { return H##type::cast(hydrogen_value()); }
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {}
191 virtual ~LInstruction() {}
193 virtual void CompileToNative(LCodeGen* generator) = 0;
194 virtual const char* Mnemonic() const = 0;
195 virtual void PrintTo(StringStream* stream);
196 virtual void PrintDataTo(StringStream* stream);
197 virtual void PrintOutputOperandTo(StringStream* stream);
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 // Try deleting this instruction if possible.
221 virtual bool TryDelete() { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {}
236 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
237 bool IsCall() const { return IsCallBits::decode(bit_field_); }
239 // Interface to the register allocator and iterators.
240 bool ClobbersTemps() const { return IsCall(); }
241 bool ClobbersRegisters() const { return IsCall(); }
242 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
246 // Interface to the register allocator and iterators.
247 bool IsMarkedAsCall() const { return IsCall(); }
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 LOperand* FirstInput() { return InputAt(0); }
253 LOperand* Output() { return HasResult() ? result() : NULL; }
255 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
261 virtual int InputCount() = 0;
262 virtual LOperand* InputAt(int i) = 0;
266 friend class InputIterator;
268 friend class TempIterator;
269 virtual int TempCount() = 0;
270 virtual LOperand* TempAt(int i) = 0;
272 class IsCallBits : public BitField<bool, 0, 1> {};
274 LEnvironment* environment_;
275 SetOncePointer<LPointerMap> pointer_map_;
276 HValue* hydrogen_value_;
281 // R = number of result operands (0 or 1).
283 class LTemplateResultInstruction : public LInstruction {
285 // Allow 0 or 1 output operands.
286 STATIC_ASSERT(R == 0 || R == 1);
287 bool HasResult() const final { return R != 0 && result() != NULL; }
288 void set_result(LOperand* operand) { results_[0] = operand; }
289 LOperand* result() const override { return results_[0]; }
292 EmbeddedContainer<LOperand*, R> results_;
296 // R = number of result operands (0 or 1).
297 // I = number of input operands.
298 // T = number of temporary operands.
299 template <int R, int I, int T>
300 class LTemplateInstruction : public LTemplateResultInstruction<R> {
302 EmbeddedContainer<LOperand*, I> inputs_;
303 EmbeddedContainer<LOperand*, T> temps_;
307 int InputCount() final { return I; }
308 LOperand* InputAt(int i) final { return inputs_[i]; }
310 int TempCount() final { return T; }
311 LOperand* TempAt(int i) final { return temps_[i]; }
315 class LGap : public LTemplateInstruction<0, 0, 0> {
317 explicit LGap(HBasicBlock* block) : block_(block) {
318 parallel_moves_[BEFORE] = NULL;
319 parallel_moves_[START] = NULL;
320 parallel_moves_[END] = NULL;
321 parallel_moves_[AFTER] = NULL;
324 // Can't use the DECLARE-macro here because of sub-classes.
325 bool IsGap() const override { return true; }
326 void PrintDataTo(StringStream* stream) override;
327 static LGap* cast(LInstruction* instr) {
328 DCHECK(instr->IsGap());
329 return reinterpret_cast<LGap*>(instr);
332 bool IsRedundant() const;
334 HBasicBlock* block() const { return block_; }
341 FIRST_INNER_POSITION = BEFORE,
342 LAST_INNER_POSITION = AFTER
345 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
346 if (parallel_moves_[pos] == NULL) {
347 parallel_moves_[pos] = new (zone) LParallelMove(zone);
349 return parallel_moves_[pos];
352 LParallelMove* GetParallelMove(InnerPosition pos) {
353 return parallel_moves_[pos];
357 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
362 class LInstructionGap final : public LGap {
364 explicit LInstructionGap(HBasicBlock* block) : LGap(block) {}
366 bool HasInterestingComment(LCodeGen* gen) const override {
367 return !IsRedundant();
370 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
374 class LGoto final : public LTemplateInstruction<0, 0, 0> {
376 explicit LGoto(HBasicBlock* block) : block_(block) {}
378 bool HasInterestingComment(LCodeGen* gen) const override;
379 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
380 void PrintDataTo(StringStream* stream) override;
381 bool IsControl() const override { return true; }
383 int block_id() const { return block_->block_id(); }
390 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
392 LLazyBailout() : gap_instructions_size_(0) {}
394 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
396 void set_gap_instructions_size(int gap_instructions_size) {
397 gap_instructions_size_ = gap_instructions_size;
399 int gap_instructions_size() { return gap_instructions_size_; }
402 int gap_instructions_size_;
406 class LDummy final : public LTemplateInstruction<1, 0, 0> {
409 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
413 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
415 explicit LDummyUse(LOperand* value) { inputs_[0] = value; }
416 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
420 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
422 bool IsControl() const override { return true; }
423 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
424 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
428 class LLabel final : public LGap {
430 explicit LLabel(HBasicBlock* block) : LGap(block), replacement_(NULL) {}
432 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
433 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
435 void PrintDataTo(StringStream* stream) override;
437 int block_id() const { return block()->block_id(); }
438 bool is_loop_header() const { return block()->IsLoopHeader(); }
439 bool is_osr_entry() const { return block()->is_osr_entry(); }
440 Label* label() { return &label_; }
441 LLabel* replacement() const { return replacement_; }
442 void set_replacement(LLabel* label) { replacement_ = label; }
443 bool HasReplacement() const { return replacement_ != NULL; }
447 LLabel* replacement_;
451 class LParameter final : public LTemplateInstruction<1, 0, 0> {
453 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
454 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
458 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
460 explicit LCallStub(LOperand* context) { inputs_[0] = context; }
462 LOperand* context() { return inputs_[0]; }
464 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
465 DECLARE_HYDROGEN_ACCESSOR(CallStub)
469 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
471 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
472 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
476 template <int I, int T>
477 class LControlInstruction : public LTemplateInstruction<0, I, T> {
479 LControlInstruction() : false_label_(NULL), true_label_(NULL) {}
481 bool IsControl() const final { return true; }
483 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
484 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
486 int TrueDestination(LChunk* chunk) {
487 return chunk->LookupDestination(true_block_id());
489 int FalseDestination(LChunk* chunk) {
490 return chunk->LookupDestination(false_block_id());
493 Label* TrueLabel(LChunk* chunk) {
494 if (true_label_ == NULL) {
495 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
499 Label* FalseLabel(LChunk* chunk) {
500 if (false_label_ == NULL) {
501 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
507 int true_block_id() { return SuccessorAt(0)->block_id(); }
508 int false_block_id() { return SuccessorAt(1)->block_id(); }
511 HControlInstruction* hydrogen() {
512 return HControlInstruction::cast(this->hydrogen_value());
520 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
522 LWrapReceiver(LOperand* receiver, LOperand* function) {
523 inputs_[0] = receiver;
524 inputs_[1] = function;
527 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
528 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
530 LOperand* receiver() { return inputs_[0]; }
531 LOperand* function() { return inputs_[1]; }
535 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
537 LApplyArguments(LOperand* function, LOperand* receiver, LOperand* length,
538 LOperand* elements) {
539 inputs_[0] = function;
540 inputs_[1] = receiver;
542 inputs_[3] = elements;
545 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
547 LOperand* function() { return inputs_[0]; }
548 LOperand* receiver() { return inputs_[1]; }
549 LOperand* length() { return inputs_[2]; }
550 LOperand* elements() { return inputs_[3]; }
554 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
556 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
557 inputs_[0] = arguments;
562 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
564 LOperand* arguments() { return inputs_[0]; }
565 LOperand* length() { return inputs_[1]; }
566 LOperand* index() { return inputs_[2]; }
568 void PrintDataTo(StringStream* stream) override;
572 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
574 explicit LArgumentsLength(LOperand* elements) { inputs_[0] = elements; }
576 LOperand* elements() { return inputs_[0]; }
578 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
582 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
584 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
585 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
589 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
591 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
592 inputs_[0] = dividend;
596 LOperand* dividend() { return inputs_[0]; }
597 int32_t divisor() const { return divisor_; }
599 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
600 DECLARE_HYDROGEN_ACCESSOR(Mod)
607 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
609 LModByConstI(LOperand* dividend, int32_t divisor) {
610 inputs_[0] = dividend;
614 LOperand* dividend() { return inputs_[0]; }
615 int32_t divisor() const { return divisor_; }
617 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
618 DECLARE_HYDROGEN_ACCESSOR(Mod)
625 class LModI final : public LTemplateInstruction<1, 2, 0> {
627 LModI(LOperand* left, LOperand* right) {
632 LOperand* left() { return inputs_[0]; }
633 LOperand* right() { return inputs_[1]; }
635 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
640 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
642 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
643 inputs_[0] = dividend;
647 LOperand* dividend() { return inputs_[0]; }
648 int32_t divisor() const { return divisor_; }
650 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
651 DECLARE_HYDROGEN_ACCESSOR(Div)
658 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
660 LDivByConstI(LOperand* dividend, int32_t divisor) {
661 inputs_[0] = dividend;
665 LOperand* dividend() { return inputs_[0]; }
666 int32_t divisor() const { return divisor_; }
668 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
669 DECLARE_HYDROGEN_ACCESSOR(Div)
676 class LDivI final : public LTemplateInstruction<1, 2, 0> {
678 LDivI(LOperand* dividend, LOperand* divisor) {
679 inputs_[0] = dividend;
680 inputs_[1] = divisor;
683 LOperand* dividend() { return inputs_[0]; }
684 LOperand* divisor() { return inputs_[1]; }
686 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
687 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
691 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
693 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
694 inputs_[0] = dividend;
698 LOperand* dividend() { return inputs_[0]; }
699 int32_t divisor() { return divisor_; }
701 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
702 "flooring-div-by-power-of-2-i")
703 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
710 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 1> {
712 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
713 inputs_[0] = dividend;
718 LOperand* dividend() { return inputs_[0]; }
719 int32_t divisor() const { return divisor_; }
720 LOperand* temp() { return temps_[0]; }
722 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
723 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
730 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
732 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
733 inputs_[0] = dividend;
734 inputs_[1] = divisor;
737 LOperand* dividend() { return inputs_[0]; }
738 LOperand* divisor() { return inputs_[1]; }
740 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
741 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
745 class LMulI final : public LTemplateInstruction<1, 2, 0> {
747 LMulI(LOperand* left, LOperand* right) {
752 LOperand* left() { return inputs_[0]; }
753 LOperand* right() { return inputs_[1]; }
755 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
756 DECLARE_HYDROGEN_ACCESSOR(Mul)
760 // Instruction for computing multiplier * multiplicand + addend.
761 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
763 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
764 LOperand* multiplicand) {
766 inputs_[1] = multiplier;
767 inputs_[2] = multiplicand;
770 LOperand* addend() { return inputs_[0]; }
771 LOperand* multiplier() { return inputs_[1]; }
772 LOperand* multiplicand() { return inputs_[2]; }
774 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
778 // Instruction for computing minuend - multiplier * multiplicand.
779 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
781 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
782 LOperand* multiplicand) {
783 inputs_[0] = minuend;
784 inputs_[1] = multiplier;
785 inputs_[2] = multiplicand;
788 LOperand* minuend() { return inputs_[0]; }
789 LOperand* multiplier() { return inputs_[1]; }
790 LOperand* multiplicand() { return inputs_[2]; }
792 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
796 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
798 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
802 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
804 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
809 LOperand* left() { return inputs_[0]; }
810 LOperand* right() { return inputs_[1]; }
812 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
813 "compare-numeric-and-branch")
814 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
816 Token::Value op() const { return hydrogen()->token(); }
817 bool is_double() const { return hydrogen()->representation().IsDouble(); }
819 void PrintDataTo(StringStream* stream) override;
823 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
825 explicit LMathFloor(LOperand* value) { inputs_[0] = value; }
827 LOperand* value() { return inputs_[0]; }
829 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
830 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
834 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
836 LMathRound(LOperand* value, LOperand* temp) {
841 LOperand* value() { return inputs_[0]; }
842 LOperand* temp() { return temps_[0]; }
844 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
845 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
849 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
851 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
859 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
861 LMathAbs(LOperand* context, LOperand* value) {
862 inputs_[1] = context;
866 LOperand* context() { return inputs_[1]; }
867 LOperand* value() { return inputs_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
870 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
874 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
876 explicit LMathLog(LOperand* value) { inputs_[0] = value; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
884 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
886 explicit LMathClz32(LOperand* value) { inputs_[0] = value; }
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
894 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
896 LMathExp(LOperand* value, LOperand* double_temp, LOperand* temp1,
901 temps_[2] = double_temp;
902 ExternalReference::InitializeMathExpData();
905 LOperand* value() { return inputs_[0]; }
906 LOperand* temp1() { return temps_[0]; }
907 LOperand* temp2() { return temps_[1]; }
908 LOperand* double_temp() { return temps_[2]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
914 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
916 explicit LMathSqrt(LOperand* value) { inputs_[0] = value; }
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
924 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
926 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
928 LOperand* value() { return inputs_[0]; }
930 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
934 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
936 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
941 LOperand* left() { return inputs_[0]; }
942 LOperand* right() { return inputs_[1]; }
944 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
945 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
949 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
951 explicit LCmpHoleAndBranch(LOperand* object) { inputs_[0] = object; }
953 LOperand* object() { return inputs_[0]; }
955 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
956 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
960 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
962 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
967 LOperand* value() { return inputs_[0]; }
968 LOperand* temp() { return temps_[0]; }
970 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
971 "cmp-minus-zero-and-branch")
972 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
976 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
978 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
983 LOperand* value() { return inputs_[0]; }
984 LOperand* temp() { return temps_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
987 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
989 void PrintDataTo(StringStream* stream) override;
993 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
995 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1000 LOperand* value() { return inputs_[0]; }
1001 LOperand* temp() { return temps_[0]; }
1003 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1004 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1006 void PrintDataTo(StringStream* stream) override;
1010 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1012 explicit LIsSmiAndBranch(LOperand* value) { inputs_[0] = value; }
1014 LOperand* value() { return inputs_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1019 void PrintDataTo(StringStream* stream) override;
1023 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1025 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1030 LOperand* value() { return inputs_[0]; }
1031 LOperand* temp() { return temps_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1034 "is-undetectable-and-branch")
1035 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1037 void PrintDataTo(StringStream* stream) override;
1041 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1043 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1044 inputs_[0] = context;
1049 LOperand* context() { return inputs_[0]; }
1050 LOperand* left() { return inputs_[1]; }
1051 LOperand* right() { return inputs_[2]; }
1053 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1054 "string-compare-and-branch")
1055 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1057 Token::Value op() const { return hydrogen()->token(); }
1059 void PrintDataTo(StringStream* stream) override;
1063 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1065 explicit LHasInstanceTypeAndBranch(LOperand* value) { inputs_[0] = value; }
1067 LOperand* value() { return inputs_[0]; }
1069 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1070 "has-instance-type-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1073 void PrintDataTo(StringStream* stream) override;
1077 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1079 explicit LGetCachedArrayIndex(LOperand* value) { inputs_[0] = value; }
1081 LOperand* value() { return inputs_[0]; }
1083 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1084 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1088 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1090 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1094 LOperand* value() { return inputs_[0]; }
1096 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1097 "has-cached-array-index-and-branch")
1098 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1100 void PrintDataTo(StringStream* stream) override;
1104 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1106 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1111 LOperand* value() { return inputs_[0]; }
1112 LOperand* temp() { return temps_[0]; }
1114 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, "class-of-test-and-branch")
1115 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1117 void PrintDataTo(StringStream* stream) override;
1121 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1123 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1124 inputs_[0] = context;
1129 LOperand* context() { return inputs_[0]; }
1130 LOperand* left() { return inputs_[1]; }
1131 LOperand* right() { return inputs_[2]; }
1133 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1134 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1136 Strength strength() { return hydrogen()->strength(); }
1138 Token::Value op() const { return hydrogen()->token(); }
1142 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1144 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1145 inputs_[0] = context;
1150 LOperand* context() { return inputs_[0]; }
1151 LOperand* left() { return inputs_[1]; }
1152 LOperand* right() { return inputs_[2]; }
1154 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1158 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1160 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1161 inputs_[0] = context;
1166 LOperand* context() { return inputs_[0]; }
1167 LOperand* value() { return inputs_[1]; }
1168 LOperand* temp() { return temps_[0]; }
1170 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1171 "instance-of-known-global")
1172 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1174 Handle<JSFunction> function() const { return hydrogen()->function(); }
1175 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1176 return lazy_deopt_env_;
1178 virtual void SetDeferredLazyDeoptimizationEnvironment(
1179 LEnvironment* env) override {
1180 lazy_deopt_env_ = env;
1184 LEnvironment* lazy_deopt_env_;
1188 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1190 LBoundsCheck(LOperand* index, LOperand* length) {
1192 inputs_[1] = length;
1195 LOperand* index() { return inputs_[0]; }
1196 LOperand* length() { return inputs_[1]; }
1198 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1199 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1203 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1205 LBitI(LOperand* left, LOperand* right) {
1210 LOperand* left() { return inputs_[0]; }
1211 LOperand* right() { return inputs_[1]; }
1213 Token::Value op() const { return hydrogen()->op(); }
1215 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1216 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1220 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1222 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1223 : op_(op), can_deopt_(can_deopt) {
1228 Token::Value op() const { return op_; }
1229 LOperand* left() { return inputs_[0]; }
1230 LOperand* right() { return inputs_[1]; }
1231 bool can_deopt() const { return can_deopt_; }
1233 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1241 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1243 LSubI(LOperand* left, LOperand* right) {
1248 LOperand* left() { return inputs_[0]; }
1249 LOperand* right() { return inputs_[1]; }
1251 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1252 DECLARE_HYDROGEN_ACCESSOR(Sub)
1256 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1258 LRSubI(LOperand* left, LOperand* right) {
1263 LOperand* left() { return inputs_[0]; }
1264 LOperand* right() { return inputs_[1]; }
1266 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1267 DECLARE_HYDROGEN_ACCESSOR(Sub)
1271 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1273 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1274 DECLARE_HYDROGEN_ACCESSOR(Constant)
1276 int32_t value() const { return hydrogen()->Integer32Value(); }
1280 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1282 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1283 DECLARE_HYDROGEN_ACCESSOR(Constant)
1285 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1289 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1291 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1292 DECLARE_HYDROGEN_ACCESSOR(Constant)
1294 double value() const { return hydrogen()->DoubleValue(); }
1295 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1299 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1301 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1302 DECLARE_HYDROGEN_ACCESSOR(Constant)
1304 ExternalReference value() const {
1305 return hydrogen()->ExternalReferenceValue();
1310 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1312 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1313 DECLARE_HYDROGEN_ACCESSOR(Constant)
1315 Handle<Object> value(Isolate* isolate) const {
1316 return hydrogen()->handle(isolate);
1321 class LBranch final : public LControlInstruction<1, 0> {
1323 explicit LBranch(LOperand* value) { inputs_[0] = value; }
1325 LOperand* value() { return inputs_[0]; }
1327 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1328 DECLARE_HYDROGEN_ACCESSOR(Branch)
1330 void PrintDataTo(StringStream* stream) override;
1334 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1336 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1341 LOperand* value() { return inputs_[0]; }
1342 LOperand* temp() { return temps_[0]; }
1344 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1345 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1347 Handle<Map> map() const { return hydrogen()->map().handle(); }
1351 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1353 explicit LMapEnumLength(LOperand* value) { inputs_[0] = value; }
1355 LOperand* value() { return inputs_[0]; }
1357 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1361 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1363 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1368 LOperand* date() { return inputs_[0]; }
1369 LOperand* temp() { return temps_[0]; }
1370 Smi* index() const { return index_; }
1372 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1373 DECLARE_HYDROGEN_ACCESSOR(DateField)
1380 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1382 LSeqStringGetChar(LOperand* string, LOperand* index) {
1383 inputs_[0] = string;
1387 LOperand* string() const { return inputs_[0]; }
1388 LOperand* index() const { return inputs_[1]; }
1390 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1391 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1395 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1397 LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1399 inputs_[0] = context;
1400 inputs_[1] = string;
1405 LOperand* string() { return inputs_[1]; }
1406 LOperand* index() { return inputs_[2]; }
1407 LOperand* value() { return inputs_[3]; }
1409 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1410 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1414 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1416 LAddI(LOperand* left, LOperand* right) {
1421 LOperand* left() { return inputs_[0]; }
1422 LOperand* right() { return inputs_[1]; }
1424 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1425 DECLARE_HYDROGEN_ACCESSOR(Add)
1429 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1431 LMathMinMax(LOperand* left, LOperand* right) {
1436 LOperand* left() { return inputs_[0]; }
1437 LOperand* right() { return inputs_[1]; }
1439 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1440 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1444 class LPower final : public LTemplateInstruction<1, 2, 0> {
1446 LPower(LOperand* left, LOperand* right) {
1451 LOperand* left() { return inputs_[0]; }
1452 LOperand* right() { return inputs_[1]; }
1454 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1455 DECLARE_HYDROGEN_ACCESSOR(Power)
1459 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1461 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1466 Token::Value op() const { return op_; }
1467 LOperand* left() { return inputs_[0]; }
1468 LOperand* right() { return inputs_[1]; }
1470 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1471 void CompileToNative(LCodeGen* generator) override;
1472 const char* Mnemonic() const override;
1479 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1481 LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1484 inputs_[0] = context;
1489 LOperand* context() { return inputs_[0]; }
1490 LOperand* left() { return inputs_[1]; }
1491 LOperand* right() { return inputs_[2]; }
1492 Token::Value op() const { return op_; }
1494 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1495 void CompileToNative(LCodeGen* generator) override;
1496 const char* Mnemonic() const override;
1498 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1500 Strength strength() { return hydrogen()->strength(); }
1507 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1509 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1511 inputs_[1] = context;
1512 inputs_[2] = parameter_count;
1515 LOperand* value() { return inputs_[0]; }
1517 bool has_constant_parameter_count() {
1518 return parameter_count()->IsConstantOperand();
1520 LConstantOperand* constant_parameter_count() {
1521 DCHECK(has_constant_parameter_count());
1522 return LConstantOperand::cast(parameter_count());
1524 LOperand* parameter_count() { return inputs_[2]; }
1526 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1530 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1532 explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1534 LOperand* object() { return inputs_[0]; }
1536 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1537 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1541 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1543 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1544 inputs_[0] = context;
1545 inputs_[1] = object;
1549 LOperand* context() { return inputs_[0]; }
1550 LOperand* object() { return inputs_[1]; }
1551 LOperand* temp_vector() { return temps_[0]; }
1553 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1554 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1556 Handle<Object> name() const { return hydrogen()->name(); }
1560 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1562 explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1564 LOperand* function() { return inputs_[0]; }
1566 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1571 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1573 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1574 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1576 Heap::RootListIndex index() const { return hydrogen()->index(); }
1580 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1582 LLoadKeyed(LOperand* elements, LOperand* key) {
1583 inputs_[0] = elements;
1587 LOperand* elements() { return inputs_[0]; }
1588 LOperand* key() { return inputs_[1]; }
1589 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1590 bool is_external() const { return hydrogen()->is_external(); }
1591 bool is_fixed_typed_array() const {
1592 return hydrogen()->is_fixed_typed_array();
1594 bool is_typed_elements() const {
1595 return is_external() || is_fixed_typed_array();
1598 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1599 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1601 void PrintDataTo(StringStream* stream) override;
1602 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1606 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1608 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1610 inputs_[0] = context;
1611 inputs_[1] = object;
1616 LOperand* context() { return inputs_[0]; }
1617 LOperand* object() { return inputs_[1]; }
1618 LOperand* key() { return inputs_[2]; }
1619 LOperand* temp_vector() { return temps_[0]; }
1621 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1626 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1628 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1630 inputs_[0] = context;
1631 inputs_[1] = global_object;
1635 LOperand* context() { return inputs_[0]; }
1636 LOperand* global_object() { return inputs_[1]; }
1637 LOperand* temp_vector() { return temps_[0]; }
1639 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1640 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1642 Handle<Object> name() const { return hydrogen()->name(); }
1643 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1647 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1649 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1651 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1654 void PrintDataTo(StringStream* stream) override;
1656 LOperand* context() { return inputs_[0]; }
1658 Handle<Object> name() const { return hydrogen()->name(); }
1659 int depth() const { return hydrogen()->depth(); }
1660 int slot_index() const { return hydrogen()->slot_index(); }
1664 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1666 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1668 LOperand* context() { return inputs_[0]; }
1670 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1671 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1673 int slot_index() { return hydrogen()->slot_index(); }
1675 void PrintDataTo(StringStream* stream) override;
1679 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1681 LStoreContextSlot(LOperand* context, LOperand* value) {
1682 inputs_[0] = context;
1686 LOperand* context() { return inputs_[0]; }
1687 LOperand* value() { return inputs_[1]; }
1689 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1690 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1692 int slot_index() { return hydrogen()->slot_index(); }
1694 void PrintDataTo(StringStream* stream) override;
1698 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1700 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1702 LOperand* value() { return inputs_[0]; }
1704 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1708 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1710 explicit LDrop(int count) : count_(count) {}
1712 int count() const { return count_; }
1714 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1721 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1723 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1724 inputs_[0] = function;
1725 inputs_[1] = code_object;
1728 LOperand* function() { return inputs_[0]; }
1729 LOperand* code_object() { return inputs_[1]; }
1731 void PrintDataTo(StringStream* stream) override;
1733 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1734 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1738 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1740 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1741 inputs_[0] = base_object;
1742 inputs_[1] = offset;
1745 LOperand* base_object() const { return inputs_[0]; }
1746 LOperand* offset() const { return inputs_[1]; }
1748 void PrintDataTo(StringStream* stream) override;
1750 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1754 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1756 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1757 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1761 class LContext final : public LTemplateInstruction<1, 0, 0> {
1763 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1764 DECLARE_HYDROGEN_ACCESSOR(Context)
1768 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1770 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1772 LOperand* context() { return inputs_[0]; }
1774 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1775 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1779 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1781 explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1783 LOperand* function() { return inputs_[0]; }
1785 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1786 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1788 void PrintDataTo(StringStream* stream) override;
1790 int arity() const { return hydrogen()->argument_count() - 1; }
1794 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1796 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1797 const ZoneList<LOperand*>& operands, Zone* zone)
1798 : descriptor_(descriptor),
1799 inputs_(descriptor.GetRegisterParameterCount() +
1800 kImplicitRegisterParameterCount,
1802 DCHECK(descriptor.GetRegisterParameterCount() +
1803 kImplicitRegisterParameterCount ==
1805 inputs_.AddAll(operands, zone);
1808 LOperand* target() const { return inputs_[0]; }
1810 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1812 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1814 // The target and context are passed as implicit parameters that are not
1815 // explicitly listed in the descriptor.
1816 static const int kImplicitRegisterParameterCount = 2;
1819 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1821 void PrintDataTo(StringStream* stream) override;
1823 int arity() const { return hydrogen()->argument_count() - 1; }
1825 CallInterfaceDescriptor descriptor_;
1826 ZoneList<LOperand*> inputs_;
1828 // Iterator support.
1829 int InputCount() final { return inputs_.length(); }
1830 LOperand* InputAt(int i) final { return inputs_[i]; }
1832 int TempCount() final { return 0; }
1833 LOperand* TempAt(int i) final { return NULL; }
1837 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1839 LInvokeFunction(LOperand* context, LOperand* function) {
1840 inputs_[0] = context;
1841 inputs_[1] = function;
1844 LOperand* context() { return inputs_[0]; }
1845 LOperand* function() { return inputs_[1]; }
1847 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1848 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1850 void PrintDataTo(StringStream* stream) override;
1852 int arity() const { return hydrogen()->argument_count() - 1; }
1856 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1858 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1860 inputs_[0] = context;
1861 inputs_[1] = function;
1866 LOperand* context() { return inputs_[0]; }
1867 LOperand* function() { return inputs_[1]; }
1868 LOperand* temp_slot() { return temps_[0]; }
1869 LOperand* temp_vector() { return temps_[1]; }
1871 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1872 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1875 void PrintDataTo(StringStream* stream) override;
1879 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1881 LCallNew(LOperand* context, LOperand* constructor) {
1882 inputs_[0] = context;
1883 inputs_[1] = constructor;
1886 LOperand* context() { return inputs_[0]; }
1887 LOperand* constructor() { return inputs_[1]; }
1889 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1890 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1892 void PrintDataTo(StringStream* stream) override;
1894 int arity() const { return hydrogen()->argument_count() - 1; }
1898 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1900 LCallNewArray(LOperand* context, LOperand* constructor) {
1901 inputs_[0] = context;
1902 inputs_[1] = constructor;
1905 LOperand* context() { return inputs_[0]; }
1906 LOperand* constructor() { return inputs_[1]; }
1908 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1909 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1911 void PrintDataTo(StringStream* stream) override;
1913 int arity() const { return hydrogen()->argument_count() - 1; }
1917 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1919 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1921 LOperand* context() { return inputs_[0]; }
1923 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1924 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1926 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1927 return save_doubles() == kDontSaveFPRegs;
1930 const Runtime::Function* function() const { return hydrogen()->function(); }
1931 int arity() const { return hydrogen()->argument_count(); }
1932 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1936 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1938 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1940 LOperand* value() { return inputs_[0]; }
1942 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1946 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1948 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1950 LOperand* value() { return inputs_[0]; }
1952 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1956 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1958 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1964 LOperand* value() { return inputs_[0]; }
1965 LOperand* temp1() { return temps_[0]; }
1966 LOperand* temp2() { return temps_[1]; }
1968 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1972 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1974 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1980 LOperand* value() { return inputs_[0]; }
1981 LOperand* temp1() { return temps_[0]; }
1982 LOperand* temp2() { return temps_[1]; }
1984 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1988 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1990 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1996 LOperand* value() { return inputs_[0]; }
1997 LOperand* temp() { return temps_[0]; }
1998 LOperand* temp2() { return temps_[1]; }
2000 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2001 DECLARE_HYDROGEN_ACCESSOR(Change)
2005 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2007 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
2009 LOperand* value() { return inputs_[0]; }
2011 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2012 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2014 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2018 // Sometimes truncating conversion from a tagged value to an int32.
2019 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2021 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
2023 LOperand* value() { return inputs_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2026 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2028 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2032 // Truncating conversion from a tagged value to an int32.
2033 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2035 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2041 LOperand* value() { return inputs_[0]; }
2042 LOperand* temp() { return temps_[0]; }
2043 LOperand* temp2() { return temps_[1]; }
2045 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2046 DECLARE_HYDROGEN_ACCESSOR(Change)
2048 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2052 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2054 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2056 LOperand* value() { return inputs_[0]; }
2058 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2059 DECLARE_HYDROGEN_ACCESSOR(Change)
2063 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2065 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2067 LOperand* value() { return inputs_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2070 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2076 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2080 LOperand* value() { return inputs_[0]; }
2081 bool needs_check() const { return needs_check_; }
2083 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2090 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2092 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2093 inputs_[0] = object;
2098 LOperand* object() { return inputs_[0]; }
2099 LOperand* value() { return inputs_[1]; }
2100 LOperand* temp() { return temps_[0]; }
2102 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2103 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2105 void PrintDataTo(StringStream* stream) override;
2107 Representation representation() const {
2108 return hydrogen()->field_representation();
2113 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2115 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2116 LOperand* slot, LOperand* vector) {
2117 inputs_[0] = context;
2118 inputs_[1] = object;
2124 LOperand* context() { return inputs_[0]; }
2125 LOperand* object() { return inputs_[1]; }
2126 LOperand* value() { return inputs_[2]; }
2127 LOperand* temp_slot() { return temps_[0]; }
2128 LOperand* temp_vector() { return temps_[1]; }
2130 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2131 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2133 void PrintDataTo(StringStream* stream) override;
2135 Handle<Object> name() const { return hydrogen()->name(); }
2136 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2140 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2142 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2143 inputs_[0] = context;
2147 LOperand* context() { return inputs_[0]; }
2148 LOperand* value() { return inputs_[1]; }
2150 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2151 "store-global-via-context")
2152 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2154 void PrintDataTo(StringStream* stream) override;
2156 Handle<Object> name() const { return hydrogen()->name(); }
2157 int depth() { return hydrogen()->depth(); }
2158 int slot_index() { return hydrogen()->slot_index(); }
2159 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2163 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2165 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2166 inputs_[0] = object;
2171 bool is_external() const { return hydrogen()->is_external(); }
2172 bool is_fixed_typed_array() const {
2173 return hydrogen()->is_fixed_typed_array();
2175 bool is_typed_elements() const {
2176 return is_external() || is_fixed_typed_array();
2178 LOperand* elements() { return inputs_[0]; }
2179 LOperand* key() { return inputs_[1]; }
2180 LOperand* value() { return inputs_[2]; }
2181 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2183 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2184 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2186 void PrintDataTo(StringStream* stream) override;
2187 bool NeedsCanonicalization() {
2188 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2189 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2192 return hydrogen()->NeedsCanonicalization();
2194 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2198 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2200 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2201 LOperand* value, LOperand* slot, LOperand* vector) {
2202 inputs_[0] = context;
2203 inputs_[1] = object;
2210 LOperand* context() { return inputs_[0]; }
2211 LOperand* object() { return inputs_[1]; }
2212 LOperand* key() { return inputs_[2]; }
2213 LOperand* value() { return inputs_[3]; }
2214 LOperand* temp_slot() { return temps_[0]; }
2215 LOperand* temp_vector() { return temps_[1]; }
2217 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2218 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2220 void PrintDataTo(StringStream* stream) override;
2222 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2226 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2228 LTransitionElementsKind(LOperand* object, LOperand* context,
2229 LOperand* new_map_temp) {
2230 inputs_[0] = object;
2231 inputs_[1] = context;
2232 temps_[0] = new_map_temp;
2235 LOperand* context() { return inputs_[1]; }
2236 LOperand* object() { return inputs_[0]; }
2237 LOperand* new_map_temp() { return temps_[0]; }
2239 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2240 "transition-elements-kind")
2241 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2243 void PrintDataTo(StringStream* stream) override;
2245 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2246 Handle<Map> transitioned_map() {
2247 return hydrogen()->transitioned_map().handle();
2249 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2250 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2254 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2256 LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2257 inputs_[0] = object;
2261 LOperand* object() { return inputs_[0]; }
2262 LOperand* temp() { return temps_[0]; }
2264 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2268 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2270 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2271 LOperand* key, LOperand* current_capacity) {
2272 inputs_[0] = context;
2273 inputs_[1] = object;
2274 inputs_[2] = elements;
2276 inputs_[4] = current_capacity;
2279 LOperand* context() { return inputs_[0]; }
2280 LOperand* object() { return inputs_[1]; }
2281 LOperand* elements() { return inputs_[2]; }
2282 LOperand* key() { return inputs_[3]; }
2283 LOperand* current_capacity() { return inputs_[4]; }
2285 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2286 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2290 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2292 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2293 inputs_[0] = context;
2298 LOperand* context() { return inputs_[0]; }
2299 LOperand* left() { return inputs_[1]; }
2300 LOperand* right() { return inputs_[2]; }
2302 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2303 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2307 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2309 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2310 inputs_[0] = context;
2311 inputs_[1] = string;
2315 LOperand* context() { return inputs_[0]; }
2316 LOperand* string() { return inputs_[1]; }
2317 LOperand* index() { return inputs_[2]; }
2319 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2320 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2324 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2326 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2327 inputs_[0] = context;
2328 inputs_[1] = char_code;
2331 LOperand* context() { return inputs_[0]; }
2332 LOperand* char_code() { return inputs_[1]; }
2334 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2335 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2339 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2341 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2343 LOperand* value() { return inputs_[0]; }
2345 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2346 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2350 class LCheckArrayBufferNotNeutered final
2351 : public LTemplateInstruction<0, 1, 0> {
2353 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2355 LOperand* view() { return inputs_[0]; }
2357 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2358 "check-array-buffer-not-neutered")
2359 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2363 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2365 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2367 LOperand* value() { return inputs_[0]; }
2369 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2370 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2374 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2376 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2381 LOperand* value() { return inputs_[0]; }
2382 LOperand* temp() { return temps_[0]; }
2384 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2385 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2389 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2391 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2393 LOperand* value() { return inputs_[0]; }
2395 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2399 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2401 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2403 LOperand* value() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2406 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2410 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2412 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2414 LOperand* unclamped() { return inputs_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2420 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2422 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2424 LOperand* unclamped() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2430 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2432 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2433 inputs_[0] = unclamped;
2437 LOperand* unclamped() { return inputs_[0]; }
2438 LOperand* temp() { return temps_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2444 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2446 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2448 LOperand* value() { return inputs_[0]; }
2450 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2451 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2455 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2457 LConstructDouble(LOperand* hi, LOperand* lo) {
2462 LOperand* hi() { return inputs_[0]; }
2463 LOperand* lo() { return inputs_[1]; }
2465 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2469 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2471 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2473 inputs_[0] = context;
2479 LOperand* context() { return inputs_[0]; }
2480 LOperand* size() { return inputs_[1]; }
2481 LOperand* temp1() { return temps_[0]; }
2482 LOperand* temp2() { return temps_[1]; }
2484 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2485 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2489 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2491 explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2493 LOperand* context() { return inputs_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2496 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2500 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2502 explicit LFunctionLiteral(LOperand* context) { inputs_[0] = context; }
2504 LOperand* context() { return inputs_[0]; }
2506 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2507 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2511 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2513 explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2515 LOperand* value() { return inputs_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2518 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2522 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2524 LTypeof(LOperand* context, LOperand* value) {
2525 inputs_[0] = context;
2529 LOperand* context() { return inputs_[0]; }
2530 LOperand* value() { return inputs_[1]; }
2532 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2536 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2538 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2540 LOperand* value() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2543 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2545 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2547 void PrintDataTo(StringStream* stream) override;
2551 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2553 explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2555 LOperand* temp() { return temps_[0]; }
2557 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2558 "is-construct-call-and-branch")
2562 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2566 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2567 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2571 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2573 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2575 LOperand* context() { return inputs_[0]; }
2577 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2578 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2580 Label* done_label() { return &done_label_; }
2587 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2589 LForInPrepareMap(LOperand* context, LOperand* object) {
2590 inputs_[0] = context;
2591 inputs_[1] = object;
2594 LOperand* context() { return inputs_[0]; }
2595 LOperand* object() { return inputs_[1]; }
2597 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2601 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2603 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2605 LOperand* map() { return inputs_[0]; }
2607 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2609 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2613 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2615 LCheckMapValue(LOperand* value, LOperand* map) {
2620 LOperand* value() { return inputs_[0]; }
2621 LOperand* map() { return inputs_[1]; }
2623 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2627 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2629 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2630 inputs_[0] = object;
2634 LOperand* object() { return inputs_[0]; }
2635 LOperand* index() { return inputs_[1]; }
2637 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2641 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2643 explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2645 LOperand* context() { return inputs_[0]; }
2647 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2651 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2653 LAllocateBlockContext(LOperand* context, LOperand* function) {
2654 inputs_[0] = context;
2655 inputs_[1] = function;
2658 LOperand* context() { return inputs_[0]; }
2659 LOperand* function() { return inputs_[1]; }
2661 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2663 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2664 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2668 class LChunkBuilder;
2669 class LPlatformChunk final : public LChunk {
2671 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2673 int GetNextSpillIndex(RegisterKind kind);
2674 LOperand* GetNextSpillSlot(RegisterKind kind);
2678 class LChunkBuilder final : public LChunkBuilderBase {
2680 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2681 : LChunkBuilderBase(info, graph),
2682 current_instruction_(NULL),
2683 current_block_(NULL),
2685 allocator_(allocator) {}
2687 // Build the sequence for the graph.
2688 LPlatformChunk* Build();
2690 // Declare methods that deal with the individual node types.
2691 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2692 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2695 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2696 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2697 LInstruction* DoRSub(HSub* instr);
2699 static bool HasMagicNumberForDivisor(int32_t divisor);
2701 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2702 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2703 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2704 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2705 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2706 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2707 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2708 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2709 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2710 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2711 LInstruction* DoDivByConstI(HDiv* instr);
2712 LInstruction* DoDivI(HDiv* instr);
2713 LInstruction* DoModByPowerOf2I(HMod* instr);
2714 LInstruction* DoModByConstI(HMod* instr);
2715 LInstruction* DoModI(HMod* instr);
2716 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2717 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2718 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2721 // Methods for getting operands for Use / Define / Temp.
2722 LUnallocated* ToUnallocated(Register reg);
2723 LUnallocated* ToUnallocated(DoubleRegister reg);
2725 // Methods for setting up define-use relationships.
2726 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2727 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2728 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2729 DoubleRegister fixed_register);
2731 // A value that is guaranteed to be allocated to a register.
2732 // Operand created by UseRegister is guaranteed to be live until the end of
2733 // instruction. This means that register allocator will not reuse it's
2734 // register for any other operand inside instruction.
2735 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2736 // instruction start. Register allocator is free to assign the same register
2737 // to some other operand used inside instruction (i.e. temporary or
2739 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2740 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2742 // An input operand in a register that may be trashed.
2743 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2745 // An input operand in a register or stack slot.
2746 MUST_USE_RESULT LOperand* Use(HValue* value);
2747 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2749 // An input operand in a register, stack slot or a constant operand.
2750 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2751 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2753 // An input operand in a register or a constant operand.
2754 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2755 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2757 // An input operand in a constant operand.
2758 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2760 // An input operand in register, stack slot or a constant operand.
2761 // Will not be moved to a register even if one is freely available.
2762 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2764 // Temporary operand that must be in a register.
2765 MUST_USE_RESULT LUnallocated* TempRegister();
2766 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2767 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2768 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2770 // Methods for setting up define-use relationships.
2771 // Return the same instruction that they are passed.
2772 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2773 LUnallocated* result);
2774 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2775 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2777 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2778 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2779 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2780 DoubleRegister reg);
2781 LInstruction* AssignEnvironment(LInstruction* instr);
2782 LInstruction* AssignPointerMap(LInstruction* instr);
2784 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2786 // By default we assume that instruction sequences generated for calls
2787 // cannot deoptimize eagerly and we do not attach environment to this
2789 LInstruction* MarkAsCall(
2790 LInstruction* instr, HInstruction* hinstr,
2791 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2793 void VisitInstruction(HInstruction* current);
2794 void AddInstruction(LInstruction* instr, HInstruction* current);
2796 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2797 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2798 LInstruction* DoArithmeticD(Token::Value op,
2799 HArithmeticBinaryOperation* instr);
2800 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2802 HInstruction* current_instruction_;
2803 HBasicBlock* current_block_;
2804 HBasicBlock* next_block_;
2805 LAllocator* allocator_;
2807 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2810 #undef DECLARE_HYDROGEN_ACCESSOR
2811 #undef DECLARE_CONCRETE_INSTRUCTION
2813 } // namespace v8::internal
2815 #endif // V8_PPC_LITHIUM_PPC_H_