Skip to content

Commit fa53602

Browse files
committed
alt: add C and Go comparison test
Change-Id: I81e3c1963bc1c748663a5e07349b2b2bfa9a79ba
1 parent 8d9c833 commit fa53602

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test.out
2323
alt/*.[56789u]
2424
alt/*.out
2525
alt/*.gnu.S
26+
alt/*.gnuopt.S
2627
alt/*.go.s
2728
alt/*.dat
2829
doc/articles/wiki/*.bin

alt/cmp1.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int
2+
f(void)
3+
{
4+
int x, y;
5+
6+
x = 5; y = 6;
7+
if (x < y) {
8+
return 1;
9+
}
10+
return 2;
11+
}

alt/cmp1.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package foo
2+
3+
func f() int {
4+
var x, y = 5, 6
5+
6+
if x < y {
7+
return 1
8+
}
9+
return 2
10+
}

alt/mkfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ LD=`go env GOTOOLDIR`/link
44
ALTROOT=`go env GOROOT`/alt
55

66
EXES=empty.u.out cmp.u.out hello.u.out call.u.out virtreg.u.out call1.6.out bigoffset.u.out mov.u.out neg.u.out branch1.u.out new3.u.out order.u.out bigmov.u.out hugealu.u.out jmp.u.out sync.u.out movcc.u.out
7-
GOS=call0.7.go.s
8-
GNUS=${EXES:%.u.out=%.u.gnu.S} conv.gnu.S fconv.gnu.S mul.gnu.S atomic.gnu.S
7+
GOS=call0.7.go.s cmp1.u.go.s cmp1.7.go.s
8+
GNUS=${EXES:%.u.out=%.u.gnu.S} conv.gnu.S fconv.gnu.S mul.gnu.S atomic.gnu.S cmp1.gnu.S
9+
GNUOPTS=${GNUS:%.gnu.S=%.gnuopt.S}
910
DATS=${EXES:%.u.out=%.u.dat}
1011

1112
all:V: $EXES $GNUS $GOS $DATS
@@ -34,7 +35,10 @@ $RT: pkg/solaris_sparc64 $RTOBJS
3435
go tool pack c $target $RTOBJS
3536

3637
%.7.go.s: tools %.go
37-
GOOS=linux GOARCH=arm64 go tool compile -S -o /dev/null $stem.go >$target
38+
GOOS=linux GOARCH=arm64 go tool compile -N -S -o /dev/null $stem.go >$target
39+
40+
%.u.go.s: tools %.go
41+
GOOS=solaris GOARCH=sparc64 go tool compile -N -S -o /dev/null $stem.go >$target
3842

3943
call1.6.a: call1.6 call1_amd64.6
4044
go tool pack c $target $prereq
@@ -49,7 +53,10 @@ call1.6.a: call1.6 call1_amd64.6
4953
sparc64-none-elf-objdump -d $prereq >$target
5054

5155
%.gnu.S: %.c
52-
sparc64-none-elf-gcc -mflat -m64 -S -O2 -o $target $prereq
56+
sparc64-none-elf-gcc -mflat -m64 -S -o $target $prereq
57+
58+
%.gnuopt.S: %.c
59+
sparc64-none-elf-gcc -mflat -m64 -O2 -S -o $target $prereq
5360

5461
%.u.dat: %.u.out
5562
sparc64-none-elf-readelf -x .data -x .rodata -x .noptrdata $prereq >$target
@@ -58,4 +65,4 @@ copy:V: $EXES
5865
rsync -i $EXES torside:~/x
5966

6067
clean:V:
61-
rm -rf pkg *.[a56789uo] *.gnu.S *.go.s *.out *.dat
68+
rm -rf pkg *.[a56789uo] *.gnu.S *.gnuopt.S *.go.s *.out *.dat

0 commit comments

Comments
 (0)