Age | Commit message (Collapse) | Author |
|
|
|
|
|
Since the environment can only be of type `l`, do
not require to write it down.
I also tightened the type information of the `pare`
and `arge` instructions.
|
|
|
|
|
|
|
|
Ori needs this. It should not cost much more memory at runtime,
only a minimal amount of address space.
|
|
The previous code was buggy. It would put a stack
pointer on the heap when handling "add $foo, 42".
The new code is more straightforward and hopefully
more correct. Only temporaries with a "stack"
alias class will have a slot pointer.
|
|
|
|
With the default toolchain, it looks like we have to
make sure all symbols are loaded using rip-relative
addressing.
|
|
Intended usage: c_count `make src` (or similar).
|
|
|
|
|
|
|
|
|
|
The vararg tests had to be changed because
va_list is 32-bit wide on arm. The astute
reader will notice that the way we pass
va_list values is wrong, we should be using
the ':valist' type as defined below instead
of 'l'. But eh, that works for now, because
of the ABI.
type :valist = align 8 { 32 }
|
|
|
|
|
|
The arm64 ABI needs to know precisely what
floating point types are being used, so we
need to store that information.
I also made typ[] a dynamic array.
|
|
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).
|
|
The size of a union is the size of the largest
element aligned with the largest alignment.
For example, the size of the following union is
16, not 13 (as returned before this patch).
union {
char c[13];
int i;
};
|
|
The register allocation now has stricter assertions
about global registers. The stricter assertions
required changes in the spiller: We now correctly
indicate to the register allocator what registers
are used by "ret" instructions.
|
|
|
|
|
|
|
|
|
|
|
|
The spec says that numbers can be arbitrarily
big, and only the last 64 bits will be taken
into consideration. Calling sscanf does not
implement this, so I wrote an ad-hoc function.
|
|
Notably, this adds a new pass to get rid of
jumps on jumps.
|
|
|
|
|
|
|
|
|
|
|
|
When a temporary marked local is escaping,
the whole slot must be marked as such. To
solve this, Alias now holds a pointer to
the alias information of the slot. For
simplicity of the code, this pointer is
always valid and fetching ->type out of it
is meaningful.
|
|
|
|
When eliminating `load %foo`, don't limit the
search to the live range of %foo, but to the
live range of its aliasing information.
For example, if %foo is a constant offset into
a stack-allocated slot,
%foo =l add %slot, 42
the search will proceed on all the code in
which %slot is live, not only below the
definition of %foo, like before.
|
|
|
|
While a minimal dead store elimination is not
implemented, the generated code looks quite a
bit better with them enabled. It also is quite
cheap.
|
|
|
|
|
|
|
|
While I was at it I also refreshed some bits
in the instruction selection.
|
|
|
|
|
|
|
|
Compiling languages with closures often requires passing
an extra environment parameter to the called function.
One solution is to use a convention, and reserve, say,
the first argument for that purpose. However, that
makes binding to C a little less smooth.
Alternatively, QBE now provides a way to remain fully
ABI compatible with C by having a "hidden" environment
argument (marked with the keyword 'env'). Calling a
function expecting an environment from C will make the
contents of the environment undefined, but the normal
arguments will be passed without alteration. Conversely,
calling a C function like it is a closure by passing
it an environemnt will work smoothly.
|
|
|
|
We conservatively assume all functions have
variable argument lists.
|
|
|