1 // Copyright 2011 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. 4 5 #ifndef V8_X64_CODEGEN_X64_H_ 6 #define V8_X64_CODEGEN_X64_H_ 7 8 #include "src/ast/ast.h" 9 #include "src/macro-assembler.h" 10 11 namespace v8 { 12 namespace internal { 13 14 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 30 31 class MathExpGenerator : public AllStatic { 32 public: 33 static void EmitMathExp(MacroAssembler* masm, 34 XMMRegister input, 35 XMMRegister result, 36 XMMRegister double_scratch, 37 Register temp1, 38 Register temp2); 39 40 private: 41 DISALLOW_COPY_AND_ASSIGN(MathExpGenerator); 42 }; 43 44 45 enum StackArgumentsAccessorReceiverMode { 46 ARGUMENTS_CONTAIN_RECEIVER, 47 ARGUMENTS_DONT_CONTAIN_RECEIVER 48 }; 49 50 51 class StackArgumentsAccessor BASE_EMBEDDED { 52 public: 53 StackArgumentsAccessor( 54 Register base_reg, 55 int argument_count_immediate, 56 StackArgumentsAccessorReceiverMode receiver_mode = 57 ARGUMENTS_CONTAIN_RECEIVER, 58 int extra_displacement_to_last_argument = 0) base_reg_(base_reg)59 : base_reg_(base_reg), 60 argument_count_reg_(no_reg), 61 argument_count_immediate_(argument_count_immediate), 62 receiver_mode_(receiver_mode), 63 extra_displacement_to_last_argument_( 64 extra_displacement_to_last_argument) { } 65 66 StackArgumentsAccessor( 67 Register base_reg, 68 Register argument_count_reg, 69 StackArgumentsAccessorReceiverMode receiver_mode = 70 ARGUMENTS_CONTAIN_RECEIVER, 71 int extra_displacement_to_last_argument = 0) base_reg_(base_reg)72 : base_reg_(base_reg), 73 argument_count_reg_(argument_count_reg), 74 argument_count_immediate_(0), 75 receiver_mode_(receiver_mode), 76 extra_displacement_to_last_argument_( 77 extra_displacement_to_last_argument) { } 78 79 StackArgumentsAccessor( 80 Register base_reg, 81 const ParameterCount& parameter_count, 82 StackArgumentsAccessorReceiverMode receiver_mode = 83 ARGUMENTS_CONTAIN_RECEIVER, 84 int extra_displacement_to_last_argument = 0) base_reg_(base_reg)85 : base_reg_(base_reg), 86 argument_count_reg_(parameter_count.is_reg() ? 87 parameter_count.reg() : no_reg), 88 argument_count_immediate_(parameter_count.is_immediate() ? 89 parameter_count.immediate() : 0), 90 receiver_mode_(receiver_mode), 91 extra_displacement_to_last_argument_( 92 extra_displacement_to_last_argument) { } 93 94 Operand GetArgumentOperand(int index); GetReceiverOperand()95 Operand GetReceiverOperand() { 96 DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER); 97 return GetArgumentOperand(0); 98 } 99 100 private: 101 const Register base_reg_; 102 const Register argument_count_reg_; 103 const int argument_count_immediate_; 104 const StackArgumentsAccessorReceiverMode receiver_mode_; 105 const int extra_displacement_to_last_argument_; 106 107 DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor); 108 }; 109 110 111 } // namespace internal 112 } // namespace v8 113 114 #endif // V8_X64_CODEGEN_X64_H_ 115