Because of the accidental deletion, mcgg on my machine followed a
garbage pointer, and never wrote calls to emit_fragment.
A wrong call to `data->emit_reg(0, 0)` instead of the correct
`data->emit_fragment(0)` caused PowerPC mcg to emit an empty string
instead of `8(fp)`, causing a syntax error in PowerPC as.
The wrong `data->emit_reg(0, 0)` called the function emit_reg() in
mach/proto/mcg/pass_instructionselection.c, but that function
unfortunately has `if (vreg) { ... }`. The call had vreg == NULL
because the fragment wasn't a vreg, but emit_reg() ignored the problem
and emit nothing.
- Don't run BUILDSYSTEM more than once if there is more than one goal
with '+'.
- Don't pass goals without '+' to BUILDSYSTEM.
- Use $(MAKE) because "make" might not be GNU make. For me, "make"
is BSD make.
- Add a comment so readers know MAKECMDGOALS is special.
Over in README, remove Lua from requirements; we always ignore any
installed Lua and build our own. Increase guesses for free space
because we build more platforms. Don't need to type MAKEFLAGS=.
@dram reported a build failure in FreeBSD at
https://github.com/davidgiven/ack/issues/1#issuecomment-273668299
Linux manual for getopt(3) says:
> If the first character of optstring is '-', then each nonoption
> argv-element is handled as if it were the argument of an option with
> character code 1....
>
> The use of '+' and '-' in optstring is a GNU extension.
GNU/Linux and OpenBSD handle '-' in this special way, but FreeBSD
seems not to. If '-' is not special, then em_ego can't find its input
file, so the build must fail. This commit stops using '-' in both
em_b and em_ego, but doesn't change mcg.
Also fix em_ego -O3 to not act like -O4.
This prevents an overflow reported by @hexcoder- in
https://github.com/davidgiven/ack/issues/56
lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow
on machines where sizeof(int) < sizeof(long). Using 1L << ... would
work for now but might fail later if arith became long long.
C doesn't specify whether negative integers use 2's complement or some
other format. Therefore, (arith) 1 << ... has an undefined value. It
should still work because the value is some integer where the sign bit
is set and all other bits are clear.
(unsigned arith) 1 << ... would also get the sign bit, but casting it
from unsigned back to signed would make the same undefined value.
(arith) -1 << ... would assume 2's complement.
This is more useful when looking for patterns; lino - 1 is probably
the line number in the patterns file. DIAGOPT is off by default but
one can edit optim.h to enable it.
The other changes just clean up whitespace.
Reported by me in https://github.com/davidgiven/ack/issues/60
This doesn't change DIV. Right now a DIV b does floor division and
a MOD b has the sign of b. This is the same as Lua, Python, Ruby,
Tcl; but is different from other Modula-2 implementations.
Traditional C compilers had long but not unsigned long. I now assume
that everyone can compile unsigned long. Remove macro UNSIGNED_ARITH
and act like it is always defined. The type `unsigned arith` works
because arith is a macro for long.
If feof(fp) or ferror(fp) was set, then our libc returned EOF for all
later reads without trying to read. Our libc now behaves like BSD
(and probably Illumos and musl) by checking only feof(fp). For
difference, glibc doesn't check feof(fp).
I described the difference between our libc and BSD libc in
https://sourceforge.net/p/tack/mailman/message/35430300/
@hexcoder- reported in https://github.com/davidgiven/ack/issues/57
that our getpw() has bugs.
I don't fix these bugs, because Illumos and Linux manual pages say
that getpw() is obsolete. The function can overflow its buffer, so it
is never safe to use. Our libc did not build getpw().
This malloc.h might get confused with the private malloc.h in our
libc. C programs should #include <stdlib.h> for malloc().
This tgmath.h has no useful content, and never worked because
complex.h is missing.
Touch build.lua (by deleting some whitespace) so the *.h globs see
the deletions.
These functions are in POSIX; hypot() is in C99. Also build cabs()
because it rides with hypot(), but don't declare cabs() in any header
file, because our compiler can't parse C99 "double complex" type.
Touch build.lua so it sees that .c files moved.
These files come from old build systems, and are useless since the old
build systems got deleted. TakeAction is from proto.make system and
config.pm is from pmfile system.
In util/ncgg, add two more errors for tables using reglap:
- "Two sizes of reg_float can't be same size"
- "Missing reg_float of size %d to contain %s"
In mach/proto/ncg, rename macro isregvar_size() to PICK_REGVAR(), so
the macro doesn't look like a function. This macro sometimes doesn't
evaluate its second argument.
In mach/powerpc/ncg/mach.c, change type of lfs_set to uint32_t, and
change the left shifts from 1U<<regno to (uint32_t)1<<regno, because
1U would be too small for machines with 16-bit int.
This relocation is specific to PowerPC. @davidgiven suggested the
name RELOPPC_LIS in
https://github.com/davidgiven/ack/pull/52#issuecomment-279856501
Reindent the list in h/out.h and util/led/ack.out.5 because
RELOLIS_PPC is a long name. I use spaces and no tabs because the tabs
looked bad in the manual page.
ack -mlinuxppc -O4 now runs more phases of ego, including the register
allocation phase, so ncg emits better code.
Set MACHOPT_F=-m3 as I did it for osxppc; see commit 0c2b6f5.
Remove CC_ALIGN=-Vr so bitfields agree with gcc for PowerPC Linux.
Remove unused C_LIB and OLD_C_LIB.
Because lwzu or stwu moves the pointer, I can remove an addi
instruction from the loop, so the loop is slightly faster.
I wrote a benchmark in Modula-2 that exercises some of these loops. I
measured its time on my old PowerPC Mac. Its user time decreases from
8.401s to 8.217s with the tighter loops.
The result of single-precision fadds, fsubs, and such can go into a
register variable, like we already do with double precision. This
avoids an extra fmr from a temporary register to the regvar.
Do the conversion by calling .cif8 or .cuf8 in libem, as it was done
before my commit 1de1e8f. I used the inline conversion to experiment
with the register allocator, which was too slow until c5bb3be.
Now that libem has the only copy of the code, move some comments and
code changes there.
Rename GPRE to GPR_EXPR, then define FPR_EXPR and FSREG_EXPR. Use
them for moves to register variables.
Keep "kills regvar($1)", because deleting it and recompiling libc
would cause many failures in my test programs. Add comment to warn,
/* ncg fails to infer that regvar($1) is dead! */
Remove "kills LOCAL %off==$1" because it seems to have no effect.
If the ncg table uses reglap, then regvar($1, reg_float) would have
two sizes of registers. An error from ncgg would happen if regvar()
was in a token that allows only one size. Now one can pick a size
with regvar_w() for word size or regvar_d() for double-word size.
Add regvar_d and regvar_w as keywords in ncgg. Modify EX_REGVAR to
include the register size. In ncg, add some checks for the register
size. In tables without reglap, regvar() works as before, and ncg
ignores the register size in EX_REGVAR.
After the RA phase of ego, a procedure may put single-word and
double-word values in the same reg_float. Then ncg will use both
LOCAL and DLOCAL tokens at the same offset.
I add isregvar_size() to ncg. It receives the size of the LOCAL or
DLOCAL token, and picks the register of the correct size. This fixes
a problem where ncg got the wrong-size register and corrupted the
stack. This problem caused one of my test programs to segfault from
stack underflow.
Also adjust how fixregvars() handles both sizes.
This merges several fixes and improvements from upstream. This
includes commit 5f6a773 to turn off qemuppc. I see several failing
tests from qemuppc; this merge will hide the test failures.
The new feature "reglap" allows two sizes of floating-point register
variables (reg_float), if each register overlaps a single register of
the other size. PowerPC ncg uses reglap to define 4-byte instances
of f14 to f31 that overlap the 8-byte instances.
When ncgg sees the definition of fs14("f14")=f14, it removes the
8-byte f14 from its rvnumbers array, and adds the 4-byte fs14 in its
place. Later, when ncg puts a variable in fs14, if it is an 8-byte
variable, then ncg switches to the 8-byte f14. The code has
/* reglap */ comments in util/ncgg or #ifdef REGLAP in mach/proto/ncg
reglap became necessary because my commit a20b87c caused PowerPC ego
to allocate reg_float in both 4-byte and 8-byte sizes.
same base name and generate multiple files based on it, we can't really use
mkstemp() for every temporary file. Instead, use mkstemp() once on a
placeholder, then generate temporary names based on this. (And delete the
placeholder once we've finished.)