blob: 154b462e499cfcff5af1e93e1c4ea240345aea7e [file] [log] [blame]
Chris Lattnerc0b42e92007-10-23 06:27:55 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3
4<html>
5<head>
6 <title>Kaleidoscope: Adding JIT and Optimizer Support</title>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8 <meta name="author" content="Chris Lattner">
9 <link rel="stylesheet" href="../llvm.css" type="text/css">
10</head>
11
12<body>
13
14<div class="doc_title">Kaleidoscope: Adding JIT and Optimizer Support</div>
15
16<div class="doc_author">
17 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a></p>
18</div>
19
20<!-- *********************************************************************** -->
21<div class="doc_section"><a name="intro">Part 4 Introduction</a></div>
22<!-- *********************************************************************** -->
23
24<div class="doc_text">
25
26<p>Welcome to part 4 of the "<a href="index.html">Implementing a language with
27LLVM</a>" tutorial.</p>
28
29</div>
30
31<!-- *********************************************************************** -->
32<div class="doc_section"><a name="basics">Code Generation setup</a></div>
33<!-- *********************************************************************** -->
34
35<div class="doc_text">
36
37<p>
38In order to generate LLVM IR, we want some simple setup to get started. First,
39we define virtual codegen methods in each AST class:</p>
40
41<div class="doc_code">
42<pre>
43/// ExprAST - Base class for all expression nodes.
44class ExprAST {
45public:
46 virtual ~ExprAST() {}
47 virtual Value *Codegen() = 0;
48};
49
50/// NumberExprAST - Expression class for numeric literals like "1.0".
51class NumberExprAST : public ExprAST {
52 double Val;
53public:
54 explicit NumberExprAST(double val) : Val(val) {}
55 virtual Value *Codegen();
56};
57...
58</pre>
59</div>
60
61
62
63</div>
64
65<!-- *********************************************************************** -->
66<hr>
67<address>
68 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
69 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
70 <a href="http://validator.w3.org/check/referer"><img
Chris Lattner8eef4b22007-10-23 06:30:50 +000071 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
Chris Lattnerc0b42e92007-10-23 06:27:55 +000072
73 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
74 <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
75 Last modified: $Date: 2007-10-17 11:05:13 -0700 (Wed, 17 Oct 2007) $
76</address>
77</body>
78</html>