This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC meets Guile at its birthday party


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:

  SHA1 sums:

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


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

  â 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

  â â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):

    (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!



Attachment: pgp00000.pgp
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]