public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* "just in time" compiler/translator for the simulators.
@ 2001-09-15  6:33 Johan Rydberg
  2001-09-15 11:07 ` graydon
       [not found] ` <20010915140753.A532.cygnus.local.cgen@venge.net>
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Rydberg @ 2001-09-15  6:33 UTC (permalink / raw)
  To: cgen

Hi, I would like your comments on something.

I'm thinking about implementing something that you might call
a `just in time' compiler/translator for GNU simulators.  This
would increase (hopefully) performance a bit.

The idea is to translate the simulated insns into native insns
and run them on the host machine.  Insns that can not be translated
will be simulated in `the old fashion way'.

The translation will be done in three steps.

  . translate a whole block of insns into intermediate code
  . perform register allocation and optimize the intermediate code
  . generate host code from the intermediate code

The intermediate code will be represented as `three address' stmts.

Well, a small example:

  The insns;

    lw  4(r1), r3

  Which is defined with CGEN RTL as;

    (set r3 (mem SI (add r1 4)))

  Would give a intermediate code tree that looks something like;

                  . assign
                 / \
                /   \
              mem    r3
              /
            add
            / \
           r1  4

  And would translate into three-address stmts;

    T1 = r1 + 4
    T2 = *T1
    r3 = T2


  Which would generate into something like;

    # begin insn
    call   nsim_insn_begin

    # read register 1 (hardware nr 0)
    mov.l  $0, 4(%esp)          # hardware number
    mov.l  $1, 8(%esp)          # register number
    call   nsim_hw_read_4

    # add "4" to register
    add.l  $4, %eax

    # read memory
    mov.l  %eax, 4(%esp)        # memory address
    call   nsim_mem_read_4

    # store value in register
    mov.l  $0, 4(%esp)
    mov.l  $3, 8(%esp)
    mov.l  %eax, 12(%esp)
    call   nsim_hw_write_4
    ...

  This could of course be optimized a bit.


Note: The translated code have a runtime environment that has
      a pointer to the current CPU structure already pushed on
      the stack.  Space is reserved on the stack for arguments
      to "nsim*" functions.

Comments? Suggestions?

-- 
Johan Rydberg

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

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

end of thread, other threads:[~2001-09-15 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-15  6:33 "just in time" compiler/translator for the simulators Johan Rydberg
2001-09-15 11:07 ` graydon
     [not found] ` <20010915140753.A532.cygnus.local.cgen@venge.net>
2001-09-15 11:44   ` Frank Ch. Eigler

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