summaryrefslogtreecommitdiff
path: root/examples/BrainF
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:41:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:41:05 +0000
commit01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch)
tree4def12e759965de927d963ac65840d663ef9d1ea /examples/BrainF
parentf0f4822ed4b66e3579e92a89f368f8fb860e218e (diff)
Diffstat (limited to 'examples/BrainF')
-rw-r--r--examples/BrainF/BrainF.cpp20
-rw-r--r--examples/BrainF/BrainF.h9
-rw-r--r--examples/BrainF/BrainFDriver.cpp25
-rw-r--r--examples/BrainF/Makefile15
4 files changed, 41 insertions, 28 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index d8c54b50b8549..97ecdab0fe950 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -1,11 +1,11 @@
-//===-- BrainF.cpp - BrainF compiler example ----------------------------===//
+//===-- BrainF.cpp - BrainF compiler example ------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// This class compiles the BrainF language into LLVM assembly.
//
@@ -21,13 +21,25 @@
// [ while(*h) { Start loop
// ] } End loop
//
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#include "BrainF.h"
-#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/Casting.h"
+#include <cstdlib>
#include <iostream>
using namespace llvm;
diff --git a/examples/BrainF/BrainF.h b/examples/BrainF/BrainF.h
index 15e9e0847141f..587be141b98f0 100644
--- a/examples/BrainF/BrainF.h
+++ b/examples/BrainF/BrainF.h
@@ -1,16 +1,16 @@
-//===-- BrainF.h - BrainF compiler class ----------------------*- C++ -*-===//
+//===-- BrainF.h - BrainF compiler class ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// This class stores the data for the BrainF compiler so it doesn't have
// to pass all of it around. The main method is parse.
//
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#ifndef BRAINF_H
#define BRAINF_H
@@ -18,6 +18,7 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include <istream>
using namespace llvm;
@@ -91,4 +92,4 @@ class BrainF {
Value *curhead;
};
-#endif
+#endif // BRAINF_H
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index 1a38c67b0d4a0..d19427add876a 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -1,11 +1,11 @@
-//===-- BrainFDriver.cpp - BrainF compiler driver -----------------------===//
+//===-- BrainFDriver.cpp - BrainF compiler driver -------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file 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 can then run using the JIT or output as BitCode.
@@ -22,21 +22,37 @@
//
// lli prog.bf.bc #Run generated BitCode
//
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#include "BrainF.h"
+#include "llvm/ADT/APInt.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstdlib>
#include <fstream>
#include <iostream>
+#include <memory>
+#include <string>
+#include <system_error>
+#include <vector>
+
using namespace llvm;
//Command line options
@@ -53,7 +69,6 @@ ArrayBoundsChecking("abc", cl::desc("Enable array bounds checking"));
static cl::opt<bool>
JIT("jit", cl::desc("Run program Just-In-Time"));
-
//Add main function so can be fully compiled
void addMainFunction(Module *mod) {
//define i32 @main(i32 %argc, i8 **%argv)
@@ -88,7 +103,7 @@ void addMainFunction(Module *mod) {
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " BrainF compiler\n");
- LLVMContext &Context = getGlobalContext();
+ LLVMContext Context;
if (InputFilename == "") {
errs() << "Error: You must specify the filename of the program to "
diff --git a/examples/BrainF/Makefile b/examples/BrainF/Makefile
deleted file mode 100644
index 3e36e0761758d..0000000000000
--- a/examples/BrainF/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- examples/BrainF/Makefile ----------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-LEVEL = ../..
-TOOLNAME = BrainF
-EXAMPLE_TOOL = 1
-
-LINK_COMPONENTS := mcjit bitwriter nativecodegen interpreter
-
-include $(LEVEL)/Makefile.common