Index: examples/BrainF/BrainF.cpp
===================================================================
--- examples/BrainF/BrainF.cpp	(revision 0)
+++ examples/BrainF/BrainF.cpp	(revision 0)
@@ -0,0 +1,765 @@
+//===-- examples/BrainF/BrainF.cpp - A JIT BrainF compiler example ------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Sterling Stein and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===--------------------------------------------------------------------===//
+//
+// This program converts the BrainF language into LLVM assembly,
+// which it then runs using the JIT.
+//
+// The BrainF language has 8 commands:
+// Command   Equivalent C    Action
+// -------   ------------    ------
+// ,         *h=getchar();   Read a character from stdin, 255 on EOF
+// .         putchar(*h);    Write a character to stdout
+// -         --*h;           Decrement tape
+// +         ++*h;           Increment tape
+// <         --h;            Move head left
+// >         ++h;            Move head right
+// [         while(*h) {     Start loop
+// ]         }               End loop
+//
+// This implementation has a tape of length 65536 consisting of chars,
+// with the head starting in the middle.
+// Range checking is off by default, so be careful.
+// It can be enabled with -a.
+//
+// Use:
+// ./BrainF -mode=jit prog.bf          #Run program now
+// ./BrainF -mode=jit -a prog.bf       #Run program now safely
+// ./BrainF -mode=ll  prog.bf          #Write as LLVM assembly
+// ./BrainF -mode=bc  prog.bc          #Write as BitCode
+//
+// lli prog.bf.bc                      #Run generated BitCode
+// llvm-ld -native -o=prog prog.bf.bc  #Compile BitCode into native executable
+//
+//===--------------------------------------------------------------------===//
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Analysis/Verifier.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/CallingConv.h"
+#include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/Interpreter.h"
+#include "llvm/ExecutionEngine/JIT.h"
+#include "llvm/Instructions.h"
+#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+
+using namespace llvm;
+
+enum CompileMode {
+  mode_LLAsm,
+  mode_BitCode,
+  mode_JIT
+};
+
+//Command line options
+
+static cl::opt<std::string>
+InputFilename(cl::Positional, cl::desc("<input brainf>"));
+
+static cl::opt<std::string>
+OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
+
+static cl::opt<bool>
+ArrayBoundsChecking("a", cl::desc("Enable array bounds checking"));
+
+cl::opt<CompileMode>
+CompileMode("mode",
+  cl::desc("Choose what to compile it to:"),
+  cl::init(mode_LLAsm),
+  cl::values(
+       clEnumValN(mode_LLAsm, "ll",
+                  "  Emit an LLVM assembly ('.ll') file"),
+       clEnumValN(mode_BitCode, "bc",
+                  "  Emit a bit code ('.bc') file"),
+       clEnumValN(mode_JIT, "jit",
+                  "  Run program with JIT compiling"),
+       clEnumValEnd));
+
+/// This class provides a parser for the BrainF language.
+/// The class itself is made to store values during
+/// parsing so they don't have to be passed around
+/// as much.
+class BrainF {
+  public:
+    /// Options for how BrainF should compile
+    enum CompileFlags {
+      flag_off         = 0,
+      flag_arraybounds = 1
+    };
+
+    /// This is the main method.  It parses BrainF from in1
+    /// and returns the module with a function
+    /// void brainf()
+    /// containing the resulting code.
+    /// On error, it calls abort.
+    /// The caller must delete the returned module.
+    Module *parse(std::istream *in1, int mem, CompileFlags cf);
+
+  protected:
+    /// The different symbols in the BrainF language
+    enum Symbol {
+      SYM_NONE,
+      SYM_READ,
+      SYM_WRITE,
+      SYM_MOVE,
+      SYM_CHANGE,
+      SYM_LOOP,
+      SYM_ENDLOOP,
+      SYM_EOF
+    };
+
+    /// Names of the different parts of the language.
+    /// Tape is used for reading and writing the tape.
+    /// headreg is used for the position of the head.
+    /// label is used for the labels for the BasicBlocks.
+    /// testreg is used for testing the loop exit condition.
+    static const char *tapereg;
+    static const char *headreg;
+    static const char *label;
+    static const char *testreg;
+
+    /// Put the brainf function preamble and other fixed pieces of code
+    void header();
+
+    /// The main loop for parsing.  It calls itself recursively
+    /// to handle the depth of nesting of "[]".
+    void readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb);
+
+    /// Constants during parsing
+    int memtotal;
+    CompileFlags comflag;
+    std::istream *in;
+    Module *module;
+    Function *brainf_func;
+    Function *getchar_func;
+    Function *putchar_func;
+    Value *ptr_arr;
+    Value *ptr_arrmax;
+    BasicBlock *endbb;
+    BasicBlock *aberrorbb;
+
+    /// Variables
+    BasicBlock *curbb;
+    Value *curhead;
+};
+
+//Set the constants from the class
+const char *BrainF::tapereg = "tape";
+const char *BrainF::headreg = "head";
+const char *BrainF::label   = "brainf";
+const char *BrainF::testreg = "test";
+
+Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf) {
+  in       = in1;
+  memtotal = mem;
+  comflag  = cf;
+
+  header();
+  readloop(0, 0, 0);
+  return module;
+}
+
+void BrainF::header() {
+  module = new Module("BrainF");
+
+  //Function prototypes
+
+  //declare void @llvm.memset.i32(i8 *, i8, i32, i32)
+  Function *memset_func;
+  {
+    const Type *memset_args[] = {
+      PointerType::get(IntegerType::Int8Ty),
+      IntegerType::Int8Ty,
+      IntegerType::Int32Ty,
+      IntegerType::Int32Ty
+    };
+    FunctionType *memset_type = FunctionType::
+      get(Type::VoidTy,
+          std::vector<const Type *>(memset_args, array_endof(memset_args)),
+          false, 0);
+    memset_func = new Function(memset_type, GlobalValue::ExternalLinkage,
+                               "llvm.memset.i32", module);
+    memset_func->setCallingConv(CallingConv::C);
+  }
+
+  //declare i32 @getchar()
+  {
+    std::vector<const Type *>getchar_args;
+    FunctionType *getchar_type = FunctionType::
+      get(IntegerType::Int32Ty, getchar_args, false, 0);
+    getchar_func = new Function(getchar_type, GlobalValue::ExternalLinkage,
+                                "getchar", module);
+    getchar_func->setCallingConv(CallingConv::C);
+  }
+
+  //declare i32 @putchar(i32)
+  {
+    const Type *putchar_args[] = {
+      IntegerType::Int32Ty
+    };
+    FunctionType *putchar_type = FunctionType::
+      get(IntegerType::Int32Ty,
+          std::vector<const Type *>(putchar_args, array_endof(putchar_args)),
+          false, 0);
+    putchar_func = new Function(putchar_type, GlobalValue::ExternalLinkage,
+                                "putchar", module);
+    putchar_func->setCallingConv(CallingConv::C);
+  }
+
+  //Function header
+
+  //define void @brainf()
+  {
+    std::vector<const Type *>main_args;
+    FunctionType *main_type = FunctionType::
+      get(Type::VoidTy, main_args, false, 0);
+    brainf_func = new Function(main_type, GlobalValue::ExternalLinkage,
+                               "brainf", module);
+    brainf_func->setCallingConv(CallingConv::C);
+  }
+
+  curbb = new BasicBlock(label, brainf_func);
+
+  //%arr = malloc i8, i32 %d
+  ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
+  ptr_arr = new MallocInst(IntegerType::Int8Ty, val_mem, "arr", curbb);
+
+  //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
+  {
+    Value *memset_params[] = {
+      ptr_arr,
+      ConstantInt::get(APInt(8, 0)),
+      val_mem,
+      ConstantInt::get(APInt(32, 1))
+    };
+    CallInst *memset_call = new CallInst(memset_func, memset_params,
+                                         array_endof(memset_params),
+                                         "", curbb);
+    memset_call->setCallingConv(CallingConv::C);
+    memset_call->setTailCall(false);
+  }
+
+  //%arrmax = getelementptr i8 *%arr, i32 %d
+  if (comflag & flag_arraybounds) {
+    ptr_arrmax = new GetElementPtrInst(ptr_arr,
+                                       ConstantInt::get(APInt(32, memtotal)),
+                                       "arrmax", curbb);
+  }
+
+  //%head.%d = getelementptr i8 *%arr, i32 %d
+  {
+    curhead = new GetElementPtrInst(ptr_arr,
+      ConstantInt::get(APInt(32, memtotal/2)), headreg, curbb);
+  }
+
+
+
+  //Function footer
+
+  //brainf.end:
+  endbb = new BasicBlock(label, brainf_func);
+
+  //free i8 *%arr
+  new FreeInst(ptr_arr, endbb);
+
+  //ret void
+  new ReturnInst(endbb);
+
+
+
+  //Error block for array out of bounds
+  if (comflag & flag_arraybounds)
+  {
+    //@aberrormsg = internal constant [%d x i8] c"\00"
+    GlobalVariable *aberrormsg;
+    {
+      aberrormsg = new GlobalVariable(
+        ArrayType::get(IntegerType::Int8Ty, 35),
+        true,
+        GlobalValue::InternalLinkage,
+        0,
+        "aberrormsg",
+        module);
+
+      Constant *msg_0 = ConstantArray::
+        get("Error: The head has left the tape.", true);
+
+      aberrormsg->setInitializer(msg_0);
+    }
+
+    //declare i32 @puts(i8 *)
+    Function *puts_func;
+    {
+      const Type *puts_args[] = {
+        PointerType::get(IntegerType::Int8Ty)
+      };
+      FunctionType *puts_type = FunctionType::
+        get(IntegerType::Int32Ty,
+            std::vector<const Type *>(puts_args, array_endof(puts_args)),
+            false, 0);
+      puts_func = new Function(puts_type, GlobalValue::ExternalLinkage,
+                               "puts", module);
+      puts_func->setCallingConv(CallingConv::C);
+    }
+
+    //brainf.aberror:
+    aberrorbb = new BasicBlock(label, brainf_func);
+
+    //call i32 @puts(i8 *getelementptr([%d x i8] *@aberrormsg, i32 0, i32 0))
+    {
+      Constant *zero_32 = Constant::getNullValue(IntegerType::Int32Ty);
+
+      Constant *gep_params[] = {
+        zero_32,
+        zero_32
+      };
+
+      Constant *msgptr = ConstantExpr::
+        getGetElementPtr(aberrormsg, gep_params,
+                         array_lengthof(gep_params));
+
+      Value *puts_params[] = {
+        msgptr
+      };
+
+      CallInst *puts_call =
+        new CallInst(puts_func,
+                     puts_params, array_endof(puts_params),
+                     "", aberrorbb);
+      puts_call->setCallingConv(CallingConv::C);
+      puts_call->setTailCall(false);
+    }
+
+    //br label %brainf.end
+    new BranchInst(endbb, aberrorbb);
+} }
+
+void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
+  Symbol cursym = SYM_NONE;
+  int curvalue = 0;
+  Symbol nextsym = SYM_NONE;
+  int nextvalue = 0;
+  char c;
+  int loop;
+  int direction;
+
+  while(cursym != SYM_EOF && cursym != SYM_ENDLOOP) {
+    // Write out commands
+    switch(cursym) {
+      case SYM_NONE:
+        // Do nothing
+        break;
+
+      case SYM_READ:
+        {
+          //%tape.%d = call i32 @getchar()
+          CallInst *getchar_call = new CallInst(getchar_func, tapereg, curbb);
+          getchar_call->setCallingConv(CallingConv::C);
+          getchar_call->setTailCall(false);
+          Value *tape_0 = getchar_call;
+
+          //%tape.%d = trunc i32 %tape.%d to i8
+          TruncInst *tape_1 = new TruncInst(tape_0, IntegerType::Int8Ty,
+                                            tapereg, curbb);
+
+          //store i8 %tape.%d, i8 *%head.%d
+          new StoreInst(tape_1, curhead, curbb);
+        }
+        break;
+
+      case SYM_WRITE:
+        {
+          //%tape.%d = load i8 *%head.%d
+          LoadInst *tape_0 = new LoadInst(curhead, tapereg, curbb);
+
+          //%tape.%d = sext i8 %tape.%d to i32
+          SExtInst *tape_1 = new SExtInst(tape_0, IntegerType::Int32Ty,
+                                          tapereg, curbb);
+
+          //call i32 @putchar(i32 %tape.%d)
+          Value *putchar_params[] = {
+            tape_1
+          };
+          CallInst *putchar_call =
+            new CallInst(putchar_func,
+                         putchar_params, array_endof(putchar_params),
+                         "", curbb);
+          putchar_call->setCallingConv(CallingConv::C);
+          putchar_call->setTailCall(false);
+        }
+        break;
+
+      case SYM_MOVE:
+        {
+          //%head.%d = getelementptr i8 *%head.%d, i32 %d
+          curhead = new
+            GetElementPtrInst(curhead, ConstantInt::get(APInt(32, curvalue)),
+                              headreg, curbb);
+
+          //Error block for array out of bounds
+          if (comflag & flag_arraybounds)
+          {
+            //%test.%d = icmp uge i8 *%head.%d, %arrmax
+            ICmpInst *test_0 = new ICmpInst(ICmpInst::ICMP_UGE, curhead,
+                                            ptr_arrmax, testreg, curbb);
+
+            //%test.%d = icmp ult i8 *%head.%d, %arr
+            ICmpInst *test_1 = new ICmpInst(ICmpInst::ICMP_ULT, curhead,
+                                            ptr_arr, testreg, curbb);
+
+            //%test.%d = or i1 %test.%d, %test.%d
+            BinaryOperator *test_2 = BinaryOperator::
+              create(Instruction::Or, test_0, test_1, testreg, curbb);
+
+            //br i1 %test.%d, label %main.%d, label %main.%d
+            BasicBlock *nextbb = new BasicBlock(label, brainf_func);
+            new BranchInst(aberrorbb, nextbb, test_2, curbb);
+
+            //main.%d:
+            curbb = nextbb;
+        } }
+        break;
+
+      case SYM_CHANGE:
+        {
+          //%tape.%d = load i8 *%head.%d
+          LoadInst *tape_0 = new LoadInst(curhead, tapereg, curbb);
+
+          //%tape.%d = add i8 %tape.%d, %d
+          BinaryOperator *tape_1 = BinaryOperator::
+            create(Instruction::Add, tape_0,
+                   ConstantInt::get(APInt(8, curvalue)), tapereg, curbb);
+
+          //store i8 %tape.%d, i8 *%head.%d\n"
+          new StoreInst(tape_1, curhead, curbb);
+        }
+        break;
+
+      case SYM_LOOP:
+        {
+          //br label %main.%d
+          BasicBlock *testbb = new BasicBlock(label, brainf_func);
+          new BranchInst(testbb, curbb);
+
+          //main.%d:
+          BasicBlock *bb_0 = curbb;
+          curbb = new BasicBlock(label, brainf_func);
+
+          //Make part of PHI instruction now, wait until end of loop to finish
+          PHINode *phi_0 = new PHINode(PointerType::get(IntegerType::Int8Ty),
+                                       headreg, testbb);
+          phi_0->reserveOperandSpace(1);
+          phi_0->addIncoming(curhead, bb_0);
+          curhead = phi_0;
+
+          readloop(phi_0, curbb, testbb);
+        }
+        break;
+
+      default:
+        cerr<<"Error: Unknown symbol.\n";
+        abort();
+        break;
+    }
+
+    cursym = nextsym;
+    curvalue = nextvalue;
+    nextsym = SYM_NONE;
+
+    // Reading stdin loop
+    loop = (cursym == SYM_NONE)
+        || (cursym == SYM_MOVE)
+        || (cursym == SYM_CHANGE);
+    while(loop) {
+      *in>>c;
+      if (in->eof()) {
+        if (cursym == SYM_NONE) {
+          cursym = SYM_EOF;
+        } else {
+          nextsym = SYM_EOF;
+        }
+        loop = 0;
+      } else {
+        direction = 1;
+        switch(c) {
+          case '-':
+            direction = -1;
+            // Fall through
+
+          case '+':
+            if (cursym == SYM_CHANGE) {
+              curvalue += direction;
+              // loop = 1
+            } else {
+              if (cursym == SYM_NONE) {
+                cursym = SYM_CHANGE;
+                curvalue = direction;
+                // loop = 1
+              } else {
+                nextsym = SYM_CHANGE;
+                nextvalue = direction;
+                loop = 0;
+            } }
+            break;
+
+          case '<':
+            direction = -1;
+            // Fall through
+
+          case '>':
+            if (cursym == SYM_MOVE) {
+              curvalue += direction;
+              // loop = 1
+            } else {
+              if (cursym == SYM_NONE) {
+                cursym = SYM_MOVE;
+                curvalue = direction;
+                // loop = 1
+              } else {
+                nextsym = SYM_MOVE;
+                nextvalue = direction;
+                loop = 0;
+            } }
+            break;
+
+          case ',':
+            if (cursym == SYM_NONE) {
+              cursym = SYM_READ;
+            } else {
+              nextsym = SYM_READ;
+            }
+            loop = 0;
+            break;
+
+          case '.':
+            if (cursym == SYM_NONE) {
+              cursym = SYM_WRITE;
+            } else {
+              nextsym = SYM_WRITE;
+            }
+            loop = 0;
+            break;
+
+          case '[':
+            if (cursym == SYM_NONE) {
+              cursym = SYM_LOOP;
+            } else {
+              nextsym = SYM_LOOP;
+            }
+            loop = 0;
+            break;
+
+          case ']':
+            if (cursym == SYM_NONE) {
+              cursym = SYM_ENDLOOP;
+            } else {
+              nextsym = SYM_ENDLOOP;
+            }
+            loop = 0;
+            break;
+
+          // Ignore other characters
+          default:
+            break;
+  } } } }
+
+  if (cursym == SYM_ENDLOOP) {
+    if (!phi) {
+      cerr<<"Error: Extra ']'\n";
+      abort();
+    }
+
+    // Write loop test
+    {
+      //br label %main.%d
+      new BranchInst(testbb, curbb);
+
+      //main.%d:
+
+      //%head.%d = phi i8 *[%head.%d, %main.%d], [%head.%d, %main.%d]
+      //Finish phi made at beginning of loop
+      phi->addIncoming(curhead, curbb);
+      Value *head_0 = phi;
+
+      //%tape.%d = load i8 *%head.%d
+      LoadInst *tape_0 = new LoadInst(head_0, tapereg, testbb);
+
+      //%test.%d = icmp eq i8 %tape.%d, 0
+      ICmpInst *test_0 = new ICmpInst(ICmpInst::ICMP_EQ, tape_0,
+                                      ConstantInt::get(APInt(8, 0)), testreg,
+                                      testbb);
+
+      //br i1 %test.%d, label %main.%d, label %main.%d
+      curbb = new BasicBlock(label, brainf_func);
+      new BranchInst(curbb, oldbb, test_0, testbb);
+
+      //main.%d:
+
+      //%head.%d = phi i8 *[%head.%d, %main.%d]
+      PHINode *phi_1 = new PHINode(PointerType::get(IntegerType::Int8Ty),
+                                   headreg, curbb);
+      phi_1->reserveOperandSpace(1);
+      phi_1->addIncoming(head_0, testbb);
+      curhead = phi_1;
+    }
+
+    return;
+  }
+
+  //End of the program, so go to return block
+  new BranchInst(endbb, curbb);
+
+  if (phi) {
+    cerr<<"Error: Missing ']'\n";
+    abort();
+} }
+
+//Add main function so can be fully compiled
+void addMainFunction(Module *mod) {
+  //define i32 @main(i32 %argc, i8 **%argv)
+  Function *main_func;
+  {
+    const Type *main_args[] = {
+      IntegerType::Int32Ty,
+      PointerType::get(PointerType::get(IntegerType::Int8Ty))
+    };
+    FunctionType *main_type = FunctionType::
+      get(IntegerType::Int32Ty,
+          std::vector<const Type *>(main_args, array_endof(main_args)),
+                                    false, 0);
+    main_func = new Function(main_type, GlobalValue::ExternalLinkage,
+                             "main", mod);
+    main_func->setCallingConv(CallingConv::C);
+
+    Function::arg_iterator args = main_func->arg_begin();
+    Value *arg_0 = args++;
+    arg_0->setName("argc");
+    Value *arg_1 = args++;
+    arg_1->setName("argv");
+  }
+
+  //main.0:
+  BasicBlock *bb = new BasicBlock("main.0", main_func);
+
+  //call void @brainf()
+  {
+    CallInst *brainf_call = new CallInst(mod->getFunction("brainf"),
+                                         "", bb);
+    brainf_call->setCallingConv(CallingConv::C);
+    brainf_call->setTailCall(false);
+  }
+
+  //ret i32 0
+  new ReturnInst(ConstantInt::get(APInt(32, 0)), bb);
+}
+
+int main(int argc, char **argv) {
+  cl::ParseCommandLineOptions(argc, argv, " BrainF compiler\n");
+
+  if (InputFilename == "") {
+    cerr<<"Error: You must specify the filename of the program to "
+          "be compiled.  Use --help to see the options.\n";
+    abort();
+  }
+
+  //Get the output stream
+  std::ostream *out = &std::cout;
+  if (CompileMode != mode_JIT) {
+    if (OutputFilename == "") {
+      std::string base = InputFilename;
+      if (InputFilename == "-") {base = "a";}
+
+      //Use default filename
+      const char *suffix = "";
+      switch(CompileMode) {
+        case mode_LLAsm:
+          suffix = ".ll";
+          break;
+
+        case mode_BitCode:
+          suffix = ".bc";
+          break;
+
+        default:
+          //No suffix
+          break;
+      }
+      OutputFilename = base+suffix;
+    }
+    if (OutputFilename != "-") {
+      out = new std::
+        ofstream(OutputFilename.c_str(),
+                 std::ios::out | std::ios::trunc | std::ios::binary);
+  } }
+
+  //Get the input stream
+  std::istream *in = &std::cin;
+  if (InputFilename != "-") {
+    in = new std::ifstream(InputFilename.c_str());
+  }
+
+  //Gather the compile flags
+  BrainF::CompileFlags cf = BrainF::flag_off;
+  if (ArrayBoundsChecking) {
+    cf = BrainF::CompileFlags(cf | BrainF::flag_arraybounds);
+  }
+
+  //Read the BrainF program
+  BrainF bf;
+  Module *mod = bf.parse(in, 65536, cf); //64 KiB
+  if (in != &std::cin) {delete in;}
+  addMainFunction(mod);
+
+  //Verify generated code
+  if (verifyModule(*mod)) {
+    cerr<<"Error: module failed verification.  This shouldn't happen.\n";
+    abort();
+  }
+
+  //Write it out
+  switch(CompileMode) {
+    case mode_LLAsm:
+      *out<<*mod;
+      break;
+
+    case mode_BitCode:
+      WriteBitcodeToFile(mod, *out);
+      break;
+
+    case mode_JIT:
+      {
+        cout<<"------- Running JIT -------\n";
+        ExistingModuleProvider *mp = new ExistingModuleProvider(mod);
+        ExecutionEngine *ee = ExecutionEngine::create(mp, false);
+        std::vector<GenericValue> args;
+        Function *brainf_func = mod->getFunction("brainf");
+        GenericValue gv = ee->runFunction(brainf_func, args);
+      }
+      break;
+
+    default:
+      cerr<<"Error: Unknown mode.  Use --help for a listing.\n";
+      abort();
+  }
+
+  //Clean up
+  if (out != &std::cout) {delete out;}
+  delete mod;
+
+  llvm_shutdown();
+
+  return 0;
+}
Index: examples/BrainF/Makefile
===================================================================
--- examples/BrainF/Makefile	(revision 0)
+++ examples/BrainF/Makefile	(revision 0)
@@ -0,0 +1,15 @@
+##===- examples/HowToUseJIT/Makefile -----------------------*- Makefile -*-===##
+# 
+#                     The LLVM Compiler Infrastructure
+#
+# This file was developed by Sterling Stein and is distributed under
+# the University of Illinois Open Source License. See LICENSE.TXT for details.
+# 
+##===----------------------------------------------------------------------===##
+LEVEL = ../..
+TOOLNAME = BrainF
+EXAMPLE_TOOL = 1
+
+LINK_COMPONENTS := jit interpreter native bitwriter linker
+
+include $(LEVEL)/Makefile.common
Index: examples/Makefile
===================================================================
--- examples/Makefile	(revision 41744)
+++ examples/Makefile	(working copy)
@@ -10,7 +10,7 @@
 
 include $(LEVEL)/Makefile.config
 
-PARALLEL_DIRS:= Fibonacci HowToUseJIT ModuleMaker
+PARALLEL_DIRS:= BrainF Fibonacci HowToUseJIT ModuleMaker
 
 ifeq ($(HAVE_PTHREAD),1)
 PARALLEL_DIRS += ParallelJIT 
