<commit_before>petard
======

a js llvm library

        For 'tis the sport to have the enginer
        Hoist with his own petar'...

                    - <NAME>

  * [introduction][90]
  * [dependencies][91]
  * [getting started][92]
  * [documentation][93]
    * [petard types][15]
      * [Type][10]
      * [Value][11]
      * [Builder][12]
      * [FunctionBuilder][13]
      * [CodeUnit][14]
    * [helpers][16]
      * [`type` dict][17]
  * [more information][94]

[![Build Status](https://travis-ci.org/couchand/petard.svg?branch=master)](https://travis-ci.org/couchand/petard)

introduction
------------

Frustrated with the state of JS support for LLVM, I built another library.
Rather than trying to be generic bindings to libLLVM, **petard** tries to make
the most common case easy: generating fresh IR.  You don't have total control
over the LLVM machinery and there aren't really facilities for working with IR
that already exists (so you can't write passes), but if those limitations aren't
a problem **petard** makes dealing with LLVM much simpler.

This software is under active development.  The README should reflect current
functionality, but don't be surprised if something you think should work causes
your computer to segfault.  **petard** aims to catch these things and throw
JavaScript errors, but we don't have very good coverage yet.  Please do submit
a ticket or pull request if there's a type of programmer error that could be
caught earlier and an error thrown.

dependencies
------------

  * a recent version of node
  * nan version 2.1
  * llvm version 3.6

getting started
---------------

First you need to install LLVM version 3.6 on your system, including the dev libs.
Look to the Travis build config for details.

when you're building **petard** you will need to set the environment variable
`LLVM_CONFIG` to be the llvm-config you've installed.  For example, if you're on
Ubuntu and it's `llvm-config-3.6`, you'll type `LLVM_CONFIG=llvm-config-3.6` on
the command line before the `npm i` or `npm run build`.

Once you've got it built successfully, try this:

```coffeescript
llvm = require 'petard'

hello = llvm.createModule "hello"

main = hello.createFunction "main", llvm.type.i32
puts = hello.declareFunction "puts", llvm.type.i32, llvm.type.pointerTo llvm.type.i8

text = hello.constant "Hello, world!\n"

message = main.loadConstant text
main.callFunction puts, message

main.return 0

hello.writeBitcodeToFile "hello.bc"
```

Then use opt and clang as usual with the LLVM IR bitcode file.

documentation<commit_msg>readme: cli env var example<commit_after>petard
======

a js llvm library

        For 'tis the sport to have the enginer
        Hoist with his own petar'...

                    - <NAME>

  * [introduction][90]
  * [dependencies][91]
  * [getting started][92]
  * [documentation][93]
    * [petard types][15]
      * [Type][10]
      * [Value][11]
      * [Builder][12]
      * [FunctionBuilder][13]
      * [CodeUnit][14]
    * [helpers][16]
      * [`type` dict][17]
  * [more information][94]

[![Build Status](https://travis-ci.org/couchand/petard.svg?branch=master)](https://travis-ci.org/couchand/petard)

introduction
------------

Frustrated with the state of JS support for LLVM, I built another library.
Rather than trying to be generic bindings to libLLVM, **petard** tries to make
the most common case easy: generating fresh IR.  You don't have total control
over the LLVM machinery and there aren't really facilities for working with IR
that already exists (so you can't write passes), but if those limitations aren't
a problem **petard** makes dealing with LLVM much simpler.

This software is under active development.  The README should reflect current
functionality, but don't be surprised if something you think should work causes
your computer to segfault.  **petard** aims to catch these things and throw
JavaScript errors, but we don't have very good coverage yet.  Please do submit
a ticket or pull request if there's a type of programmer error that could be
caught earlier and an error thrown.

dependencies
------------

  * a recent version of node
  * nan version 2.1
  * llvm version 3.6

getting started
---------------

First you need to install LLVM version 3.6 on your system, including the dev libs.
Look to the Travis build config for details.

when you're building **petard** you will need to set the environment variable
`LLVM_CONFIG` to be the llvm-config you've installed.  For example, if you're on
Ubuntu where it's isntalled as `llvm-config-3.6`, you'll enter:

    > LLVM_CONFIG=llvm-config-3.6 npm run build

or

    > LLVM_CONFIG=llvm-config-3.6 npm install petard

Once you've got it built successfully, try this:

```coffeescript
llvm = require 'petard'

hello = llvm.createModule "hello"

main = hello.createFunction "main", llvm.type.i32
puts = hello.declareFunction "puts", llvm.type.i32, llvm.type.pointerTo llvm.type.i8

text = hello.constant "Hello, world!\n"

message = main.loadConstant text
main.callFunction puts, message

main.return 0

hello.writeBitcodeToFile "hello.bc"
```

Then use opt and clang as usual with the LLVM IR bitcode file.

documentation
{'fraction_non_alphanumeric': 0.10643229669692872, 'fraction_numerical': 0.016611937415491596, 'mean_word_length': 3.5341506129597198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1822592', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1507, 'n_words': 631}