# Linux Kernel Module Cheat

#### 24.22.8. gem5 code generation

gem5 uses a ton of code generation, which makes the project horrendous:

- lots of magic happen on top of pybind11, which is already magic, to more automatically glue the C++ and Python worlds: gem5 Python C++ interaction

- .isa code which describes most of the instructions: gem5 instruction definitions

- Ruby for memory systems

To find files that are not symlinks use https://stackoverflow.com/questions/16303449/how-to-find-files-excluding-symbolic-links

    find build -type f

To find the definition of generated code, do a:

    grep -I -r build/ 'code of interest'

where:

- `-I`: ignore binray file matches on built objects

- `-r`: ignore symlinks due to Why are all C++ symlinked into the gem5 build dir? as explained at https://stackoverflow.com/questions/21738574/how-do-you-exclude-symlinks-in-a-grep

The code generation exists partly to support insanely generic cross ISA instructions mapping to one compute model, where it might be reasonable.

But it has been widely overused to insanity. It likely also exists partly because when the project started in 2003 C++ compilers weren’t that good, so you couldn’t rely on features like templates that much.

- gem5 THE_ISA