how to write port

Stephane Carrez Stephane.Carrez@worldnet.fr
Wed Mar 20 15:28:00 GMT 2002


Hi!

"M.Khaja Mohideen" a écrit :
> 
> hello,
> my project is to make some optimizations to an existing port of gcc for
> motorola hc12 . i have found out that i have to make some modifications in
> the files m68hc11.c , m68hc11.h and m68hc11.md .
> but the problem is the definitions given in Gcc documentation about the
> Maschine descriptions and RTL definitions are not clear.
> 
> 1 . i dont understand how the definitions given in the Maschine description
> documenation matches with those used in the m68h11.md files.
> e.g. define_insn etc

All machine description files use define_expand and define_insn and other define_xxx.
They specify, in terms of RTL, what the machine is able to do.

There are well known names for some define_expand/define_insn (see "Standard Names"
section in MD doc).  These are the entry points for code generation.  At this first
level (of code gen), you can't add a pattern and see it magically used by gcc-core.
Within a define_expand, a port can generate several insns corresponding to
specific define_insn.  For example, look at "movdi" expand pattern.  This is the
gcc standard name/entry point.  For HC11, this define_expand calls "gen_movdi_internal"
which corresponds to the define_insn "movdi_internal".  This later insn, is never
called (directly) by gcc-core.


Later on, during optimization, gcc reorganizes the RTL, replaces expressions and
creates new complex and sometimes hypothetical insns.  It then tries to recognize
such insns against the MD file (recog/validate).  At this level, if the MD file
has a define_insn whose definition matches the gcc-optimized insn, it use it.
For HC11, the define_insn "*logicalsi3_zexthi" is an example of such hypothetical insn
tried by the optimizer.

Of course, the quick&dirty explanation I give here is not enough to understand
all the details (and there are many).  Reading the MD doc several times really helps.

> 
> 2. then i dont understand how the compiler when it compiles the C program
> uses the files mentioned above if i for instance mentioned the target as
> -m68hc12 .

-mXXX is just an option specific to the gcc backend.  In the 68hc11 case,
the -m68hc12 option turns out into the TARGET_M6812 flag, exclusive with
TARGET_M6811 flag (see TARGET_SWITCHES in m68hc11.h).

In the MD file, the 68HC12 specific patterns are conditionalized with TARGET_M6812
that is they are valid only when -m68hc12 is specified.  Likewise for m68hc11
specific patterns with TARGET_M6811.  Those patterns that do not depend on TARGET_xxx
are always valid and common to both.

Hope this helps,
	Stephane



More information about the Gcc mailing list