GCC Middle and Back End API Reference
optrecord_json_writer Class Reference

#include <optinfo-emit-json.h>

Collaboration diagram for optrecord_json_writer:

Public Member Functions

 optrecord_json_writer ()
 
 ~optrecord_json_writer ()
 
void write () const
 
void add_record (const optinfo *optinfo)
 
void pop_scope ()
 
void add_record (json::object *obj)
 
json::objectimpl_location_to_json (dump_impl_location_t loc)
 
json::objectlocation_to_json (location_t loc)
 
json::objectprofile_count_to_json (profile_count count)
 
json::stringget_id_value_for_pass (opt_pass *pass)
 
json::objectpass_to_json (opt_pass *pass)
 
json::valueinlining_chain_to_json (location_t loc)
 
json::objectoptinfo_to_json (const optinfo *optinfo)
 
void add_pass_list (json::array *arr, opt_pass *pass)
 

Private Attributes

json::arraym_root_tuple
 
auto_vec< json::array * > m_scopes
 

Detailed Description

A class for writing out optimization records in JSON format.   

Constructor & Destructor Documentation

◆ optrecord_json_writer()

optrecord_json_writer::optrecord_json_writer ( )
Emit optimization information as JSON files.
   Copyright (C) 2018-2024 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
optrecord_json_writer's ctor.  Populate the top-level parts of the
in-memory JSON representation.   

References json::array::append(), GCC_PASS_LISTS, ggc_alloc(), m_root_tuple, m_scopes, lang_hooks::name, json::object::set(), and json::object::set_string().

◆ ~optrecord_json_writer()

optrecord_json_writer::~optrecord_json_writer ( )
optrecord_json_writer's ctor.
Delete the in-memory JSON representation.   

References m_root_tuple.

Member Function Documentation

◆ add_pass_list()

void optrecord_json_writer::add_pass_list ( json::array * arr,
opt_pass * pass )
Add a json description of PASS and its siblings to ARR, recursing into
child passes (adding their descriptions within a "children" array).   

References add_pass_list(), ggc_alloc(), opt_pass::next, pass_to_json(), and opt_pass::sub.

Referenced by add_pass_list().

◆ add_record() [1/2]

void optrecord_json_writer::add_record ( const optinfo * optinfo)
Add a record for OPTINFO to the queue of records to be written.   

References add_record(), optinfo::get_kind(), m_scopes, OPTINFO_KIND_SCOPE, optinfo_to_json(), and json::object::set().

Referenced by add_record(), and dump_context::emit_optinfo().

◆ add_record() [2/2]

void optrecord_json_writer::add_record ( json::object * obj)
Private methods of optrecord_json_writer.   
Add record OBJ to the innermost scope.   

References gcc_assert, and m_scopes.

◆ get_id_value_for_pass()

json::string * optrecord_json_writer::get_id_value_for_pass ( opt_pass * pass)
Get a string for use when referring to PASS in the saved optimization
records.   

References pp_formatted_text(), and pp_pointer.

Referenced by optinfo_to_json(), and pass_to_json().

◆ impl_location_to_json()

json::object * optrecord_json_writer::impl_location_to_json ( dump_impl_location_t loc)

◆ inlining_chain_to_json()

json::value * optrecord_json_writer::inlining_chain_to_json ( location_t loc)
Create a JSON array for LOC representing the chain of inlining
locations.
Compare with lhd_print_error_function and cp_print_error_function.   

References json::array::append(), BLOCK_ABSTRACT_ORIGIN, BLOCK_SOURCE_LOCATION, BLOCK_SUPERCONTEXT, lang_hooks::decl_printable_name, ggc_alloc(), LOCATION_BLOCK, LOCATION_LOCUS, location_to_json(), NULL, json::object::set(), json::object::set_string(), TREE_CODE, and UNKNOWN_LOCATION.

Referenced by optinfo_to_json().

◆ location_to_json()

json::object * optrecord_json_writer::location_to_json ( location_t loc)

◆ optinfo_to_json()

◆ pass_to_json()

◆ pop_scope()

void optrecord_json_writer::pop_scope ( )
Pop the innermost scope.   

References gcc_assert, and m_scopes.

Referenced by dump_context::end_scope().

◆ profile_count_to_json()

json::object * optrecord_json_writer::profile_count_to_json ( profile_count count)
Create a JSON object representing COUNT.   

References count, profile_quality_as_string(), json::object::set_integer(), and json::object::set_string().

Referenced by optinfo_to_json().

◆ write()

void optrecord_json_writer::write ( ) const
Choose an appropriate filename, and write the saved records to it.   

References error_at(), free(), ggc_alloc(), m_root_tuple, NULL, pp_formatted_text(), json::array::print(), and UNKNOWN_LOCATION.

Referenced by dump_context::finish_any_json_writer().

Field Documentation

◆ m_root_tuple

json::array* optrecord_json_writer::m_root_tuple
private

◆ m_scopes

auto_vec<json::array *> optrecord_json_writer::m_scopes
private

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