Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame^] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_X64_CODEGEN_X64_H_ |
| 6 | #define V8_X64_CODEGEN_X64_H_ |
| 7 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame^] | 8 | #include "src/ast.h" |
| 9 | #include "src/macro-assembler.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 10 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 14 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 15 | enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
| 16 | |
| 17 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 18 | class StringCharLoadGenerator : public AllStatic { |
| 19 | public: |
| 20 | // Generates the code for handling different string types and loading the |
| 21 | // indexed character into |result|. We expect |index| as untagged input and |
| 22 | // |result| as untagged output. |
| 23 | static void Generate(MacroAssembler* masm, |
| 24 | Register string, |
| 25 | Register index, |
| 26 | Register result, |
| 27 | Label* call_runtime); |
| 28 | |
| 29 | private: |
| 30 | DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator); |
| 31 | }; |
| 32 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame^] | 33 | |
| 34 | class MathExpGenerator : public AllStatic { |
| 35 | public: |
| 36 | static void EmitMathExp(MacroAssembler* masm, |
| 37 | XMMRegister input, |
| 38 | XMMRegister result, |
| 39 | XMMRegister double_scratch, |
| 40 | Register temp1, |
| 41 | Register temp2); |
| 42 | |
| 43 | private: |
| 44 | DISALLOW_COPY_AND_ASSIGN(MathExpGenerator); |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | enum StackArgumentsAccessorReceiverMode { |
| 49 | ARGUMENTS_CONTAIN_RECEIVER, |
| 50 | ARGUMENTS_DONT_CONTAIN_RECEIVER |
| 51 | }; |
| 52 | |
| 53 | |
| 54 | class StackArgumentsAccessor BASE_EMBEDDED { |
| 55 | public: |
| 56 | StackArgumentsAccessor( |
| 57 | Register base_reg, |
| 58 | int argument_count_immediate, |
| 59 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 60 | ARGUMENTS_CONTAIN_RECEIVER, |
| 61 | int extra_displacement_to_last_argument = 0) |
| 62 | : base_reg_(base_reg), |
| 63 | argument_count_reg_(no_reg), |
| 64 | argument_count_immediate_(argument_count_immediate), |
| 65 | receiver_mode_(receiver_mode), |
| 66 | extra_displacement_to_last_argument_( |
| 67 | extra_displacement_to_last_argument) { } |
| 68 | |
| 69 | StackArgumentsAccessor( |
| 70 | Register base_reg, |
| 71 | Register argument_count_reg, |
| 72 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 73 | ARGUMENTS_CONTAIN_RECEIVER, |
| 74 | int extra_displacement_to_last_argument = 0) |
| 75 | : base_reg_(base_reg), |
| 76 | argument_count_reg_(argument_count_reg), |
| 77 | argument_count_immediate_(0), |
| 78 | receiver_mode_(receiver_mode), |
| 79 | extra_displacement_to_last_argument_( |
| 80 | extra_displacement_to_last_argument) { } |
| 81 | |
| 82 | StackArgumentsAccessor( |
| 83 | Register base_reg, |
| 84 | const ParameterCount& parameter_count, |
| 85 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 86 | ARGUMENTS_CONTAIN_RECEIVER, |
| 87 | int extra_displacement_to_last_argument = 0) |
| 88 | : base_reg_(base_reg), |
| 89 | argument_count_reg_(parameter_count.is_reg() ? |
| 90 | parameter_count.reg() : no_reg), |
| 91 | argument_count_immediate_(parameter_count.is_immediate() ? |
| 92 | parameter_count.immediate() : 0), |
| 93 | receiver_mode_(receiver_mode), |
| 94 | extra_displacement_to_last_argument_( |
| 95 | extra_displacement_to_last_argument) { } |
| 96 | |
| 97 | Operand GetArgumentOperand(int index); |
| 98 | Operand GetReceiverOperand() { |
| 99 | DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER); |
| 100 | return GetArgumentOperand(0); |
| 101 | } |
| 102 | |
| 103 | private: |
| 104 | const Register base_reg_; |
| 105 | const Register argument_count_reg_; |
| 106 | const int argument_count_immediate_; |
| 107 | const StackArgumentsAccessorReceiverMode receiver_mode_; |
| 108 | const int extra_displacement_to_last_argument_; |
| 109 | |
| 110 | DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor); |
| 111 | }; |
| 112 | |
| 113 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 114 | } } // namespace v8::internal |
| 115 | |
| 116 | #endif // V8_X64_CODEGEN_X64_H_ |