extract architecture independent gen.c
commit7d0f092898fc1d7138aaff4a1b2186674481498a
authorAli Gholami Rudi <ali@rudi.ir>
Fri, 23 Dec 2011 07:55:08 +0000 (23 11:25 +0330)
committerAli Gholami Rudi <ali@rudi.ir>
Fri, 6 Jan 2012 18:59:33 +0000 (6 22:29 +0330)
tree6f92a8ad2e7ffc9943509059b60db823397cfd89
parent58774381cc50c2822415aab6ca67d34743ecc1b6
extract architecture independent gen.c

This is actually the next version of neatcc.  Previously, code generation
was done independently for each architecture.  That included handling
different instructions, optimizing instructions using immediate, constant
inlining, handling jumps, locals, stack and temporaries, in addition to
a separate optimization patch for each architecture, which was separated
to make the complexity more manageable.  I was satisfied with the design
when there were only one architecture, but with three architectures and
an optimization patch for each, things started to look awful.

This patch extracts the architecture-independent gen.c from the old
code generation files.  The new layout of neatcc is:

1. cpp.c   preprocessing
2. tok.c   tokenizing
3. ncc.c   parsing
4. gen.c   architecture independent code generation and optimization
5. x86.c   architecture dependent code generation
6. out.c   output executable file

It has many benefits:

* Architecture-dependent files are much shorter and easier to maintain,
  so adding new architectures or tweaking instructions for old
  architectures are much easier now.
* All architectures are maintained on the same branch; this makes
  distributing neatcc as a single package much easier and without
  depending on git.
* The architecture-independent gen.c now leaves a lot of room for
  optimizations.  neatcc's two pass optimization, which used to be a hack
  and left as a separate patch, is now an effective optimization method.
  A lot of improvements are possible.
16 files changed:
Makefile
README
arm.c
arm.h [new file with mode: 0644]
cpp.c
gen.c [new file with mode: 0644]
gen.h
ncc.c
neatcc
out.c
out.h
tok.h
x64.c [new file with mode: 0644]
x64.h [new file with mode: 0644]
x86.c
x86.h [new file with mode: 0644]