unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GCC meets Guile at its birthday party
@ 2012-02-16 11:32 Ludovic Courtès
  0 siblings, 0 replies; only message in thread
From: Ludovic Courtès @ 2012-02-16 11:32 UTC (permalink / raw)
  To: gcc; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 2544 bytes --]

Hello,

Today is the first anniversary of GNU Guile 2.0 [0].  To celebrate it,
several Guile users took on the challenge to come up in one week with a
neat hack to showcase Guile integration [1].

So I’m happy to announce that this silly challenge gave birth (among
other things) to Guile-GCC, Guile bindings that allow GCC plug-ins to be
written in Guile:

  http://www.fdn.fr/~lcourtes/software/guile/guile-gcc-0.0.tar.gz
  http://www.fdn.fr/~lcourtes/software/guile/guile-gcc-0.0.tar.gz.asc

  SHA1 sums:

    2d46faf75b5ceb62c326f320495aa594479468bf  guile-gcc-0.0.tar.gz
    7f0817e1b8b4a35f0a99602a8d9c1b080fea1851  guile-gcc-0.0.tar.gz.asc

  Repository:

    https://gitorious.org/guile-gcc/guile-gcc

The plug-in currently wraps a small subset of the libcpp, tree, and
cgraph APIs, which was enough to create these plug-ins available in the
distribution:

  • The ‘birthday’ plug-in defines a ‘birthday’ pragma that emits a
    ‘puts’ call.

  • ‘meta’ shows an unprecedented way of doing meta-programming from C.
    It defines two pragmas: one to define a “meta-function”, and one to
    invoke said function at a particular point in the code, with
    specific tree objects as its arguments.

    The ‘examples/meta.c’ file defines a meta-function that generates
    code to print the value of each field of the structure passed as its
    argument.

  • ‘call-graph’ unimaginatively traverses the call graph of the
    compilation unit and emits a ‘dot’ representation of that graph.

The (gcc) module comes with an embedded domain-specific language (EDSL)
that makes it easy to write code-generating code.  For instance:

  (tree loc
    (printf "value is %d (%p)\n" (foo dot "bar") (& foo)))

… expands to (simplified):

  (build-call-expr
    loc
    printf
    (list (build-string-literal "value is %d (%p)\n")
          (build-component-ref loc foo "bar")
          (build-addr foo)))

The bindings currently lack GIMPLE and basic-blocks.  Everyone is
invited to join in and help with this.  :-)

Besides, fun work would include augmenting the tree EDSL so it can build
BIND_EXPRs, VAR_DECLs, COND_EXPRs, etc., and extending Guile’s
(ice-9 match) pattern matcher to support tree and GIMPLE objects, which
would probably be handy.

Feedback welcome!

Thanks,
Ludo’.

[0] http://lists.gnu.org/archive/html/guile-devel/2011-02/msg00173.html
[1] http://lists.gnu.org/archive/html/guile-user/2012-02/msg00019.html

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-16 11:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-16 11:32 GCC meets Guile at its birthday party Ludovic Courtès

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).