Commit Graph

37 Commits (master)

Author SHA1 Message Date
cinap_lenrek 4fd09def0f kencc: revert back to "set but not used"
The change to "assignment not used" breaks symmetry with
"used and not set" and removes the reference to the
specific warning mentioned in /sys/doc/comp.ms.

Also, the patch was half-assed as that it left some typos
in like "used an not set", which this change also fixed.
2021-06-26 13:16:36 +00:00
Noam Preil 1a09421f7d kencc: clarify warning for unused assignments 2021-06-21 03:29:58 +00:00
cinap_lenrek 9de5aac7a2 5c, 6c, 7c, 8c, kc, qc, vc: use explicit gmove(... , nn) in cgen() for result of OAS*, OPREINC, OPOSTINC
The expression value of the assignment operation was
returned implicitely by relying on regalloc() on the
right hand side "nod" borrowing the register from nn.

But this only works if nn is a register.

In case of 6c, it can also be a ONAME from a .safe
rathole returned by regsalloc().

This change adds explicit gmove() calls to assign the
expression value. Note that gmove() checks if source
and destination are the same register so it wont emit
redundant move operations in the common case.

The same is applied also to OPREINC and OPOSTINC operations.
2021-03-13 13:56:40 +01:00
Ori Bernstein 3ba1d83d20 cc: promote integer constants according to c99 spec.
C99 integer constants with no type suffix promote differently
depending on the way that they're written: hex and oct consts
promote as int => uint => long => ulong => vlong => uvlong.
Decimal constants are always signed.

We used to promote all values to uint on overflow, and never
went wider. This change fixes that, and adds a warning when
a decimal constant that would have been promoted to uint in
the past gets promoted to int.
2020-08-08 11:39:25 -07:00
cinap_lenrek 313216e6fb ?c: get rid of sprint(), strcpy() and strcat()/strncat(), cleanup 2020-04-19 23:51:18 +02:00
cinap_lenrek 34a1b1bb22 ?c: fix Bconv() misusage of strncat() 2020-04-19 04:33:07 +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 4cffc04364 8c, 6c: LEA x, R; MOV (R), R -> MOV x, R 2019-06-24 19:38:46 +02:00
cinap_lenrek 345714dd56 8c, 6c: avoid allocating index registers when we don't have to
when a operation receives a chain of OINDEX nodes as its operands,
each indexing step used to allocate a new index register. this
is wastefull an can result in running out of fixed registers on 386
for code such as: x = a[a[a[a[i]]]].

instead we attempt to reuse the destination register of the operation
as the index register if it is not otherwise referenced. this results
in the index chain to use a single register for index and result and
leaves registers free to be used for something usefull instead.

for 6c, try to avoid R13 as well as BP index base register.
2019-06-24 19:36:01 +02:00
cinap_lenrek 9f6967ed7e 8c: skip 64-bit regpair allocation for OINDEX nodes in cgen64()
OINDEX can only return TLONG result on 386 so give it
a register instead of a regpair and let gmove() handle
the conversion.
2019-06-24 19:25:13 +02:00
cinap_lenrek 63191949b9 cc: remove nullwarn() from OCAST codegen, zap void casts
implicit casts would cause spurious "result of operation not used"
warnings such as ape's stdio putc() macro.

make (void) casts non-ops when the casted expression has no
side effects. this avoid spurious warning with ape's assert()
macro.
2019-06-19 23:50:33 +02:00
cinap_lenrek f360729664 merge 2019-06-18 13:29:29 +02:00
cinap_lenrek 3bb5168c6f 8c, 6c: fix INDEX node #reg calculation 2019-06-18 13:28:15 +02:00
Ori Bernstein 84076e3716 Delete dead code.
Nothing is using (or even building) bound.[ch]
2019-06-17 21:12:35 -07:00
cinap_lenrek 97a2f14b1c [5678vq]c: fix .safe node type for *FUNC() = *FUNC() sugen 2019-05-01 08:55:24 +02:00
spew 3d0ebdc439 6c, 8c: Fix nocast cast bug which prevents address arithmetic from being computed at compile time 2018-05-28 19:38:33 -04:00
spew 1ddf581f8c cc: fix result of operation not used warning for void casts 2018-05-24 19:31:55 -04:00
cinap_lenrek 19dc7c2097 6c, 8c: fix "DI botch" evacuating DI/SI/CX registers to ".save" variables 2017-01-02 05:49:18 +01:00
cinap_lenrek 95609d520e 8c: fix double compiling FNX complex lvalue in cgen64()
sugen() calls cgen64() speculatively so that when cgen64() returns
zero, it will fall back and compile 64-bit copy.

the bug was that cgen64() compiled the left hand side and then recursively
called cgen64() again, which didnt handle the memory copy so it returned
zero and sugen() would compile the left hand side again resulting in two
function calls being emited.

some code that reproduced the issue:

#include <u.h>
#include <libc.h>

typedef struct
{
	char x[10];
	vlong a;
} X;

X a;
X *f(void) { return &a; }

void
main(int argc, char *argv[])
{
	f()->a = a.a;
}

producing:

TEXT	f+0(SB),0,$0
	MOVL	$a+0(SB),AX
	RET	,
	RET	,
	TEXT	main+0(SB),0,$0
	CALL	,f+0(SB)
	CALL	,f+0(SB)			<- bug
	MOVL	AX,CX
	LEAL	a+12(SB),DX
	MOVL	(DX),AX
	MOVL	AX,12(CX)
	MOVL	4(DX),AX
	MOVL	AX,16(CX)
	RET	,
	GLOBL	a+0(SB),$20
	END	,
2016-10-30 23:30:13 +01:00
cinap_lenrek a00b6bdbfa 8c, 6c: native ROL (cyclic shift) instruction support, improve peephole optimizers
introduce rolor() function to subsitute (a << c) | (a >> (bits(a) - c))
with (a <<< c) where <<< is cyclic rotation and c is constant.
this almost doubles the speed of chacha encryption of 386 and amd64.

the peephole optimizer used to stop when it hit a shift or rol
instruction when attempting to eleminate moves by register
substitution. but we do not have to as long as the shift count
operand is not CX (which cannot be substituted) and CX is not
a subject for substitution.
2016-06-09 23:12:46 +02:00
cinap_lenrek 5cdabc5eb1 ?c: track ../cc/cc.h dependency and rebuild cc.a$O as neccesary 2016-06-09 23:03:30 +02:00
cinap_lenrek 2d59b15c39 5c/6c/8c/vc: import various changes from charles forsyth
- cover more cases that have no side effects
- ensure function has complex FNX
- pull operators out of OFUNC level
- rewrite OSTRUCT lhs to avoid all side-effects, use regalloc() instead of regret()
2015-10-06 06:20:01 +02:00
cinap_lenrek 36876b9522 8c: dont abort() when running out of registers. 2015-10-04 22:09:36 +02:00
cinap_lenrek e6d64bab9d 8c: handle 64 bit mixedmode asop and type vlong <-> float/double type conversions 2015-10-04 20:06:59 +02:00
cinap_lenrek 74a557a167 8c: make cgen64() compile target first when it contains functoin call so final assignment wont trash the registers 2015-10-03 12:18:20 +02:00
cinap_lenrek 03feba8cc1 [125678kqv][cl]: fix sprint() and strcpy() buffer overflows 2015-02-17 22:13:35 +01:00
cinap_lenrek decc7ec518 6c/8c: eleminate moves by swaping source and destination operands in peephole pass 2014-09-24 20:45:16 +02:00
cinap_lenrek bc306a5a63 8c, 6c: generate enam.c file, just like 5c 2014-08-07 21:35:52 +02:00
cinap_lenrek 391198888a 8c, 6c: fix peephole bug for eleminating CMPL $0,R after shift
the shift instructions does not change the zero flag
when the shift count is 0, so we cannot remove the
compare instruction in this case.

this fixes oggdec under 386.
2014-04-28 22:53:50 +02:00
cinap_lenrek cde97a4d5f 6c, 8c: optimize away CMPL/CMPQ reg, $0 instruction in peephole pass
when the previous instruction sets the zero flag,
we can remove the CMPL/CMPQ instruction.
this removes compares for zero/non zero tests only.
it only looks at the previous non-nop instruction
to see if it sets our compare value register.
2014-03-29 19:44:04 +01:00
cinap_lenrek 393dfd1ced 8c, 6c: fix mulgen botch error for handling multiplication by zero constant 2014-03-21 19:05:17 +01:00
cinap_lenrek 6c4d8f8b11 8c: apply charles forsyth's 8c-cgen64-mul-savereg patch (from sources)
If 64-bit multiply has to save both AX and DX, it could load the wrong value
into DX; also, biggen shouldn't allocate either AX or DX as temporaries
when using the template for MUL.
2013-06-01 18:51:47 +02:00
jpathy 213bf50893 add 6(a|l) sse support to 8(a|l) 2013-05-21 23:15:13 +05:30
cinap_lenrek 4f33c88a51 import updated compilers from sources 2012-07-30 19:11:16 +02:00
aiju 5851650367 added Blethal to libbio 2011-07-12 18:39:40 +02: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