Gcc plugin: error: ‘LAST_AND_UNUSED_RTX_CODE’ undeclared

2010-02-26 Thread ashish jain
Hi,

I am trying to write a simple gcc plugin and am getting the following errors.

In file included from /home/aj/gcc/trunk/gcc/rtl.h:49,  
 
 from /home/aj/gcc/testcode/plugin/ctla_gcc_plugin.c:22:
 
/home/aj/gcc/trunk/gcc/rtl.def:336: error: expected identifier before ‘const’   
 
In file included from /home/aj/gcc/testcode/plugin/ctla_gcc_plugin.c:22:
 
/home/aj/gcc/trunk/gcc/rtl.h:99: error: ‘LAST_AND_UNUSED_RTX_CODE’ undeclared 
here (not in a function)   
In file included from /home/aj/gcc/trunk/gcc/basic-block.h:28,  
 
 from /home/aj/gcc/testcode/plugin/ctla_gcc_plugin.c:23:
 
/home/aj/gcc/trunk/gcc/hard-reg-set.h: In function ‘hard_reg_set_iter_set’: 
 
/home/aj/gcc/trunk/gcc/hard-reg-set.h:545: error: ‘FIRST_PSEUDO_REGISTER’ 
undeclared (first use in this function)
/home/aj/gcc/trunk/gcc/hard-reg-set.h:545: error: (Each undeclared identifier 
is reported only once  
/home/aj/gcc/trunk/gcc/hard-reg-set.h:545: error: for each function it appears 
in.)  
/home/aj/gcc/trunk/gcc/hard-reg-set.h: At top level:
 
/home/aj/gcc/trunk/gcc/hard-reg-set.h:583: error: ‘FIRST_PSEUDO_REGISTER’ 
undeclared here (not in a function)
/home/aj/gcc/trunk/gcc/hard-reg-set.h:644: error: ‘N_REG_CLASSES’ undeclared 
here (not in a function)
In file included from /home/aj/gcc/trunk/gcc/basic-block.h:31,  
 
 from /home/aj/gcc/testcode/plugin/ctla_gcc_plugin.c:23:
/home/aj/gcc/trunk/gcc/function.h:222: error: expected specifier-qualifier-list 
before ‘CUMULATIVE_ARGS’
/home/aj/gcc/trunk/gcc/function.h:698: error: expected ‘)’ before ‘*’ token
/home/aj/gcc/trunk/gcc/function.h:700: error: expected ‘)’ before ‘*’ token
In file included from /home/aj/gcc/testcode/plugin/ctla_gcc_plugin.c:32:
/home/aj/gcc/trunk/gcc/target.h:910: error: expected ‘)’ before ‘*’ token
/home/aj/gcc/trunk/gcc/target.h:913: error: expected ‘;’ before ‘rtx’

I googled for a solution and found a similar message in which it was suggested 
to include "tm.h". I verified my code, and I am getting the same error even 
after including the file.

My CMake file is as follows:

set( GCC_SRC_DIR "/home/aj/gcc/trunk")
set( GCC_BUILD_DIR "/home/aj/gcc/trunk-obj" )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${GCC_BUILD_DIR}/gcc )
include_directories( ${GCC_SRC_DIR}/gcc )
include_directories( ${GCC_SRC_DIR}/libcpp/include )
include_directories( ${GCC_SRC_DIR}/include )
include_directories( ${GCC_SRC_DIR}/host-i686-pc-linux-gnu/gcc )

I am not able to figure out what is going wrong, can you please guide me on 
where am I making a mistake?

Thanks,
Ashish


  Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/


Re: Gcc plugin: error: ‘LAST_AND_UNUSED_RTX_CODE’ undeclared

2010-02-27 Thread ashish jain
Hi,

--- On Fri, 26/2/10, Andrew Pinski  wrote:

> From the looks of it, you have a define for CONST as
> const.  This
> first error is the reason for the rest of the errors.
> 
> Thanks,
> Andrew Pinski

I havent modified anything in that part of the code. Reordering the header 
files somehow made all the errors disappear.

Thanks,
Ashish Jain


  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/


Help with gimple_build_call

2010-03-22 Thread ashish jain
Hi,

I am writing a pass in which I need to insert a call to a library
function. Specifically I need to call the function
"pthread_mutex_lock" from the library "pthread". I am working on
GIMPLE, specifically after the "build_cfg" pass.

Looking around the documentation, what I found is I will have to use
the function gimple_build_call. My question is how do I build the tree
fn, and the arguments which have to be provided to gimple_build_call.

Do I have to use build_function_type_list and build_fn_decl for
building tree fn? The original function call "pthread_mutex_lock"
requires an "pthread_mutex_t" type variable as an argument, how can I
declare that in the pass, and use it as an argument in
gimple_build_call?

Thanks,
Ashish