Commit graph

19 commits

Author SHA1 Message Date
Quentin Carbonneaux
49a4593c33 prepare for multi-target
This big diff does multiple changes to allow
the addition of new targets to qbe.  The
changes are listed below in decreasing order
of impact.

1. Add a new Target structure.

To add support for a given target, one has to
implement all the members of the Target
structure.  All the source files where changed
to use this interface where needed.

2. Single out amd64-specific code.

In this commit, the amd64 target T_amd64_sysv
is the only target available, it is implemented
in the amd64/ directory.  All the non-static
items in this directory are prefixed with either
amd64_ or amd64_sysv (for items that are
specific to the System V ABI).

3. Centralize Ops information.

There is now a file 'ops.h' that must be used to
store all the available operations together with
their metadata.  The various targets will only
select what they need; but it is beneficial that
there is only *one* place to change to add a new
instruction.

One good side effect of this change is that any
operation 'xyz' in the IL now as a corresponding
'Oxyz' in the code.

4. Misc fixes.

One notable change is that instruction selection
now generates generic comparison operations and
the lowering to the target's comparisons is done
in the emitter.

GAS directives for data are the same for many
targets, so data emission was extracted in a
file 'gas.c'.

5. Modularize the Makefile.

The Makefile now has a list of C files that
are target-independent (SRC), and one list
of C files per target.  Each target can also
use its own 'all.h' header (for example to
define registers).
2017-04-08 21:56:20 -04:00
Quentin Carbonneaux
fc124dd22e update isel comment 2017-02-24 09:32:13 -05:00
Quentin Carbonneaux
eebbb69291 do not err on address comparisons
While I was at it I also refreshed some bits
in the instruction selection.
2017-02-22 12:48:04 -05:00
Quentin Carbonneaux
8799dc30ac make rsp and rbp globally live 2017-02-08 10:49:55 -05:00
Quentin Carbonneaux
e38da51c14 isel fixes for lame apple assembler 2017-01-10 20:24:10 -05:00
Quentin Carbonneaux
ed8fe831fe remove debugging stub 2016-12-29 20:58:30 -05:00
Quentin Carbonneaux
e9ccf35b8a do not create useless mem refs 2016-12-29 17:58:56 -05:00
Quentin Carbonneaux
7815610cd8 simplify seladdr()
This also provides a violent fix to a bug causing an invalid
addressing to be generated when indexing into a global variable.
The fix is not satisfactory, though, as bad code is generated
(instead of invalid code before).
2016-12-29 17:51:26 -05:00
Quentin Carbonneaux
f4e0bfbbb9 correctly update nuse for jump arguments 2016-04-23 09:31:35 -04:00
Quentin Carbonneaux
55476d0738 refine fp conversion instructions 2016-04-22 15:11:18 -04:00
Quentin Carbonneaux
657c3fa66b match jumps/ops with il text 2016-04-20 09:56:29 -04:00
Quentin Carbonneaux
3bec2c6087 call fixarg on the correct instruction
Because one call to fixarg can emit an instruction,
using curi, for the second fixarg calls patched is
incorrect.  AFL found that bug.
2016-04-13 17:53:07 -04:00
Quentin Carbonneaux
3bb4f8a647 nicer agony message in isel 2016-04-12 14:51:50 -04:00
Quentin Carbonneaux
4999d6ebf0 more extensive handling of fast locals 2016-04-12 14:51:45 -04:00
Quentin Carbonneaux
5c3c410c60 both comparison arguments need to be fixed
The second argument will not be a constant because
of the assertion.  But it could be a fast local, and
this situation needs to be handled by the last case
of fixarg().
2016-04-12 13:00:16 -04:00
Quentin Carbonneaux
c416da5a70 handle dumb conditional jumps in isel
I also removed the code to handle jumps with a
constant argument since those should be eliminated
by the folding pass.
2016-04-12 12:06:51 -04:00
Quentin Carbonneaux
0a81036fa2 move abi code in a new file 2016-03-31 17:17:09 -04:00
Quentin Carbonneaux
729aa97b79 cleanup error handling 2016-03-31 09:15:50 -04:00
Quentin Carbonneaux
b75cb8388f new layout, put LICENSE in root 2016-03-29 10:10:22 -04:00
Renamed from src/isel.c (Browse further)