Coder Social home page Coder Social logo

drycpp / machinery Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 1.0 592 KB

[Inactive] Toolchain machinery for compilers, code generators, assemblers, linkers, and emulators.

Home Page: http://machinery.dryproject.org/

License: The Unlicense

Shell 0.07% C++ 88.57% Python 2.80% Common Lisp 0.64% Ruby 0.44% C 7.48%

machinery's Introduction

DRY Machinery

Travis CI build status Coverity Scan build status

Toolchain machinery for compilers, code generators, assemblers, linkers, and emulators.

Features

  • Currently targets the x86-64, ARMv8 AArch64, and MIPS32 architectures.
  • No runtime dependencies other than the system's C++ standard library.
  • No build prerequisites beyond the Autotools toolchain and a C++11 compiler.
  • Compatible with Clang and GCC, or any standard C++11 implementation.
  • 100% free and unencumbered public domain software, usable in any context and for any purpose.

Examples

x86-64 JIT calculator

#include <machinery/arch/x86.h>
#include <machinery/util/buffer.h>

#include <cstdio>  /* for std::printf() */
#include <cstdlib> /* for std::atoi() */

using namespace machinery::arch;
using namespace machinery::arch::x86;
using namespace machinery::util;

int main(int argc, char* argv[]) {
  executable_buffer code;
  x86_emitter<executable_buffer> emit(code);

  /* Function prolog: */
  emit.push(reg64::rbp);
  emit.mov(reg64::rbp, reg64::rsp);

  /* Clear the RAX register: */
  emit.mov(reg64::rax, imm64{0});

  /* For each command-line argument: */
  for (auto i = 1; i < argc; i++) {
    /* Convert the argument to an integer: */
    const int arg = std::atoi(argv[i]);

    /* Add the integer argument to RAX: */
    emit.add(imm32(arg));
  }

  /* Function epilog: */
  emit.pop(reg64::rbp);
  emit.ret();

  /* Execute the code buffer and print out the result: */
  std::printf("%d\n", code.execute<std::int32_t>());

  return EXIT_SUCCESS;
}

Build Prerequisites

Note

Older releases may work, but are not actively tested for.

Installation

Installation on Unix

$ ./autogen.sh
$ ./configure                        # on Linux
$ ./configure --with-stdlib=libc++   # on FreeBSD / Mac OS X
$ make
$ sudo make install
$ sudo ldconfig                      # on Linux

Elsewhere

Find this project at: GitHub, Bitbucket, Ohloh, SourceForge, Travis CI, and Coverity Scan.

Author

This project is part of the DRY initiative.

Donations

If you found this software useful and would like to encourage its maintenance and further development, please consider making a $5 donation to the author(s) via Gratipay or Bitcoin.

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

machinery's People

Contributors

artob avatar

Stargazers

 avatar  avatar Seppo Pakonen avatar Onur Bulut avatar  avatar  avatar  avatar Michael Mior avatar Pawel Cyrta avatar  avatar

Watchers

 avatar James Cloos avatar Dmitry Atamanov avatar

Forkers

ajunlonglive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.