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_fixed_typed_array() const {
1591 return hydrogen()->is_fixed_typed_array();
1594 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1597 void PrintDataTo(StringStream* stream) override;
1598 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1602 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1604 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1606 inputs_[0] = context;
1607 inputs_[1] = object;
1612 LOperand* context() { return inputs_[0]; }
1613 LOperand* object() { return inputs_[1]; }
1614 LOperand* key() { return inputs_[2]; }
1615 LOperand* temp_vector() { return temps_[0]; }
1617 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1622 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1624 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1626 inputs_[0] = context;
1627 inputs_[1] = global_object;
1631 LOperand* context() { return inputs_[0]; }
1632 LOperand* global_object() { return inputs_[1]; }
1633 LOperand* temp_vector() { return temps_[0]; }
1635 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1636 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1638 Handle<Object> name() const { return hydrogen()->name(); }
1639 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1643 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1645 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1647 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1648 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1650 void PrintDataTo(StringStream* stream) override;
1652 LOperand* context() { return inputs_[0]; }
1654 Handle<Object> name() const { return hydrogen()->name(); }
1655 int depth() const { return hydrogen()->depth(); }
1656 int slot_index() const { return hydrogen()->slot_index(); }
1660 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1662 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1664 LOperand* context() { return inputs_[0]; }
1666 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1667 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1669 int slot_index() { return hydrogen()->slot_index(); }
1671 void PrintDataTo(StringStream* stream) override;
1675 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1677 LStoreContextSlot(LOperand* context, LOperand* value) {
1678 inputs_[0] = context;
1682 LOperand* context() { return inputs_[0]; }
1683 LOperand* value() { return inputs_[1]; }
1685 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1686 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1688 int slot_index() { return hydrogen()->slot_index(); }
1690 void PrintDataTo(StringStream* stream) override;
1694 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1696 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1698 LOperand* value() { return inputs_[0]; }
1700 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1704 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1706 explicit LDrop(int count) : count_(count) {}
1708 int count() const { return count_; }
1710 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1717 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1719 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1720 inputs_[0] = function;
1721 inputs_[1] = code_object;
1724 LOperand* function() { return inputs_[0]; }
1725 LOperand* code_object() { return inputs_[1]; }
1727 void PrintDataTo(StringStream* stream) override;
1729 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1730 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1734 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1736 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1737 inputs_[0] = base_object;
1738 inputs_[1] = offset;
1741 LOperand* base_object() const { return inputs_[0]; }
1742 LOperand* offset() const { return inputs_[1]; }
1744 void PrintDataTo(StringStream* stream) override;
1746 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1750 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1752 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1753 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1757 class LContext final : public LTemplateInstruction<1, 0, 0> {
1759 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1760 DECLARE_HYDROGEN_ACCESSOR(Context)
1764 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1766 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1768 LOperand* context() { return inputs_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1771 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1775 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1777 explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1779 LOperand* function() { return inputs_[0]; }
1781 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1782 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1784 void PrintDataTo(StringStream* stream) override;
1786 int arity() const { return hydrogen()->argument_count() - 1; }
1790 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1792 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1793 const ZoneList<LOperand*>& operands, Zone* zone)
1794 : descriptor_(descriptor),
1795 inputs_(descriptor.GetRegisterParameterCount() +
1796 kImplicitRegisterParameterCount,
1798 DCHECK(descriptor.GetRegisterParameterCount() +
1799 kImplicitRegisterParameterCount ==
1801 inputs_.AddAll(operands, zone);
1804 LOperand* target() const { return inputs_[0]; }
1806 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1808 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1810 // The target and context are passed as implicit parameters that are not
1811 // explicitly listed in the descriptor.
1812 static const int kImplicitRegisterParameterCount = 2;
1815 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1817 void PrintDataTo(StringStream* stream) override;
1819 int arity() const { return hydrogen()->argument_count() - 1; }
1821 CallInterfaceDescriptor descriptor_;
1822 ZoneList<LOperand*> inputs_;
1824 // Iterator support.
1825 int InputCount() final { return inputs_.length(); }
1826 LOperand* InputAt(int i) final { return inputs_[i]; }
1828 int TempCount() final { return 0; }
1829 LOperand* TempAt(int i) final { return NULL; }
1833 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1835 LInvokeFunction(LOperand* context, LOperand* function) {
1836 inputs_[0] = context;
1837 inputs_[1] = function;
1840 LOperand* context() { return inputs_[0]; }
1841 LOperand* function() { return inputs_[1]; }
1843 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1844 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1846 void PrintDataTo(StringStream* stream) override;
1848 int arity() const { return hydrogen()->argument_count() - 1; }
1852 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1854 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1856 inputs_[0] = context;
1857 inputs_[1] = function;
1862 LOperand* context() { return inputs_[0]; }
1863 LOperand* function() { return inputs_[1]; }
1864 LOperand* temp_slot() { return temps_[0]; }
1865 LOperand* temp_vector() { return temps_[1]; }
1867 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1868 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1870 int arity() const { return hydrogen()->argument_count() - 1; }
1871 void PrintDataTo(StringStream* stream) override;
1875 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1877 LCallNew(LOperand* context, LOperand* constructor) {
1878 inputs_[0] = context;
1879 inputs_[1] = constructor;
1882 LOperand* context() { return inputs_[0]; }
1883 LOperand* constructor() { return inputs_[1]; }
1885 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1886 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1888 void PrintDataTo(StringStream* stream) override;
1890 int arity() const { return hydrogen()->argument_count() - 1; }
1894 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1896 LCallNewArray(LOperand* context, LOperand* constructor) {
1897 inputs_[0] = context;
1898 inputs_[1] = constructor;
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* constructor() { return inputs_[1]; }
1904 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1905 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1907 void PrintDataTo(StringStream* stream) override;
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1913 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1915 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1917 LOperand* context() { return inputs_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1920 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1922 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1923 return save_doubles() == kDontSaveFPRegs;
1926 const Runtime::Function* function() const { return hydrogen()->function(); }
1927 int arity() const { return hydrogen()->argument_count(); }
1928 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1932 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1934 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1936 LOperand* value() { return inputs_[0]; }
1938 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1942 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1944 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1946 LOperand* value() { return inputs_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1952 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1954 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1960 LOperand* value() { return inputs_[0]; }
1961 LOperand* temp1() { return temps_[0]; }
1962 LOperand* temp2() { return temps_[1]; }
1964 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1968 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1970 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1976 LOperand* value() { return inputs_[0]; }
1977 LOperand* temp1() { return temps_[0]; }
1978 LOperand* temp2() { return temps_[1]; }
1980 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1984 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1986 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1992 LOperand* value() { return inputs_[0]; }
1993 LOperand* temp() { return temps_[0]; }
1994 LOperand* temp2() { return temps_[1]; }
1996 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1997 DECLARE_HYDROGEN_ACCESSOR(Change)
2001 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2003 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
2005 LOperand* value() { return inputs_[0]; }
2007 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2008 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2010 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2014 // Sometimes truncating conversion from a tagged value to an int32.
2015 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2017 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
2019 LOperand* value() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2022 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2024 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2028 // Truncating conversion from a tagged value to an int32.
2029 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2031 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2042 DECLARE_HYDROGEN_ACCESSOR(Change)
2044 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2048 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2050 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2055 DECLARE_HYDROGEN_ACCESSOR(Change)
2059 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2061 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2063 LOperand* value() { return inputs_[0]; }
2065 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2066 DECLARE_HYDROGEN_ACCESSOR(Change)
2070 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2072 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2076 LOperand* value() { return inputs_[0]; }
2077 bool needs_check() const { return needs_check_; }
2079 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2086 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2088 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2089 inputs_[0] = object;
2094 LOperand* object() { return inputs_[0]; }
2095 LOperand* value() { return inputs_[1]; }
2096 LOperand* temp() { return temps_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2099 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2101 void PrintDataTo(StringStream* stream) override;
2103 Representation representation() const {
2104 return hydrogen()->field_representation();
2109 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2111 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2112 LOperand* slot, LOperand* vector) {
2113 inputs_[0] = context;
2114 inputs_[1] = object;
2120 LOperand* context() { return inputs_[0]; }
2121 LOperand* object() { return inputs_[1]; }
2122 LOperand* value() { return inputs_[2]; }
2123 LOperand* temp_slot() { return temps_[0]; }
2124 LOperand* temp_vector() { return temps_[1]; }
2126 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2127 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2129 void PrintDataTo(StringStream* stream) override;
2131 Handle<Object> name() const { return hydrogen()->name(); }
2132 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2136 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2138 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2139 inputs_[0] = context;
2143 LOperand* context() { return inputs_[0]; }
2144 LOperand* value() { return inputs_[1]; }
2146 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2147 "store-global-via-context")
2148 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2150 void PrintDataTo(StringStream* stream) override;
2152 Handle<Object> name() const { return hydrogen()->name(); }
2153 int depth() { return hydrogen()->depth(); }
2154 int slot_index() { return hydrogen()->slot_index(); }
2155 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2159 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2161 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2162 inputs_[0] = object;
2167 bool is_fixed_typed_array() const {
2168 return hydrogen()->is_fixed_typed_array();
2170 LOperand* elements() { return inputs_[0]; }
2171 LOperand* key() { return inputs_[1]; }
2172 LOperand* value() { return inputs_[2]; }
2173 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2175 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2176 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2178 void PrintDataTo(StringStream* stream) override;
2179 bool NeedsCanonicalization() {
2180 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2181 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2184 return hydrogen()->NeedsCanonicalization();
2186 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2190 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2192 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2193 LOperand* value, LOperand* slot, LOperand* vector) {
2194 inputs_[0] = context;
2195 inputs_[1] = object;
2202 LOperand* context() { return inputs_[0]; }
2203 LOperand* object() { return inputs_[1]; }
2204 LOperand* key() { return inputs_[2]; }
2205 LOperand* value() { return inputs_[3]; }
2206 LOperand* temp_slot() { return temps_[0]; }
2207 LOperand* temp_vector() { return temps_[1]; }
2209 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2212 void PrintDataTo(StringStream* stream) override;
2214 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2218 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2220 LTransitionElementsKind(LOperand* object, LOperand* context,
2221 LOperand* new_map_temp) {
2222 inputs_[0] = object;
2223 inputs_[1] = context;
2224 temps_[0] = new_map_temp;
2227 LOperand* context() { return inputs_[1]; }
2228 LOperand* object() { return inputs_[0]; }
2229 LOperand* new_map_temp() { return temps_[0]; }
2231 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2232 "transition-elements-kind")
2233 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2235 void PrintDataTo(StringStream* stream) override;
2237 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2238 Handle<Map> transitioned_map() {
2239 return hydrogen()->transitioned_map().handle();
2241 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2242 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2246 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2248 LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2249 inputs_[0] = object;
2253 LOperand* object() { return inputs_[0]; }
2254 LOperand* temp() { return temps_[0]; }
2256 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2260 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2262 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2263 LOperand* key, LOperand* current_capacity) {
2264 inputs_[0] = context;
2265 inputs_[1] = object;
2266 inputs_[2] = elements;
2268 inputs_[4] = current_capacity;
2271 LOperand* context() { return inputs_[0]; }
2272 LOperand* object() { return inputs_[1]; }
2273 LOperand* elements() { return inputs_[2]; }
2274 LOperand* key() { return inputs_[3]; }
2275 LOperand* current_capacity() { return inputs_[4]; }
2277 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2278 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2282 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2284 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2285 inputs_[0] = context;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* left() { return inputs_[1]; }
2292 LOperand* right() { return inputs_[2]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2295 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2299 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2301 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2302 inputs_[0] = context;
2303 inputs_[1] = string;
2307 LOperand* context() { return inputs_[0]; }
2308 LOperand* string() { return inputs_[1]; }
2309 LOperand* index() { return inputs_[2]; }
2311 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2312 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2316 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2318 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2319 inputs_[0] = context;
2320 inputs_[1] = char_code;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* char_code() { return inputs_[1]; }
2326 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2327 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2331 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2335 LOperand* value() { return inputs_[0]; }
2337 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2338 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2342 class LCheckArrayBufferNotNeutered final
2343 : public LTemplateInstruction<0, 1, 0> {
2345 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2347 LOperand* view() { return inputs_[0]; }
2349 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2350 "check-array-buffer-not-neutered")
2351 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2355 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2357 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2359 LOperand* value() { return inputs_[0]; }
2361 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2362 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2366 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2368 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2373 LOperand* value() { return inputs_[0]; }
2374 LOperand* temp() { return temps_[0]; }
2376 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2377 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2381 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2383 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2385 LOperand* value() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2391 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2393 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2395 LOperand* value() { return inputs_[0]; }
2397 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2398 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2402 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2404 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2406 LOperand* unclamped() { return inputs_[0]; }
2408 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2412 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2414 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2416 LOperand* unclamped() { return inputs_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2422 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2424 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2425 inputs_[0] = unclamped;
2429 LOperand* unclamped() { return inputs_[0]; }
2430 LOperand* temp() { return temps_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2436 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2438 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2440 LOperand* value() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2443 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2447 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2449 LConstructDouble(LOperand* hi, LOperand* lo) {
2454 LOperand* hi() { return inputs_[0]; }
2455 LOperand* lo() { return inputs_[1]; }
2457 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2461 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2463 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2465 inputs_[0] = context;
2471 LOperand* context() { return inputs_[0]; }
2472 LOperand* size() { return inputs_[1]; }
2473 LOperand* temp1() { return temps_[0]; }
2474 LOperand* temp2() { return temps_[1]; }
2476 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2477 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2481 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2483 explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2485 LOperand* context() { return inputs_[0]; }
2487 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2488 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2492 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2494 explicit LFunctionLiteral(LOperand* context) { inputs_[0] = context; }
2496 LOperand* context() { return inputs_[0]; }
2498 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2499 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2503 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2505 explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2507 LOperand* value() { return inputs_[0]; }
2509 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2510 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2514 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2516 LTypeof(LOperand* context, LOperand* value) {
2517 inputs_[0] = context;
2521 LOperand* context() { return inputs_[0]; }
2522 LOperand* value() { return inputs_[1]; }
2524 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2528 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2530 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2532 LOperand* value() { return inputs_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2535 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2537 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2539 void PrintDataTo(StringStream* stream) override;
2543 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2545 explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2547 LOperand* temp() { return temps_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2550 "is-construct-call-and-branch")
2554 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2558 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2559 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2563 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2565 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2567 LOperand* context() { return inputs_[0]; }
2569 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2570 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2572 Label* done_label() { return &done_label_; }
2579 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2581 LForInPrepareMap(LOperand* context, LOperand* object) {
2582 inputs_[0] = context;
2583 inputs_[1] = object;
2586 LOperand* context() { return inputs_[0]; }
2587 LOperand* object() { return inputs_[1]; }
2589 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2593 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2595 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2597 LOperand* map() { return inputs_[0]; }
2599 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2601 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2605 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2607 LCheckMapValue(LOperand* value, LOperand* map) {
2612 LOperand* value() { return inputs_[0]; }
2613 LOperand* map() { return inputs_[1]; }
2615 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2619 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2621 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2622 inputs_[0] = object;
2626 LOperand* object() { return inputs_[0]; }
2627 LOperand* index() { return inputs_[1]; }
2629 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2633 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2635 explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2637 LOperand* context() { return inputs_[0]; }
2639 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2643 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2645 LAllocateBlockContext(LOperand* context, LOperand* function) {
2646 inputs_[0] = context;
2647 inputs_[1] = function;
2650 LOperand* context() { return inputs_[0]; }
2651 LOperand* function() { return inputs_[1]; }
2653 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2655 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2656 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2660 class LChunkBuilder;
2661 class LPlatformChunk final : public LChunk {
2663 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2665 int GetNextSpillIndex(RegisterKind kind);
2666 LOperand* GetNextSpillSlot(RegisterKind kind);
2670 class LChunkBuilder final : public LChunkBuilderBase {
2672 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2673 : LChunkBuilderBase(info, graph),
2674 current_instruction_(NULL),
2675 current_block_(NULL),
2677 allocator_(allocator) {}
2679 // Build the sequence for the graph.
2680 LPlatformChunk* Build();
2682 // Declare methods that deal with the individual node types.
2683 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2684 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2687 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2688 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2689 LInstruction* DoRSub(HSub* instr);
2691 static bool HasMagicNumberForDivisor(int32_t divisor);
2693 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2694 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2695 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2696 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2697 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2698 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2699 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2700 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2701 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2702 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2703 LInstruction* DoDivByConstI(HDiv* instr);
2704 LInstruction* DoDivI(HDiv* instr);
2705 LInstruction* DoModByPowerOf2I(HMod* instr);
2706 LInstruction* DoModByConstI(HMod* instr);
2707 LInstruction* DoModI(HMod* instr);
2708 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2709 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2710 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2713 // Methods for getting operands for Use / Define / Temp.
2714 LUnallocated* ToUnallocated(Register reg);
2715 LUnallocated* ToUnallocated(DoubleRegister reg);
2717 // Methods for setting up define-use relationships.
2718 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2719 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2720 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2721 DoubleRegister fixed_register);
2723 // A value that is guaranteed to be allocated to a register.
2724 // Operand created by UseRegister is guaranteed to be live until the end of
2725 // instruction. This means that register allocator will not reuse it's
2726 // register for any other operand inside instruction.
2727 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2728 // instruction start. Register allocator is free to assign the same register
2729 // to some other operand used inside instruction (i.e. temporary or
2731 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2732 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2734 // An input operand in a register that may be trashed.
2735 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2737 // An input operand in a register or stack slot.
2738 MUST_USE_RESULT LOperand* Use(HValue* value);
2739 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2741 // An input operand in a register, stack slot or a constant operand.
2742 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2743 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2745 // An input operand in a register or a constant operand.
2746 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2747 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2749 // An input operand in a constant operand.
2750 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2752 // An input operand in register, stack slot or a constant operand.
2753 // Will not be moved to a register even if one is freely available.
2754 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2756 // Temporary operand that must be in a register.
2757 MUST_USE_RESULT LUnallocated* TempRegister();
2758 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2759 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2760 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2762 // Methods for setting up define-use relationships.
2763 // Return the same instruction that they are passed.
2764 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2765 LUnallocated* result);
2766 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2767 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2769 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2770 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2771 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2772 DoubleRegister reg);
2773 LInstruction* AssignEnvironment(LInstruction* instr);
2774 LInstruction* AssignPointerMap(LInstruction* instr);
2776 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2778 // By default we assume that instruction sequences generated for calls
2779 // cannot deoptimize eagerly and we do not attach environment to this
2781 LInstruction* MarkAsCall(
2782 LInstruction* instr, HInstruction* hinstr,
2783 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2785 void VisitInstruction(HInstruction* current);
2786 void AddInstruction(LInstruction* instr, HInstruction* current);
2788 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2789 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2790 LInstruction* DoArithmeticD(Token::Value op,
2791 HArithmeticBinaryOperation* instr);
2792 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2794 HInstruction* current_instruction_;
2795 HBasicBlock* current_block_;
2796 HBasicBlock* next_block_;
2797 LAllocator* allocator_;
2799 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2802 #undef DECLARE_HYDROGEN_ACCESSOR
2803 #undef DECLARE_CONCRETE_INSTRUCTION
2805 } // namespace v8::internal
2807 #endif // V8_PPC_LITHIUM_PPC_H_