mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-09-11 19:47:31 +03:00
commit 41ba8c36a90cc11723b14ce6c45599eabdcfaa53 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 21:02:57 2015 -0500 type provenance commit be5eda941bb4c44b4c4af0ddbbd793643938f4ff Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 20:13:06 2015 -0500 provenance prototype commit 7aa958b9c279e7571f7c4887f6aa19443e16f6fb Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 19:35:08 2015 -0500 fix misc typos commit 52d60b3b2630e50ef0cd6ea5f0fa1f308d92e26d Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 15:15:58 2015 -0500 license badge commit 7d34274afe6f05a0002c8f87e5077b6a130b42b4 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 15:07:28 2015 -0500 fix resolution for llvm cfg graphs commit 14d9bc836ecc64f8e9acc60bcbd2da02335255b9 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 13:12:39 2015 -0500 added codegen dsl stub commit 0f74cdd6f95d0a1fe1cafd73e45cb1407709efd8 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 13:01:14 2015 -0500 llvm cfg graphs commit a199d721503985954060e7670c1d2f5e1a65dd11 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 10:56:54 2015 -0500 source code font commit c7db0c5d67b73d8633f08be093971877e2d6ede0 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sun Jan 18 09:59:37 2015 -0500 change phrasing around recursion commit 6903700db482524233262e722df54b1066218250 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sat Jan 17 18:20:06 2015 -0500 contributors.md commit 14d90a3f2ebf7ddf1229c084fe4a1e9fa13f2e41 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sat Jan 17 17:35:41 2015 -0500 added llvm logo commit d270df6d94cbf1ef9eddfdd64af5aabc36ebca72 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sat Jan 17 15:50:28 2015 -0500 initial llvm chapter commit e71b189c057ea9e399e90e47d9d49bb4cf12cda8 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Sat Jan 17 12:21:00 2015 -0500 system-f typing rules commit 2a7d5c7f137cf352eeae64836df634c98118f594 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Thu Jan 15 15:21:14 2015 -0500 flesh out system-f commit 7b3b2f0a2aea5e1102abe093cf5e0559090720aa Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Wed Jan 14 22:22:14 2015 -0500 started on extended parser commit cdeaf1a2658f15346fe1dc665ca09e954cce6c2e Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Wed Jan 14 17:25:02 2015 -0500 creative commons license commit f09d210be253a05fc8ad0827cd72ffa32404e2ba Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Wed Jan 14 16:54:10 2015 -0500 higher res images commit 8555eadfea8843f5683621e6652857e4259fa896 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Wed Jan 14 14:48:44 2015 -0500 cover page commit e5e542e92610f4bb4c5ac726ffa86cd1e07753e3 Author: Stephen Diehl <stephen.m.diehl@gmail.com> Date: Tue Jan 13 17:31:01 2015 -0500 initial happy/alex parser
94 lines
2.5 KiB
C++
94 lines
2.5 KiB
C++
// Generated by llvm2cpp - DO NOT MODIFY!
|
|
|
|
#include <llvm/LLVMContext.h>
|
|
#include <llvm/Module.h>
|
|
#include <llvm/DerivedTypes.h>
|
|
#include <llvm/Constants.h>
|
|
#include <llvm/GlobalVariable.h>
|
|
#include <llvm/Function.h>
|
|
#include <llvm/CallingConv.h>
|
|
#include <llvm/BasicBlock.h>
|
|
#include <llvm/Instructions.h>
|
|
#include <llvm/InlineAsm.h>
|
|
#include <llvm/Support/FormattedStream.h>
|
|
#include <llvm/Support/MathExtras.h>
|
|
#include <llvm/Pass.h>
|
|
#include <llvm/PassManager.h>
|
|
#include <llvm/ADT/SmallVector.h>
|
|
#include <llvm/Analysis/Verifier.h>
|
|
#include <llvm/Assembly/PrintModulePass.h>
|
|
#include <algorithm>
|
|
using namespace llvm;
|
|
|
|
Module* makeLLVMModule();
|
|
|
|
int main(int argc, char**argv) {
|
|
Module* Mod = makeLLVMModule();
|
|
verifyModule(*Mod, PrintMessageAction);
|
|
PassManager PM;
|
|
PM.add(createPrintModulePass(&outs()));
|
|
PM.run(*Mod);
|
|
return 0;
|
|
}
|
|
|
|
|
|
Module* makeLLVMModule() {
|
|
// Module Construction
|
|
Module* mod = new Module("example.ll", getGlobalContext());
|
|
|
|
// Type Definitions
|
|
std::vector<Type*>FuncTy_0_args;
|
|
FuncTy_0_args.push_back(IntegerType::get(mod->getContext(), 32));
|
|
FuncTy_0_args.push_back(IntegerType::get(mod->getContext(), 32));
|
|
FuncTy_0_args.push_back(IntegerType::get(mod->getContext(), 32));
|
|
FunctionType* FuncTy_0 = FunctionType::get(
|
|
/*Result=*/IntegerType::get(mod->getContext(), 32),
|
|
/*Params=*/FuncTy_0_args,
|
|
/*isVarArg=*/false);
|
|
|
|
|
|
// Function Declarations
|
|
|
|
Function* func_test1 = mod->getFunction("test1");
|
|
if (!func_test1) {
|
|
func_test1 = Function::Create(
|
|
/*Type=*/FuncTy_0,
|
|
/*Linkage=*/GlobalValue::ExternalLinkage,
|
|
/*Name=*/"test1", mod);
|
|
func_test1->setCallingConv(CallingConv::C);
|
|
}
|
|
AttrListPtr func_test1_PAL;
|
|
func_test1->setAttributes(func_test1_PAL);
|
|
|
|
// Global Variable Declarations
|
|
|
|
|
|
// Constant Definitions
|
|
|
|
// Global Variable Definitions
|
|
|
|
// Function Definitions
|
|
|
|
// Function: test1 (func_test1)
|
|
{
|
|
Function::arg_iterator args = func_test1->arg_begin();
|
|
Value* int32_x = args++;
|
|
int32_x->setName("x");
|
|
Value* int32_y = args++;
|
|
int32_y->setName("y");
|
|
Value* int32_z = args++;
|
|
int32_z->setName("z");
|
|
|
|
BasicBlock* label_1 = BasicBlock::Create(mod->getContext(), "",func_test1,0);
|
|
|
|
// Block (label_1)
|
|
BinaryOperator* int32_a = BinaryOperator::Create(Instruction::And, int32_z, int32_x, "a", label_1);
|
|
BinaryOperator* int32_b = BinaryOperator::Create(Instruction::And, int32_z, int32_y, "b", label_1);
|
|
BinaryOperator* int32_c = BinaryOperator::Create(Instruction::Xor, int32_a, int32_b, "c", label_1);
|
|
ReturnInst::Create(mod->getContext(), int32_c, label_1);
|
|
|
|
}
|
|
|
|
return mod;
|
|
}
|