GithubHelp home page GithubHelp logo

symba's Introduction

symba - The Symbolic Assembler

A ClojureCLR library to metaprogram LLVM bitcode

$ nos symba/demo demo.bc
Compiling to demo.bc:
(symba/module
 [(symba/function
   "one-or-the-other"
   symba.types/i32
   [symba.types/i32 symba.types/i32]
   [(symba/block
     [(symba/br
       (symba/icmp :eq (symba/param 1) (symba/param 0))
       (symba/block
        [(symba/ret (symba/add (symba/param 0) (symba/param 1)))])
       (symba/block [(symba/ret (symba/param 1))]))])])])
$ opt -S demo.bc
; ModuleID = 'demo.bc'

define i32 @one-or-the-other(i32, i32) {
  %3 = icmp eq i32 %1, %0
  br i1 %3, label %4, label %6

; <label>:4:                                      ; preds = %2
  %5 = add i32 %0, %1
  ret i32 %5

; <label>:6:                                      ; preds = %2
  ret i32 %1
}

Status

Very early and not terribly usable yet. Expect everything to change. Watch this space.

It beginnings of a functional representation of LLVM bitcode are in place. symba can generate functions in memory, execute them, and write them to disk.

Usage

symba bundles its LLVM dependencies for OSX but no other OS at the moment. symba is built and run using nostrand. Set nostrand up and run the Clojure/West 2017 demo with nos symba/demo demo.bc as above. Install LLVM for access to the opt command. LLVM is available via homebrew on OSX.

Goal

This is an experiment. Like MAGE does to MSIL, the goal here is to represent LLVM bitcode as a functional data structure to make functional compilers easier to write. This approach makes reasoning about low-level code easier while allowing you to experiment in the REPL as you would in standard Clojure programming. Despite how high level this all is, all of LLVM remains available and is not abstracted in any way.

Another way to think of it is the Terra approach to low-level metaprogramming, but with Clojure instead of Lua.

License

MIT

symba's People

Contributors

nasser avatar

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.