This is the mail archive of the
mailing list for the CGEN project.
"just in time" compiler/translator for the simulators.
- To: <cgen at sources dot redhat dot com>
- Subject: "just in time" compiler/translator for the simulators.
- From: Johan Rydberg <johan at rydberg dot com>
- Date: Sat, 15 Sep 2001 15:33:18 +0200 (MEST)
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:
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;
And would translate into three-address stmts;
T1 = r1 + 4
T2 = *T1
r3 = T2
Which would generate into something like;
# begin insn
# read register 1 (hardware nr 0)
mov.l $0, 4(%esp) # hardware number
mov.l $1, 8(%esp) # register number
# add "4" to register
add.l $4, %eax
# read memory
mov.l %eax, 4(%esp) # memory address
# store value in register
mov.l $0, 4(%esp)
mov.l $3, 8(%esp)
mov.l %eax, 12(%esp)
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.
$ ON F$ERROR("LANGUAGE","ENGLISH","IN_MESSAGE").GT.F$ERROR("NORMAL") -