From 260ec53e244a43a2a251344d30ddb098ee88ea5a Mon Sep 17 00:00:00 2001 From: devans Date: Thu, 18 Jun 2009 18:12:32 +0000 Subject: [PATCH] * 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. --- cgen/ChangeLog | 10 ++++++++++ cgen/dev.scm | 24 ++++++++++++------------ cgen/doc/porting.texi | 20 +++++++++++--------- cgen/read.scm | 19 ++++++++++++------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/cgen/ChangeLog b/cgen/ChangeLog index cca9e7e705..8f81996da5 100644 --- a/cgen/ChangeLog +++ b/cgen/ChangeLog @@ -1,3 +1,13 @@ +2009-06-18 Doug Evans + + * 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. + 2009-06-14 Doug Evans * gen-all-doc: Use files in ../cpu where possible. diff --git a/cgen/dev.scm b/cgen/dev.scm index f404ea40b7..ddf9065b53 100644 --- a/cgen/dev.scm +++ b/cgen/dev.scm @@ -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' diff --git a/cgen/doc/porting.texi b/cgen/doc/porting.texi index e5633251ec..0f17369f4e 100644 --- a/cgen/doc/porting.texi +++ b/cgen/doc/porting.texi @@ -771,7 +771,7 @@ and developing the .CPU file interactively. The basic steps are: @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 interactive guile session with @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 interactive guile session with 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/")} +@item @code{(cload #:arch "cpu/.cpu")} @item Run each of: @itemize @bullet @item @code{(cgen-desc.h)} @@ -1005,7 +1007,7 @@ The same basic procedure for opcodes porting applies here. @item @code{(load "dev.scm")} @item @code{(load-sim)} @item Edit your @file{cpu/.cpu} file. -@item @code{(cload #:arch "cpu/")} +@item @code{(cload #:arch "cpu/.cpu")} @item Run each of: @itemize @bullet @item @code{(cgen-arch.h)} @@ -1014,7 +1016,7 @@ The same basic procedure for opcodes porting applies here. @end itemize @item Repeat steps 4,5,6 until the output looks reasonable. @item Edit your cpu/.cpu file. -@item @code{(cload #:arch "cpu/" #:machs "mach1[,mach2[,...]]")} +@item @code{(cload #:arch "cpu/.cpu" #:machs "mach1[,mach2[,...]]")} @item Run each of: @itemize @bullet @item @code{(cgen-cpu.h)} diff --git a/cgen/read.scm b/cgen/read.scm index 70800ec6c9..3b7ac9bc6a 100644 --- a/cgen/read.scm +++ b/cgen/read.scm @@ -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)) -- 2.11.0