Target Specific Code Generation in GCC Core
Ranjit Mathew
rmathew@hotmail.com
Tue Nov 19 07:34:00 GMT 2002
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.
The stub is generated by the GCC java front-end (in
"gcc/java/expr.c") and I need to tell it to use the
stdcall calling convention only when the *target* is one
of the Windows targets (mingw32 or cygwin). The patch
in my previous mail does it only if the *host* is
one of these targets. Hence the question.
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 any of you can tell me an alternative way of
doing it, I'll be very grateful.
Sincerely Yours,
Ranjit.
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/
More information about the Gcc
mailing list