public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* problems simulating register-only architecture...
@ 2001-05-24 13:39 lehotsky
  2001-05-24 15:35 ` Ben Elliston
  0 siblings, 1 reply; 6+ messages in thread
From: lehotsky @ 2001-05-24 13:39 UTC (permalink / raw)
  To: cgen

The machine I'm developing a simulator for is a "register only"
architecture, whose only memory is 512, 32-bit registers.

I'm trying to model this as as a group of virtual registers
with a 2k memory.

  There are 4 registers that are "special", in that
they are auto-indexed (e.g.) reading register X uses the contents of
register Y as an indirect register number.

But when I set up my "model" as follows, it doesn't work; is it
possible that the define-pmacro EA is evaluated at the wrong time?

Or, do I need to write my "get" and "set" accessors as escapes to
C code to make this work?

It appears that with these hardware elements defined, the generated
sem.c expands to code that is doing GETMEMSI() directly, 

Here's the code from my .cpu file

(define-hardware
  (name h-register)
  (comment "all addressable registers")
  (attrs VIRTUAL)
  (type memory SI (512))
  (get (index) (mem SI (EA index)))
  (set (index newval) (set (mem SI (EA index)) newval))
)

; The actual memory.... 512 32 bit words == 2048 bytes
;
(define-hardware
  (name h-memory)
  (comment "all addressable data memory")
  (type memory QI (2048))
)

.,.
...

(define-pmacro (EA index)
  (sll (cond SI
	     ((eq index ptr0x) (and #x1ff (reg SI h-register ptr0)))
	     ((eq index ptr1x) (and #x1ff (reg SI h-register ptr1)))
	     ((eq index ptr2x) (and #x1ff (reg SI h-register ptr2)))
	     ((eq index spx)   (and #x1ff (reg SI h-register sp)))
	     (else		  index))
       2)
)

......
(dni cmpi "cmp reg/imm"
     ()
     "cmpi $rd,$imm16"
     (+ OP5_CMPI  (f-dc2 #x0) rd imm16)
     (sequence ((SI result))
	       (set result (sub SI (reg SI h-register rd) (zext USI imm16)))
	       (set zbit (zflag result))
	       (set nbit (nflag result))
	       (set cbit (sub-cflag (reg SI h-register rd)
				    (zext USI imm16) (const 0))))
     ()
)


===========================
But the resulting expansion in the sem file looks like...

  SI tmp_result;
  tmp_result = SUBSI (GETMEMSI (current_cpu, pc, i_rd), ZEXTSISI (f_imm16));

Note that the REGISTER access has been optimized to a GETMEMSI, but
when I step my way thru the expansion of the GETMEMSI, the code to
evaluate the effective address is gone.

Any thoughts on this?

Is there a better way to achieve this?

-- Al

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

end of thread, other threads:[~2001-05-24 16:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200105242031.QAA10298.cygnus.local.cgen@iron>
2001-05-24 16:04 ` problems simulating register-only architecture Frank Ch. Eigler
2001-05-24 16:23   ` Alan Lehotsky
2001-05-24 16:25     ` Frank Ch. Eigler
2001-05-24 13:39 lehotsky
2001-05-24 15:35 ` Ben Elliston
2001-05-24 16:18   ` Alan Lehotsky

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