PR modula2/119779 ASM examples no longer work
This patch introduces four dejagnu tests matching four documentation examples. Both asm examples are added and only built if the x86_64 target is available. The other two are hello world using libc and StrIO. The doc/gm2.texi asm examples are changed to use eax rather than rax. gcc/ChangeLog: PR modula2/119779 * doc/gm2.texi (Interface to assembly language): Use eax rather than rax in both examples. gcc/testsuite/ChangeLog: PR modula2/119779 * gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test. * gm2.dg/doc/examples/pass/exampleadd.mod: New test. * gm2.dg/doc/examples/pass/exampleadd2.mod: New test. * gm2.dg/doc/examples/pass/hello.mod: New test. * gm2.dg/doc/examples/pass/hellopim.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
5a32e85810
commit
9e0a98a47c
6 changed files with 106 additions and 4 deletions
|
@ -2699,10 +2699,10 @@ PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
|
|||
VAR
|
||||
myout: CARDINAL ;
|
||||
BEGIN
|
||||
ASM VOLATILE ("movq %1,%%rax; addq %2,%%rax; movq %%rax,%0"
|
||||
ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
|
||||
: "=rm" (myout) (* outputs *)
|
||||
: "rm" (foo), "rm" (bar) (* inputs *)
|
||||
: "rax") ; (* we trash *)
|
||||
: "eax") ; (* we trash *)
|
||||
RETURN( myout )
|
||||
END Example ;
|
||||
@end example
|
||||
|
@ -2720,10 +2720,10 @@ VAR
|
|||
myout: CARDINAL ;
|
||||
BEGIN
|
||||
ASM VOLATILE (
|
||||
"movq %[left],%%rax; addq %[right],%%rax; movq %%rax,%[output]"
|
||||
"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
|
||||
: [output] "=rm" (myout) (* outputs *)
|
||||
: [left] "rm" (foo), [right] "rm" (bar) (* inputs *)
|
||||
: "rax") ; (* we trash *)
|
||||
: "eax") ; (* we trash *)
|
||||
RETURN( myout )
|
||||
END Example ;
|
||||
@end example
|
||||
|
|
18
gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
Normal file
18
gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Compile tests, no torture testing.
|
||||
#
|
||||
# These tests should all pass.
|
||||
|
||||
# Load support procs.
|
||||
load_lib gm2-dg.exp
|
||||
|
||||
gm2_init_pim4 $srcdir/$subdir
|
||||
|
||||
# Initialize `dg'.
|
||||
dg-init
|
||||
|
||||
# Main loop.
|
||||
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
|
||||
|
||||
# All done.
|
||||
dg-finish
|
32
gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
Normal file
32
gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
Normal file
|
@ -0,0 +1,32 @@
|
|||
(* { dg-do assemble { target { x86_64-*-* } } } *)
|
||||
(* { dg-options "-g" } *)
|
||||
|
||||
MODULE exampleadd ;
|
||||
|
||||
FROM libc IMPORT printf, exit ;
|
||||
|
||||
|
||||
PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
|
||||
VAR
|
||||
myout: CARDINAL ;
|
||||
BEGIN
|
||||
ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
|
||||
: "=rm" (myout) (* outputs *)
|
||||
: "rm" (foo), "rm" (bar) (* inputs *)
|
||||
: "eax") ; (* we trash *)
|
||||
RETURN( myout )
|
||||
END Example ;
|
||||
|
||||
|
||||
VAR
|
||||
a, b, c: CARDINAL ;
|
||||
BEGIN
|
||||
a := 1 ;
|
||||
b := 2 ;
|
||||
c := Example (a, b) ;
|
||||
IF c # 3
|
||||
THEN
|
||||
printf ("Example procedure function failed to return 3, seen %d", c) ;
|
||||
exit (1)
|
||||
END
|
||||
END exampleadd.
|
32
gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
Normal file
32
gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
Normal file
|
@ -0,0 +1,32 @@
|
|||
(* { dg-do assemble { target { x86_64-*-* } } } *)
|
||||
(* { dg-options "-g" } *)
|
||||
|
||||
MODULE exampleadd2 ;
|
||||
|
||||
FROM libc IMPORT printf, exit ;
|
||||
|
||||
|
||||
PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
|
||||
VAR
|
||||
myout: CARDINAL ;
|
||||
BEGIN
|
||||
ASM VOLATILE (
|
||||
"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
|
||||
: [output] "=rm" (myout) (* outputs *)
|
||||
: [left] "rm" (foo), [right] "rm" (bar) (* inputs *)
|
||||
: "eax") ; (* we trash *)
|
||||
RETURN( myout )
|
||||
END Example ;
|
||||
|
||||
VAR
|
||||
a, b, c: CARDINAL ;
|
||||
BEGIN
|
||||
a := 1 ;
|
||||
b := 2 ;
|
||||
c := Example (a, b) ;
|
||||
IF c # 3
|
||||
THEN
|
||||
printf ("Example procedure function failed to return 3, seen %d", c) ;
|
||||
exit (1)
|
||||
END
|
||||
END exampleadd2.
|
10
gcc/testsuite/gm2.dg/doc/examples/pass/hello.mod
Normal file
10
gcc/testsuite/gm2.dg/doc/examples/pass/hello.mod
Normal file
|
@ -0,0 +1,10 @@
|
|||
(* { dg-do run } *)
|
||||
(* { dg-options "-g -fno-scaffold-dynamic" } *)
|
||||
|
||||
MODULE hello ;
|
||||
|
||||
FROM libc IMPORT printf ;
|
||||
|
||||
BEGIN
|
||||
printf ("hello world\n")
|
||||
END hello.
|
10
gcc/testsuite/gm2.dg/doc/examples/pass/hellopim.mod
Normal file
10
gcc/testsuite/gm2.dg/doc/examples/pass/hellopim.mod
Normal file
|
@ -0,0 +1,10 @@
|
|||
(* { dg-do run } *)
|
||||
(* { dg-options "-g -fno-scaffold-dynamic" } *)
|
||||
|
||||
MODULE hellopim ;
|
||||
|
||||
FROM StrIO IMPORT WriteString, WriteLn ;
|
||||
|
||||
BEGIN
|
||||
WriteString ("hello world") ; WriteLn
|
||||
END hellopim.
|
Loading…
Add table
Reference in a new issue