1e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch// Copyright 2011 the V8 project authors. All rights reserved.
2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file.
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_X64_CODEGEN_X64_H_
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_X64_CODEGEN_X64_H_
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/ast/ast.h"
9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/macro-assembler.h"
106ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal {
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
153ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochclass StringCharLoadGenerator : public AllStatic {
163ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch public:
173ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // Generates the code for handling different string types and loading the
183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // indexed character into |result|.  We expect |index| as untagged input and
193ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // |result| as untagged output.
203ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  static void Generate(MacroAssembler* masm,
213ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register string,
223ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register index,
233ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register result,
243ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Label* call_runtime);
253ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
263ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch private:
273ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator);
283ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch};
293ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
30b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
31b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass MathExpGenerator : public AllStatic {
32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch public:
33b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void EmitMathExp(MacroAssembler* masm,
34b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          XMMRegister input,
35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          XMMRegister result,
36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          XMMRegister double_scratch,
37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          Register temp1,
38b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          Register temp2);
39b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
40b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch private:
41b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  DISALLOW_COPY_AND_ASSIGN(MathExpGenerator);
42b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch};
43b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
44b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
45b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochenum StackArgumentsAccessorReceiverMode {
46b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  ARGUMENTS_CONTAIN_RECEIVER,
47b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  ARGUMENTS_DONT_CONTAIN_RECEIVER
48b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch};
49b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
50b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
51b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass StackArgumentsAccessor BASE_EMBEDDED {
52b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch public:
53b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  StackArgumentsAccessor(
54b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      Register base_reg,
55b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      int argument_count_immediate,
56b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      StackArgumentsAccessorReceiverMode receiver_mode =
57b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch          ARGUMENTS_CONTAIN_RECEIVER,
58b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      int extra_displacement_to_last_argument = 0)
59b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      : base_reg_(base_reg),
60b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_reg_(no_reg),
61b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_immediate_(argument_count_immediate),
62b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        receiver_mode_(receiver_mode),
63b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        extra_displacement_to_last_argument_(
64b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch            extra_displacement_to_last_argument) { }
65b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
66b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  StackArgumentsAccessor(
67b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      Register base_reg,
68b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      Register argument_count_reg,
69b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      StackArgumentsAccessorReceiverMode receiver_mode =
70b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch          ARGUMENTS_CONTAIN_RECEIVER,
71b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      int extra_displacement_to_last_argument = 0)
72b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      : base_reg_(base_reg),
73b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_reg_(argument_count_reg),
74b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_immediate_(0),
75b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        receiver_mode_(receiver_mode),
76b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        extra_displacement_to_last_argument_(
77b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch            extra_displacement_to_last_argument) { }
78b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
79b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  StackArgumentsAccessor(
80b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      Register base_reg,
81b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      const ParameterCount& parameter_count,
82b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      StackArgumentsAccessorReceiverMode receiver_mode =
83b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch          ARGUMENTS_CONTAIN_RECEIVER,
84b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      int extra_displacement_to_last_argument = 0)
85b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch      : base_reg_(base_reg),
86b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_reg_(parameter_count.is_reg() ?
87b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                            parameter_count.reg() : no_reg),
88b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        argument_count_immediate_(parameter_count.is_immediate() ?
89b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                                  parameter_count.immediate() : 0),
90b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        receiver_mode_(receiver_mode),
91b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch        extra_displacement_to_last_argument_(
92b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch            extra_displacement_to_last_argument) { }
93b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
94b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  Operand GetArgumentOperand(int index);
95b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  Operand GetReceiverOperand() {
96b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch    DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER);
97b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch    return GetArgumentOperand(0);
98b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  }
99b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
100b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch private:
101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  const Register base_reg_;
102b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  const Register argument_count_reg_;
103b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  const int argument_count_immediate_;
104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  const StackArgumentsAccessorReceiverMode receiver_mode_;
105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  const int extra_displacement_to_last_argument_;
106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
107b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
108b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch};
109b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
110b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
111014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch}  // namespace internal
112014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch}  // namespace v8
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_X64_CODEGEN_X64_H_
115