This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: porting gcc to a different architecture
- To: marco dot marcello at tin dot it
- Subject: Re: porting gcc to a different architecture
- From: Nick Clifton <nickc at redhat dot com>
- Date: Sat, 10 Feb 2001 11:56:07 -0800
- CC: gcc at gcc dot gnu dot org
Hi Marco,
: Hi, I have to modify gcc to use it with an ARM-based architecture
: with some coprocessors. I have some knowledge about C,C++, assembly
: and the ARM instruction set, but I don't know how gcc works. Can
: anybody tell me which files I have to modify to adapt the ARM gcc
: compiler?
First of all, if your coprocessors include new instruction mnemonics
&/or registers, (instead of just using the normal ARM coprocessor
instructions) you should add the new instructions to the assembler and
disassembler. Look at the files opcodes/arm-opc.h, opcodes/arm-dis.c,
gas/config/tc-arm.c for this. The check that you can assemble and
disassemble programs using the new opcodes. You may also want to
consider adding code to the arm simulator (sim/arm/*) to emulate the
coprocessors.
To modify gcc, you are going to want to look at the ARM machine
description file (gcc/config/arm/arm.md) and the accompanying
documentation describing machine description files (gcc/md.texi).
You will need to learn about gcc's internal representation (called
RTL) and you will also want to look at the other files int he ARM
backend, especially arm.c and arm.h.
Basically what you will need to do is to add new patterns to the
arm.md file that describe the new coprocessor instructions.
Depending upon how well the coprocessor instructions map onto the kind
of instructions that gcc generates, you may also be able to modify
existing patterns to make use of coprocessor as well.
If gcc is unable to generate your new instructions (because they do
things that it does not know about) you may have to add them as
builtins. Have a look at how the '__builtin_prefetch' instruction is
handled in the current gcc sources.
Remember, when in doubt - read the sources. Especially have a look at
the sources for other ports as well. They may give you some clues if
you are stuck on how to modify the ARM port.
Cheers
Nick