Commit graph

23 commits

Author SHA1 Message Date
Ori Bernstein 5b8b5884f4 5l: fix shifts by zero
on arm32, we can do one of 4 shifts
by a constant:

	reg<<(0..31)
	reg>>(1..32)
	((u32int)reg)>>(1..32)
	reg ROT (0..31)

There's no way to encode a 0 bit right
shift,  so when encoding reg>>0, flip
it to the equivalent nop reg<<0, which
can be encoded.
2021-01-23 20:36:09 -08:00
cinap_lenrek 8ca102d42e cc: dont export gethunk(), hunk, nhunk and thunk 2020-05-12 23:18:48 +02:00
cinap_lenrek ecdf3f921e ?l: remove direct hunk manipulation from linkers, just call malloc()
as with recent changes, cc's malloc() could make the hunk pointer
misaligned. in the the compilers, the hunk pointer is used directly
by the lexer with no effort to to keep the hunk pointer aligned.

alloc/malloc still return aligned pointers, but hunk itself can
be on a odd address after allocation of a odd sized amount of bytes.

however, in the linkers, this assumption appears to be differnet. as
most allocations mostly allocate padded structures. however, symbol
lookup allocates strings on byte-size ganularity and the cc's malloc
would misalign the hunk pointer after the malloc() call. while the
rest of the code assumed hunk pointer was always aligned.

this change removes all the hunk pointer fiddling from the linker,
and we just call malloc() (which will use the fast implmenentation
of cc, and should not really make much of a performance difference).
2020-05-12 22:04:30 +02:00
cinap_lenrek b43720e3f7 [257]l: cleanup fmt routines, replace sprint() 2020-04-19 23:47:23 +02:00
cinap_lenrek 1b8a569417 cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compat
for gethunk() to work, all allocators have to use it,
including allocations done by libc thru malloc(),
so the fake allocation functions are mandatory for
everyone.

to avoid duplication the code is moved to cc/compat
and prototypes provided in new cc/compat.h header.
2020-04-11 05:03:49 +02:00
cinap_lenrek 9d46360c9d backout the gethunk() again, as that breaks the assemblers
the assemblers share gethunk() cc/macbody but are compiled
without compat.c, so calls such as getenv() trigger malloc()
which does its own sbrk() calls, breaking the continuity
of the hunk.

so this change needs another revision. until then, this is
backed out.
2020-04-11 01:26:36 +02:00
cinap_lenrek 1d3644a168 cc, ?l: fix gethunk() to actually grow allocation
the compilers and linkers use ther own memory allocator.
free memory is between hunk and hunk+nhunk. allocation
works by checking if nhunk is bigger or equal to the
amount needed, and if not, repeatedly call gethunk()
until there is. after that, the allocated amount is added
from hunk and subtracted from nhunk by the user.

the problem was when the needed amount was bigger than
the default NHUNK size gethunk() allocates per call.
gethunk() would not actually grow nhunk, but instead
just set hunk and nhunk variables to the last allocated
block. this resulted in a infinite loop of calls to
gethunk() until sbrk() would hit the maximum size for
the BSS segment.

this change makes gethunk() actually grow the hunk space,
increasing nhunk, and only updating hunk when nhunk was
previously zero. we assume that mysbrk() retuns increasing
addresses and that the space between the previous hunk+nhunk
and the new block base returned by mysbrk() is usable.
2020-04-10 23:11:25 +02:00
Sigrid 2cdf1a3c79 cc, ?a, ?l: change thunk type to uintptr 2020-04-10 20:38:45 +02:00
cinap_lenrek da9b38c75c 5l,6l,8l,kl,ql,vl: allow duplicate GLOBAL symbols (from Ori Bernstein)
The plan 9 assemblers support the DUPOK flag on text symbols. They parse and
ignore it on GLOBL symbols. This patch makes it work in the linkers.

The reason I ran into this is because my programming language (Myrddin) uses
data symbols to generate type information, and it's useful to avoid
duplicating all of the type info in every file that gets generated.
2017-03-19 03:05:24 +01:00
cinap_lenrek 607f3bc55c 5l: format assembly constant right shift encoding 0 as >>32 2016-09-03 17:01:56 +02:00
cinap_lenrek 49cd794fbd 5l: ROR instruction 2016-07-08 04:16:37 +02:00
cinap_lenrek 03feba8cc1 [125678kqv][cl]: fix sprint() and strcpy() buffer overflows 2015-02-17 22:13:35 +01:00
cinap_lenrek 4e94094e94 5l: remove -f flag and add -F flag to disable VFP code generation
almost nobody uses FPA anymore, so make VFP the default but
provide -F flag to disable it.
2014-12-24 11:38:44 +01:00
cinap_lenrek d304dc8119 5a, 5l: add LDREX/STREX/CLREX instructions 2014-08-07 20:22:00 +02:00
cinap_lenrek 87fd5240f0 remove old copies of kernels l.s from cmd/?a 2014-05-08 18:48:51 +02:00
cinap_lenrek cc24222672 fixes for new setmalloctag() prototype 2014-02-01 10:29:14 +01:00
cinap_lenrek cb8eac54ed 5l: apply richard millers 5l-incfloat patch (from sources)
Generate correct ARM vfp code for x++ where x is single precision float.
Example test program (link with '5l -f'): void _main() { float x; x++;}
2013-10-06 01:49:15 +02:00
cinap_lenrek ea0f580909 add arm vfp support to compiler and linker (from sources) 2013-01-26 18:03:45 +01:00
cinap_lenrek a5756259cf 5l -H7 (elf) support (import from sources) 2012-09-18 18:22:38 +02:00
cinap_lenrek 4f33c88a51 import updated compilers from sources 2012-07-30 19:11:16 +02:00
aiju c8524f52ad add -P flag to 5l to produce proper flat binaries 2011-11-05 09:48:29 +01:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00