1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 13:00:26 +02:00

Update texinfo documentation to match current implementation.

* check/Makefile.am: "make debug" target should pass only
	the main test tool program as argument for running gdb

	* configure.ac: Add the --enable-assertions options.

	* doc/Makefile.am, doc/body.texi, doc/lightning.texi:
	Major rewrite of the documentation to match the current
	implementation.

	* doc/version.texi: Automatic date update.

	* doc/ifib.c, doc/incr.c, doc/printf.c, doc/rfib.c, doc/rpn.c:
	Implementation of the documentation examples, that are also
	compiled during a normal build.

	* doc/p-lightning.texi, doc/porting.texi, doc/toc.texi,
	doc/u-lightning.texi, doc/using.texi: These files were
	renamed in the documentation rewrite, as the documentation
	was significantly trimmed due to full removal of the porting
	chapters. Better porting documentation should be added but
	for the moment it was just removed the documentation not
	matching the implementation.
This commit is contained in:
pcpa 2013-01-24 19:41:35 -02:00
parent 2da31e82fa
commit 16d18f11d3
18 changed files with 1431 additions and 3389 deletions

1
.gitignore vendored
View file

@ -20,6 +20,7 @@ missing
stamp-h1 stamp-h1
test-driver test-driver
check/.deps check/.deps
doc/.deps
lib/.deps lib/.deps
m4/libtool.m4 m4/libtool.m4
m4/lt~obsolete.m4 m4/lt~obsolete.m4

View file

@ -1,6 +1,31 @@
2013-01-24 Paulo Andrade <pcpa@gnu.org>
* check/Makefile.am: "make debug" target should pass only
the main test tool program as argument for running gdb
* configure.ac: Add the --enable-assertions options.
* doc/Makefile.am, doc/body.texi, doc/lightning.texi:
Major rewrite of the documentation to match the current
implementation.
* doc/version.texi: Automatic date update.
* doc/ifib.c, doc/incr.c, doc/printf.c, doc/rfib.c, doc/rpn.c:
Implementation of the documentation examples, that are also
compiled during a normal build.
* doc/p-lightning.texi, doc/porting.texi, doc/toc.texi,
doc/u-lightning.texi, doc/using.texi: These files were
renamed in the documentation rewrite, as the documentation
was significantly trimmed due to full removal of the porting
chapters. Better porting documentation should be added but
for the moment it was just removed the documentation not
matching the implementation.
2013-01-18 Paulo Andrade <pcpa@gnu.org> 2013-01-18 Paulo Andrade <pcpa@gnu.org>
lib/jit_note.c: Correct bounds check and wrong code keeping * lib/jit_note.c: Correct bounds check and wrong code keeping
a pointer that could be changed after a realloc call. a pointer that could be changed after a realloc call.
2013-01-18 Paulo Andrade <pcpa@gnu.org> 2013-01-18 Paulo Andrade <pcpa@gnu.org>

View file

@ -172,6 +172,6 @@ CLEANFILES = $(TESTS)
#TESTS_ENVIRONMENT=$(srcdir)/run-test; #TESTS_ENVIRONMENT=$(srcdir)/run-test;
debug: $(check_PROGRAMS) debug: lightning
$(LIBTOOL) --mode=execute gdb $(check_PROGRAMS) $(LIBTOOL) --mode=execute gdb lightning

View file

@ -56,6 +56,17 @@ if test "x$DISASSEMBLER" != "xno"; then
LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1" LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
fi fi
AC_ARG_ENABLE(assertions,
AS_HELP_STRING([--enable-assertions],
[Enable runtime code generation assertions]),
[DEBUG=$enableval], [DEBUG=auto])
if test "x$DEBUG" = xyes; then
LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEBUG=1"
else
LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DNDEBUG"
DEBUG=no
fi
cpu= cpu=
case "$target_cpu" in case "$target_cpu" in
i?86|x86_64) cpu=x86 ;; i?86|x86_64) cpu=x86 ;;

View file

@ -1,7 +1,40 @@
#
# Copyright 2012 Free Software Foundation, Inc.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
AM_CFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE
info_TEXINFOS = lightning.texi info_TEXINFOS = lightning.texi
EXTRA_TEXINFOS = u-lightning.texi p-lightning.texi
MOSTLYCLEANFILES = lightning.tmp MOSTLYCLEANFILES = lightning.tmp
lightning_TEXINFOS = body.texi toc.texi using.texi porting.texi version.texi lightning_TEXINFOS = body.texi version.texi
u_lightning_TEXINFOS = body.texi toc.texi using.texi version.texi
p_lightning_TEXINFOS = body.texi toc.texi porting.texi version.texi noinst_PROGRAMS = incr printf rpn rfib ifib
$(top_builddir)/lib/liblightning.la:
cd $(top_builddir)/lib; $(MAKE) $(AM_MAKEFLAGS) liblightning.la
incr_LDADD = $(top_builddir)/lib/liblightning.la -lm -ldl
incr_SOURCES = incr.c
printf_LDADD = $(top_builddir)/lib/liblightning.la -lm -ldl
printf_SOURCES = printf.c
rpn_LDADD = $(top_builddir)/lib/liblightning.la -lm -ldl
rpn_SOURCES = rpn.c
rfib_LDADD = $(top_builddir)/lib/liblightning.la -lm -ldl
rfib_SOURCES = rfib.c
ifib_LDADD = $(top_builddir)/lib/liblightning.la -lm -ldl
ifib_SOURCES = ifib.c

File diff suppressed because it is too large Load diff

44
doc/ifib.c Normal file
View file

@ -0,0 +1,44 @@
#include <stdio.h>
#include <lightning.h>
static jit_state_t *_jit;
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
int main(int argc, char *argv[])
{
pifi fib;
jit_node_t *in; /* offset of the argument */
jit_node_t *ref; /* to patch the forward reference */
jit_node_t *jump; /* jump to start of loop */
jit_node_t *loop; /* start of the loop */
init_jit(argv[0]);
_jit = jit_new_state();
jit_prolog ();
in = jit_arg ();
jit_getarg (JIT_R2, in); /* R2 = n */
jit_movi (JIT_R1, 1);
ref = jit_blti (JIT_R2, 2);
jit_subi (JIT_R2, JIT_R2, 1);
jit_movi (JIT_R0, 1);
loop= jit_label();
jit_subi (JIT_R2, JIT_R2, 1); /* decr. counter */
jit_addr (JIT_V0, JIT_R0, JIT_R1); /* V0 = R0 + R1 */
jit_movr (JIT_R0, JIT_R1); /* R0 = R1 */
jit_addi (JIT_R1, JIT_V0, 1); /* R1 = V0 + 1 */
jump= jit_bnei (JIT_R2, 0); /* if (R2) goto loop; */
jit_patch_at(jump, loop);
jit_patch(ref); /* patch forward jump */
jit_movr (JIT_R0, JIT_R1); /* R0 = R1 */
jit_retr (JIT_R0);
/* call the generated code, passing 36 as an argument */
fib = jit_emit();
printf("fib(%d) = %d\n", 36, fib(36));
finish_jit();
return 0;
}

29
doc/incr.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdio.h>
#include <lightning.h>
static jit_state_t *_jit;
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
int main(int argc, char *argv[])
{
jit_node_t *in;
pifi incr;
init_jit(argv[0]);
_jit = jit_new_state();
jit_prolog(); /* @t{ prolog } */
in = jit_arg(); /* @t{ in = arg } */
jit_getarg(JIT_R0, in); /* @t{ getarg R0 } */
jit_addi(JIT_R0, JIT_R0, 1); /* @t{ addi R0\, R0\, 1 } */
jit_retr(JIT_R0); /* @t{ retr R0 } */
incr = jit_emit();
/* call the generated code\, passing 5 as an argument */
printf("%d + 1 = %d\n", 5, incr(5));
finish_jit();
return 0;
}

View file

@ -3,11 +3,8 @@
@setfilename lightning.info @setfilename lightning.info
@set TITLE Using and porting @sc{gnu} @i{lightning} @set TITLE Using @sc{gnu} @i{lightning}
@set TOPIC installing, using and porting @set TOPIC installing and using
@set BOTH
@set USING
@set PORTING
@settitle @value{TITLE} @settitle @value{TITLE}
@ -63,29 +60,9 @@
@c References to the other half of the manual @c References to the other half of the manual
@c --------------------------------------------------------------------- @c ---------------------------------------------------------------------
@ifset USING
@macro usingref{node, name} @macro usingref{node, name}
@ref{\node\, , \name\} @ref{\node\, , \name\}
@end macro @end macro
@end ifset
@ifclear USING
@macro usingref{node, name}
@ref{\node\, , \name\, u-lightning, Using @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@ifset PORTING
@macro portingref{node, name}
@ref{\node\, , \name\}
@end macro
@end ifset
@ifclear PORTING
@macro portingref{node, name}
@ref{\node\, , \name\, p-lightning, Porting @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@c --------------------------------------------------------------------- @c ---------------------------------------------------------------------
@c End of macro section @c End of macro section
@ -98,3 +75,4 @@
@c *********************************************************************** @c ***********************************************************************
@bye

View file

@ -1,100 +0,0 @@
\input texinfo.tex @c -*- texinfo -*-
@c %**start of header (This is for running Texinfo on a region.)
@setfilename lightning.info
@set TITLE Using @sc{gnu} @i{lightning}
@set TOPIC installing and using
@clear BOTH
@clear USING
@set PORTING
@settitle @value{TITLE}
@c ---------------------------------------------------------------------
@c Common macros
@c ---------------------------------------------------------------------
@macro bulletize{a}
@item
\a\
@end macro
@macro rem{a}
@r{@i{\a\}}
@end macro
@macro gnu{}
@sc{gnu}
@end macro
@macro lightning{}
@gnu{} @i{lightning}
@end macro
@c ---------------------------------------------------------------------
@c Macros for Texinfo 3.1/4.0 compatibility
@c ---------------------------------------------------------------------
@c @hlink (macro), @url and @email are used instead of @uref for Texinfo 3.1
@c compatibility
@macro hlink{url, link}
\link\ (\url\)
@end macro
@c ifhtml can only be true in Texinfo 4.0, which has uref
@ifhtml
@unmacro hlink
@macro hlink{url, link}
@uref{\url\, \link\}
@end macro
@macro email{mail}
@uref{mailto:\mail\, , \mail\}
@end macro
@macro url{url}
@uref{\url\}
@end macro
@end ifhtml
@c ---------------------------------------------------------------------
@c References to the other half of the manual
@c ---------------------------------------------------------------------
@ifset USING
@macro usingref{node, name}
@ref{\node\, , \name\}
@end macro
@end ifset
@ifclear USING
@macro usingref{node, name}
@ref{\node\, , \name\, u-lightning, Using @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@ifset PORTING
@macro portingref{node, name}
@ref{\node\, , \name\}
@end macro
@end ifset
@ifclear PORTING
@macro portingref{node, name}
@ref{\node\, , \name\, p-lightning, Porting @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@c ---------------------------------------------------------------------
@c End of macro section
@c ---------------------------------------------------------------------
@include version.texi
@include body.texi
@c %**end of header (This is for running Texinfo on a region.)
@c ***********************************************************************

File diff suppressed because it is too large Load diff

38
doc/printf.c Normal file
View file

@ -0,0 +1,38 @@
#include <stdio.h>
#include <lightning.h>
static jit_state_t *_jit;
typedef void (*pvfi)(int); /* Pointer to Void Function of Int */
int main(int argc, char *argv[])
{
pvfi myFunction; /* ptr to generated code */
jit_node_t *start, *end; /* a couple of labels */
jit_node_t *in; /* to get the argument */
init_jit(argv[0]);
_jit = jit_new_state();
start = jit_note(__FILE__, __LINE__);
jit_prolog();
in = jit_arg();
jit_getarg(JIT_R1, in);
jit_pushargi((jit_word_t)"generated %d bytes\n");
jit_ellipsis();
jit_pushargr(JIT_R1);
jit_finishi(printf);
jit_ret();
jit_epilog();
end = jit_note(__FILE__, __LINE__);
myFunction = jit_emit();
/* call the generated code, passing its size as argument */
myFunction((char*)jit_address(end) - (char*)jit_address(start));
jit_disassemble();
finish_jit();
return 0;
}

49
doc/rfib.c Normal file
View file

@ -0,0 +1,49 @@
#include <stdio.h>
#include <lightning.h>
static jit_state_t *_jit;
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
int main(int argc, char *argv[])
{
pifi fib;
jit_node_t *label;
jit_node_t *call;
jit_node_t *in; /* offset of the argument */
jit_node_t *ref; /* to patch the forward reference */
init_jit(argv[0]);
_jit = jit_new_state();
label = jit_label();
jit_prolog ();
in = jit_arg ();
jit_getarg (JIT_V0, in); /* V0 = n */
ref = jit_blti (JIT_V0, 2);
jit_subi (JIT_V1, JIT_V0, 1); /* V1 = n-1 */
jit_subi (JIT_V2, JIT_V0, 2); /* V2 = n-2 */
jit_prepare();
jit_pushargr(JIT_V1);
call = jit_finishi(NULL);
jit_patch_at(call, label);
jit_retval(JIT_V1); /* V1 = fib(n-1) */
jit_prepare();
jit_pushargr(JIT_V2);
call = jit_finishi(NULL);
jit_patch_at(call, label);
jit_retval(JIT_V2); /* V2 = fib(n-2) */
jit_addi(JIT_V1, JIT_V1, 1);
jit_addr(JIT_R0, JIT_V1, JIT_V2); /* R0 = V1 + V2 + 1 */
jit_retr(JIT_R0);
jit_patch(ref); /* patch jump */
jit_movi(JIT_R0, 1); /* R0 = 1 */
jit_retr(JIT_R0);
/* call the generated code, passing 32 as an argument */
fib = jit_emit();
printf("fib(%d) = %d\n", 32, fib(32));
finish_jit();
return 0;
}

94
doc/rpn.c Normal file
View file

@ -0,0 +1,94 @@
#include <stdio.h>
#include <lightning.h>
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
static jit_state_t *_jit;
void stack_push(int reg, int *sp)
{
jit_stxi_i (*sp, JIT_FP, reg);
*sp += sizeof (int);
}
void stack_pop(int reg, int *sp)
{
*sp -= sizeof (int);
jit_ldxi_i (reg, JIT_FP, *sp);
}
jit_node_t *compile_rpn(char *expr)
{
jit_node_t *in, *fn;
int stack_base, stack_ptr;
fn = jit_note(NULL, 0);
jit_prolog();
in = jit_arg();
stack_ptr = stack_base = jit_allocai (32 * sizeof (int));
jit_getarg_i(JIT_R2, in);
while (*expr) {
char buf[32];
int n;
if (sscanf(expr, "%[0-9]%n", buf, &n)) {
expr += n - 1;
stack_push(JIT_R0, &stack_ptr);
jit_movi(JIT_R0, atoi(buf));
} else if (*expr == 'x') {
stack_push(JIT_R0, &stack_ptr);
jit_movr(JIT_R0, JIT_R2);
} else if (*expr == '+') {
stack_pop(JIT_R1, &stack_ptr);
jit_addr(JIT_R0, JIT_R1, JIT_R0);
} else if (*expr == '-') {
stack_pop(JIT_R1, &stack_ptr);
jit_subr(JIT_R0, JIT_R1, JIT_R0);
} else if (*expr == '*') {
stack_pop(JIT_R1, &stack_ptr);
jit_mulr(JIT_R0, JIT_R1, JIT_R0);
} else if (*expr == '/') {
stack_pop(JIT_R1, &stack_ptr);
jit_divr(JIT_R0, JIT_R1, JIT_R0);
} else {
fprintf(stderr, "cannot compile: %s\n", expr);
abort();
}
++expr;
}
jit_retr(JIT_R0);
jit_epilog();
return fn;
}
int main(int argc, char *argv[])
{
jit_node_t *nc, *nf;
pifi c2f, f2c;
int i;
init_jit(argv[0]);
_jit = jit_new_state();
nc = compile_rpn("32x9*5/+");
nf = compile_rpn("x32-5*9/");
(void)jit_emit();
c2f = (pifi)jit_address(nc);
f2c = (pifi)jit_address(nf);
printf("\nC:");
for (i = 0; i <= 100; i += 10) printf("%3d ", i);
printf("\nF:");
for (i = 0; i <= 100; i += 10) printf("%3d ", c2f(i));
printf("\n");
printf("\nF:");
for (i = 32; i <= 212; i += 18) printf("%3d ", i);
printf("\nC:");
for (i = 32; i <= 212; i += 18) printf("%3d ", f2c(i));
printf("\n");
finish_jit();
return 0;
}

View file

@ -1,76 +0,0 @@
@c These macros are used because these items could go both in the
@c short listing (for partial books) and in the detailed listing
@c (for full books - i.e. using & porting)
@macro usingmenu{}
@ifset USING
* Installation:: Configuring and installing GNU lightning
* The instruction set:: The RISC instruction set used i GNU lightning
* GNU lightning macros:: GNU lightning's macros
* Reentrancy:: Re-entrant usage of GNU lightning
* Bundling GNU lightning:: Using GNU lightning in your programs
@end ifset
@end macro
@macro portingmenu{}
@ifset PORTING
* Structure of a port:: An overview of the porting process
* Adjusting configure:: Automatically recognizing the new platform
* Run-time assemblers:: An internal layer to simplify porting
* Standard macros:: The platform-independent layer used by clients.
* Standard functions:: Doing more complex tasks.
* Floating-point macros:: Implementing macros for floating point.
@end ifset
@end macro
@macro standardmacrosmenu{}
@c This comment is needed because of makeinfo's vagaries...
* Forward references:: Implementing forward references
* Common features:: Common features supported by @file{core-common.h}
* Delay slots:: Supporting scheduling of delay slots
* Immediate values:: Supporting arbitrarily sized immediate values
* Implementing the ABI:: Function prologs and epilogs, and argument passing
* Macro list:: Macros composing the platform-independent layer
@end macro
@menu
@ifclear BOTH
* Overview:: What GNU lightning is
@usingmenu{}
@portingmenu{}
* Future:: Tasks for GNU lightning's subsequent releases
* Acknowledgements:: Acknowledgements for GNU lightning
@ifset PORTING
@detailmenu
--- The detailed node listing ---
Standard macros:
@standardmacrosmenu{}
@end detailmenu
@end ifset
@end ifclear
@ifset BOTH
* Overview:: What GNU lightning is.
* Using GNU lightning:: Using GNU lightning in your programs
* Porting GNU lightning:: Retargeting GNU lightning to a new system
* Future:: Tasks for GNU lightning's subsequent releases
* Acknowledgements:: Acknowledgements for GNU lightning
@detailmenu
--- The detailed node listing ---
Using @lightning{}:
@usingmenu{}
Porting @lightning{}:
@portingmenu{}
Standard macros:
@standardmacrosmenu{}
@end detailmenu
@end ifset
@end menu

View file

@ -1,100 +0,0 @@
\input texinfo.tex @c -*- texinfo -*-
@c %**start of header (This is for running Texinfo on a region.)
@setfilename lightning.info
@set TITLE Porting @sc{gnu} @i{lightning}
@set TOPIC Porting
@clear BOTH
@set USING
@clear PORTING
@settitle @value{TITLE}
@c ---------------------------------------------------------------------
@c Common macros
@c ---------------------------------------------------------------------
@macro bulletize{a}
@item
\a\
@end macro
@macro rem{a}
@r{@i{\a\}}
@end macro
@macro gnu{}
@sc{gnu}
@end macro
@macro lightning{}
@gnu{} @i{lightning}
@end macro
@c ---------------------------------------------------------------------
@c Macros for Texinfo 3.1/4.0 compatibility
@c ---------------------------------------------------------------------
@c @hlink (macro), @url and @email are used instead of @uref for Texinfo 3.1
@c compatibility
@macro hlink{url, link}
\link\ (\url\)
@end macro
@c ifhtml can only be true in Texinfo 4.0, which has uref
@ifhtml
@unmacro hlink
@macro hlink{url, link}
@uref{\url\, \link\}
@end macro
@macro email{mail}
@uref{mailto:\mail\, , \mail\}
@end macro
@macro url{url}
@uref{\url\}
@end macro
@end ifhtml
@c ---------------------------------------------------------------------
@c References to the other half of the manual
@c ---------------------------------------------------------------------
@ifset USING
@macro usingref{node, name}
@ref{\node\, , \name\}
@end macro
@end ifset
@ifclear USING
@macro usingref{node, name}
@ref{\node\, , \name\, u-lightning, Using @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@ifset PORTING
@macro portingref{node, name}
@ref{\node\, , \name\}
@end macro
@end ifset
@ifclear PORTING
@macro portingref{node, name}
@ref{\node\, , \name\, p-lightning, Porting @sc{gnu} @i{lightning}}
@end macro
@end ifclear
@c ---------------------------------------------------------------------
@c End of macro section
@c ---------------------------------------------------------------------
@include version.texi
@include body.texi
@c %**end of header (This is for running Texinfo on a region.)
@c ***********************************************************************

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
@set UPDATED 3 June 2009 @set UPDATED 24 January 2013
@set UPDATED-MONTH June 2009 @set UPDATED-MONTH January 2013
@set EDITION 1.2c @set EDITION 2.0
@set VERSION 1.2c @set VERSION 2.0