Commit graph

20 commits

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
cinap_lenrek 4bbf1d12b5 7c: now really fix OASxxx operations
the previous patch broke 64-bit ops as the type for the
operation is determined from the first argument to
gopcode() (nod1.type), not the type the result (nod.type).

so we need to include the conversion of nod1 type to
the type of nod.
2020-08-04 00:50:33 +02:00
cinap_lenrek d42f9b5110 reverting 7c change, breaks some 64-bit shifts... 2020-08-03 23:16:41 +02:00
cinap_lenrek cbe45e78f9 7c: fix wrong type on OASxxx operations
the bug can be reproduced with the following test case:

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

void
main()
{
	int size = 1;
	size*=1.5;
	exits(0);
}

this produces the following assembly:

	TEXT	main+0(SB),0,$16
	MOVW	$1,R1
	FCVTZSDW	$1.50000000000000000e+00,R2	<- tries to convert rhs to int??
	MULW	R2,R1,R2 <- multiplication done in int? bug!
	MOV	$0,R0
	BL	,exits+0(SB)
	RETURN	,
	END	,

the confusion comes from the *= operation using the wrong type
for the multiplication. in this case we should use the float
type of the rhs, do the operation, and then convert the result
back to int type of the lhs.

this change ports the same logic from 5c's getasop().
2020-08-02 19:48:25 +02:00
cinap_lenrek 313216e6fb ?c: get rid of sprint(), strcpy() and strcat()/strncat(), cleanup 2020-04-19 23:51:18 +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 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 97a2f14b1c [5678vq]c: fix .safe node type for *FUNC() = *FUNC() sugen 2019-05-01 08:55:24 +02:00
cinap_lenrek 3fe9730645 7c: don't emit SXTW for non-register source operand 2019-04-25 19:44:16 +02:00
cinap_lenrek 15c3f45e5f 7c: fix long to vlong/pointer conversion, avoid negative immediate offsets
we have to explicitely convert to vlong by sign or
zero extending as not every operation leaves a proper
zero/sign extended result in the register. for example
NEGW will zero extend, breaking negative int offsets
on pointers.

we explicitely insert SXTW or MOVWU instructions which
the peephole optimizer takes out again when it is safe
todo so.

when promoting constant offsets to immediate offsets,
make sure the offset will be in range. otherwise the
linker will produce not so optimal pointer arithmetic
instructions to calculate the offset.
2019-04-17 23:38:00 +02:00
cinap_lenrek 14c7edf96e 7c: fix registerization of vlong constants 2019-04-08 13:47:45 +02:00
cinap_lenrek b29d5ac7b1 add arm64 c compiler and assembler (thanks charles forsyth)
this is the the initial sync of charles forsyths plan9 c
compiler suite from http://bitbucket.org/plan9-from-bell-labs/9-cc
at changeset version 54:65fb8bb56c59
2019-04-08 13:45:49 +02:00
cinap_lenrek 986886f2b8 retire the dec alpha port 2016-05-04 16:11:48 +02:00
cinap_lenrek 29a53a52fd 1c,2c,7c,kc,vc: honor suppress condition for outstring() in swt.c 2015-08-02 14:52:54 +02:00
cinap_lenrek 03feba8cc1 [125678kqv][cl]: fix sprint() and strcpy() buffer overflows 2015-02-17 22:13:35 +01:00
cinap_lenrek 4f33c88a51 import updated compilers from sources 2012-07-30 19:11:16 +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