public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>,
	gcc-patches@gcc.gnu.org, jit@gcc.gnu.org
Subject: Re: [PATCH 08/27] New file: gcc/jit/libgccjit.h
Date: Wed, 01 Jan 2014 00:00:00 -0000	[thread overview]
Message-ID: <5457E406.2040907@redhat.com> (raw)
In-Reply-To: <1414774977-25605-9-git-send-email-dmalcolm@redhat.com>

On 10/31/14 11:02, David Malcolm wrote:
> This header is the public API for the library.
>
> gcc/jit/
> 	* libgccjit.h: New.
Given this is inside the JIT subdirectory, I'm not doing a depth review.

  +
> +/* A gcc_jit_block encapsulates a "basic block" of statements within a
> +   function (i.e. with one entry point and one exit point).
> +
> +   Every block within a function must be terminated with a conditional,
> +   a branch, or a return.
? That doesn't seem right.   We don't really place restrictions on what 
ends a block, but we do place restrictions on what kinds of IL 
statements can appear in the middle of a block.

> +
> +   All of the blocks in a function must be reachable via some path from
> +   the first block.
?  Is this something your code requires?  While we have some code which 
assumes unreachable blocks do not exist, we generally deal with that by 
running the cfgcleanup passes which will identify and remove the 
unreachables.

And this raises one of those questions that's been in the back of my 
mind.  What's the right level of documentation and exposure of 
internals.  When I read the docs, one of questions I kept to myself was 
whether or not we've giving the users too much or too little 
information.  As well as a vague concern that actually using the JIT is 
going to be so painful due to exposure of implementation details that we 
might want to just go in with the expectation that this is really a V0 
implementation and that it's all going to have to change and be 
rewritten as GCC's internals get sorted out.



> +
> +/*
> +   Acquire a JIT-compilation context.
> +
> +   FIXME: error-handling?
There's a whole class of problems with error handling. GCC has always 
had this notation that it can terminate compilation when something "bad" 
happens.  In a JIT world that may not be appropriate.  But that's 
probably outside the scope of what we want to try and tackle at this stage.


> +enum gcc_jit_int_option
> +{
> +  /* How much to optimize the code.
> +     Valid values are 0-3, corresponding to GCC's command-line options
> +     -O0 through -O3.
> +
> +     The default value is 0 (unoptimized).  */
> +  GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
> +
> +  GCC_JIT_NUM_INT_OPTIONS
> +};
I don't think we explicitly disallow optimization values > 3, they just 
don't do anything.


> +
> +/* Options taking boolean values.
> +   These all default to "false".  */
> +enum gcc_jit_bool_option
> +{
> +  /* If true, gcc_jit_context_compile will attempt to do the right
> +     thing so that if you attach a debugger to the process, it will
> +     be able to inspect variables and step through your code.
> +
> +     Note that you can't step through code unless you set up source
> +     location information for the code (by creating and passing in
> +     gcc_jit_location instances).  */
> +  GCC_JIT_BOOL_OPTION_DEBUGINFO,
The comment makes me ask, why not always have this on and have 
gcc_jit_context_compile try to do the right thing? :-)

> +
> +  /* If true, gcc_jit_context_compile will dump its initial "tree"
> +     representation of your code to stderr (before any
> +     optimizations).  */
> +  GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE,
Is stderr really the best place for the debugging dumps?


> +
> +/* Populating the fields of a formerly-opaque struct type.
> +   This can only be called once on a given struct type.  */
> +extern void
> +gcc_jit_struct_set_fields (gcc_jit_struct *struct_type,
> +			   gcc_jit_location *loc,
> +			   int num_fields,
> +			   gcc_jit_field **fields);
What happens if you call it more than once?  Is the once only property 
something we ought to be enforcing, or is that really an internal issue?

> +
> +enum gcc_jit_function_kind
[ ... ]
So do we have any use for alias, thunks, etc here?

And WRT types (and perhaps other stuff), there's a pretty direct mapping 
between the rest of GCC and the JIT stuff.  I worry a bit that someone 
changing the core of GCC may not know they need to make analogous 
changes to the JIT bits.  It's a general concern, no need to do anything 
about it right now.  If it breaks you get to fix it ;-)
[ ... ]

In your code to build up the contents of blocks, would it make sense to 
"finalize" the block or somesuch concept after adding a  statement which 
terminates the block to ensure someone doesn't append statements after 
the block terminitating statement?


Patch is OK -- the issues noted above are more things I think are worth 
discussing and possibly making changes in the future.  Nothing above is 
significant enough today to warrant making changes in the codebase IMHO.
Jeff

  reply	other threads:[~2014-11-03 20:22 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-01  0:00 [PATCH 00/27] Merger of jit branch v3 David Malcolm
2014-01-01  0:00 ` [PATCH 0/3] Minor tweaks to jit David Malcolm
2014-01-01  0:00   ` [PATCH 1/3] New test cases David Malcolm
2014-01-01  0:00   ` [PATCH 0/3] Minor tweaks to jit Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00   ` [PATCH 3/3] Add comments to various functions in libgccjit.h David Malcolm
2014-01-01  0:00   ` [PATCH 2/3] Documentation tweak David Malcolm
2014-01-01  0:00 ` [PATCH 14/27] New files: gcc/jit/jit-builtins.{c|h} David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00 ` [PATCH 05/27] New file: gcc/jit/config-lang.in David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 23/27] Documentation: the "intro" subdirectory David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00       ` Jeff Law
2014-01-01  0:00 ` [PATCH 09/27] New file: gcc/jit/libgccjit.map David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 16/27] New file: gcc/jit/jit-playback.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` [jit] Drop the disabled debugging code within handle_locations David Malcolm
2014-01-01  0:00 ` [PATCH 24/27] Documentation: add "topics" subdirectory David Malcolm
2014-01-01  0:00 ` [PATCH 06/27] New file: gcc/jit/Make-lang.in David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 21/27] Documentation: the "examples" subdirectory David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 22/27] Documentation: top-level index.rst David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 04/27] New file: gcc/jit/notes.txt David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 01/27] gcc: configure and Makefile changes needed by jit David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00   ` Thomas Schwinge
2014-01-01  0:00 ` [PATCH 03/27] Add Sphinx to install.texi David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 10/27] New file: gcc/jit/libgccjit.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00       ` Jeff Law
2014-01-01  0:00         ` David Malcolm
2014-01-01  0:00           ` Jeff Law
2014-01-01  0:00             ` David Malcolm
2014-01-01  0:00         ` [jit] Use ISALPHA and ISALNUM rather than writing our own David Malcolm
2014-01-01  0:00           ` Jeff Law
2014-01-01  0:00 ` [PATCH 02/27] JIT-related changes outside of jit subdir David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 17/27] New file: gcc/jit/libgccjit++.h David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 07/27] New file: gcc/jit/dummy-frontend.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 20/27] Documentation: Makefile and conf.py David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 25/27] Documentation: add "internals" subdirectory David Malcolm
2014-01-01  0:00 ` [PATCH 18/27] New file: gcc/jit/TODO.rst David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 08/27] New file: gcc/jit/libgccjit.h David Malcolm
2014-01-01  0:00   ` Jeff Law [this message]
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00 ` [PATCH 15/27] New file: gcc/jit/jit-playback.h David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 00/27] Merger of jit branch v3 Jeff Law
2014-01-01  0:00 ` [PATCH 11/27] New file: gcc/jit/jit-common.h David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 13/27] New file: gcc/jit/jit-recording.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00       ` Jeff Law
2014-01-01  0:00 ` [PATCH 12/27] New file: gcc/jit/jit-recording.h David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00       ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5457E406.2040907@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).