public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* cgen bug with larger-than-normal instructions?
@ 2000-09-14 16:31 matthew green
  2000-09-14 17:07 ` Doug Evans
  2000-10-13  2:49 ` matthew green
  0 siblings, 2 replies; 6+ messages in thread
From: matthew green @ 2000-09-14 16:31 UTC (permalink / raw)
  To: cgen

hi folks.


i am doing a sim port for an architecture that has 16 bit insns for
all but the 16-bit & 32-bit immediately load insns, which are 32-bits
& 48-bits long each, with the immediate value placed after the insn.

currently, cgen produces code that fails to compile:

decode.cxx:1457: implicit declaration of function `int GETIMEMUHI(...)'



this function is currently missing from cgen-cpu.h, but even after i
add it there, the problem persists.  i believe the generate code is
wrong, and (with an insight from bje) i have developed the following
patch.  it makes two changes to cgen itself:

	- call GETIMEM* as "current_cpu->GETIMEM*"

	- first argument of GETIMEM*() is "pc"

this allows my decoder to build, but i haven't tested that it works
yet (i have now pages of errors for sem.cxx to deal with).


is this patch valid?  if so, could someone commit it to sourcware?


thanks,


.mrg.




Index: utils-cgen.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/utils-cgen.scm,v
retrieving revision 1.55
diff -p -r1.55 utils-cgen.scm
*** utils-cgen.scm	2000/07/27 04:53:32	1.55
--- utils-cgen.scm	2000/09/14 23:17:09
***************
*** 630,642 ****
  ; ??? Aligned/unaligned support?
  
  (define (gen-ifetch pc-var bitoffset bitsize)
!   (string-append "GETIMEM"
  		 (case bitsize
  		   ((8) "UQI")
  		   ((16) "UHI")
  		   ((32) "USI")
  		   (else (error "bad bitsize argument to gen-ifetch" bitsize)))
! 		 " (current_cpu, "
  		 pc-var " + " (number->string (quotient bitoffset 8))
  		 ")")
  )
--- 630,642 ----
  ; ??? Aligned/unaligned support?
  
  (define (gen-ifetch pc-var bitoffset bitsize)
!   (string-append "current_cpu->GETIMEM"
  		 (case bitsize
  		   ((8) "UQI")
  		   ((16) "UHI")
  		   ((32) "USI")
  		   (else (error "bad bitsize argument to gen-ifetch" bitsize)))
! 		 " (pc, "
  		 pc-var " + " (number->string (quotient bitoffset 8))
  		 ")")
  )

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

* cgen bug with larger-than-normal instructions?
  2000-09-14 16:31 cgen bug with larger-than-normal instructions? matthew green
@ 2000-09-14 17:07 ` Doug Evans
  2000-09-14 19:19   ` matthew green
  2000-10-13  2:49 ` matthew green
  1 sibling, 1 reply; 6+ messages in thread
From: Doug Evans @ 2000-09-14 17:07 UTC (permalink / raw)
  To: matthew green; +Cc: cgen

matthew green writes:
 > i am doing a sim port for an architecture that has 16 bit insns for
 > all but the 16-bit & 32-bit immediately load insns, which are 32-bits
 > & 48-bits long each, with the immediate value placed after the insn.
 > 
 > currently, cgen produces code that fails to compile:
 > 
 > decode.cxx:1457: implicit declaration of function `int GETIMEMUHI(...)'
 > 
 > this function is currently missing from cgen-cpu.h, but even after i
 > add it there, the problem persists.  i believe the generate code is
 > wrong, and (with an insight from bje) i have developed the following
 > patch.  it makes two changes to cgen itself:
 > 
 > 	- call GETIMEM* as "current_cpu->GETIMEM*"

This is a sid-ism and as such doesn't belong in utils-cgen.scm.
How do the other sid ports invoke GETIMEM?

 > 	- first argument of GETIMEM*() is "pc"
 > 
 > this allows my decoder to build, but i haven't tested that it works
 > yet (i have now pages of errors for sem.cxx to deal with).

I don't quite follow why adding "pc" is necessary.

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

* re: cgen bug with larger-than-normal instructions?
  2000-09-14 17:07 ` Doug Evans
@ 2000-09-14 19:19   ` matthew green
  2000-09-15  8:55     ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: matthew green @ 2000-09-14 19:19 UTC (permalink / raw)
  To: Doug Evans; +Cc: cgen

   matthew green writes:
    > i am doing a sim port for an architecture that has 16 bit insns for
    > all but the 16-bit & 32-bit immediately load insns, which are 32-bits
    > & 48-bits long each, with the immediate value placed after the insn.
    > 
    > currently, cgen produces code that fails to compile:
    > 
    > decode.cxx:1457: implicit declaration of function `int GETIMEMUHI(...)'
    > 
    > this function is currently missing from cgen-cpu.h, but even after i
    > add it there, the problem persists.  i believe the generate code is
    > wrong, and (with an insight from bje) i have developed the following
    > patch.  it makes two changes to cgen itself:
    > 
    > 	- call GETIMEM* as "current_cpu->GETIMEM*"
   
   This is a sid-ism and as such doesn't belong in utils-cgen.scm.

yes, now you point that out i agree.

   How do the other sid ports invoke GETIMEM?

i can't find anything else that actually uses this in generated code, only
in hand written code....
   
    > 	- first argument of GETIMEM*() is "pc"
    > 
    > this allows my decoder to build, but i haven't tested that it works
    > yet (i have now pages of errors for sem.cxx to deal with).
   
   I don't quite follow why adding "pc" is necessary.

well, the function is defined as:

	inline UHI GETIMEMUHI(PCADDR pc, IADDR addr) const

so replacing `current_cpu' with `pc' seemed the right thing to do.


i don't know what the right way to do this is.

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

* re: cgen bug with larger-than-normal instructions?
  2000-09-14 19:19   ` matthew green
@ 2000-09-15  8:55     ` Doug Evans
       [not found]       ` <20000915115929.G14583@redhat.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2000-09-15  8:55 UTC (permalink / raw)
  To: matthew green; +Cc: cgen

matthew green writes:
 >     > 	- first argument of GETIMEM*() is "pc"
 >     > 
 >     > this allows my decoder to build, but i haven't tested that it works
 >     > yet (i have now pages of errors for sem.cxx to deal with).
 >    
 >    I don't quite follow why adding "pc" is necessary.
 > 
 > well, the function is defined as:
 > 
 > 	inline UHI GETIMEMUHI(PCADDR pc, IADDR addr) const
 > 
 > so replacing `current_cpu' with `pc' seemed the right thing to do.

Well, my question really was: given that you have `addr',
why is `pc' present at all?  The GNU simulators only pass `addr',
so I'm wondering you you also need to pass `pc'.
[for clarity: for the first "element" of the insn, addr == pc,
for subsequent fetches of the same insn addr == pc + n]

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

* Re: cgen bug with larger-than-normal instructions?
       [not found]       ` <20000915115929.G14583@redhat.com>
@ 2000-09-15  9:14         ` Doug Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Evans @ 2000-09-15  9:14 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: cgen

Frank Ch. Eigler writes:
 > The `pc' argument
 > lets us find the instruction to blame for the access.

Figgered as much.
Is the pc cached somewhere, or can you get it from current_cpu?

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

* re: cgen bug with larger-than-normal instructions?
  2000-09-14 16:31 cgen bug with larger-than-normal instructions? matthew green
  2000-09-14 17:07 ` Doug Evans
@ 2000-10-13  2:49 ` matthew green
  1 sibling, 0 replies; 6+ messages in thread
From: matthew green @ 2000-10-13  2:49 UTC (permalink / raw)
  To: cgen

OK, here's a patch to move the affected function into si[dm].scm and fix
it there.  i've tested that this doesn't affect any other port.

if this is OK, would someone please commit it?


thanks,

.mrg.


2000-10-13  matthew green  <mrg@cygnus.com>

	* utils-cgen.scm (get-ifetch): Move from here ...
	* sim.scm (get-ifetch): ... to here.
	* sid.scm (get-ifetch): Copy and port to c++.


Index: sid.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/sid.scm,v
retrieving revision 1.34
diff -p -r1.34 sid.scm
*** sid.scm	2000/09/08 15:20:01	1.34
--- sid.scm	2000/10/13 09:42:23
***************
*** 181,186 ****
--- 181,203 ----
      )
  )
  
+ ; Return C code to fetch a value from instruction memory.
+ ; PC-VAR is the C expression containing the address of the start of the
+ ; instruction.
+ ; ??? Aligned/unaligned support?
+ 
+ (define (gen-ifetch pc-var bitoffset bitsize)
+   (string-append "current_cpu->GETIMEM"
+ 		 (case bitsize
+ 		   ((8) "UQI")
+ 		   ((16) "UHI")
+ 		   ((32) "USI")
+ 		   (else (error "bad bitsize argument to gen-ifetch" bitsize)))
+ 		 " (pc, "
+ 		 pc-var " + " (number->string (quotient bitoffset 8))
+ 		 ")")
+ )
+ 
  ; Return definition of an object's attributes.
  ; This is like gen-obj-attr-defn, except split for sid.
  ; TYPE is one of 'ifld, 'hw, 'operand, 'insn.
Index: sim.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/sim.scm,v
retrieving revision 1.88
diff -p -r1.88 sim.scm
*** sim.scm	2000/09/05 18:39:31	1.88
--- sim.scm	2000/10/13 09:42:24
***************
*** 152,157 ****
--- 152,175 ----
    (string-append c-cpu-macro " (" sym ")")
  )
  \f
+ 
+ ; Return C code to fetch a value from instruction memory.
+ ; PC-VAR is the C expression containing the address of the start of the
+ ; instruction.
+ ; ??? Aligned/unaligned support?
+ 
+ (define (gen-ifetch pc-var bitoffset bitsize)
+   (string-append "GETIMEM"
+ 		 (case bitsize
+ 		   ((8) "UQI")
+ 		   ((16) "UHI")
+ 		   ((32) "USI")
+ 		   (else (error "bad bitsize argument to gen-ifetch" bitsize)))
+ 		 " (current_cpu, "
+ 		 pc-var " + " (number->string (quotient bitoffset 8))
+ 		 ")")
+ )
+ 
  ; Instruction field support code.
  
  ; Return a <c-expr> object of the value of an ifield.
Index: utils-cgen.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/utils-cgen.scm,v
retrieving revision 1.55
diff -p -r1.55 utils-cgen.scm
*** utils-cgen.scm	2000/07/27 04:53:32	1.55
--- utils-cgen.scm	2000/10/13 09:42:25
***************
*** 624,645 ****
     ";} while (0)\n")
  )
  
- ; Return C code to fetch a value from instruction memory.
- ; PC-VAR is the C expression containing the address of the start of the
- ; instruction.
- ; ??? Aligned/unaligned support?
- 
- (define (gen-ifetch pc-var bitoffset bitsize)
-   (string-append "GETIMEM"
- 		 (case bitsize
- 		   ((8) "UQI")
- 		   ((16) "UHI")
- 		   ((32) "USI")
- 		   (else (error "bad bitsize argument to gen-ifetch" bitsize)))
- 		 " (current_cpu, "
- 		 pc-var " + " (number->string (quotient bitoffset 8))
- 		 ")")
- )
  \f
  ; Called before loading the .cpu file to initialize.
  
--- 624,629 ----

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

end of thread, other threads:[~2000-10-13  2:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-14 16:31 cgen bug with larger-than-normal instructions? matthew green
2000-09-14 17:07 ` Doug Evans
2000-09-14 19:19   ` matthew green
2000-09-15  8:55     ` Doug Evans
     [not found]       ` <20000915115929.G14583@redhat.com>
2000-09-15  9:14         ` Doug Evans
2000-10-13  2:49 ` matthew green

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).