Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gcc/jit/jit-playback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ get_type (enum gcc_jit_types type_)
return new type (type_node);
}

void
playback::context::
set_output_ident (const char* ident)
{
targetm.asm_out.output_ident (ident);
}

/* Construct a playback::type instance (wrapping a tree) for the given
array type. */

Expand Down
3 changes: 3 additions & 0 deletions gcc/jit/jit-playback.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class context : public log_user
type *
get_type (enum gcc_jit_types type);

void
set_output_ident (const char* ident);

type *
new_array_type (location *loc,
type *element_type,
Expand Down
51 changes: 51 additions & 0 deletions gcc/jit/jit-recording.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,13 @@ recording::context::set_str_option (enum gcc_jit_str_option opt,
log_str_option (opt);
}

void
recording::context::set_output_ident (const char *ident)
{
recording::output_ident *memento = new output_ident (this, ident);
record (memento);
}

/* Set the given integer option for this context, or add an error if
it's not recognized.

Expand Down Expand Up @@ -2313,6 +2320,50 @@ recording::string::write_reproducer (reproducer &)
/* Empty. */
}

/* The implementation of class gcc::jit::recording::output_ident. */

/* Constructor for gcc::jit::recording::output_ident, allocating a
copy of the given text using new char[]. */

recording::output_ident::output_ident (context *ctxt, const char *ident)
: memento (ctxt)
{
m_ident = ident ? xstrdup (ident) : NULL;
}

/* Destructor for gcc::jit::recording::output_ident. */

recording::output_ident::~output_ident ()
{
delete[] m_ident;
}

/* Implementation of pure virtual hook recording::memento::replay_into
for recording::output_ident. */

void
recording::output_ident::replay_into (replayer *r)
{
r->set_output_ident (m_ident);
}

/* Implementation of recording::memento::make_debug_string for output_ident. */

recording::string *
recording::output_ident::make_debug_string ()
{
return m_ctxt->new_string (m_ident);
}

/* Implementation of recording::memento::write_reproducer for output_ident. */

void
recording::output_ident::write_reproducer (reproducer &)
{
/* TODO */
}


/* The implementation of class gcc::jit::recording::location. */

/* Implementation of recording::memento::replay_into for locations.
Expand Down
22 changes: 22 additions & 0 deletions gcc/jit/jit-recording.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ class context : public log_user
set_str_option (enum gcc_jit_str_option opt,
const char *value);

void
set_output_ident (const char *output_ident);

void
set_int_option (enum gcc_jit_int_option opt,
int value);
Expand Down Expand Up @@ -497,6 +500,25 @@ class string : public memento
bool m_escaped;
};

class output_ident : public memento
{
public:
output_ident (context *ctxt, const char *text);
~output_ident ();

void replay_into (replayer *) final override;

output_ident (const output_ident&) = delete;
output_ident& operator= (const output_ident&) = delete;

private:
string * make_debug_string () final override;
void write_reproducer (reproducer &r) final override;

private:
const char *m_ident;
};

class location : public memento
{
public:
Expand Down
15 changes: 15 additions & 0 deletions gcc/jit/libgccjit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3919,6 +3919,21 @@ gcc_jit_context_get_target_info (gcc_jit_context *ctxt)
return (gcc_jit_target_info*) jit_get_target_info ();
}

/* Public entrypoint. See description in libgccjit.h.

After error-checking, the real work is done by the
gcc::jit::recording::context::set_str_option method in
jit-recording.cc. */

void
gcc_jit_context_set_output_ident (gcc_jit_context *ctxt, const char* output_ident)
{
RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context");
JIT_LOG_FUNC (ctxt->get_logger ());

ctxt->set_output_ident (output_ident);
}

void
gcc_jit_target_info_release (gcc_jit_target_info *info)
{
Expand Down
3 changes: 3 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,9 @@ gcc_jit_type_unqualified (gcc_jit_type *type);
extern gcc_jit_target_info *
gcc_jit_context_get_target_info (gcc_jit_context *ctxt);

extern void
gcc_jit_context_set_output_ident (gcc_jit_context *ctxt, const char* output_ident);

extern void
gcc_jit_target_info_release (gcc_jit_target_info *info);

Expand Down
5 changes: 5 additions & 0 deletions gcc/jit/libgccjit.map
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,8 @@ LIBGCCJIT_ABI_35 {
gcc_jit_context_new_sizeof;
gcc_jit_function_add_integer_array_attribute;
} LIBGCCJIT_ABI_34;

LIBGCCJIT_ABI_36 {
global:
gcc_jit_context_set_output_ident;
} LIBGCCJIT_ABI_35;