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]

"just in time" compiler/translator for the simulators.



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


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