[LLVMdev] Re: Use of LLVM in a Machine Simulator.

Vladimir Prus ghost at cs.msu.su
Mon Apr 17 00:06:07 PDT 2006


Ralph Corderoy wrote:

> I'm slowly getting to grips with what makes up LLVM.  I intend to use it
> in a machine simulator, 

Interesting. We have a simulator that we plan to port to LLVM too ;-)

> e.g. processor, clock, RAM, UART, and other 
> devices, where the processor will be one of several.  It would take a
> block of target instructions, e.g. ARM, and produce LLVM to simulate
> those on the target machine state, and then JIT them to host
> instructions and then execute.
> 
> The peripheral simulations would be in C and end up as LLVM too so
> optimisations could occur across the ARM->LLVM/peripheral->LLVM
> boundary.
> 
> Does this sound a good fit so far?

I'm not sure. I would suspect that your peripherals have some internal logic
that's independent from CPU. This means that in order to simulate the whole
system, you need to use some discrete-event simulation engine, where
processor and each peripheral will generate events that will be then
executed in order. With such scheme, I don't think you can do optimization
across ARM->LLVM/peripheral->LLVM boundary. Well, unless your
discrete-event engine is also fully in LLVM, but even then, I'm not sure
there's much potential for optimization.

Maybe, I misunderstood what you're trying to do?

> My main question relates to TableGen and decoding the target
> instructions.  I was initially going to use something specific to the
> task of decoding, e.g. New Jersey Machine Code Toolkit, but wonder if I
> could/should make use of the *.td for the various processors already
> known to LLVM with a new TableGen back-end?  (I know there isn't support
> for ARM yet in LLVM.)  And perhaps the DAG selector is of use in
> matching patterns in ARM instructions to the desired LLVM rather than
> just doing one ARM instruction at a time production?  (For ARM,
> substitute other ISAs, some of which aren't in LLVM.)
> 
> I'm looking for guidance so I avoid a dead-end.

As Chris already mentioned, it does not seem like .td file format is very
suitable for that. It might be better to use some other tool or implement
bit pattern matching manually.

- Volodya




More information about the llvm-dev mailing list