<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Good morning everyone,<div><br></div><div>It seems the LLVM tutorial is not up to date anymore and doesn't compile as is...</div><div><br></div><div>The function makeLLVMModule() function doesn't compile at all. Here is a fix:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span style="color: #a05141">Module</span> *makeLLVMModule()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(0, 175, 0); "><span style="color: #000000"> </span>// Caches the global context to share it with new Module() and IntegerType::get() calls</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(160, 81, 65); "><span style="color: #000000"> </span>LLVMContext<span style="color: #000000"> &context = </span>getGlobalContext<span style="color: #000000">();</span></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; min-height: 16.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(0, 175, 0); "><span style="color: #000000"> </span>// Module Construction</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Module</span> *mod = <span style="color: #1700ff">new</span> <span style="color: #a05141">Module</span>(<span style="color: #7a77ac">"test"</span>, context);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; min-height: 16.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(160, 81, 65); "><span style="color: #000000"> </span>Constant<span style="color: #000000"> *c = mod-></span>getOrInsertFunction<span style="color: #000000">(</span><span style="color: #7a77ac">"mul_add"</span><span style="color: #000000">,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(0, 175, 0); "><span style="color: #000000"> </span>// IntegerType::get(context, 32) instead of IntegerType::get(32)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">IntegerType</span>::<span style="color: #00a169">get</span>(context, <span style="color: #7a77ac">32</span>), <span style="color: #00af00">// Return type</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">IntegerType</span>::<span style="color: #00a169">get</span>(context, <span style="color: #7a77ac">32</span>), <span style="color: #00af00">// Arguments</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">IntegerType</span>::<span style="color: #00a169">get</span>(context, <span style="color: #7a77ac">32</span>),</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">IntegerType</span>::<span style="color: #00a169">get</span>(context, <span style="color: #7a77ac">32</span>),</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #1700ff">NULL</span> <span style="color: #00af00">// Varargs terminated with NULL</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> );</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; min-height: 16.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Function</span>* mul_add = cast<<span style="color: #a05141">Function</span>>(c);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> mul_add-><span style="color: #a05141">setCallingConv</span>(CallingConv::<span style="color: #0063a8">C</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Function</span>::<span style="color: #002fff">arg_iterator</span> args = mul_add-><span style="color: #a05141">arg_begin</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Value</span> *x = args++;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> x-><span style="color: #a05141">setName</span>(<span style="color: #7a77ac">"x"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Value</span> *y = args++;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> y-><span style="color: #a05141">setName</span>(<span style="color: #7a77ac">"y"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Value</span> *z = args++;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> z-><span style="color: #a05141">setName</span>(<span style="color: #7a77ac">"z"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(160, 81, 65); "><span style="color: #000000"> </span>BasicBlock<span style="color: #000000"> *block = </span>BasicBlock<span style="color: #000000">::</span>Create<span style="color: #000000">(</span>getGlobalContext<span style="color: #000000">(), </span><span style="color: #7a77ac">"entry"</span><span style="color: #000000">, mul_add);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">IRBuilder</span><> builder(block);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Value</span> *tmp = builder.<span style="color: #a05141">CreateBinOp</span>(<span style="color: #a05141">Instruction</span>::Mul,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> x, y, <span style="color: #7a77ac">"tmp"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #a05141">Value</span> *tmp2 = builder.<span style="color: #a05141">CreateBinOp</span>(<span style="color: #a05141">Instruction</span>::Add,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> tmp, z, <span style="color: #7a77ac">"tmp2"</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; min-height: 16.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> builder.<span style="color: #a05141">CreateRet</span>(tmp2);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; min-height: 16.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "> <span style="color: #1700ff">return</span> mod;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">}</div></div><div><br><div>
<span class="Apple-style-span" style="font-family: 'Comic Sans MS'; font-size: 12px; "><div>__________________________</div><div>Remy Demarest</div><div><a href="mailto:remy.demarest@gmail.com">remy.demarest@gmail.com</a></div><div><br class="webkit-block-placeholder"></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>