csa-generator.h 1.94 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_TORQUE_CSA_GENERATOR_H_
#define V8_TORQUE_CSA_GENERATOR_H_

8
#include "src/torque/torque-code-generator.h"
9 10 11 12 13

namespace v8 {
namespace internal {
namespace torque {

14
class CSAGenerator : public TorqueCodeGenerator {
15 16 17
 public:
  CSAGenerator(const ControlFlowGraph& cfg, std::ostream& out,
               base::Optional<Builtin::Kind> linkage = base::nullopt)
18
      : TorqueCodeGenerator(cfg, out), linkage_(linkage) {}
19 20 21 22 23 24 25 26 27
  base::Optional<Stack<std::string>> EmitGraph(Stack<std::string> parameters);

  static constexpr const char* ARGUMENTS_VARIABLE_STRING = "arguments";

  static void EmitCSAValue(VisitResult result, const Stack<std::string>& values,
                           std::ostream& out);

 private:
  base::Optional<Builtin::Kind> linkage_;
28

29 30
  void EmitSourcePosition(SourcePosition pos,
                          bool always_emit = false) override;
31

32 33
  std::string PreCallableExceptionPreparation(
      base::Optional<Block*> catch_block);
34 35 36 37
  void PostCallableExceptionPreparation(
      const std::string& catch_name, const Type* return_type,
      base::Optional<Block*> catch_block, Stack<std::string>* stack,
      const base::Optional<DefinitionLocation>& exception_object_definition);
38

39 40 41
  std::vector<std::string> ProcessArgumentsCommon(
      const TypeVector& parameter_types,
      std::vector<std::string> constexpr_arguments, Stack<std::string>* stack);
42

43
  Stack<std::string> EmitBlock(const Block* block);
44 45 46 47
#define EMIT_INSTRUCTION_DECLARATION(T)                                 \
  void EmitInstruction(const T& instruction, Stack<std::string>* stack) \
      override;
  TORQUE_BACKEND_DEPENDENT_INSTRUCTION_LIST(EMIT_INSTRUCTION_DECLARATION)
48 49 50 51 52 53 54 55
#undef EMIT_INSTRUCTION_DECLARATION
};

}  // namespace torque
}  // namespace internal
}  // namespace v8

#endif  // V8_TORQUE_CSA_GENERATOR_H_