----- Message d'origine ---- De : Philip Herron <redbrain@xxxxxxxxxxx> À : charfi asma <charfiasma@xxxxxxxx> Cc : gcc-help@xxxxxxxxxxx Envoyé le : Lun 13 décembre 2010, 20h 49min 44s Objet : Re: new gcc front end question On 13 December 2010 11:33, charfi asma <charfiasma@xxxxxxxx> wrote: > Hello, > > I build a new gcc front end for my language called "uml", > I do not use a parser or a lexer, I generate the GENRIC form directly from > another tool that parse my source file "test.uml". in a txt file that I include > in my compiler parse_file hook. > > void uml_parse_file (int debug_flag ATTRIBUTE_UNUSED) > { > ..... > #include "/export/home/charfi/test.txt"; > ..... > gimplify_function_tree(main_fn_decl); > cgraph_node(main_fn_decl); > cgraph_finalize_function(main_fn_decl, false); > }my test.txt looks contains all the tree that correspond to my source file > > ( for example if I have int x ; > my test.txt contains : > tree x_tree = build_decl(BUILTINS_LOCATION, VAR_DECL, get_identifier("x"), > integer_type_node); ) > > this works perfectly when I compile test.uml after generating the test.txt by > calling : guml test.uml -S -fdump-tree-all > > however, when I try to compile another file test2.uml that need to read > test2.txt , I have to re make , re make install my front end. and modify the > uml_parse_file hook to modify the name of the text file .. #include > "/export/home/charfi/test2.txt"; > > I can modify this langhook by recovering the name using in_fnames[0] (first > argument of guml command) > but I can not pass this argument to the include command that requires only > <FILENAME> or "filename". (i,e. #include in_fnames[0] ; did not works ) > > my question is: > > 1. How can I modify my front end in order to not re make and remake install >each > time I want to compile a new file (knowing that I want to keep my method that > build the Generic form first )? > Hey I feel a little confused reading that, are you in your gcc front-end doing #include <bla> which is c-code generated from this 3rd tool which generates the generic you want within your front-end? So basically that means you need to re-compile your front-end every time you want to compile a new file. I really dont understand why you would do this approach to be honest. It means you basically have a hard-coded input and output each time you compile your front-end. Maybe i am missing something but i dont see why you would do this. --Phil Hi Phil ;) you do not miss anything ;) when I call my driver "guml test.uml", it calls the uml1.c (the compiler). in all other fe, the compiler (uml1.c in my case, py_lang.c for python , etc) calls a parser and a lexer to parse the source file, build the generic and then interface with the middle end (gimplify functions...) In my case, for each source file, I can build the equivalent Generic form and I pass this representation to my compiler so what I want to do is to tell my front end compile the new generic form (which is a c file) every time I call you ;) i,e every time I call guml test.uml, the file test.c (which represent the Generic form) is compiled , so it is not static , it depends on the generic form that is produced from another tool. my problem is that the compiler itself (uml1.c) is compiled when calling make, so the uml1.o is fixed and evry time I call guml it uses the old uml1.o Andi suggest a solution in this post http://gcc.gnu.org/ml/gcc-help/2010-10/msg00293.html but I do not understand where should I put : " gcc my_hook.o my_generic.o <other_stuff> -o <your_compiler> " In fact, I have 2 big questions: 1. Can we add a shell command (for example execute a shell script) when calling the front end driver. If yes where should we add this command ? (this is for the call of the other tool that produce my generic file, I want to generate Genric file when calling guml, it is just like the call of uml1 (the compiler) : when I call guml, uml1 is also called, so could I execute a script whencalling guml ?) 2. In all existing front ends, when running the driver (calling the driver that itself calls the compiler) the compiler takes the name of the file and parse it (for exmple, for the python front end, it calls gpy_lex_parse( t ) that it calls yyparse( void ) . so we did not recompile the front end , only the t parameter in gpy_lex_parse( t ) change, and we produce a differnet generic, gimple, ... In my front end, Instead of giving the name of the source file (parameter t ) to the gpy_lex_parse to produce the genric form, I give directly the file that contains the generic form. How should I process ? I tried to include the generic file with #include "/export/home/charfi/test2.txt"; but it is not a good idea since preprocessor directives are executed before compilation so uml1.o will not change unless we call make each time we compile. thanks a lot Asma