This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
[patch] dev.scm (cload): Change #:arch argument to take .cpu path
- From: Doug Evans <dje at sebabeach dot org>
- To: cgen at sourceware dot org
- Date: Sun, 14 Jun 2009 12:48:20 -0700
- Subject: [patch] dev.scm (cload): Change #:arch argument to take .cpu path
Hi.
Interactive development is a bit problematic for files in ../cpu
(as opposed to files in ./cpu).
This changes the #:arch argument of cload to take the path
so that one can refer to the files in ../cpu.
It also tweaks arch-path a bit.
I'll check this in in a few days if there are no objections.
2009-06-14 Doug Evans <dje@sebabeach.org>
* dev.scm (cload): Change #:arch argument to take the path to the
.cpu file instead of just the name of the architecture.
* read.scm (arch-path): Remove trailing '/'.
(cpu-load): Set `arch-path' to directory of .cpu file.
(-cgen): Don't set `arch-path' here.
(include): Update.
* doc/porting.texi: Update.
Index: dev.scm
===================================================================
RCS file: /cvs/src/src/cgen/dev.scm,v
retrieving revision 1.10
diff -u -p -r1.10 dev.scm
--- dev.scm 14 Mar 2006 12:48:21 -0000 1.10
+++ dev.scm 14 Jun 2009 21:29:47 -0000
@@ -10,7 +10,7 @@
; (load-opc)
; (load-sim)
; (load-sid)
-; (cload #:arch arch #:machs "mach-list" #:isas "isa-list" #:options "options")
+; (cload #:arch path-to-cpu-file #:machs "mach-list" #:isas "isa-list" #:options "options")
; First load guile.scm to coerce guile into something we've been using.
; Guile is always in flux.
@@ -30,7 +30,7 @@
; Supply the path name and suffic for the .cpu file and delete the analyzer
; arg from cpu-load to lessen the typing.
(define (cload . args)
- (let ((arch #f)
+ (let ((cpu-file #f)
(keep-mach "all")
(keep-isa "all")
(options ""))
@@ -42,7 +42,7 @@
#f ; done
(begin
(case (car args)
- ((#:arch) (set! arch (cadr args)))
+ ((#:arch) (set! cpu-file (cadr args)))
((#:machs) (set! keep-mach (cadr args)))
((#:isas) (set! keep-isa (cadr args)))
((#:options) (set! options (cadr args)))
@@ -51,37 +51,37 @@
(case APPLICATION
((UNKNOWN) (error "application not loaded"))
- ((DESC) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((DESC) (cpu-load cpu-file
keep-mach keep-isa options
desc-init!
desc-finish!
desc-analyze!))
- ((DOC) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((DOC) (cpu-load cpu-file
keep-mach keep-isa options
doc-init!
doc-finish!
doc-analyze!))
- ((OPCODES) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((OPCODES) (cpu-load cpu-file
keep-mach keep-isa options
opcodes-init!
opcodes-finish!
opcodes-analyze!))
- ((GAS-TEST) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((GAS-TEST) (cpu-load cpu-file
keep-mach keep-isa options
gas-test-init!
gas-test-finish!
gas-test-analyze!))
- ((SIMULATOR) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((SIMULATOR) (cpu-load cpu-file
keep-mach keep-isa options
sim-init!
sim-finish!
sim-analyze!))
- ((SID-SIMULATOR) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((SID-SIMULATOR) (cpu-load cpu-file
keep-mach keep-isa options
sim-init!
sim-finish!
sim-analyze!))
- ((SIM-TEST) (cpu-load (string-append "./cpu/" arch ".cpu")
+ ((SIM-TEST) (cpu-load cpu-file
keep-mach keep-isa options
sim-test-init!
sim-test-finish!
@@ -105,7 +105,7 @@
; ??? Necessary for the following case, dunno why.
; bash$ guile -l dev.scm
; guile> (load-doc)
- ; guile> (cload #:arch "m32r")
+ ; guile> (cload #:arch "./cpu/m32r.cpu")
(set! APPLICATION 'DOC)
)
@@ -181,7 +181,7 @@ Then choose the application via one of:
Then load the .cpu file with:
-(cload #:arch \"arch\" #:machs \"keep-mach\" #:isas \"keep-isa\" #:options \"options\")
+(cload #:arch \"path-to-cpu-file\" #:machs \"keep-mach\" #:isas \"keep-isa\" #:options \"options\")
keep-mach:
comma separated list of machs to keep or `all'
Index: read.scm
===================================================================
RCS file: /cvs/src/src/cgen/read.scm,v
retrieving revision 1.14
diff -u -p -r1.14 read.scm
--- read.scm 10 May 2006 17:49:38 -0000 1.14
+++ read.scm 14 Jun 2009 21:29:47 -0000
@@ -1,5 +1,5 @@
; Top level file for reading and recording .cpu file contents.
-; Copyright (C) 2000, 2001, 2006 Red Hat, Inc.
+; Copyright (C) 2000, 2001, 2006, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
@@ -695,7 +695,6 @@
(reader-add-command! 'if
"(if test then . else)\n"
nil '(test then . else) cmd-if
-
)
; Rather than add cgen specific stuff to pmacros.scm, we create
@@ -728,7 +727,7 @@ Define a preprocessor-style macro.
)
; Install any builtin objects.
-; This is defered until define-arch is read.
+; This is deferred until define-arch is read.
; One reason is that attributes MACH and ISA don't exist until then.
(define (reader-install-builtin!)
@@ -781,8 +780,8 @@ Define a preprocessor-style macro.
; .cpu file include mechanism
(define (include file)
- (logit 1 "Including file " (string-append arch-path file) " ...\n")
- (reader-read-file! (string-append arch-path file))
+ (logit 1 "Including file " (string-append arch-path "/" file) " ...\n")
+ (reader-read-file! (string-append arch-path "/" file))
(logit 2 "Resuming previous file ...\n")
)
@@ -832,12 +831,15 @@ Define a preprocessor-style macro.
; ANALYZER! is a zero argument proc to call after loading the .cpu file.
; It is expected to set up various tables and things useful for the application
; in question.
+;
+; This function isn't local because it's used by dev.scm.
(define (cpu-load file keep-mach keep-isa options
app-initer! app-finisher! analyzer!)
(-init-parse-cpu! keep-mach keep-isa options)
(app-initer!)
(logit 1 "Loading cpu description " file "\n")
+ (set! arch-path (dirname file))
(reader-read-file! file)
(logit 2 "Processing cpu description " file "\n")
(-finish-parse-cpu!)
@@ -1000,7 +1002,10 @@ Define a preprocessor-style macro.
)
)
-(define arch-path (string-append srcdir "/cpu/"))
+; Default place to look.
+; This gets overridden to point to the directory of the loaded .cpu file.
+; ??? Ideally this would be local to this file.
+(define arch-path (string-append srcdir "/cpu"))
; Accessors for application option specs
(define (opt-get-first-pass opt)
@@ -1080,7 +1085,6 @@ Define a preprocessor-style macro.
(else
(cond ((str=? "-a" (car opt))
(set! arch-file arg)
- (set! arch-path (string-append (dirname arg) "/"))
)
((str=? "-b" (car opt))
(set! debugging #t)
@@ -1181,6 +1185,7 @@ Define a preprocessor-style macro.
)
; Main entry point called by application file generators.
+
(define cgen
(lambda args
(cgen-debugging-stack-start -cgen args))
Index: doc/porting.texi
===================================================================
RCS file: /cvs/src/src/cgen/doc/porting.texi,v
retrieving revision 1.10
diff -u -p -r1.10 porting.texi
--- doc/porting.texi 14 Jun 2009 18:32:27 -0000 1.10
+++ doc/porting.texi 14 Jun 2009 21:29:48 -0000
@@ -771,7 +771,7 @@ and developing the .CPU file interactive
@item Run @code{guile}.
@item @code{(load "dev.scm")}
@item Load application, e.g. @code{(load-opc)} or @code{(load-sim)}
-@item Load CPU description file, e.g. @code{(cload #:arch "m32r")}
+@item Load CPU description file, e.g. @code{(cload #:arch "cpu/m32r")}
@item Run generators until output looks reasonable, e.g. @code{(cgen-opc.c)}
@end enumerate
@@ -785,19 +785,19 @@ Example:
@example
(define (m32r-opc)
(load-opc)
- (cload #:arch "m32r")
+ (cload #:arch "cpu/m32r.cpu")
)
(define (m32r-sim)
(load-sim)
- (cload #:arch "m32r" #:options "with-scache with-profile=fn")
+ (cload #:arch "cpu/m32r.cpu" #:options "with-scache with-profile=fn")
)
(define (m32rbf-sim)
(load-sim)
- (cload #:arch "m32r" #:machs "m32r" #:options "with-scache with-profile=fn")
+ (cload #:arch "cpu/m32r.cpu" #:machs "m32r" #:options "with-scache with-profile=fn")
)
(define (m32rxf-sim)
(load-sim)
- (cload #:arch "m32r" #:machs "m32rx" #:options "with-scache with-profile=fn")
+ (cload #:arch "cpu/m32r.cpu" #:machs "m32rx" #:options "with-scache with-profile=fn")
)
@end example
@@ -805,7 +805,7 @@ CPU description files are loaded into an
@code{cload}. The syntax is:
@example
-(cload #:arch arch
+(cload #:arch "cpu-file-path"
[#:machs "mach-list"]
[#:isas "isa-list"]
[#:options "option-list"])
@@ -813,6 +813,8 @@ CPU description files are loaded into an
Only the @code{#:arch} argument is mandatory.
+@samp{cpu-file} is the path to the @file{.cpu} file.
+
@samp{mach-list} is a comma separated string of machines to keep.
@samp{isa-list} is a comma separated string of isas to keep.
@@ -835,7 +837,7 @@ development routines.
@item The @file{.cpu} file is the main description file.
@item The @file{.opc} file provides additional C support code.
@end itemize
-@item @code{(cload #:arch "cpu/<arch>")}
+@item @code{(cload #:arch "cpu/<arch>.cpu")}
@item Run each of:
@itemize @bullet
@item @code{(cgen-desc.h)}
@@ -1005,7 +1007,7 @@ The same basic procedure for opcodes por
@item @code{(load "dev.scm")}
@item @code{(load-sim)}
@item Edit your @file{cpu/<arch>.cpu} file.
-@item @code{(cload #:arch "cpu/<arch>")}
+@item @code{(cload #:arch "cpu/<arch>.cpu")}
@item Run each of:
@itemize @bullet
@item @code{(cgen-arch.h)}
@@ -1014,7 +1016,7 @@ The same basic procedure for opcodes por
@end itemize
@item Repeat steps 4,5,6 until the output looks reasonable.
@item Edit your cpu/<arch>.cpu file.
-@item @code{(cload #:arch "cpu/<arch>" #:machs "mach1[,mach2[,...]]")}
+@item @code{(cload #:arch "cpu/<arch>.cpu" #:machs "mach1[,mach2[,...]]")}
@item Run each of:
@itemize @bullet
@item @code{(cgen-cpu.h)}