11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_TORQUE_CSA_GENERATOR_H_ 61cb0ef41Sopenharmony_ci#define V8_TORQUE_CSA_GENERATOR_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/torque/torque-code-generator.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cinamespace v8 { 111cb0ef41Sopenharmony_cinamespace internal { 121cb0ef41Sopenharmony_cinamespace torque { 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciclass CSAGenerator : public TorqueCodeGenerator { 151cb0ef41Sopenharmony_ci public: 161cb0ef41Sopenharmony_ci CSAGenerator(const ControlFlowGraph& cfg, std::ostream& out, 171cb0ef41Sopenharmony_ci base::Optional<Builtin::Kind> linkage = base::nullopt) 181cb0ef41Sopenharmony_ci : TorqueCodeGenerator(cfg, out), linkage_(linkage) {} 191cb0ef41Sopenharmony_ci base::Optional<Stack<std::string>> EmitGraph(Stack<std::string> parameters); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci static constexpr const char* ARGUMENTS_VARIABLE_STRING = "arguments"; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci static void EmitCSAValue(VisitResult result, const Stack<std::string>& values, 241cb0ef41Sopenharmony_ci std::ostream& out); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci private: 271cb0ef41Sopenharmony_ci base::Optional<Builtin::Kind> linkage_; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci void EmitSourcePosition(SourcePosition pos, 301cb0ef41Sopenharmony_ci bool always_emit = false) override; 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci std::string PreCallableExceptionPreparation( 331cb0ef41Sopenharmony_ci base::Optional<Block*> catch_block); 341cb0ef41Sopenharmony_ci void PostCallableExceptionPreparation( 351cb0ef41Sopenharmony_ci const std::string& catch_name, const Type* return_type, 361cb0ef41Sopenharmony_ci base::Optional<Block*> catch_block, Stack<std::string>* stack, 371cb0ef41Sopenharmony_ci const base::Optional<DefinitionLocation>& exception_object_definition); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci std::vector<std::string> ProcessArgumentsCommon( 401cb0ef41Sopenharmony_ci const TypeVector& parameter_types, 411cb0ef41Sopenharmony_ci std::vector<std::string> constexpr_arguments, Stack<std::string>* stack); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci Stack<std::string> EmitBlock(const Block* block); 441cb0ef41Sopenharmony_ci#define EMIT_INSTRUCTION_DECLARATION(T) \ 451cb0ef41Sopenharmony_ci void EmitInstruction(const T& instruction, Stack<std::string>* stack) \ 461cb0ef41Sopenharmony_ci override; 471cb0ef41Sopenharmony_ci TORQUE_BACKEND_DEPENDENT_INSTRUCTION_LIST(EMIT_INSTRUCTION_DECLARATION) 481cb0ef41Sopenharmony_ci#undef EMIT_INSTRUCTION_DECLARATION 491cb0ef41Sopenharmony_ci}; 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci} // namespace torque 521cb0ef41Sopenharmony_ci} // namespace internal 531cb0ef41Sopenharmony_ci} // namespace v8 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci#endif // V8_TORQUE_CSA_GENERATOR_H_ 56