public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* enums
@ 2000-12-06  0:30 Johan Rydberg
  2000-12-06  3:16 ` enums Frank Ch. Eigler
  0 siblings, 1 reply; 9+ messages in thread
From: Johan Rydberg @ 2000-12-06  0:30 UTC (permalink / raw)
  To: cgen

Hi!

I define an enum like this:

 (define-enum
   (name e-exception)
   (comment "exception vectors")
   ()
   (prefix E_)
   (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -) 
           ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
           ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) 
           ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
 )

And the result in the "desc.h" file:

  /* Enum declaration for exception vectors.  */
  typedef enum e_exception {
    E_RESET
  } E_EXCEPTION;

As you can tell, all enums but the first one is left out.
And if I define the values like this,

  (values ("RESET" #x100) ("BUSERR" -) ("DPF" -) ("IPF" -) 
          ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
          ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) 
          ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))

I get the following message for CGEN:

  ERROR: In procedure caar:
  ERROR: Wrong type argument in position 1: ()

Have I missed something as usual?

-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
             THEN EXCUSE/OBJECT=ME

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  0:30 enums Johan Rydberg
@ 2000-12-06  3:16 ` Frank Ch. Eigler
  2000-12-06  3:23   ` enums Johan Rydberg
  0 siblings, 1 reply; 9+ messages in thread
From: Frank Ch. Eigler @ 2000-12-06  3:16 UTC (permalink / raw)
  To: Johan Rydberg; +Cc: cgen

Hi -

On Wed, Dec 06, 2000 at 09:31:09AM +0100, Johan Rydberg wrote:
: [...]
: I define an enum like this:
: [...]
:    (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -) 
:            ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
:            ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) 
:            ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
: [...]
: As you can tell, all enums but the first one is left out.

Is this intentional?  Why define the others with value "-" ?


: And if I define the values like this,
: 
:   (values ("RESET" #x100) ("BUSERR" -) ("DPF" -) ("IPF" -) 
:           ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
:           ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) 
:           ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
: 
: I get the following message for CGEN:
:   ERROR: In procedure caar:
:   ERROR: Wrong type argument in position 1: ()

Just a bug.  Could you try running cgen with error backtracing?
(CGENFLAGS="-b"; works for guile 1.3.*)


- FChE
-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6LiAgVZbdDOm/ZT0RAliYAJ0VfN82yiOF9Q53Is/g/RcjnFQ5gwCeO3qk
1CthDqyB1BSPI/WolUqcUz0=
=KGcc
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  3:16 ` enums Frank Ch. Eigler
@ 2000-12-06  3:23   ` Johan Rydberg
  2000-12-06  3:35     ` enums Ben Elliston
  2000-12-06  8:55     ` enums Doug Evans
  0 siblings, 2 replies; 9+ messages in thread
From: Johan Rydberg @ 2000-12-06  3:23 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: cgen

"Frank Ch. Eigler" wrote:

> :    (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -)
> :            ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
> :            ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -)
> :            ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
>
> Is this intentional?  Why define the others with value "-" ?

Well, first i defined it like: ("RESET" #x100) ("BUFFER" #x200)
And that didn't work at all.  All the "-" values is just the
result of a search-and-replace.
 
> : And if I define the values like this,
> :
> :   (values ("RESET" #x100) ("BUSERR" -) ("DPF" -) ("IPF" -)
> :           ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
> :           ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -)
> :           ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
> :
> : I get the following message for CGEN:
> :   ERROR: In procedure caar:
> :   ERROR: Wrong type argument in position 1: ()
> 
> Just a bug.  Could you try running cgen with error backtracing?
> (CGENFLAGS="-b"; works for guile 1.3.*)

Ofcouse, here's the result:

ERROR: In procedure caar:
ERROR: Wrong type argument in position 1: ()

Backtrace:
 0  (begin (apply display-error #f ...) (save-stack) ...)
 1* (if (= (length args) 5) (begin (apply display-error #f ...) (save-stack) ...))
 2* [#<procedure args> wrong-type-arg "caar" ...]
 3* [caar (() (prefix E_) (values # # ...))]
 4  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
 5  (if (null? arg-list) nil ...)
 6  [#<procedure (arg-list)> (() (prefix E_) (values # # ...))]
 7  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
 8  (if (null? arg-list) nil ...)
 9  [#<procedure (arg-list)> ((comment "exception vectors") () (prefix E_) ...)]
10  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
11  (if (null? arg-list) nil ...)
12  [#<procedure (arg-list)> ((name e-exception) (comment "exception vectors") () ...)]
13* (letrec ((loop #)) (loop arg-list))
14  (let ((name nil) (comment "") (attrs nil) ...) (letrec (#) (loop arg-list)) ...)
15  [-enum-read "define-enum" (name e-exception) ...]
16* [apply #<procedure -enum-read (errtxt . arg-list)> ("define-enum" (name e-exception) (comment "exception vectors") ...)]
17  (let ((e #)) (current-enum-add! e) ...)
18  [define-enum (name e-exception) (comment "exception vectors") ...]
19  [apply #<procedure define-enum arg-list> ((name e-exception) (comment "exception vectors") () ...)]
20  (if (< (length #) (car num-args)) (reader-error (string-append "Incorrect number of arguments to " # ...) entry ...) ...)
21  (if (cdr num-args) (if (< # #) (reader-error # entry ...) ...) ...)
22  (let* ((handler #) (arg-spec #) (num-args #)) (if (cdr num-args) (if # # ...) ...))
23  (if command (let* (# # #) (if # # ...)) ...)
24* (let ((command #)) (if command (let* # #) ...))
25  [-reader-process-expanded-1 (define-enum (name e-exception) (comment "exception vectors") ...)]
26  (if (eq? (car entry) (quote begin)) (for-each -reader-process-expanded (cdr entry)) ...)
27  [-reader-process-expanded (define-enum (name e-exception) (comment "exception vectors") ...)]
28  (let ((expansion #)) (-reader-process-expanded expansion))
29* [reader-process (define-enum (name e-exception) (comment "exception vectors") ...)]
30  (begin (reader-process entry) (loop (read)))
    ...
31  (if (eof-object? entry) #t ...)
32  [#<procedure (entry)> (define-isa (name or32) (base-insn-bitsize 32) ...)]
33  (begin (reader-process entry) (loop (read)))
34  (if (eof-object? entry) #t ...)
35  [#<procedure (entry)> (define-arch (name or32) (comment "OpenRISC 1000") ...)]
36  (begin (reader-process entry) (loop (read)))
37  (if (eof-object? entry) #t ...)
38  [#<procedure (entry)> (include "simplify.inc")]
39* (letrec ((loop #)) (loop (read)))
40* [#<procedure ()>]
41  [lazy-catch #t #<procedure ()> ...]
    ...
42  (let* () (set! srcdir (find-srcdir #)) ...)
43* [cgen-opc ("./../cgen/cgen-opc.scm" "-s" "./../cgen" ...)]
44* [primitive-load "./../cgen/cgen-opc.scm"]


-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
             THEN EXCUSE/OBJECT=ME

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  3:23   ` enums Johan Rydberg
@ 2000-12-06  3:35     ` Ben Elliston
  2000-12-06  3:38       ` enums Johan Rydberg
  2000-12-06  8:55     ` enums Doug Evans
  1 sibling, 1 reply; 9+ messages in thread
From: Ben Elliston @ 2000-12-06  3:35 UTC (permalink / raw)
  To: Johan Rydberg; +Cc: Frank Ch. Eigler, cgen

   > :    (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -)
   > :            ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
   > :            ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -)
   > :            ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))

   > Is this intentional?  Why define the others with value "-" ?

   Well, first i defined it like: ("RESET" #x100) ("BUFFER" #x200) And
   that didn't work at all.  All the "-" values is just the result of a
   search-and-replace.

In other contexts, an enum value can be:

	(values "RESET" "BUSERR" "DPF" ..)

Does that work?

Ben

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  3:35     ` enums Ben Elliston
@ 2000-12-06  3:38       ` Johan Rydberg
  0 siblings, 0 replies; 9+ messages in thread
From: Johan Rydberg @ 2000-12-06  3:38 UTC (permalink / raw)
  To: Ben Elliston; +Cc: Frank Ch. Eigler, cgen

Ben Elliston wrote:

> In other contexts, an enum value can be:
> 
>         (values "RESET" "BUSERR" "DPF" ..)
> 
> Does that work?

No, and here's the backtrace:

ERROR: In procedure caar:
ERROR: Wrong type argument in position 1: ()

Backtrace:
 0  (begin (apply display-error #f ...) (save-stack) ...)
 1* (if (= (length args) 5) (begin (apply display-error #f ...) (save-stack) ...))
 2* [#<procedure args> wrong-type-arg "caar" ...]
 3* [caar (() (prefix E_) (values "RESET" "BUSERR" ...))]
 4  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
 5  (if (null? arg-list) nil ...)
 6  [#<procedure (arg-list)> (() (prefix E_) (values "RESET" "BUSERR" ...))]
 7  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
 8  (if (null? arg-list) nil ...)
 9  [#<procedure (arg-list)> ((comment "exception vectors") () (prefix E_) ...)]
10  (let ((arg #) (elm-name #)) (case elm-name (# #) ...) ...)
11  (if (null? arg-list) nil ...)
12  [#<procedure (arg-list)> ((name e-exception) (comment "exception vectors") () ...)]
13* (letrec ((loop #)) (loop arg-list))
14  (let ((name nil) (comment "") (attrs nil) ...) (letrec (#) (loop arg-list)) ...)
15  [-enum-read "define-enum" (name e-exception) ...]
16* [apply #<procedure -enum-read (errtxt . arg-list)> ("define-enum" (name e-exception) (comment "exception vectors") ...)]
17  (let ((e #)) (current-enum-add! e) ...)
18  [define-enum (name e-exception) (comment "exception vectors") ...]
19  [apply #<procedure define-enum arg-list> ((name e-exception) (comment "exception vectors") () ...)]
20  (if (< (length #) (car num-args)) (reader-error (string-append "Incorrect number of arguments to " # ...) entry ...) ...)
21  (if (cdr num-args) (if (< # #) (reader-error # entry ...) ...) ...)
22  (let* ((handler #) (arg-spec #) (num-args #)) (if (cdr num-args) (if # # ...) ...))
23  (if command (let* (# # #) (if # # ...)) ...)
24* (let ((command #)) (if command (let* # #) ...))
25  [-reader-process-expanded-1 (define-enum (name e-exception) (comment "exception vectors") ...)]
26  (if (eq? (car entry) (quote begin)) (for-each -reader-process-expanded (cdr entry)) ...)
27  [-reader-process-expanded (define-enum (name e-exception) (comment "exception vectors") ...)]
28  (let ((expansion #)) (-reader-process-expanded expansion))
29* [reader-process (define-enum (name e-exception) (comment "exception vectors") ...)]
30  (begin (reader-process entry) (loop (read)))
    ...
31  (if (eof-object? entry) #t ...)
32  [#<procedure (entry)> (define-isa (name or32) (base-insn-bitsize 32) ...)]
33  (begin (reader-process entry) (loop (read)))
34  (if (eof-object? entry) #t ...)
35  [#<procedure (entry)> (define-arch (name or32) (comment "OpenRISC 1000") ...)]
36  (begin (reader-process entry) (loop (read)))
37  (if (eof-object? entry) #t ...)
38  [#<procedure (entry)> (include "simplify.inc")]
39* (letrec ((loop #)) (loop (read)))
40* [#<procedure ()>]
41  [lazy-catch #t #<procedure ()> ...]
    ...
42  (let* () (set! srcdir (find-srcdir #)) ...)
43* [cgen-opc ("./../cgen/cgen-opc.scm" "-s" "./../cgen" ...)]
44* [primitive-load "./../cgen/cgen-opc.scm"]

-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
             THEN EXCUSE/OBJECT=ME

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  3:23   ` enums Johan Rydberg
  2000-12-06  3:35     ` enums Ben Elliston
@ 2000-12-06  8:55     ` Doug Evans
  2000-12-06  9:06       ` enums Johan Rydberg
  1 sibling, 1 reply; 9+ messages in thread
From: Doug Evans @ 2000-12-06  8:55 UTC (permalink / raw)
  To: Johan Rydberg; +Cc: Frank Ch. Eigler, cgen

Johan Rydberg writes:
 > Ofcouse, here's the result:
 > 
 > ERROR: In procedure caar:
 > ERROR: Wrong type argument in position 1: ()

cgen needs to be more robust with bad input.
One might construct an argument that () should just be ignored
instead of flagged as an error.  dunno.

Take the line with () out.

 (define-enum
   (name e-exception)
   (comment "exception vectors")
>  ()
   (prefix E_)
   (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -) 
           ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -)
           ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) 
           ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
 )

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  8:55     ` enums Doug Evans
@ 2000-12-06  9:06       ` Johan Rydberg
  2000-12-06  9:28         ` enums Doug Evans
  0 siblings, 1 reply; 9+ messages in thread
From: Johan Rydberg @ 2000-12-06  9:06 UTC (permalink / raw)
  To: Doug Evans; +Cc: Frank Ch. Eigler, cgen

Doug Evans wrote:

> Take the line with () out.

Well, it "works" (cgen doesn't complain that is) now. But the
result int the "desc.h" file is still the same.

-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
             THEN EXCUSE/OBJECT=ME

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  9:06       ` enums Johan Rydberg
@ 2000-12-06  9:28         ` Doug Evans
  2000-12-07  6:33           ` enums Johan Rydberg
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Evans @ 2000-12-06  9:28 UTC (permalink / raw)
  To: Johan Rydberg; +Cc: Frank Ch. Eigler, cgen

Johan Rydberg writes:
 > Doug Evans wrote:
 > 
 > > Take the line with () out.
 > 
 > Well, it "works" (cgen doesn't complain that is) now. But the
 > result int the "desc.h" file is still the same.

Righto.  One more

 (define-enum
   (name e-exception)
   (comment "exception vectors")
-   ()
   (prefix E_)
-  (values ("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -)  
+  (values (("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -)  
 	  ("EXTINT" -) ("ALIGN" -) ("ILLEGAL" -) ("PEINT" -) 
 	  ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -)  
-	  ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))
+	  ("SYSCALL" -) ("BREAK" -) ("RESERVED" -)) )
 )

I think I chose to require the extra parens in case I wanted to
add a new parameter.  If y'all can't imagine anything
being added we can change things - without the parens is simpler.

[One can certainly argue cgen should prohibit extra args
to avoid breaking a port in the future if it should happen to have
junk there - the extra args are silently ignored now.
This gets back to being more robust with bad input.]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: enums
  2000-12-06  9:28         ` enums Doug Evans
@ 2000-12-07  6:33           ` Johan Rydberg
  0 siblings, 0 replies; 9+ messages in thread
From: Johan Rydberg @ 2000-12-07  6:33 UTC (permalink / raw)
  To: Doug Evans; +Cc: Frank Ch. Eigler, cgen

Doug Evans wrote:
> 
> Johan Rydberg writes:
>  > Doug Evans wrote:
>  >
>  > > Take the line with () out.
>  >
>  > Well, it "works" (cgen doesn't complain that is) now. But the
>  > result int the "desc.h" file is still the same.
> 
> Righto.  One more
>
> I think I chose to require the extra parens in case I wanted to
> add a new parameter.  If y'all can't imagine anything
> being added we can change things - without the parens is simpler.

This works.

-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -
             THEN EXCUSE/OBJECT=ME

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2000-12-07  6:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-06  0:30 enums Johan Rydberg
2000-12-06  3:16 ` enums Frank Ch. Eigler
2000-12-06  3:23   ` enums Johan Rydberg
2000-12-06  3:35     ` enums Ben Elliston
2000-12-06  3:38       ` enums Johan Rydberg
2000-12-06  8:55     ` enums Doug Evans
2000-12-06  9:06       ` enums Johan Rydberg
2000-12-06  9:28         ` enums Doug Evans
2000-12-07  6:33           ` enums Johan Rydberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).