This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] frv.cpu and frv.opc moved from src/cgen/cpu to src/cpu


Thanks!

I'll get rid of the Makefile hacks when these are committed.

Dave

Doug Evans wrote:

Dave Brolley writes:
> It would be better if the CGEN application had a way to specify the > location of the source files


Yep. Standard excuse. Incremental complication.

I'm currently testing this patch for opcodes.
The other apps will be done too of course.

[changes to regenerated Makefile.in left out]

2003-08-29 Doug Evans <dje@casey.transmeta.com>

cgen:
	Pass in paths to input files, instead of assuming they live in
	$srcdir/cpu.  Plus misc. option processing cleanup.
	* cgen-doc.scm (doc-arguments): Make options strings not symbols.
	Add pre-process pass to all options.
	* cgen-gas.scm (gas-arguments): Ditto.
	* cgen-sid.scm (sim-arguments): Ditto.
	* cgen-sim.scm (sim-arguments): Ditto.
	* cgen-stest.scm (stest-arguments): Ditto.
	* cgen-opc.scm (opc-arguments): Ditto.  New argument -OPC.
	(-opc-file-path): New global.
	(opc-file-path): New fn.
	* opcodes.scm (read-cpu.opc): Replace srcdir,cpu args with opc-file.
	All callers updated.
	(gen-extra-cpu.h,gen-extra-cpu.c,gen-extra-opc.h,gen-extra-opc.c,
	gen-extra-asm.c,gen-extra-dis.c,gen-extra-ibld.h,gen-extra-ibld.c):
	Replace srcdir arg with opc-file.  All callers updated.
	* read.scm (-opt-spec-update): Delete.
	(opt-get-first-pass,opt-get-second-pass): New fns.
	(-cgen): Process application-specific arguments in two passes.

opcodes:
	* Makefile.asm (run-cgen): Pass new args archfile and opcfile
	to cgen.sh.
	(stamp-ip2k,stamp-m32r,stamp-fr30,stamp-frv,stamp-openrisc,
	stamp-iq2000,stamp-xstormy16): Pass paths of .cpu and .opc files
	to cgen.sh.
	(stamp-frv): Delete hardcoded path spec workaround.
	* Makefile.in: Regenerate.
	* cgen.sh: New args archfile and opcfile.  Pass on to cgen.

Index: cgen/cgen-doc.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-doc.scm,v
retrieving revision 1.2
diff -u -p -r1.2 cgen-doc.scm
--- cgen/cgen-doc.scm	10 Jun 2003 21:22:02 -0000	1.2
+++ cgen/cgen-doc.scm	29 Aug 2003 22:08:53 -0000
@@ -20,12 +20,14 @@

(define doc-arguments
  (list
-   (list '-H "file" "generate $arch.html in <file>"
+   (list "-H" "file" "generate $arch.html in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen.html)))
-   ; can't use '-I because that gets interpreted as a complex number
-   (list (string->symbol "-I") "file" "generate $arch-insn.html in <file>"
+   (list "-I" "file" "generate $arch-insn.html in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-insn.html)))
-   (list '-N "file" "specify name of insn.html file"
+   (list "-N" "file" "specify name of insn.html file"
+	 #f
	 (lambda (arg) (set! *insn-html-file-name* arg)))
   )
)
Index: cgen/cgen-gas.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-gas.scm,v
retrieving revision 1.2
diff -u -p -r1.2 cgen-gas.scm
--- cgen/cgen-gas.scm	23 Mar 2001 09:45:55 -0000	1.2
+++ cgen/cgen-gas.scm	29 Aug 2003 22:08:53 -0000
@@ -24,9 +24,11 @@

(define gas-arguments
  (list
-   (list '-B "file" "generate build script in <file>"
+   (list "-B" "file" "generate build script in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-build.sh)))
-   (list '-E "file" "generate allinsn.exp in <file>"
+   (list "-E" "file" "generate allinsn.exp in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-allinsn.exp)))
   )
)
Index: cgen/cgen-opc.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-opc.scm,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 cgen-opc.scm
--- cgen/cgen-opc.scm	28 Jul 2000 04:11:52 -0000	1.1.1.1
+++ cgen/cgen-opc.scm	29 Aug 2003 22:08:53 -0000
@@ -23,25 +23,45 @@
  (load (string-append srcdir "/opc-opinst.scm"))
)

+; Records the -OPC arg which specifies the path to the .opc file.
+(define -opc-file-path #f)
+(define (opc-file-path)
+  (if -opc-file-path
+      -opc-file-path
+      (error ".opc file unspecified, missing -OPC argument"))
+)
+
(define opc-arguments
  (list
-   (list '-H "file" "generate $arch-desc.h in <file>"
+   (list "-OPC" "file" "specify path to .opc file"
+	 (lambda (arg) (set! -opc-file-path arg))
+	 #f)
+   (list "-H" "file" "generate $arch-desc.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-desc.h)))
-   (list '-C "file" "generate $arch-desc.c in <file>"
+   (list "-C" "file" "generate $arch-desc.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-desc.c)))
-   (list '-O "file" "generate $arch-opc.h in <file>"
+   (list "-O" "file" "generate $arch-opc.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-opc.h)))
-   (list '-P "file" "generate $arch-opc.c in <file>"
+   (list "-P" "file" "generate $arch-opc.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-opc.c)))
-   (list '-Q "file" "generate $arch-opinst.c in <file>"
+   (list "-Q" "file" "generate $arch-opinst.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-opinst.c)))
-   (list '-B "file" "generate $arch-ibld.h in <file>"
+   (list "-B" "file" "generate $arch-ibld.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-ibld.h)))
-   (list '-L "file" "generate $arch-ibld.in in <file>"
+   (list "-L" "file" "generate $arch-ibld.in in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-ibld.in)))
-   (list '-A "file" "generate $arch-asm.in in <file>"
+   (list "-A" "file" "generate $arch-asm.in in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-asm.in)))
-   (list '-D "file" "generate $arch-dis.in in <file>"
+   (list "-D" "file" "generate $arch-dis.in in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-dis.in)))
   )
)
Index: cgen/cgen-sid.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-sid.scm,v
retrieving revision 1.2
diff -u -p -r1.2 cgen-sid.scm
--- cgen/cgen-sid.scm	16 Apr 2003 18:09:06 -0000	1.2
+++ cgen/cgen-sid.scm	29 Aug 2003 22:08:53 -0000
@@ -23,25 +23,35 @@

(define sim-arguments
  (list
-   (list '-H "file" "generate desc.h in <file>"
+   (list "-H" "file" "generate desc.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-desc.h)))
-   (list '-C "file" "generate cpu.h in <file>"
+   (list "-C" "file" "generate cpu.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-cpu.h)))
-   (list '-E "file" "generate defs.h in <file>"
+   (list "-E" "file" "generate defs.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-defs.h)))
-   (list '-T "file" "generate decode.h in <file>"
+   (list "-T" "file" "generate decode.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-decode.h)))
-   (list '-D "file" "generate decode.cxx in <file>"
+   (list "-D" "file" "generate decode.cxx in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-decode.cxx)))
-   (list '-W "file" "generate write.cxx in <file>"
+   (list "-W" "file" "generate write.cxx in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-write.cxx)))
-   (list '-S "file" "generate semantics.cxx in <file>"
+   (list "-S" "file" "generate semantics.cxx in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-semantics.cxx)))
-   (list '-X "file" "generate sem-switch.cxx in <file>"
+   (list "-X" "file" "generate sem-switch.cxx in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-sem-switch.cxx)))
-   (list '-M "file" "generate model.cxx in <file>"
+   (list "-M" "file" "generate model.cxx in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-model.cxx)))
-   (list '-N "file" "generate model.h in <file>"
+   (list "-N" "file" "generate model.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-model.h)))
   )
)
Index: cgen/cgen-sim.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-sim.scm,v
retrieving revision 1.2
diff -u -p -r1.2 cgen-sim.scm
--- cgen/cgen-sim.scm	1 Dec 2000 04:45:20 -0000	1.2
+++ cgen/cgen-sim.scm	29 Aug 2003 22:08:53 -0000
@@ -27,41 +27,59 @@

(define sim-arguments
  (list
-   (list '-A "file" "generate arch.h in <file>"
+   (list "-A" "file" "generate arch.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-arch.h)))
-   (list '-B "file" "generate arch.c in <file>"
+   (list "-B" "file" "generate arch.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-arch.c)))
-   (list '-C "file" "generate cpu-<cpu>.h in <file>"
+   (list "-C" "file" "generate cpu-<cpu>.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-cpu.h)))
-   (list '-U "file" "generate cpu-<cpu>.c in <file>"
+   (list "-U" "file" "generate cpu-<cpu>.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-cpu.c)))
-   (list '-N "file" "generate cpu-all.h in <file>"
+   (list "-N" "file" "generate cpu-all.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-cpuall.h)))
-   (list '-F "file" "generate memops.h in <file>"
+   (list "-F" "file" "generate memops.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-mem-ops.h)))
-   (list '-G "file" "generate defs.h in <file>"
+   (list "-G" "file" "generate defs.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-defs.h)))
-   (list '-P "file" "generate semops.h in <file>"
+   (list "-P" "file" "generate semops.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-sem-ops.h)))
-   (list '-T "file" "generate decode.h in <file>"
+   (list "-T" "file" "generate decode.h in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-decode.h)))
-   (list '-D "file" "generate decode.c in <file>"
+   (list "-D" "file" "generate decode.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-decode.c)))
-   (list '-E "file" "generate extract.c in <file>"
+   (list "-E" "file" "generate extract.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-extract.c)))
-   (list '-R "file" "generate read.c in <file>"
+   (list "-R" "file" "generate read.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-read.c)))
-   (list '-W "file" "generate write.c in <file>"
+   (list "-W" "file" "generate write.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-write.c)))
-   (list '-S "file" "generate semantics.c in <file>"
+   (list "-S" "file" "generate semantics.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-semantics.c)))
-   (list '-X "file" "generate sem-switch.c in <file>"
+   (list "-X" "file" "generate sem-switch.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-sem-switch.c)))
-   (list '-O "file" "generate ops.c in <file>"
+   (list "-O" "file" "generate ops.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-ops.c)))
-   (list '-M "file" "generate model.c in <file>"
+   (list "-M" "file" "generate model.c in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-model.c)))
-   (list '-L "file" "generate mainloop.in in <file>"
+   (list "-L" "file" "generate mainloop.in in <file>"
+	 #f
	 (lambda (arg) (file-write arg cgen-mainloop.in)))
   )
)
Index: cgen/cgen-stest.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-stest.scm,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 cgen-stest.scm
--- cgen/cgen-stest.scm	28 Jul 2000 04:11:52 -0000	1.1.1.1
+++ cgen/cgen-stest.scm	29 Aug 2003 22:08:53 -0000
@@ -24,9 +24,11 @@

(define stest-arguments
  (list
-   (list '-B "file" "generate build.sh"
+   (list "-B" "file" "generate build.sh"
+	 #f
	 (lambda (arg) (file-write arg cgen-build.sh)))
-   (list '-E "file" "generate the testsuite .exp"
+   (list "-E" "file" "generate the testsuite .exp"
+	 #f
	 (lambda (arg) (file-write arg cgen-allinsn.exp)))
   )
)
Index: cgen/desc-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/desc-cpu.scm,v
retrieving revision 1.17
diff -u -p -r1.17 desc-cpu.scm
--- cgen/desc-cpu.scm	16 Jul 2003 05:35:47 -0000	1.17
+++ cgen/desc-cpu.scm	29 Aug 2003 22:08:53 -0000
@@ -1017,7 +1017,7 @@ init_tables ()
   -gen-mach-table-decls
   gen-hw-table-decls
   "\n"
-   (lambda () (gen-extra-cpu.h srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-cpu.h (opc-file-path) (current-arch-name)))
   "

#endif /* @ARCH@_CPU_H */
@@ -1050,7 +1050,7 @@ init_tables ()
#include \"libiberty.h\"
#include \"xregex.h\"
\n"
-   (lambda () (gen-extra-cpu.c srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-cpu.c (opc-file-path) (current-arch-name)))
   gen-attr-table-defns
   -gen-isa-table-defns
   -gen-mach-table-defns
Index: cgen/opc-asmdis.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-asmdis.scm,v
retrieving revision 1.3
diff -u -p -r1.3 opc-asmdis.scm
--- cgen/opc-asmdis.scm	25 Nov 2001 23:18:15 -0000	1.3
+++ cgen/opc-asmdis.scm	29 Aug 2003 22:08:53 -0000
@@ -85,7 +85,7 @@ void
  (string-write
   ; No need for copyright, appended to file with one.
   "\n"
-   (lambda () (gen-extra-asm.c srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-asm.c (opc-file-path) (current-arch-name)))
   "\n"
   -gen-parse-switch
   (lambda () (gen-handler-table "parse" opc-parse-handlers))
@@ -178,7 +178,7 @@ void
  (string-write
   ; No need for copyright, appended to file with one.
   "\n"
-   (lambda () (gen-extra-dis.c srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-dis.c (opc-file-path) (current-arch-name)))
   "\n"
   -gen-print-switch
   (lambda () (gen-handler-table "print" opc-print-handlers))
Index: cgen/opc-ibld.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-ibld.scm,v
retrieving revision 1.4
diff -u -p -r1.4 opc-ibld.scm
--- cgen/opc-ibld.scm	15 May 2003 07:25:02 -0000	1.4
+++ cgen/opc-ibld.scm	29 Aug 2003 22:08:53 -0000
@@ -307,7 +307,7 @@ void
#define @ARCH@_IBLD_H

"
-   (lambda () (gen-extra-ibld.h srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-ibld.h (opc-file-path) (current-arch-name)))
   "\n"
   gen-insn-builders
   "
Index: cgen/opc-itab.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-itab.scm,v
retrieving revision 1.10
diff -u -p -r1.10 opc-itab.scm
--- cgen/opc-itab.scm	16 Jul 2003 05:35:47 -0000	1.10
+++ cgen/opc-itab.scm	29 Aug 2003 22:08:53 -0000
@@ -698,7 +698,7 @@ void
#define @ARCH@_OPC_H

"
-   (lambda () (gen-extra-opc.h srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-opc.h (opc-file-path) (current-arch-name)))
   -gen-insn-enum
   -gen-ifield-decls
   -gen-init-macros
@@ -725,7 +725,7 @@ void
#include \"@prefix@-opc.h\"
#include \"libiberty.h\"
\n"
-   (lambda () (gen-extra-opc.c srcdir (current-arch-name))) ; from <arch>.opc
+   (lambda () (gen-extra-opc.c (opc-file-path) (current-arch-name)))
   -gen-hash-decls
   -gen-ifmt-table
   -gen-insn-opcode-table
Index: cgen/opcodes.scm
===================================================================
RCS file: /cvs/src/src/cgen/opcodes.scm,v
retrieving revision 1.6
diff -u -p -r1.6 opcodes.scm
--- cgen/opcodes.scm	16 Jul 2003 05:35:47 -0000	1.6
+++ cgen/opcodes.scm	29 Aug 2003 22:08:53 -0000
@@ -697,7 +697,6 @@
)

; Extra target specific code generation.
-; For now, such code lives in <arch>.opc.

; Pick out a section from the .opc file.
; The section is delimited with:
@@ -708,10 +707,8 @@
; FIXME: This is a pretty involved bit of code.  'twould be nice to split
; it up into manageable chunks.

-(define (read-cpu.opc srcdir cpu delim)
-  (let ((file (string-append srcdir "/cpu/"
-			     (symbol->string (current-arch-name))
-			     ".opc"))
+(define (read-cpu.opc opc-file delim)
+  (let ((file opc-file)
	(start-delim (string-append "/* -- " delim))
	(end-delim "/* -- "))
    (if (file-exists? file)
@@ -756,38 +753,37 @@
	))
)

-; FIXME: collapse into one?
-(define (gen-extra-cpu.h srcdir arch)
+(define (gen-extra-cpu.h opc-file arch)
  (logit 2 "Generating extra cpu.h stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "cpu.h")
+  (read-cpu.opc opc-file "cpu.h")
)
-(define (gen-extra-cpu.c srcdir arch)
+(define (gen-extra-cpu.c opc-file arch)
  (logit 2 "Generating extra cpu.c stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "cpu.c")
+  (read-cpu.opc opc-file "cpu.c")
)
-(define (gen-extra-opc.h srcdir arch)
+(define (gen-extra-opc.h opc-file arch)
  (logit 2 "Generating extra opc.h stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "opc.h")
+  (read-cpu.opc opc-file "opc.h")
)
-(define (gen-extra-opc.c srcdir arch)
+(define (gen-extra-opc.c opc-file arch)
  (logit 2 "Generating extra opc.c stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "opc.c")
+  (read-cpu.opc opc-file "opc.c")
)
-(define (gen-extra-asm.c srcdir arch)
+(define (gen-extra-asm.c opc-file arch)
  (logit 2 "Generating extra asm.c stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "asm.c")
+  (read-cpu.opc opc-file "asm.c")
)
-(define (gen-extra-dis.c srcdir arch)
+(define (gen-extra-dis.c opc-file arch)
  (logit 2 "Generating extra dis.c stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "dis.c")
+  (read-cpu.opc opc-file "dis.c")
)
-(define (gen-extra-ibld.h srcdir arch)
+(define (gen-extra-ibld.h opc-file arch)
  (logit 2 "Generating extra ibld.h stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "ibld.h")
+  (read-cpu.opc opc-file "ibld.h")
)
-(define (gen-extra-ibld.c srcdir arch)
+(define (gen-extra-ibld.c opc-file arch)
  (logit 2 "Generating extra ibld.c stuff from " arch ".opc ...\n")
-  (read-cpu.opc srcdir arch "ibld.c")
+  (read-cpu.opc opc-file "ibld.c")
)

; For debugging.
Index: cgen/read.scm
===================================================================
RCS file: /cvs/src/src/cgen/read.scm,v
retrieving revision 1.8
diff -u -p -r1.8 read.scm
--- cgen/read.scm	16 Jul 2003 05:35:47 -0000	1.8
+++ cgen/read.scm	29 Aug 2003 22:08:54 -0000
@@ -913,17 +913,6 @@ Define a preprocessor-style macro.
	       (cons (cons opt #f) (cdr argv))))))
)

-; Convert old style option spec to new style.
-; This involves converting a symbol option name to a string.
-
-(define (-opt-spec-update spec-list)
-  (map (lambda (spec)
-	 (if (symbol? (car spec))
-	     (cons (symbol->string (car spec)) (cdr spec))
-	     spec))
-       spec-list)
-)
-
; Used to ensure backtraces are printed if an error occurs.

(define (catch-with-backtrace thunk)
@@ -1009,7 +998,7 @@ Define a preprocessor-style macro.
; arguments specified up til now, then continue with next batch of args".

(define common-arguments
-  '(("-a" "arch"      "set arch, specifies name of .cpu file to load")
+  '(("-a" "arch-file" "specify path of .cpu file to load")
    ("-b" #f          "use debugging evaluator, for backtraces")
    ("-d" #f          "start interactive debugging session")
    ("-f" "flags"     "specify a set of flags to control code generation")
@@ -1023,6 +1012,12 @@ Define a preprocessor-style macro.
    )
)

+; Accessors for application option specs
+(define (opt-get-first-pass opt)
+  (or (list-ref opt 3) (lambda args #f)))
+(define (opt-get-second-pass opt)
+  (or (list-ref opt 4) (lambda args #f)))
+
; Parse options and call generators.
; ARGS is a #:keyword delimited list of arguments.
; #:app-name name
@@ -1071,10 +1066,10 @@ Define a preprocessor-style macro.
      ; ARGS has been processed, now we can process ARGV.

      (let (
-	    (opt-spec (append common-arguments (-opt-spec-update opt-spec)))
+	    (opt-spec (append common-arguments opt-spec))
	    (app-args nil)    ; application's args are queued here
	    (repl? #f)
-	    (arch #f)
+	    (arch-file #f)
	    (keep-mach "all") ; default is all machs
	    (keep-isa "all")  ; default is all isas
	    (flags "")
@@ -1093,7 +1088,7 @@ Define a preprocessor-style macro.
	      ((missing) (cgen-usage 'missing arg opt-spec))
	      (else
	       (cond ((str=? "-a" (car opt))
-		      (set! arch arg)
+		      (set! arch-file arg)
		      )
		     ((str=? "-b" (car opt))
		      (if (memq 'debug-extensions *features*)
@@ -1158,12 +1153,12 @@ Define a preprocessor-style macro.

; All arguments have been parsed.

-	(if (not arch)
+	(if (not arch-file)
	    (error "-a option missing, no architecture specified"))

	(if repl?
	    (debug-repl nil))
-	(cpu-load (string-append srcdir "/cpu/" arch ".cpu")
+	(cpu-load arch-file
		  keep-mach keep-isa flags
		  app-init! app-finish! app-analyze!)
	; Start another repl loop if -d.
@@ -1171,15 +1166,26 @@ Define a preprocessor-style macro.
	(if repl?
	    (debug-repl nil))

-	; Done with processing the arguments.  Call the application's
-	; file generators.
+	; Done with processing the arguments.
+	; Application arguments are processed in two passes.
+	; This is because the app may have arguments that specify things
+	; that affect file generation (e.g. to specify another input file)
+	; and we don't want to require an ordering of the options.
+
+	(for-each (lambda (opt-arg)
+		    (let ((opt (car opt-arg))
+			  (arg (cdr opt-arg)))
+		      (if (cadr opt)
+			  ((opt-get-first-pass opt) arg)
+			  ((opt-get-first-pass opt)))))
+		  (reverse app-args))

	(for-each (lambda (opt-arg)
		    (let ((opt (car opt-arg))
			  (arg (cdr opt-arg)))
		      (if (cadr opt)
-			  ((cadddr opt) arg)
-			  ((cadddr opt)))))
+			  ((opt-get-second-pass opt) arg)
+			  ((opt-get-second-pass opt)))))
		  (reverse app-args))
	)
      )
Index: opcodes/Makefile.am
===================================================================
RCS file: /cvs/src/src/opcodes/Makefile.am,v
retrieving revision 1.69
diff -u -p -r1.69 Makefile.am
--- opcodes/Makefile.am	29 Aug 2003 19:14:54 -0000	1.69
+++ opcodes/Makefile.am	29 Aug 2003 22:08:54 -0000
@@ -378,8 +378,8 @@ endif

run-cgen:
	$(SHELL) $(srcdir)/cgen.sh opcodes $(srcdir) $(CGEN) \
-	  $(CGENDIR) "$(CGENFLAGS)" $(arch) $(prefix) \
-	  "$(options)" $(extrafiles)
+	  $(CGENDIR) "$(CGENFLAGS)" $(arch) $(prefix) $(archfile) $(opcfile) \
+	  "$(options)" "$(extrafiles)"
	touch stamp-${prefix}
.PHONY: run-cgen

@@ -395,44 +395,47 @@ run-cgen-all:
$(srcdir)/ip2k-desc.h $(srcdir)/ip2k-desc.c $(srcdir)/ip2k-opc.h $(srcdir)/ip2k-opc.c $(srcdir)/ip2k-ibld.c $(srcdir)/ip2k-asm.c $(srcdir)/ip2k-dis.c: $(IP2K_DEPS)
	@true
stamp-ip2k: $(CGENDEPS) $(CPUDIR)/ip2k.cpu $(CPUDIR)/ip2k.opc
-	$(MAKE) run-cgen arch=ip2k prefix=ip2k options= extrafiles=
+	$(MAKE) run-cgen arch=ip2k prefix=ip2k options= \
+		archfile=$(CPUDIR)/ip2k.cpu opcfile=$(CPUDIR)/ip2k.opc extrafiles=

$(srcdir)/m32r-desc.h $(srcdir)/m32r-desc.c $(srcdir)/m32r-opc.h $(srcdir)/m32r-opc.c $(srcdir)/m32r-ibld.c $(srcdir)/m32r-opinst.c $(srcdir)/m32r-asm.c $(srcdir)/m32r-dis.c: $(M32R_DEPS)
	@true
stamp-m32r: $(CGENDEPS) $(CPUDIR)/m32r.cpu $(CPUDIR)/m32r.opc
-	$(MAKE) run-cgen arch=m32r prefix=m32r options=opinst extrafiles=opinst
+	$(MAKE) run-cgen arch=m32r prefix=m32r options=opinst \
+		archfile=$(CPUDIR)/m32r.cpu opcfile=$(CPUDIR)/m32r.opc extrafiles=opinst

$(srcdir)/fr30-desc.h $(srcdir)/fr30-desc.c $(srcdir)/fr30-opc.h $(srcdir)/fr30-opc.c $(srcdir)/fr30-ibld.c $(srcdir)/fr30-asm.c $(srcdir)/fr30-dis.c: $(FR30_DEPS)
	@true
stamp-fr30: $(CGENDEPS) $(CPUDIR)/fr30.cpu $(CPUDIR)/fr30.opc
-	$(MAKE) run-cgen arch=fr30 prefix=fr30 options= extrafiles=
+	$(MAKE) run-cgen arch=fr30 prefix=fr30 options= \
+		archfile=$(CPUDIR)/fr30.cpu opcfile=$(CPUDIR)/fr30.opc extrafiles=

$(srcdir)/frv-desc.h $(srcdir)/frv-desc.c $(srcdir)/frv-opc.h $(srcdir)/frv-opc.c $(srcdir)/frv-ibld.c $(srcdir)/frv-asm.c $(srcdir)/frv-dis.c: $(FRV_DEPS)
	@true
# .cpu and .opc files for frv are kept in a different directory, but cgen has no switch to specify that location, so
# copy those file to the regular place.
stamp-frv: $(CGENDEPS) $(srcdir)/../cpu/frv.cpu $(srcdir)/../cpu/frv.opc
-	cp -fp $(srcdir)/../cpu/frv.cpu $(CPUDIR)/frv.cpu
-	cp -fp $(srcdir)/../cpu/frv.opc $(CPUDIR)/frv.opc
-	$(MAKE) run-cgen arch=frv prefix=frv options= extrafiles=
-	rm -f $(CPUDIR)/frv.cpu
-	rm -f $(CPUDIR)/frv.opc
+	$(MAKE) run-cgen arch=frv prefix=frv options= \
+		archfile=$(srcdir)/../cpu/frv.cpu opcfile=$(srcdir)/../cpu/frv.opc extrafiles=

$(srcdir)/openrisc-desc.h $(srcdir)/openrisc-desc.c $(srcdir)/openrisc-opc.h $(srcdir)/openrisc-opc.c $(srcdir)/openrisc-ibld.c $(srcdir)/openrisc-asm.c $(srcdir)/openrisc-dis.c: $(OPENRISC_DEPS)
	@true
stamp-openrisc: $(CGENDEPS) $(CPUDIR)/openrisc.cpu $(CPUDIR)/openrisc.opc
-	$(MAKE) run-cgen arch=openrisc prefix=openrisc options= extrafiles=
+	$(MAKE) run-cgen arch=openrisc prefix=openrisc options= \
+		archfile=$(CPUDIR)/openrisc.cpu opcfile=$(CPUDIR)/openrisc.opc extrafiles=

$(srcdir)/iq2000-desc.h $(srcdir)/iq2000-desc.c $(srcdir)/iq2000-opc.h $(srcdir)/iq2000-opc.c $(srcdir)/iq2000-ibld.c $(srcdir)/iq2000-asm.c $(srcdir)/iq2000-dis.c: $(IQ2000_DEPS)
	@true
stamp-iq2000: $(CGENDEPS) $(CPUDIR)/iq2000.cpu $(CPUDIR)/iq2000.opc \
	$(CPUDIR)/iq2000m.cpu $(CPUDIR)/iq10.cpu
-	$(MAKE) run-cgen arch=iq2000 prefix=iq2000 options= extrafiles=
+	$(MAKE) run-cgen arch=iq2000 prefix=iq2000 options= \
+		archfile=$(CPUDIR)/iq2000.cpu opcfile=$(CPUDIR)/iq2000.opc extrafiles=

$(srcdir)/xstormy16-desc.h $(srcdir)/xstormy16-desc.c $(srcdir)/xstormy16-opc.h $(srcdir)/xstormy16-opc.c $(srcdir)/xstormy16-ibld.c $(srcdir)/xstormy16-asm.c $(srcdir)/xstormy16-dis.c: $(XSTORMY16_DEPS)
	@true
stamp-xstormy16: $(CGENDEPS) $(CPUDIR)/xstormy16.cpu $(CPUDIR)/xstormy16.opc
-	$(MAKE) run-cgen arch=xstormy16 prefix=xstormy16 options= extrafiles=
+	$(MAKE) run-cgen arch=xstormy16 prefix=xstormy16 options= \
+		archfile=$(CPUDIR)/xstormy16.cpu opcfile=$(CPUDIR)/xstormy16.opc extrafiles=

ia64-gen: ia64-gen.o
$(LINK) ia64-gen.o $(LIBIBERTY)
Index: opcodes/cgen.sh
===================================================================
RCS file: /cvs/src/src/opcodes/cgen.sh,v
retrieving revision 1.2
diff -u -p -r1.2 cgen.sh
--- opcodes/cgen.sh 13 Mar 2001 22:58:34 -0000 1.2
+++ opcodes/cgen.sh 29 Aug 2003 22:08:54 -0000
@@ -23,11 +23,19 @@
# arch-asm.c, arch-dis.c, arch-opinst.c, arch-ibld.[ch].
#
# Usage:
-# cgen.sh action srcdir cgen cgendir cgenflags arch prefix options
+# cgen.sh action srcdir cgen cgendir cgenflags arch prefix \
+# arch-file opc-file options [extrafiles]
#
# ACTION is currently always "opcodes". It exists to be consistent with the # simulator.
-# OPTIONS is comma separated list of options:
+# ARCH is the name of the architecture.
+# It is substituted into @arch@ and @ARCH@ in the generated files.
+# PREFIX is both the generated file prefix and is substituted into
+# @prefix@ in the generated files.
+# ARCH-FILE is the name of the .cpu file (including path).
+# OPC-FILE is the name of the .opc file (including path).
+# OPTIONS is comma separated list of options (???).
+# EXTRAFILES is a space separated list (1 arg still) of extra files to build:
# - opinst - arch-opinst.c is being made, causes semantic analysis
#
# We store the generated files in the source directory until we decide to
@@ -44,11 +52,13 @@ cgendir=$4
cgenflags=$5
arch=$6
prefix=$7
-options=$8
+archfile=$8
+opcfile=$9
+shift ; options=$9


# List of extra files to build.
# Values: opinst (only 1 extra file at present)
-extrafiles=$9
+shift ; extrafiles=$9

rootdir=${srcdir}/..

@@ -88,7 +98,8 @@ opcodes)
${cgenflags} \
-f "${options}" \
-m all \
- -a ${arch} \
+ -a ${archfile} \
+ -OPC ${opcfile} \
-H tmp-desc.h1 \
-C tmp-desc.c1 \
-O tmp-opc.h1 \





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]