Lines Matching +full:turing +full:- +full:complete
12 LLVM <index.html>`_" tutorial. Chapters 1-3 described the implementation
101 to make complete decisions about what optimizations to use, in which
107 program). It also supports and includes "per-function" passes which just
117 to run a few per-function optimizations as the user types the function
122 In order to get per-function optimizations going, we need to set up a
123 `FunctionPassManager <../WritingAnLLVMPass.html#what-passmanager-doesr>`_ to hold
130 .. code-block:: c++
136 TheModule->setDataLayout(TheJIT->getTargetMachine().createDataLayout());
143 // Do simple "peephole" optimizations and bit-twiddling optzns.
168 .. code-block:: c++
170 if (Value *RetVal = Body->codegen()) {
178 TheFPM->run(*TheFunction);
204 passes <../Passes.html>`_ is available, but it isn't very complete.
210 Now that we have reasonable code coming out of our front-end, lets talk
225 function bodies as they do now, but immediately evaluate the top-level
234 .. code-block:: c++
256 We can take this simple API and change our code that parses top-level expressions to
259 .. code-block:: c++
262 // Evaluate a top-level expression into an anonymous function.
264 if (FnAST->codegen()) {
268 auto H = TheJIT->addModule(std::move(TheModule));
272 auto ExprSymbol = TheJIT->findSymbol("__anon_expr");
281 TheJIT->removeModule(H);
285 the top-level expression to the JIT. We do this by calling addModule, which
293 the name of the top-level expression function: ``__anon_expr``. Since we just
296 Next, we get the in-memory address of the ``__anon_expr`` function by calling
297 ``getAddress()`` on the symbol. Recall that we compile top-level expressions
298 into a self-contained LLVM function that takes no arguments and returns the
305 Finally, since we don't support re-evaluation of top-level expressions, we
316 Read top-level expression:
326 synthesize for each top-level expression that is typed in. This
341 Read top-level expression:
371 that will make our environment more REPL-like: Functions can be added to the
401 re-generate previous function declarations into each new module we open:
403 .. code-block:: c++
411 if (auto *F = TheModule->getFunction(Name))
418 return FI->second->codegen();
436 FunctionProtos[Proto->getName()] = std::move(Proto);
444 method, ``getFunction()``, to replace calls to ``TheModule->getFunction()``.
448 call to ``TheModule->getFunction()``. In ``FunctionAST::codegen()`` we need to
455 .. code-block:: c++
459 if (auto *FnIR = FnAST->codegen()) {
461 FnIR->dump();
462 TheJIT->addModule(std::move(TheModule));
473 if (auto *FnIR = ProtoAST->codegen()) {
475 FnIR->dump();
476 FunctionProtos[ProtoAST->getName()] = std::move(ProtoAST);
503 Even with this simple code, we get some surprisingly powerful capabilities -
517 Read top-level expression:
538 Read top-level expression:
566 .. code-block:: c++
568 /// putchard - putchar that takes a double and returns 0.
581 tutorial. At this point, we can compile a non-Turing-complete
582 programming language, optimize and JIT compile it in a user-driven way.
590 Here is the complete code listing for our running example, enhanced with
593 .. code-block:: bash
596 …clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -O3 -…
600 If you are compiling this on Linux, make sure to add the "-rdynamic"