David Given
d7df126730
Merge pull request #44 from kernigh/kernigh-pr-as
...
mach/proto/as: allow more tokens
2017-01-18 23:33:40 +01:00
George Koehler
f705339f86
Allow more tokens in the assembler.
...
I need this so I can add more %token lines to mach/powerpc/as/mach2.c
The assembler's tempfile encoded each token in a byte. This only
worked with tokens 0 to 127 and 256 and 383. If a token 384 or higher
existed, the assembler stopped working. I need tokens 384 and higher.
I change the token encoding to a 2-byte little-endian integer. I also
change a byte in the string encoding.
2017-01-17 22:41:11 -05:00
George Koehler
ba2a03705e
Use prototypes in mach/proto/as/comm5.c
...
Order the function prototypes in comm1.h to match the order of the
function definitions in *.c files.
2017-01-17 16:41:29 -05:00
David Given
81c677d218
Add a bunch more set operations to the PowerPC backends, and the Pascal test
...
for the same.
2017-01-17 22:31:38 +01:00
George Koehler
916d270534
Delay inclusion of <stdint.h> when compiling comm2.y
...
See issue #1 (https://github.com/davidgiven/ack/issues/1 ). The file
mach/proto/as/comm2.y goes through cpp twice. The _include macro,
defined in comm2.y and used in comm0.h, delays the inclusion of system
header files. The inclusion of <stdint.h> wasn't delayed. This
caused multiple inclusions of <sys/_types.h> in FreeBSD and
<machine/_types.h> in OpenBSD.
Use _include to delay <stdint.h>. Also use _include for "arch.h" and
"out.h", because h/out.h includes <stdint.h> and h/arch.h might
include it in the future.
Sort the system includes in comm0.h by moving them up to be with
<stdint.h>. Must include <stdint.h> before "mach0.c", because
mach/powerpc/as/mach0.c needs it. Must include "mach0.c" before
checking ASLD.
2017-01-16 22:39:44 -05:00
George Koehler
e97116c037
Remove some obsolete code that causes a gcc warning.
...
In my OpenBSD/amd64 system, the code becomes
if (0)
outname.on_valu &= ~(((0xFFFFFFFF)<<32)<<32);
The 0xFFFFFFFF is a 32-bit int, so the left shift by 32 is out of
range and causes the gcc warning.
The intent might be to clear any sign-extended bits, if the assignment
outname.on_valu = valu did sign extension. Old C had no unsigned
long, so .on_valu would have been long. The code is obsolete because
h/out.h now declares .on_valu as uint32_t.
2017-01-16 18:09:55 -05:00
David Given
c471f617b7
Ensure that memory is zero-initialised.
2017-01-16 22:45:03 +01:00
David Given
2cdcc16bc2
Fix a buffer overrun that was manifesting on OpenBSD; also fix a bounds check and some uninitialised variable problems.
2017-01-16 22:44:37 +01:00
David Given
fa5675d439
Run through clang-format.
2017-01-16 21:16:33 +01:00
David Given
e7e29d34ff
Add a test (currently failing) to check that Pascal char sets can store all 256
...
possible values. Add the PowerPC ncg and mcg backend support to let the test
actually run, including modifying a bunch of PowrePC libem functions so that
they can be called from both ncg and mcg.
2017-01-15 22:28:14 +01:00
David Given
efab08178b
Fix a bunch of issues with pushing and popping mismatched sizes, which the B
...
compiler does a lot; dup 8 for pairs of words is now optimised.
2017-01-07 18:47:00 +01:00
David Given
7710c76d56
Introduce sequence points before store instructions to prevent loads from the
...
same address being delayed until after the store (at which point they'll return
the wrong value).
2017-01-07 13:17:39 +01:00
David Given
fbd6e8f63d
Add support for consecutive labels; needed by the B compiler.
2016-11-27 21:18:00 +01:00
David Given
953c08839f
inn works now; add a helper for it.
2016-11-20 12:53:44 +01:00
David Given
196fa914b3
lxa now works, I hope; traps are better (and stubbed out on qemuppc).
2016-11-20 11:57:21 +01:00
David Given
d5328492d7
Better handling of float conversions; more tests; converting to unsigned ints
...
works now.
2016-11-20 11:27:40 +01:00
David Given
cc660b230f
Floats and doubles are now written out correctly.
2016-11-19 11:39:13 +01:00
David Given
d31bc6a3f9
Made csa and csb work with mcg; adjust the libem functions and the
...
corresponding invocation in the ncg table so the same helpers can be used for
both mcg and ncg. Add a new IR opcode, FARJUMP, which jumps to a helper
function but saves volatile registers.
2016-11-19 10:55:41 +01:00
David Given
43439c6d0c
Remember to push the result of lor onto the stack.
2016-11-17 22:04:32 +01:00
David Given
81bc2c74c5
A bb's regsin are no longer the same as those of its first instruction;
...
occasionally the first hop of a block would try to rearrange its registers (due
to evicted throughs), resulting in the phi moves copying values into the wrong
registers.
2016-11-16 20:52:15 +01:00
David Given
581fa4a457
Reenable eviction of corrupted registers, which had been broken by a previous
...
change. Change the register move code to get swaps right, or at least righter.
2016-11-15 21:55:10 +01:00
David Given
0289b1004e
Allow values left on the stack at the end of the procedure (it's legal!).
2016-11-14 21:47:49 +01:00
David Given
e7132183fb
Fix buffer overrun: if LABEL_STARTER is seen but LABEL_TERMINATOR is not, the
...
label parser will keep going forever looking for the end of the label. It now
stops at the end of the string.
2016-11-13 14:04:58 +01:00
David Given
852d3a691d
Update the table to return call output values in the right registers. Fix the
...
register allocator so the corrupted registers only apply to throughs
(otherwise, you can't put output registers in corrupted registers).
2016-11-11 21:48:36 +01:00
David Given
b5c1d622f5
Rework the way stack frames are laid out to be simpler and, hopefully, more
...
correct. Saved registers are now placed in what may be the right place.
2016-11-11 21:17:45 +01:00
David Given
84ee75ec07
Merge from default.
2016-11-11 20:17:54 +01:00
David Given
d82df74a7a
Rename addr_t to address_t to avoid clashes with the system addr_t.
2016-11-11 20:17:10 +01:00
David Given
fd91851005
Add enough return types to the K&R C that the ACK builds (on Linux) using clang
...
now.
2016-11-10 22:04:18 +01:00
David Given
4fa2c94a4a
Correctly mangle labels used in initialisers.
2016-10-31 23:21:33 +01:00
David Given
e19850b114
Fix a few c11isms.
2016-10-30 16:51:06 +01:00
David Given
ca5b6e07bb
Properly export symbols.
2016-10-29 23:52:17 +02:00
David Given
8c3670483f
Get top working with the PowerPC; use it to eliminate useless branches and
...
moves.
2016-10-29 23:37:11 +02:00
David Given
a8c4dac67c
Merge from default (merging in George Koehler's PowerPC changes).
2016-10-29 22:40:40 +02:00
David Given
a311e61360
Add support for preserved registers.
2016-10-29 20:22:44 +02:00
David Given
e3ebf986e9
More opcodes.
2016-10-29 13:32:09 +02:00
David Given
acaae765af
Emit negative constants correctly.
2016-10-29 12:55:21 +02:00
David Given
61349389fb
More opcodes. sti can now cope with non-standard sizes (really need a better
...
fix for this). Hack in crude support for mismatched stack pushes and pops (ints
vs longs).
2016-10-29 12:48:05 +02:00
David Given
2cc2c0ae98
Lots more opcodes. Rearrange the stack layout so that fp->ab is a fixed value
...
(needed for CHAINFP and FPTOAB). Wire up lfrs to calls via a phi when
necessary, to allow call-bra-lfr chains.
2016-10-29 11:57:56 +02:00
David Given
bfa65168e2
Don't generate phis if unnecessary (because this breaks the
...
critical-edge-splitting guarantee and causes insertion of phi copies to fail).
2016-10-29 10:55:48 +02:00
David Given
658db4ba71
Mangle label names (turns out that the ACK assembler can't really cope with
...
labels that are the same name as instructions...).
2016-10-27 23:17:16 +02:00
David Given
81525c0f2c
Swaps work (at least for registers). More opcodes. Rearrange the stack layout
...
so we can always trivially find fp, which lets CHAINFP work.
2016-10-27 21:50:58 +02:00
David Given
be3dece5af
Allow emission of strings containing ".
2016-10-27 21:48:46 +02:00
David Given
51bd3ee4dd
Fix bug where some phis weren't being inserted when a given variable definition
...
needed more than one phi (due to the dominance frontier containing more than
one basic block).
2016-10-27 21:40:25 +02:00
David Given
9977ce841a
Remove the bytes1, bytes2, bytes4, bytes8 attributes; remove the concept of a
...
register 'type'; now use int/float/long/double throughout to identify
registers. Lots of register allocator tweaks and table bugfixes --- we now get
through the dreading Mathlib.mod!
2016-10-25 23:04:20 +02:00
David Given
45a7f2e993
Phi copies are now inserted as part of type inference. More opcodes.
2016-10-24 22:14:08 +02:00
David Given
111c13e253
More opcodes.
2016-10-24 20:15:22 +02:00
David Given
a4644dee4d
More opcodes.
2016-10-24 12:08:40 +02:00
David Given
b22780c075
More opcodes, including the difficult and fairly stupid los/sts.
2016-10-23 22:24:08 +02:00
David Given
abd0cedd61
Massive change to how IR types are handled; we use the type code for matching
...
rather than the size. Much cleaner and simpler.
2016-10-23 21:54:14 +02:00
David Given
b1a3d76d6f
Re-re-add the type inference layer, now I know more about how things work.
...
Remove that terrible float promotion code.
2016-10-22 23:04:13 +02:00