docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::codegen::CStyleBaseCodeGenerator Class Referenceabstract

#include <sdfg/codegen/code_generators/c_style_base_code_generator.h>

Inheritance diagram for sdfg::codegen::CStyleBaseCodeGenerator:
[legend]

Public Member Functions

 CStyleBaseCodeGenerator (StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan, std::shared_ptr< CodeSnippetFactory > library_snippet_factory=std::make_shared< CodeSnippetFactory >(), const std::string &externals_prefix="")
bool generate () override
 Generate the code.
bool emit_header (PrettyPrinter &out) override
 write the contents of the main header into out
bool emit_main_source (std::ostream &out, const std::filesystem::path &header_path) override
 write the contents of the main source file into out.
bool as_source (const std::filesystem::path &header_path, const std::filesystem::path &source_path) override
 Generate the SDFG's code into source files.
void append_function_source (std::ostream &ofs_source) override
 Generate only the function source code and append it to the source file.
virtual void emit_capture_context_init (std::ostream &ofs_source) const =0
Public Member Functions inherited from sdfg::codegen::CodeGenerator
 CodeGenerator (StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan, std::shared_ptr< CodeSnippetFactory > library_snippet_factory=std::make_shared< CodeSnippetFactory >(), const std::string &externals_prefix="")
virtual ~CodeGenerator ()=default
const StructuredSDFG & sdfg () const
virtual std::string function_definition ()=0
 Generate a function definition for the SDFG.
const PrettyPrinter & includes () const
 Get the includes.
const PrettyPrinter & classes () const
 Get the classes.
const PrettyPrinter & globals () const
 Get the globals.
const std::unordered_map< std::string, CodeSnippet > & library_snippets () const
 all created library snippets
const PrettyPrinter & main () const
 Get the main stream.

Protected Member Functions

virtual LanguageExtension & language_extension ()=0
void dispatch_header (PrettyPrinter &out)
void dispatch_includes ()
virtual void dispatch_header_includes (PrettyPrinter &out)=0
void dispatch_structures ()
virtual void dispatch_header_structures (PrettyPrinter &out)=0
virtual void dispatch_globals ()=0
virtual void dispatch_schedule ()=0

Additional Inherited Members

Protected Attributes inherited from sdfg::codegen::CodeGenerator
StructuredSDFG & sdfg_
 Reference to the schedule.
analysis::AnalysisManager & analysis_manager_
 Analysis manager for the SDFG.
InstrumentationPlan & instrumentation_plan_
 Instrumentation strategy.
ArgCapturePlan & arg_capture_plan_
PrettyPrinter includes_stream_
 Stream for includes.
PrettyPrinter classes_stream_
 Stream for classes.
PrettyPrinter globals_stream_
 Stream for global variables and functions.
std::shared_ptr< CodeSnippetFactory > library_snippet_factory_
 Stream for library functions.
PrettyPrinter main_stream_
 Main stream.
std::string externals_prefix_
 Prefix to use for external functions.

Constructor & Destructor Documentation

◆ CStyleBaseCodeGenerator()

sdfg::codegen::CStyleBaseCodeGenerator::CStyleBaseCodeGenerator ( StructuredSDFG & sdfg,
analysis::AnalysisManager & analysis_manager,
InstrumentationPlan & instrumentation_plan,
ArgCapturePlan & arg_capture_plan,
std::shared_ptr< CodeSnippetFactory > library_snippet_factory = std::make_shared< CodeSnippetFactory >(),
const std::string & externals_prefix = "" )

Member Function Documentation

◆ append_function_source()

void sdfg::codegen::CStyleBaseCodeGenerator::append_function_source ( std::ostream & ofs_source)
overridevirtual

Generate only the function source code and append it to the source file.

as_source generates this into source_path after includes, globals and structs

Implements sdfg::codegen::CodeGenerator.

◆ as_source()

bool sdfg::codegen::CStyleBaseCodeGenerator::as_source ( const std::filesystem::path & header_path,
const std::filesystem::path & source_path )
overridevirtual

Generate the SDFG's code into source files.

Deprecated
this requires generate() being run manually prior and will output directly into filepaths for header and source at the same time. Which is quite restrictive. New parallel builder require [emit_header] and [emit_main_source] instead

Implements sdfg::codegen::CodeGenerator.

◆ dispatch_globals()

virtual void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_globals ( )
protectedpure virtual

◆ dispatch_header()

void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_header ( PrettyPrinter & out)
protected

◆ dispatch_header_includes()

virtual void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_header_includes ( PrettyPrinter & out)
protectedpure virtual

◆ dispatch_header_structures()

virtual void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_header_structures ( PrettyPrinter & out)
protectedpure virtual

◆ dispatch_includes()

void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_includes ( )
protected

◆ dispatch_schedule()

virtual void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_schedule ( )
protectedpure virtual

◆ dispatch_structures()

void sdfg::codegen::CStyleBaseCodeGenerator::dispatch_structures ( )
protected

◆ emit_capture_context_init()

virtual void sdfg::codegen::CStyleBaseCodeGenerator::emit_capture_context_init ( std::ostream & ofs_source) const
pure virtual

◆ emit_header()

bool sdfg::codegen::CStyleBaseCodeGenerator::emit_header ( PrettyPrinter & out)
overridevirtual

write the contents of the main header into out

Implements sdfg::codegen::CodeGenerator.

◆ emit_main_source()

bool sdfg::codegen::CStyleBaseCodeGenerator::emit_main_source ( std::ostream & out,
const std::filesystem::path & header_path )
overridevirtual

write the contents of the main source file into out.

Can also generate additional source files (snippets) that also depend on the header

Implements sdfg::codegen::CodeGenerator.

◆ generate()

bool sdfg::codegen::CStyleBaseCodeGenerator::generate ( )
overridevirtual

Generate the code.

Returns
true if the code was generated successfully

Implements sdfg::codegen::CodeGenerator.

◆ language_extension()

virtual LanguageExtension & sdfg::codegen::CStyleBaseCodeGenerator::language_extension ( )
protectedpure virtual

The documentation for this class was generated from the following file: