Re: Add support for PLUGIN_PRAGMAS
by Justin Tai
Thanks Dave for the support :-D. I've implemented the four calls to
register pragma under one gcc method using parameters based on your advice.
Here are the four GCC API used to register new pragma:
c_register_pragma()
c_register_pragma_with_data()
c_register_pragma_with_expansion()
c_register_pragma_with_expansion_and_data()
Here's the call signature that I've implemented.
gcc.c_register_pragma(<directive space>, <directive>, <callback>, <pointer
to user params>, <bool indicating with expansion or not>)
Right now all this is on my own github fork of the repo (user: taijusti).
Did you want this on the main repo? I'm willing to go through the necessary
review process, however I have everything I need right now for my project,
so this would be low priority for me unfortunately :(. Right now it passes
all tests except for LTO. I'm able to register my own pragma in python via
this plugin. I would also want to do a little more cleanup to get it to
production quality if you would like this on the main repo.
BTW, with this is all implemented/tested at Fedora 21 4.0.6-200, GCC 4.9.2,
Python 2.7.8. Upgrading the plugin to this platform only required
artificial changes--expected error messages for tests changed a little bit.
Justin
8 years, 9 months
Re: Add support for PLUGIN_PRAGMAS
by Justin Tai
Not sure how to continue the email chain on this mailing list, so copying
it below.
Thanks David for your response :-). I'm having trouble converting a python
callable object to a C function to pass into c_register_pragma() to
register the new callback. Should this be implemented like how attribute
support was added? That is, have a single callback in the python plugin for
whenever a pragma is parsed, and from there do a lookup on an internal
table of all registered pragma? This seems like a poor use of
c_register_pragma().
Justin
Message: 5
Date: Mon, 06 Jul 2015 21:02:10 +0000
From: Justin Tai <taijusti(a)gmail.com>
To: gcc-python-plugin(a)lists.fedorahosted.org
Subject: Add support for PLUGIN_PRAGMAS
Message-ID:
<CAKYQ15jkkr3G=Dh+hymMQuBdOs+7b0B7z7jv0yvtsxY=aFu8KQ(a)mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi everyone,
I'm trying to add support for a new pragma to gcc. This requires support
for the PLUGIN_PRAGMAS event, which I'm currently trying to add support for.
1) Any tips?
2) I've added support for registering a callback for the PLUGIN_PRAGMAS
event. The next step is to add support for the GCC API c_register_pragma()
by adding an entry to GccMethods in gcc-python.c and adding and populating
gcc-python-pragmas.c/h. Does this sound about right?
Thanks!
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
https://lists.fedorahosted.org/pipermail/gcc-python-plugin/attachments/20...
>
------------------------------
Message: 6
Date: Mon, 06 Jul 2015 17:24:53 -0400
From: David Malcolm <dmalcolm(a)redhat.com>
To: gcc-python-plugin(a)lists.fedorahosted.org
Subject: Re: Add support for PLUGIN_PRAGMAS
Message-ID: <1436217893.24803.44.camel@surprise>
Content-Type: text/plain; charset="UTF-8"
On Mon, 2015-07-06 at 21:02 +0000, Justin Tai wrote:
> Hi everyone,
> I'm trying to add support for a new pragma to gcc. This requires
> support for the PLUGIN_PRAGMAS event, which I'm currently trying to
> add support for.
>
>
> 1) Any tips?
> 2) I've added support for registering a callback for the
> PLUGIN_PRAGMAS event. The next step is to add support for the GCC API
> c_register_pragma() by adding an entry to GccMethods in gcc-python.c
> and adding and populating gcc-python-pragmas.c/h. Does this sound
> about right?
Yes, this sounds sane.
I have a vague feeling I looked at doing this, and that I could see a
usable void * user_data place for pragmas for storing the associated
Python callable. But looking at
c-family/c-pragma.c:c_register_pragma_with_data I see that the C
frontend somehow manages to stash a void *, so presumably it's possible.
Hope this is helpful
Dave
8 years, 9 months
Add support for PLUGIN_PRAGMAS
by Justin Tai
Hi everyone,
I'm trying to add support for a new pragma to gcc. This requires support
for the PLUGIN_PRAGMAS event, which I'm currently trying to add support for.
1) Any tips?
2) I've added support for registering a callback for the PLUGIN_PRAGMAS
event. The next step is to add support for the GCC API c_register_pragma()
by adding an entry to GccMethods in gcc-python.c and adding and populating
gcc-python-pragmas.c/h. Does this sound about right?
Thanks!
Justin
8 years, 9 months
compilation with gcc-4.9.2
by Mickael Sergent
Hi,
I will try to compil gcc-python-plugin with gcc-4.9.2 (from debian Jessie),
I encountered the following error :
make[1]: Entering directory
'/media/extras/mickael/programmation/lib_ext/gcc-python-plugin/gcc-c-api'
python xml-to-h.py
cc -O2 -Werror -g -fPIC -fno-strict-aliasing -Wall
-I/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include
-I/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/c-family -I. -c -x c++
-fno-rtti -o gcc-callgraph.o gcc-callgraph.c
In file included from gcc-callgraph.c:31:0:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:283:10: error:
use of enum ‘internal_fn’ without previous declaration
enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn;
^
In file included from gcc-callgraph.c:31:0:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:1170:41: error:
use of enum ‘internal_fn’ without previous declaration
gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:1171:45: error:
use of enum ‘internal_fn’ without previous declaration
gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h: In function
‘bool gimple_store_p(gimple)’:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:2346:36: error:
‘is_gimple_reg’ was not declared in this scope
return lhs && !is_gimple_reg (lhs);
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h: At global scope:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:2444:20: error:
use of enum ‘internal_fn’ without previous declaration
static inline enum internal_fn
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:2544:46: error:
use of enum ‘internal_fn’ without previous declaration
gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h: In function
‘tree_node* gimple_call_fndecl(const_gimple)’:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:2559:54: error:
‘gimple_call_addr_fndecl’ was not declared in this scope
return gimple_call_addr_fndecl (gimple_call_fn (gs));
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h: In function
‘tree_node* gimple_expr_type(const_gimple)’:
/usr/lib/gcc/x86_64-linux-gnu/4.9/plugin/include/gimple.h:5657:45: error:
‘IFN_MASK_STORE’ was not declared in this scope
&& gimple_call_internal_fn (stmt) == IFN_MASK_STORE)
^
Makefile:92: recipe for target 'gcc-callgraph.o' failed
After searching, it seems that some #include file are missing in
gcc-callgraph.c
I do the following modification and the compilation finishs correctly:
diff --git a/gcc-c-api/gcc-callgraph.c b/gcc-c-api/gcc-callgraph.c
index aa05a53..e9feb96 100644
--- a/gcc-c-api/gcc-callgraph.c
+++ b/gcc-c-api/gcc-callgraph.c
@@ -26,6 +26,8 @@
#if (GCC_VERSION >= 5000)
#include "gimple-expr.h"
#endif
+#include "internal-fn.h"
+#include "gimple-expr.h"
#include "gimple.h"
/***********************************************************
Can you check and may be commit if you think that the following patch is OK
for you ?
Thanks,
Mickael.
8 years, 9 months