2 new revisions:
Revision: e5de45fbc1
Author: Michael Lippautz <
michael....@gmail.com>
Date: Mon Jun 21 15:55:57 2010
Log: gogo: Various changes and cleanup (should have no effect on sc)
http://code.google.com/p/gogc/source/detail?r=e5de45fbc1
Revision: 7013e4c71c
Author: Michael Lippautz <
michael....@gmail.com>
Date: Tue Jun 22 04:19:10 2010
Log: gogo: Modify linker to save output to file (_final_.sog) and add
self-...
http://code.google.com/p/gogc/source/detail?r=7013e4c71c
==============================================================================
Revision: e5de45fbc1
Author: Michael Lippautz <
michael....@gmail.com>
Date: Mon Jun 21 15:55:57 2010
Log: gogo: Various changes and cleanup (should have no effect on sc)
http://code.google.com/p/gogc/source/detail?r=e5de45fbc1
Modified:
/src/libgogo/convert.go
/src/libgogo/convert_amd64.s
/src/symtable.go
/src/utils.go
=======================================
--- /src/libgogo/convert.go Sat Jun 12 08:58:08 2010
+++ /src/libgogo/convert.go Mon Jun 21 15:55:57 2010
@@ -8,6 +8,8 @@
package libgogo
+func DerefUint64Ptr(ptr *uint64) uint64;
+
//
// Converts a byte to an unsigned 64-bit integer
// Implemented in assembler (see corresponding .s file)
=======================================
--- /src/libgogo/convert_amd64.s Mon Jun 21 00:30:23 2010
+++ /src/libgogo/convert_amd64.s Mon Jun 21 15:55:57 2010
@@ -6,6 +6,13 @@
// GoGo conversion functions (ASM)
//
+TEXT ·DerefUint64Ptr(SB),$0-16
+ MOVQ $0, 16(SP)
+ MOVQ 8(SP), AX
+ MOVQ (AX), AX
+ MOVQ AX, 16(SP)
+ RET
+
TEXT ·ToIntFromByte(SB),$0-16 //ToIntFromByte: 1 parameter, 1 return value
MOVQ $0, 16(SP) //Initialize return value (return value after one
parameter => SP+2*64bit)
MOVB 8(SP), AX //Move byte parameter to AX (first parameter => SP+64bit)
=======================================
--- /src/symtable.go Wed Jun 16 15:23:00 2010
+++ /src/symtable.go Mon Jun 21 15:55:57 2010
@@ -630,3 +630,20 @@
}
return tempFcn;
}
+
+//
+// Checks whether a given type list contains any forward declarations.
+// Returns: 1 if there are any, 0 otherwise
+//
+func ContainsFwdDecls(list *libgogo.TypeDesc) uint64 {
+ var tmpObjType *libgogo.TypeDesc;
+ var retValue uint64 = 0;
+ if list != nil {
+ for tmpObjType = list; tmpObjType.Next != nil; tmpObjType =
tmpObjType.Next {
+ if tmpObjType.ForwardDecl != 0 {
+ retValue = 1;
+ }
+ }
+ }
+ return retValue;
+}
=======================================
--- /src/utils.go Sun Jun 20 07:40:54 2010
+++ /src/utils.go Mon Jun 21 15:55:57 2010
@@ -191,25 +191,3 @@
libgogo.Exit(4);
}
-func DebugItem(item *libgogo.Item) {
- var tmpStr string;
- libgogo.PrintString("Item\n");
- libgogo.PrintString("====\n");
- tmpStr = libgogo.IntToString(item.Mode);
- libgogo.PrintString("Mode: ");
- libgogo.PrintString(tmpStr);
- libgogo.PrintString("\n");
- tmpStr = libgogo.IntToString(item.A);
- libgogo.PrintString("A: ");
- libgogo.PrintString(tmpStr);
- libgogo.PrintString("\n");
- libgogo.PrintString("R: ");
- tmpStr = libgogo.IntToString(item.R);
- libgogo.PrintString(tmpStr);
- libgogo.PrintString("\n");
- libgogo.PrintString("C: ");
- tmpStr = libgogo.IntToString(item.C);
- libgogo.PrintString(tmpStr);
- libgogo.PrintString("\n");
- libgogo.PrintString("\n");
-}
==============================================================================
Revision: 7013e4c71c
Author: Michael Lippautz <
michael....@gmail.com>
Date: Tue Jun 22 04:19:10 2010
Log: gogo: Modify linker to save output to file (_final_.sog) and add
self-compilaton fixpoint test (sc).
http://code.google.com/p/gogc/source/detail?r=7013e4c71c
Added:
/src/sc
Modified:
/src/linker.go
=======================================
--- /dev/null
+++ /src/sc Tue Jun 22 04:19:10 2010
@@ -0,0 +1,216 @@
+#!/bin/sh
+
+# Copyright 2009 The GoGo Authors. All rights reserved.
+# Use of this source code is governed by the MIT
+# license that can be found in the LICENSE file.
+
+# Program name from it's filename
+prog=${0##*/}
+
+# Text color variables
+txtund=$(tput sgr 0 1) # Underline
+txtbld=$(tput bold) # Bold
+txtred=$(tput setaf 1) # Red
+txtgrn=$(tput setaf 2) # Green
+txtylw=$(tput setaf 3) # Yellow
+txtblu=$(tput setaf 4) # Blue
+txtpur=$(tput setaf 5) # Purple
+txtcyn=$(tput setaf 6) # Cyan
+txtwht=$(tput setaf 7) # White
+txtrst=$(tput sgr0) # Text reset
+txtund=$(tput sgr 0 1) # Underline
+txtbld=$(tput bold) # Bold
+bldred=${txtbld}$(tput setaf 1) # red
+bldblu=${txtbld}$(tput setaf 4) # blue
+bldwht=${txtbld}$(tput setaf 7) # white
+txtrst=$(tput sgr0) # Reset
+info=${txtgrn}*${txtrst} # Feedback
+pass=${bldblu}*${txtrst}
+warn=${bldred}!${txtrst}
+
+COMPILE="\
+./gogo-bs -c \
+libgogo/convert.go \
+libgogo/convert_amd64.s \
+libgogo/io.go \
+libgogo/io_amd64.s \
+libgogo/list.go \
+libgogo/memmgr.go \
+libgogo/memmgr_amd64.s \
+libgogo/strlist.go \
+libgogo/symbol.go \
+libgogo/symbol_amd64.s \
+libgogo/string.go \
+libgogo/string_amd64.s \
+libgogo/item.go \
+libgogo/item_amd64.s \
+libgogo/libgogo.go \
+libgogo/libgogo_amd64.s \
+libgogo/stack.go \
+globals.go \
+token.go \
+symtable.go \
+parser.go \
+gogo.go \
+asm_out.go \
+inspector.go \
+codegen.go \
+gen-arith.go \
+gen-assign.go \
+gen-cond.go \
+gen-const.go \
+gen-expr.go \
+gen-fcn.go \
+gen-for.go \
+gen-if.go \
+linker.go \
+parse-utils.go \
+scanner.go \
+utils.go \
+"
+
+COMPILE2="\
+./gogo-self -c \
+libgogo/convert.go \
+libgogo/convert_amd64.s \
+libgogo/io.go \
+libgogo/io_amd64.s \
+libgogo/list.go \
+libgogo/memmgr.go \
+libgogo/memmgr_amd64.s \
+libgogo/strlist.go \
+libgogo/symbol.go \
+libgogo/symbol_amd64.s \
+libgogo/string.go \
+libgogo/string_amd64.s \
+libgogo/item.go \
+libgogo/item_amd64.s \
+libgogo/libgogo.go \
+libgogo/libgogo_amd64.s \
+libgogo/stack.go \
+globals.go \
+token.go \
+symtable.go \
+parser.go \
+gogo.go \
+asm_out.go \
+inspector.go \
+codegen.go \
+gen-arith.go \
+gen-assign.go \
+gen-cond.go \
+gen-const.go \
+gen-expr.go \
+gen-fcn.go \
+gen-for.go \
+gen-if.go \
+linker.go \
+parse-utils.go \
+scanner.go \
+utils.go \
+"
+
+echo ""
+echo ">>> ${txtbld}Cleaning${txtrst}"
+echo ""
+cd libgogo
+make clean
+cd ..
+make clean
+
+echo ""
+echo ">>> ${txtbld}Bootstrapping${txtrst}"
+echo ""
+cd libgogo
+make
+cd ..
+make
+
+echo ""
+echo ">>> ${txtbld}Preparing for self-compilation${txtrst} (using
bootstrapped compiler)"
+echo ""
+CMD="mv gogo gogo-bs"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Compiling compiler${txtrst} (=> _gogo_.sog)"
+echo ""
+echo $COMPILE
+TIME=$(time $COMPILE)
+echo $TIME
+
+echo ""
+echo ">>> ${txtbld}Linking compiler${txtrst} (=> _final_.sog)"
+echo ""
+LINK="./gogo-bs -l _gogo_.sog"
+echo $LINK
+TIME=$(time $LINK)
+echo $TIME
+
+echo ""
+echo ">>> ${txtbld}Saving output for fixpoint test${txtrst} (=>
_final_1_.sog)"
+echo ""
+CMD="cp _final_.sog _final_1_.sog"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Assembly to Linux amd64 ELF${txtrst} (=> 6.out)"
+echo ""
+CMD="6a _final_.sog"
+echo $CMD
+$($CMD)
+CMD="6l _final_.sog.6"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Preparing for self-compilation${txtrst} (using our own
compiler)"
+echo ""
+CMD="mv ./6.out gogo-self"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Compiling compiler${txtrst} (=> _gogo_.sog)"
+echo ""
+echo $COMPILE2
+TIME=$(time $COMPILE2)
+echo $TIME
+
+echo ""
+echo ">>> ${txtbld}Linking compiler${txtrst} (=> _final_.sog)"
+echo ""
+LINK="./gogo-self -l _gogo_.sog"
+echo $LINK
+TIME=$(time $LINK)
+echo $TIME
+
+echo ""
+echo ">>> ${txtbld}Saving output for fixpoint test${txtrst} (=>
_final_2_.sog)"
+echo ""
+CMD="cp _final_.sog _final_2_.sog"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Assembly to Linux amd64 ELF${txtrst} (=> 6.out)"
+echo ""
+CMD="6a _final_.sog"
+echo $CMD
+$($CMD)
+CMD="6l _final_.sog.6"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Fixpoint test${txtrst}"
+echo ""
+CMD="diff -u _final_1_.sog _final_2_.sog"
+echo $CMD
+$($CMD)
+
+echo ""
+echo ">>> ${txtbld}Cu!${txtrst}"
+echo ""
=======================================
--- /src/linker.go Mon Jun 21 13:00:46 2010
+++ /src/linker.go Tue Jun 22 04:19:10 2010
@@ -309,7 +309,7 @@
//
// Function processing a line and fixing offsets if necessary
//
-func FixOffset(ld *LineDesc) {
+func FixOffset(fd uint64, ld *LineDesc) {
var i uint64;
var strLen uint64;
var size uint64;
@@ -392,12 +392,12 @@
}
- libgogo.PrintString(newLine);
- libgogo.PrintString("\n");
+ libgogo.WriteString(fd, newLine);
+ libgogo.WriteString(fd, "\n");
if ld.NeedsByteFix == 1 {
- libgogo.PrintString(" ANDQ $255, ");
- libgogo.PrintString(fixedAdr);
- libgogo.PrintString("\n");
+ libgogo.WriteString(fd, " ANDQ $255, ");
+ libgogo.WriteString(fd, fixedAdr);
+ libgogo.WriteString(fd, "\n");
ld.NeedsByteFix = 0;
}
}
@@ -409,9 +409,15 @@
var strCmp uint64;
var symtable uint64 = 0;
var ld LineDesc;
+ var fd uint64;
InitLineDesc(&ld);
+ // The following line creates a new file for the assembler code
+ // flags: O_WRONLY | O_CREAT | O_TRUNC => 577
+ // mode: S_IWUSR | S_IRUSR | S_IRGRP => 416
+ fd = libgogo.FileOpen2("_final_.sog", 577, 416);
+
for
curFileIndex=0;curFileIndex<fileInfoLen;curFileIndex=curFileIndex+1 {
ResetToken();
@@ -432,12 +438,12 @@
} else { // Parse normal lines and fix everything
if ld.NeedsFix != 0 {
GetLine(&ld);
- FixOffset(&ld);
+ FixOffset(fd, &ld);
} else {
strCmp =
libgogo.StringCompare(ld.Line, "__UNLINKED_CODE");
if strCmp != 0 {
- libgogo.PrintString(ld.Line);
- libgogo.PrintString("\n");
+ libgogo.WriteString(fd, ld.Line);
+ libgogo.WriteString(fd, "\n");
}
}