Description
There are a bunch of features we might want to support for arcilator simulations that are a pain to implement in MLIR / LLVM IR directly and should preferably made available by a runtime library. Off the top of my head, this could include:
- Advanced formatted printing (arbitrary width integers, binary formatting, padding, X/Z values)
- Everything involving the file system
- Parsing memory initialization files
- Managing dynamic buffers and containers
- PRNG algorithms and seeding for reproducible random initialization
- Multi-threading (enqueue a series of simulation runs and dispatch them to a thread pool)
We also want these features to be available in JITed runs, so we need to make sure the compiled functions are visible to the execution engine. Depending on the host platform this can get a little messy. The arc-jit-env
library (#8483) was an attempt to compile the current header-only implementation in arcilator-runtime.h
to a shared library.
I've also experimented with a Rust implementation of a runtime library. Admittedly, more out of personal curiosity rather than for technical reasons. Having the Rust Standard Library and cargo available to pull in crates like num_bigint
certainly is nice to get things done quickly. On the other hand we inevitably have to do a fair amount of unsafe pointer ping-pong between the IR model and the runtime, potentially defeating the whole memory safety aspect of Rust. If we were to go for a Rust implementation we'd also have to figure out to what extent we want to isolate it from the rest. Should we keep the sources in-tree or in a separate project? Should it be integrated in the CMake build process?
But first of all, we need a lowering pipeline that can make use of such a library. 😅