1257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch// Copyright 2011 the V8 project authors. All rights reserved.
23100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Redistribution and use in source and binary forms, with or without
33100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// modification, are permitted provided that the following conditions are
43100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// met:
53100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//
63100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//     * Redistributions of source code must retain the above copyright
73100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       notice, this list of conditions and the following disclaimer.
83100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//     * Redistributions in binary form must reproduce the above
93100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       copyright notice, this list of conditions and the following
103100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       disclaimer in the documentation and/or other materials provided
113100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       with the distribution.
123100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//     * Neither the name of Google Inc. nor the names of its
133100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       contributors may be used to endorse or promote products derived
143100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//       from this software without specific prior written permission.
153100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu//
163100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
173100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
193100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
203100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
223100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
283100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
293100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#ifndef V8_MIPS_CODEGEN_MIPS_H_
303100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#define V8_MIPS_CODEGEN_MIPS_H_
313100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
3244f0eee88ff00398ff7f715fab053374d808c90dSteve Block
3344f0eee88ff00398ff7f715fab053374d808c90dSteve Block#include "ast.h"
3444f0eee88ff00398ff7f715fab053374d808c90dSteve Block#include "ic-inl.h"
3544f0eee88ff00398ff7f715fab053374d808c90dSteve Block
363100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescunamespace v8 {
373100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescunamespace internal {
383100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
393100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Forward declarations
403100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuclass CompilationInfo;
413100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
423100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuenum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
4344f0eee88ff00398ff7f715fab053374d808c90dSteve Block
4444f0eee88ff00398ff7f715fab053374d808c90dSteve Block// -------------------------------------------------------------------------
453100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// CodeGenerator
463100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
473100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuclass CodeGenerator: public AstVisitor {
483100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu public:
4944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  static bool MakeCode(CompilationInfo* info);
503100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
513100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  // Printing of AST, etc. as requested by flags.
523100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  static void MakeCodePrologue(CompilationInfo* info);
533100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
543100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  // Allocate and install the code.
553100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
563100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu                                       Code::Flags flags,
573100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu                                       CompilationInfo* info);
583100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
5944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // Print the code after compiling it.
6044f0eee88ff00398ff7f715fab053374d808c90dSteve Block  static void PrintCode(Handle<Code> code, CompilationInfo* info);
6144f0eee88ff00398ff7f715fab053374d808c90dSteve Block
623100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  static bool ShouldGenerateLog(Expression* type);
633100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
643100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  static void SetFunctionInfo(Handle<JSFunction> fun,
653100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu                              FunctionLiteral* lit,
663100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu                              bool is_toplevel,
673100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu                              Handle<Script> script);
683100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
6944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  static bool RecordPositions(MacroAssembler* masm,
7044f0eee88ff00398ff7f715fab053374d808c90dSteve Block                              int pos,
7144f0eee88ff00398ff7f715fab053374d808c90dSteve Block                              bool right_here = false);
723100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch private:
743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch};
76257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch
77257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch
783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochclass StringCharLoadGenerator : public AllStatic {
793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch public:
803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // Generates the code for handling different string types and loading the
813ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // indexed character into |result|.  We expect |index| as untagged input and
823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  // |result| as untagged output.
833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  static void Generate(MacroAssembler* masm,
843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register string,
853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register index,
863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Register result,
873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch                       Label* call_runtime);
883100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
8944f0eee88ff00398ff7f715fab053374d808c90dSteve Block private:
903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator);
913100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu};
923100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
933100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu} }  // namespace v8::internal
943100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu
953100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#endif  // V8_MIPS_CODEGEN_MIPS_H_
96