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 | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/ast/ast.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 15 | class StringCharLoadGenerator : public AllStatic { |
| 16 | public: |
| 17 | // Generates the code for handling different string types and loading the |
| 18 | // indexed character into |result|. We expect |index| as untagged input and |
| 19 | // |result| as untagged output. |
| 20 | static void Generate(MacroAssembler* masm, |
| 21 | Register string, |
| 22 | Register index, |
| 23 | Register result, |
| 24 | Label* call_runtime); |
| 25 | |
| 26 | private: |
| 27 | DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator); |
| 28 | }; |
| 29 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 31 | enum StackArgumentsAccessorReceiverMode { |
| 32 | ARGUMENTS_CONTAIN_RECEIVER, |
| 33 | ARGUMENTS_DONT_CONTAIN_RECEIVER |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | class StackArgumentsAccessor BASE_EMBEDDED { |
| 38 | public: |
| 39 | StackArgumentsAccessor( |
| 40 | Register base_reg, |
| 41 | int argument_count_immediate, |
| 42 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 43 | ARGUMENTS_CONTAIN_RECEIVER, |
| 44 | int extra_displacement_to_last_argument = 0) |
| 45 | : base_reg_(base_reg), |
| 46 | argument_count_reg_(no_reg), |
| 47 | argument_count_immediate_(argument_count_immediate), |
| 48 | receiver_mode_(receiver_mode), |
| 49 | extra_displacement_to_last_argument_( |
| 50 | extra_displacement_to_last_argument) { } |
| 51 | |
| 52 | StackArgumentsAccessor( |
| 53 | Register base_reg, |
| 54 | Register argument_count_reg, |
| 55 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 56 | ARGUMENTS_CONTAIN_RECEIVER, |
| 57 | int extra_displacement_to_last_argument = 0) |
| 58 | : base_reg_(base_reg), |
| 59 | argument_count_reg_(argument_count_reg), |
| 60 | argument_count_immediate_(0), |
| 61 | receiver_mode_(receiver_mode), |
| 62 | extra_displacement_to_last_argument_( |
| 63 | extra_displacement_to_last_argument) { } |
| 64 | |
| 65 | StackArgumentsAccessor( |
| 66 | Register base_reg, |
| 67 | const ParameterCount& parameter_count, |
| 68 | StackArgumentsAccessorReceiverMode receiver_mode = |
| 69 | ARGUMENTS_CONTAIN_RECEIVER, |
| 70 | int extra_displacement_to_last_argument = 0) |
| 71 | : base_reg_(base_reg), |
| 72 | argument_count_reg_(parameter_count.is_reg() ? |
| 73 | parameter_count.reg() : no_reg), |
| 74 | argument_count_immediate_(parameter_count.is_immediate() ? |
| 75 | parameter_count.immediate() : 0), |
| 76 | receiver_mode_(receiver_mode), |
| 77 | extra_displacement_to_last_argument_( |
| 78 | extra_displacement_to_last_argument) { } |
| 79 | |
| 80 | Operand GetArgumentOperand(int index); |
| 81 | Operand GetReceiverOperand() { |
| 82 | DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER); |
| 83 | return GetArgumentOperand(0); |
| 84 | } |
| 85 | |
| 86 | private: |
| 87 | const Register base_reg_; |
| 88 | const Register argument_count_reg_; |
| 89 | const int argument_count_immediate_; |
| 90 | const StackArgumentsAccessorReceiverMode receiver_mode_; |
| 91 | const int extra_displacement_to_last_argument_; |
| 92 | |
| 93 | DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor); |
| 94 | }; |
| 95 | |
| 96 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 97 | } // namespace internal |
| 98 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 99 | |
| 100 | #endif // V8_X64_CODEGEN_X64_H_ |