This is the mail archive of the gcc@gcc.gnu.org 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]

Re: Target Specific Code Generation in GCC Core


Ranjit Mathew writes:
 > Richard Henderson wrote:
 > > On Wed, Nov 13, 2002 at 05:07:55PM +0530, Ranjit Mathew wrote:
 > > 
 > >>    How does one specify target-specific code in core GCC?
 > > 
 > > 
 > > You don't.
 > 
 > :-)
 > 
 > Ok, I guess I need to elaborate a little to justify the
 > need: when GCJ encounters a call to a Java Native Interface
 > (JNI) method in a Java class, it generates a stub that calls
 > the "native" ("written in C/C++") method. This stub should
 > use the "stdcall" calling convention on Windows instead of
 > the normal calling convention, to be in accordance with
 > the precedent set by Sun's JDKs.

Is "stdcall" used on all Windows targets or just x86?

 > I realise that one should not pollute the GCC front-ends
 > with target-specific code - the way I've seen it done
 > in GCC is through the use of TARGET_FOO_BAR macros that are
 > defined, if needed, by target-specific code in (say)
 > "gcc/config/i386/i386.c". On these lines, the change could
 > look something like:
 > ------------------------- 8< ------------------------------
 > +  tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types);
 > +
 > +  #ifdef MODIFY_JNI_FN_TYPE
 > +    tem = MODIFY_JNI_FN_TYPE(tem)
 > +  #endif
 > ------------------------- 8< ------------------------------
 > 
 > Where the macro MODIFY_JNI_FN_TYPE is defined only by
 > "gcc/config/i386/cygming.h" as only these targets need
 > to change the JNI ABI used.
 > 
 > Since I really can't propose a new TARGET_FOO_BAR style
 > macro, I must find some other way of achieving the same
 > result.

If JNI uses stdcall on every machine where stdcall is defined, there
is no problem: we'll just define a TARGET_STDCALL macro which does the
appropriate thing.  

Andrew.


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