lunatic is an ARM (32-bit) dynamic recompiler for low-level emulators.

Related tags

Compilers lunatic
Overview

lunatic

license CodeFactor

lunatic is an ARM (32-bit) dynamic recompiler for low-level emulators.
At the moment this is alpha level software and is not ready for general use yet.

General

lunatic currently supports the following guest and host architectures:

Guest architectures

  • ARMv4T
  • ARMv5TE (work in progress)

Host architectures

  • x86_64

AArch64 host support is planned.

Credit

I would like to thank the following people:

for answering my questions (especially related to x86-64) and pointing out bugs and improvements.

Comments
  • Use the Intel VTune JIT Profiling API

    Use the Intel VTune JIT Profiling API

    The library allows the program to send information to VTune about JITted code so that we can profile programs without it losing track of the call stack. See documentation here.

    opened by StrikerX3 1
  • Naïve cycle counting

    Naïve cycle counting

    This makes CPU::Run() return the number of "cycles" (that is, instructions) executed so that user applications that count cycles externally can do their cycle counting. A return value of 0 means that the CPU is halted/waiting for an IRQ. This should not have any impact on existing code.

    opened by StrikerX3 1
  • Allow IRQ wait to be cancelled

    Allow IRQ wait to be cancelled

    This adds the CancelIRQWait() function counterpart to WaitForIRQ() that clears the wait_for_irq flag which is necessary for save state support. Alternatively, we could expose the flag as a reference on WaitForIRQ() and let the user set the value accordingly, but that would break existing code.

    opened by StrikerX3 1
  • Implement Windows-specific aligned_alloc

    Implement Windows-specific aligned_alloc

    Windows does not implement std::aligned_alloc because the requirements for std::free are incompatible with the way the Windows kernel does aligned memory allocations.

    I've implemented memory::aligned_alloc that uses _aligned_malloc on Windows or std::aligned_alloc on other systems. The counterpart is memory::aligned_free, which uses _aligned_free or std::free.

    opened by StrikerX3 1
  • Add option to use externally provided {fmt} library and fix a few warnings

    Add option to use externally provided {fmt} library and fix a few warnings

    Added a CMake option named LUNATIC_USE_EXTERNAL_FMT (OFF by default) to allow users of the library to provide their own {fmt} library.

    These changes also include setting -fbracket-depth=4096 for Clang in the test project as the new default used in the compiler included in VS2019 16.11.0 is too low.

    Also cleaned up a few compilation warnings and fixed the include paths for proper CMake installation.

    opened by StrikerX3 1
  • Block Linking: jump into the next block immediately, if its address is known and it is already compiled.

    Block Linking: jump into the next block immediately, if its address is known and it is already compiled.

    If a basic block jumps to an address that is known at compile-time and that block is already compiled (or can be compiled upfront), then we can jump to that block directly and bypass the expensive block key construction and lookup step.

    codegen 
    opened by fleroviux 1
  • X64Backend: Using cmp to implement cmn results in incorrect flags

    X64Backend: Using cmp to implement cmn results in incorrect flags

    https://github.com/fleroviux/lunatic/blob/538a60f1d6c5bf835a92f7e690558e25f4045be0/src/backend/x86_64/backend.cpp#L481

    Fairly sure this would break for the case of cmn against immediate zero. You could expect a cmn with immediate zero to produce an unset carry flag, unfortunately this code results in a set carry flag.

    opened by merryhime 1
  • Cast enum value to its underlying type for {fmt}

    Cast enum value to its underlying type for {fmt}

    Later versions of {fmt} are more strict with parameters and require an implementation of the formatter for custom types including enum classes/structs. This is the only instance in lunatic where {fmt} complains about unformattable parameters.

    opened by StrikerX3 0
  • More branch optimisations

    More branch optimisations

    • Follow branches to discover and compile blocks early
    • Branch to already compiled blocks immediately if possible
    • Allocate JIT memory from a single, large buffer
    • Other minor cleanups
    opened by fleroviux 0
  • WIP: Implement ARMv6K emulation

    WIP: Implement ARMv6K emulation

    TODO

    • [ ] New ARM instructions
      • [ ] implement Media instructions
        • [ ] Parallel add/sub, signed
        • [ ] Parallel add/sub, unsigned
        • [ ] Packing, unpacking, saturation and reversal
        • [ ] Signed multiply
        • [ ] USAD8
        • [ ] USADA8
      • [ ] implement exclusive monitor instructions (ldrex/strex/clrex)
      • [ ] implement Hint instructions (mainly nop and wfi)
      • [ ] implement UMAAL instruction
      • [ ] implement VFP instructions
    • [ ] New Thumb instructions
      • TODO
    • [ ] implement unaligned memory accesses
    • [ ] rework armv5te flag in lunatic::frontend::Translator
    • ...
    opened by fleroviux 0
  • Distinguish CPU architecture and model.

    Distinguish CPU architecture and model.

    We should distinguish between CPU model (ARM7TDMI-S or ARM946E-S e.g.) and architecture (ARMv4T or ARMv5TE). For example the unaligned LDRSH edge-case is documented as ARMv4T edge-case but it's actually unpredictable and specific to the ARM7TDMI-S.

    documentation codequality 
    opened by fleroviux 0
  • X64Backend: sign flag after BT is undefined

    X64Backend: sign flag after BT is undefined

    In AND, EOR and ORR we use bt to restore the shifter carry flag, but this leaves the sign flag undefined.

    https://www.felixcloutier.com/x86/bt

    The CF flag contains the value of the selected bit. The ZF flag is unaffected. The OF, SF, AF, and PF flags are undefined.

    backend: x64 codegen 
    opened by fleroviux 0
Owner
fleroviux
I like graphics programming and emulators, math and operating systems. She/They
fleroviux
A minimal C-Compiler for my 16-bit RISC Architecture.

A minimal C-Compiler for my 16-bit RISC Architecture.

Mathis 20 Dec 30, 2022
Przemyslaw Skibinski 579 Jan 8, 2023
Lambda code is a new high level compiled statically typed programming language

Lambda code is a new high level compiled statically typed programming language. Written in python, C, C++. Its syntax is far more easier then other middle level compiled languages.

Lambda Code 13 Dec 16, 2022
Legion Low Level Rendering Interface provides a graphics API agnostic rendering interface with minimal CPU overhead and low level access to verbose GPU operations.

Legion-LLRI Legion-LLRI, or “Legion Low Level Rendering Interface” is a rendering API that aims to provide a graphics API agnostic approach to graphic

Rythe Interactive 25 Dec 6, 2022
BokutachiHook - Hook for Lunatic Rave 2 to parse score data and send it to an HTTP server, made specifically for Bokutachi IR.

BokutachiHook Hook for Lunatic Rave 2 to parse score data and send it to an HTTP server, made specifically for Bokutachi IR (https://bokutachi.xyz). T

null 6 Dec 24, 2022
High-level interface for low-level programming

Singeli Singeli is now able to compile useful programs to C, but it's very rough around the edges, with poor error reporting. We are beginning to use

Marshall Lochbaum 40 Dec 30, 2022
A water tank level sensor **Built With WisBlock** to detect overflow and low level conditions.

RAK12014 Laser TOF sensor coming soon WisBlock Watertank Level Sensor Watertank Overflow detection using the RAKwireless WisBlock modules. It implemen

Bernd Giesecke 3 Feb 3, 2022
Provenance - An iOS & tvOS Frontend for Multiple Emulators

iOS & tvOS multi-emulator frontend, supporting various Atari, Bandai, NEC, Nintendo, Sega, SNK and Sony console systems…

Provenance Emu 5.1k Jan 8, 2023
General repository for all software (emulators, dev tools, etc) related to Vircon32 but not running on console itself

Vircon32: Computer software This is a general repository containing source code related to Vircon32 implementation, this is, software that does NOT ru

Vircon32 12 Nov 15, 2022
Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable executables. Has a modern C++ wrapper.

memscan Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable

cristei 15 Oct 2, 2022
Bit-Map is a simple bit map.

Bit-Map Bit-Map is a simple bit map. Usage Create a map uint8** bitmap; uint64 map_size = 32; // bit number pfs_create_bitmap(bitmap,

Pink 2 Feb 18, 2022
A video input (V4L2) to NDI converter that works with Raspberry Pi (32-bit and 64-bit), and Intel/AMD CPUs

V4L2 to NDI V4L2 to NDI is an application that connects to attached V4L2 devices and encodes the video signal into NDI It uses the NDI library, allowi

Luke Plassman 52 Dec 30, 2022
COBS framing with implicit run-length-encoding, optimized for data containing statistically a bit more 0 and FF bytes in a row, as data often carry 16, 32 or 64 bit numbers with small values.

TCOBS Table of Contents About The project TCOBS Specification TCOBS code Getting Started 4.1. Prerequisites 4.2. Installation 4.3. Usage in Go 4.3.1.

Thomas Höhenleitner 17 Nov 6, 2022
Experimental data compressor for 8-bit computers and low-end platforms

ZX5 (experimental) ZX5 is an experimental data compressor derived from ZX0, similarly targeted for low-end platforms, including 8-bit computers like t

Einar Saukas 9 Apr 14, 2022
CC2500 Low-Cost Low-Power 2.4 GHz RF Transceiver driver for esp-idf

esp-idf-cc2500 CC2500 Low-Cost Low-Power 2.4 GHz RF Transceiver driver for esp-idf. I ported from this. 2.00mm pitch External Antena 1.27mm pitch PCB

null 3 May 29, 2022
The bit level data interchange format for serializing data structures.

bitproto Bitproto is a fast, lightweight and easy-to-use bit level data interchange format for serializing data structures. Website: https://bitproto.

Chao Wang 80 Jan 3, 2023
An Arduino library to control 2-bit (4 gray level) LCD displays

TwoBitDisplay (2-bpp LCD library) Project started 10/23/2021 Copyright (c) 2021 BitBank Software, Inc. Written by Larry Bank [email protected] The pur

Larry Bank 8 Mar 21, 2022
FastDynamicCast - Fast dynamic cast in C++ for MSVC, outperforming the regular dynamic cast by up to 25 times

Fast dynamic cast This is a single header, dynamic cast implementation which outperforms the regular dynamic_cast by up to 25 times. Works on MSVC 201

tobspr 85 Oct 23, 2022
A modern cross-platform low-level graphics library and rendering framework

Diligent Engine A Modern Cross-Platform Low-Level 3D Graphics Library Diligent Engine is a lightweight cross-platform graphics API abstraction library

Diligent Graphics 2.6k Dec 30, 2022