summaryrefslogtreecommitdiff
path: root/sys/src/cmd/6c
AgeCommit message (Collapse)Author
2023-01-286c: copy all of packed structs in OASJacob Moody
code assumed struct was aligned to atleast LONG. For packed structs we need to copy the reaminder as well. Repro: typedef struct { char a; char b; short c; short d; char e; char f; char g; char h; } A; void main(int argc, char **argv) { A a1, a2; a2.a = 1; a2.b = 2; a2.c = 3; a2.d = 4; a2.e = 5; a2.f = 6; a2.g = 7; a2.h = 8; a1 = a2; print("%d %d %d %d %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, a1.h); }
2021-11-176c: extern registers must be considered used on returncinap_lenrek
the peephole optimizer would remove stores to extern register before a return statement as it would think they are only set, but not used.
2021-06-26kencc: revert back to "set but not used"cinap_lenrek
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-21kencc: clarify warning for unused assignmentsNoam Preil
2021-03-135c, 6c, 7c, 8c, kc, qc, vc: use explicit gmove(... , nn) in cgen() for ↵cinap_lenrek
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.
2020-04-25Backed out changeset 2737b9af622bOri Bernstein
not what I wanted to commit.
2020-04-25fix typos in time calculationOri Bernstein
the results of the time calculation were garbled -- and apparently negative on my system when testing, so the test passed when it shouldn't have.
2020-04-19?c: fix Bconv() misusage of strncat()cinap_lenrek
2020-04-196c: conserve registers for floating point operationscinap_lenrek
for floating point operations, reuse the return register on the right hand side if it has higher complex number than the left hand side to conserve registers. this makes the following code compile, that was previously run out of floating point register: float f(float r[15]) { return (r[0] + (r[1] * (r[2] + r[3] * (r[4] + r[5] * (r[6] + r[7] * (r[8] + r[9] * (r[10] + r[11] * (r[12] + r[13] * r[14])))))))); } the downside is that this produces extra move operations.
2020-04-116c: remove mystery sys.c filecinap_lenrek
2020-04-11cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compatcinap_lenrek
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.
2019-06-248c, 6c: LEA x, R; MOV (R), R -> MOV x, Rcinap_lenrek
2019-06-248c, 6c: avoid allocating index registers when we don't have tocinap_lenrek
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-19cc: remove nullwarn() from OCAST codegen, zap void castscinap_lenrek
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-188c, 6c: fix INDEX node #reg calculationcinap_lenrek
2019-05-01[5678vq]c: fix .safe node type for *FUNC() = *FUNC() sugencinap_lenrek
2018-05-286c, 8c: Fix nocast cast bug which prevents address arithmetic from being ↵spew
computed at compile time
2018-05-24cc: fix result of operation not used warning for void castsspew
2017-01-086c: reverse register allocation order to avoid having to spill AX,DX and CXcinap_lenrek
allocating AX,CX,DX last improves 64-bit multiplication-add chains like a*b + c*d as the multiplication does not need to save and restore AX and DX registers in most cases. reserving CX for shifts also helps.
2017-01-026c, 8c: fix "DI botch" evacuating DI/SI/CX registers to ".save" variablescinap_lenrek
2016-08-146c: subsitute floating point registers eleminating MOVSD and MOVSS ↵cinap_lenrek
instructions in peephole pass
2016-06-098c, 6c: native ROL (cyclic shift) instruction support, improve peephole ↵cinap_lenrek
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?c: track ../cc/cc.h dependency and rebuild cc.a$O as neccesarycinap_lenrek
2015-10-065c/6c/8c/vc: import various changes from charles forsythcinap_lenrek
- 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-046c: remove 6c/vlrt.c filecinap_lenrek
2015-10-04cc/6c: fix return type of mixed asop expressions, preserve type for moves so ↵cinap_lenrek
fixed<->float conversions work correctly
2015-03-176c: MOVL xxx, r; MOVLQZX r, r -> MOVL xxx, rcinap_lenrek
eleminate MOVLQXZ instructions after MOVL as MOVL implicitely zero extends the result.
2015-03-016c: fix missing memset in Bconv()cinap_lenrek
2015-02-186c: eleminate more MOV instructionscinap_lenrek
convert: x = B || W MOVxLZX a, r; MOVxQZX r, b -> MOVxQZX a, r; MOVQ r, b MOVxLSX a, r; MOVxQSX r, r -> MOVxQSX a, r; MOVQ r, r the MOVQ can then be eleminated by copy propagation. improve subprop() by accepting other mov and lea instructions as the source op.
2015-02-17[125678kqv][cl]: fix sprint() and strcpy() buffer overflowscinap_lenrek
2014-09-246c/8c: eleminate moves by swaping source and destination operands in ↵cinap_lenrek
peephole pass
2014-08-078c, 6c: generate enam.c file, just like 5ccinap_lenrek
2014-05-306a, 6c, 6l: fix copy propagationAram Hăvărneanu
Without an explicit signal for a truncation, copy propagation will sometimes propagate a 32-bit truncation and end up overwriting uses of the original 64-bit value. This was independently discovered and fixed in Go. See: http://golang.org/issue/1315 https://codereview.appspot.com/6002043/ Thanks Charles Forsyth for tips and advice.
2014-04-288c, 6c: fix peephole bug for eleminating CMPL $0,R after shiftcinap_lenrek
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-03-296c, 8c: optimize away CMPL/CMPQ reg, $0 instruction in peephole passcinap_lenrek
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-218c, 6c: fix mulgen botch error for handling multiplication by zero constantcinap_lenrek
2013-02-286c: fix 32bit pointer truncation (from patch/6c-sugen-types)cinap_lenrek
1. Go group spotted that a slightly-obscured pointer move was done by AMOVL not AMOVQ. 2. Inspecting the code further, I noticed that other pointer types were set to TLONG not TIND, causing similar truncation of pointers to 32 bits.
2012-09-186c: extern register fix (import from patch/6c-extreg)cinap_lenrek
to make it easy to use normal libraries (such as libdraw, libsec, and libmp) with the kernel, which uses extern register, don't stray into the external register set when allocating values to registers.
2012-07-30import updated compilers from sourcescinap_lenrek