wasmer/rustdoc/inkwell/builder/struct.Builder.html

418 lines
165 KiB
HTML
Raw Normal View History

2019-09-06 15:57:44 -07:00
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Builder` struct in crate `inkwell`."><meta name="keywords" content="rust, rustlang, rust-lang, Builder"><title>inkwell::builder::Builder - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../inkwell/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Struct Builder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.build_address_space_cast">build_address_space_cast</a><a href="#method.build_aggregate_return">build_aggregate_return</a><a href="#method.build_alloca">build_alloca</a><a href="#method.build_and">build_and</a><a href="#method.build_array_alloca">build_array_alloca</a><a href="#method.build_array_malloc">build_array_malloc</a><a href="#method.build_atomicrmw">build_atomicrmw</a><a href="#method.build_bitcast">build_bitcast</a><a href="#method.build_call">build_call</a><a href="#method.build_cast">build_cast</a><a href="#method.build_cmpxchg">build_cmpxchg</a><a href="#method.build_conditional_branch">build_conditional_branch</a><a href="#method.build_extract_element">build_extract_element</a><a href="#method.build_extract_value">build_extract_value</a><a href="#method.build_fence">build_fence</a><a href="#method.build_float_add">build_float_add</a><a href="#method.build_float_cast">build_float_cast</a><a href="#method.build_float_compare">build_float_compare</a><a href="#method.build_float_div">build_float_div</a><a href="#method.build_float_ext">build_float_ext</a><a href="#method.build_float_mul">build_float_mul</a><a href="#method.build_float_neg">build_float_neg</a><a href="#method.build_float_rem">build_float_rem</a><a href="#method.build_float_sub">build_float_sub</a><a href="#method.build_float_to_signed_int">build_float_to_signed_int</a><a href="#method.build_float_to_unsigned_int">build_float_to_unsigned_int</a><a href="#method.build_float_trunc">build_float_trunc</a><a href="#method.build_free">build_free</a><a href="#method.build_gep">build_gep</a><a href="#method.build_global_string">build_global_string</a><a href="#method.build_global_string_ptr">build_global_string_ptr</a><a href="#method.build_in_bounds_gep">build_in_bounds_gep</a><a href="#method.build_indirect_branch">build_indirect_branch</a><a href="#method.build_insert_element">build_insert_element</a><a href="#method.build_insert_value">build_insert_value</a><a href="#method.build_int_add">build_int_add</a><a href="#method.build_int_cast">build_int_cast</a><a href="#method.build_int_compare">build_int_compare</a><a href="#method.build_int_exact_signed_div">build_int_exact_signed_div</a><a href="#method.build_int_mul">build_int_mul</a><a href="#method.build_int_neg">build_int_neg</a><a href="#method.build_int_nsw_add">build_int_nsw_add</a><a href="#method.build_int_nsw_mul">build_int_nsw_mul</a><a href="#method.build_int_nsw_neg">build_int_nsw_neg</a><a href="#method.build_int_nsw_sub">build_int_nsw_sub</a><a href="#method.build_int_nuw_add">build_int_nuw_add</a><a href="#method.build_int_nuw_mul">build_int_nuw_mul</a><a hr
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">builder</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">create</span>();</pre></div>
</div><h4 id='method.build_return' class="method"><code id='build_return.v'>pub fn <a href='#method.build_return' class='fnname'>build_return</a>(&amp;self, value: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="../../inkwell/values/trait.BasicValue.html" title="trait inkwell::values::BasicValue">BasicValue</a>&gt;) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#72-78' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a function return instruction. It should be provided with <code>None</code> if the return type
is void otherwise <code>Some(&amp;value)</code> should be provided.</p>
<h1 id="example-1" class="section-header"><a href="#example-1">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="comment">// A simple function which returns its argument:</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">arg_types</span> <span class="op">=</span> [<span class="ident">i32_type</span>.<span class="ident">into</span>()];
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span><span class="ident">arg_types</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_arg</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">i32_arg</span>));</pre></div>
</div><h4 id='method.build_aggregate_return' class="method"><code id='build_aggregate_return.v'>pub fn <a href='#method.build_aggregate_return' class='fnname'>build_aggregate_return</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;values: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="enum" href="../../inkwell/values/enum.BasicValueEnum.html" title="enum inkwell::values::BasicValueEnum">BasicValueEnum</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#103-112' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a function return instruction for a return type which is an aggregate type (ie structs and arrays).
It is not necessary to use this over <code>build_return</code> but may be more convenient to use.</p>
<h1 id="example-2" class="section-header"><a href="#example-2">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="comment">// This builds a simple function which returns a struct (tuple) of two ints.</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_three</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">3</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">i32_seven</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">7</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">struct_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">struct_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_type</span>.<span class="ident">into</span>(), <span class="ident">i32_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">struct_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_aggregate_return</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_three</span>.<span class="ident">into</span>(), <span class="ident">i32_seven</span>.<span class="ident">into</span>()]);</pre></div>
</div><h4 id='method.build_call' class="method"><code id='build_call.v'>pub fn <a href='#method.build_call' class='fnname'>build_call</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;function: F, <br>&nbsp;&nbsp;&nbsp;&nbsp;args: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="enum" href="../../inkwell/values/enum.BasicValueEnum.html" title="enum inkwell::values::BasicValueEnum">BasicValueEnum</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.CallSiteValue.html" title="struct inkwell::values::CallSiteValue">CallSiteValue</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="../../either/enum.Either.html" title="enum either::Either">Either</a>&lt;<a class="struct" href="../../inkwell/values/struct.FunctionValue.html" title="struct inkwell::values::FunctionValue">FunctionValue</a>, <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>&gt;&gt;,&nbsp;</span></code><a class='srclink' href='../../src/inkwell/builder.rs.html#142-181' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a function call instruction. It can take either a <code>FunctionValue</code> or a <code>PointerValue</code>
which is a function pointer. It will panic if the <code>PointerValue</code> is not a function pointer.
This may be turned into a Result in the future, however.</p>
<h1 id="example-3" class="section-header"><a href="#example-3">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="comment">// A simple function which calls itself:</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_arg</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="kw">let</span> <span class="ident">ret_val</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_call</span>(<span class="ident">fn_value</span>, <span class="kw-2">&amp;</span>[<span class="ident">i32_arg</span>], <span class="string">&quot;call&quot;</span>)
.<span class="ident">try_as_basic_value</span>()
.<span class="ident">left</span>()
.<span class="ident">unwrap</span>();
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">ret_val</span>));</pre></div>
</div><h4 id='method.build_gep' class="method"><code id='build_gep.v'>pub unsafe fn <a href='#method.build_gep' class='fnname'>build_gep</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;ordered_indexes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#185-194' title='goto source code'>[src]</a></h4><div class='docblock'><p>GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.</p>
</div><h4 id='method.build_in_bounds_gep' class="method"><code id='build_in_bounds_gep.v'>pub unsafe fn <a href='#method.build_in_bounds_gep' class='fnname'>build_in_bounds_gep</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;ordered_indexes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#199-208' title='goto source code'>[src]</a></h4><div class='docblock'><p>GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.</p>
</div><h4 id='method.build_struct_gep' class="method"><code id='build_struct_gep.v'>pub unsafe fn <a href='#method.build_struct_gep' class='fnname'>build_struct_gep</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#214-220' title='goto source code'>[src]</a></h4><div class='docblock'><p>GEP is very likely to segfault if indexes are used incorrectly, and is therefore an unsafe function. Maybe we can change this in the future.</p>
</div><h4 id='method.build_ptr_diff' class="method"><code id='build_ptr_diff.v'>pub fn <a href='#method.build_ptr_diff' class='fnname'>build_ptr_diff</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs_ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs_ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#247-255' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds an instruction which calculates the difference of two pointers.</p>
<h1 id="example-4" class="section-header"><a href="#example-4">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">AddressSpace</span>;
<span class="comment">// Builds a function which diffs two pointers</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_ptr_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">ptr_type</span>(<span class="ident">AddressSpace</span>::<span class="ident">Generic</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_ptr_type</span>.<span class="ident">into</span>(), <span class="ident">i32_ptr_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_param1</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="kw">let</span> <span class="ident">i32_ptr_param2</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_nth_param</span>(<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_ptr_diff</span>(<span class="ident">i32_ptr_param1</span>, <span class="ident">i32_ptr_param2</span>, <span class="string">&quot;diff&quot;</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.build_phi' class="method"><code id='build_phi.v'>pub fn <a href='#method.build_phi' class='fnname'>build_phi</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/types/trait.BasicType.html" title="trait inkwell::types::BasicType">BasicType</a>&gt;(&amp;self, type_: T, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../../inkwell/values/struct.PhiValue.html" title="struct inkwell::values::PhiValue">PhiValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#262-270' title='goto source code'>[src]</a></h4><h4 id='method.build_store' class="method"><code id='build_store.v'>pub fn <a href='#method.build_store' class='fnname'>build_store</a>&lt;V:&nbsp;<a class="trait" href="../../inkwell/values/trait.BasicValue.html" title="trait inkwell::values::BasicValue">BasicValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;value: V<br>) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#297-303' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a store instruction. It allows you to store a value of type <code>T</code> in a pointer to a type <code>T</code>.</p>
<h1 id="example-5" class="section-header"><a href="#example-5">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">AddressSpace</span>;
<span class="comment">// Builds a function which takes an i32 pointer and stores a 7 in it.</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_ptr_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">ptr_type</span>(<span class="ident">AddressSpace</span>::<span class="ident">Generic</span>);
<span class="kw">let</span> <span class="ident">i32_seven</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">7</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_ptr_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_store</span>(<span class="ident">i32_ptr_param</span>, <span class="ident">i32_seven</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.build_load' class="method"><code id='build_load.v'>pub fn <a href='#method.build_load' class='fnname'>build_load</a>(&amp;self, ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="../../inkwell/values/enum.BasicValueEnum.html" title="enum inkwell::values::BasicValueEnum">BasicValueEnum</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#330-338' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a load instruction. It allows you to retrieve a value of type <code>T</code> from a pointer to a type <code>T</code>.</p>
<h1 id="example-6" class="section-header"><a href="#example-6">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">AddressSpace</span>;
<span class="comment">// Builds a function which takes an i32 pointer and returns the pointed at i32.</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;ret&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_ptr_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">ptr_type</span>(<span class="ident">AddressSpace</span>::<span class="ident">Generic</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_ptr_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;ret&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="kw">let</span> <span class="ident">pointee</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_load</span>(<span class="ident">i32_ptr_param</span>, <span class="string">&quot;load&quot;</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">pointee</span>));</pre></div>
</div><h4 id='method.build_alloca' class="method"><code id='build_alloca.v'>pub fn <a href='#method.build_alloca' class='fnname'>build_alloca</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/types/trait.BasicType.html" title="trait inkwell::types::BasicType">BasicType</a>&gt;(&amp;self, ty: T, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#341-349' title='goto source code'>[src]</a></h4><h4 id='method.build_array_alloca' class="method"><code id='build_array_alloca.v'>pub fn <a href='#method.build_array_alloca' class='fnname'>build_array_alloca</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/types/trait.BasicType.html" title="trait inkwell::types::BasicType">BasicType</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ty: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;size: <a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#352-360' title='goto source code'>[src]</a></h4><h4 id='method.build_malloc' class="method"><code id='build_malloc.v'>pub fn <a href='#method.build_malloc' class='fnname'>build_malloc</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/types/trait.BasicType.html" title="trait inkwell::types::BasicType">BasicType</a>&gt;(&amp;self, ty: T, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#363-371' title='goto source code'>[src]</a></h4><h4 id='method.build_array_malloc' class="method"><code id='build_array_malloc.v'>pub fn <a href='#method.build_array_malloc' class='fnname'>build_array_malloc</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/types/trait.BasicType.html" title="trait inkwell::types::BasicType">BasicType</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ty: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;size: <a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#374-382' title='goto source code'>[src]</a></h4><h4 id='method.build_free' class="method"><code id='build_free.v'>pub fn <a href='#method.build_free' class='fnname'>build_free</a>(&amp;self, ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#385-391' title='goto source code'>[src]</a></h4><h4 id='method.insert_instruction' class="method"><code id='insert_instruction.v'>pub fn <a href='#method.insert_instruction' class='fnname'>insert_instruction</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;instruction: &amp;<a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a>, <br>&nbsp;&nbsp;
into a value of another type which has the same bit width.</p>
<h1 id="example-7" class="section-header"><a href="#example-7">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;bc&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">f32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">f32_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">arg_types</span> <span class="op">=</span> [<span class="ident">i32_type</span>.<span class="ident">into</span>()];
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span><span class="ident">arg_types</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;bc&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_arg</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_bitcast</span>(<span class="ident">i32_arg</span>, <span class="ident">f32_type</span>, <span class="string">&quot;i32tof32&quot;</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">module</span>.<span class="ident">verify</span>().<span class="ident">is_ok</span>());</pre></div>
</div><h4 id='method.build_int_s_extend_or_bit_cast' class="method"><code id='build_int_s_extend_or_bit_cast.v'>pub fn <a href='#method.build_int_s_extend_or_bit_cast' class='fnname'>build_int_s_extend_or_bit_cast</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_value: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_type: T::<a class="type" href="../../inkwell/values/trait.IntMathValue.html#associatedtype.BaseType" title="type inkwell::values::IntMathValue::BaseType">BaseType</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#540-548' title='goto source code'>[src]</a></h4><h4 id='method.build_int_z_extend' class="method"><code id='build_int_z_extend.v'>pub fn <a href='#method.build_int_z_extend' class='fnname'>build_int_z_extend</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_value: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_type: T::<a class="type" href="../../inkwell/values/trait.IntMathValue.html#associatedtype.BaseType" title="type inkwell::values::IntMathValue::BaseType">BaseType</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#550-558' title='goto source code'>[src]</a></h4><h4 id='method.build_int_z_extend_or_bit_cast' class="method"><code id='build_int_z_extend_or_bit_cast.v'>pub fn <a href='#method.build_int_z_extend_or_bit_cast' class='fnname'>build_int_z_extend_or_bit_cast</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_value: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_type: T::<a class="type" href="../../inkwell/values/trait.IntMathValue.html#associatedtype.BaseType" title="type inkwell::values::IntMathValue::BaseType">BaseType</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#560-568' title='goto source code'>[src]</a></h4><h4 id='method.build_int_truncate' class="method"><code id='build_int_truncate.v'>pub fn <a href='#method.build_int_truncate' class='fnname'>build_int_truncate</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_value: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_type: T::<a class="type" href="../../inkwell/values/trait.IntMathValue.html#associatedtype.BaseType" title="type inkwell::values::IntMathValue::BaseType">BaseType</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#570-578' title='goto source code'>[src]</a></h4><h4 id='method.build_int_truncate_or_bit_cast' class="method"><code id='build_int_truncate_or_bit_cast.v'>pub fn <a href='#method.build_int_truncate_or_bit_cast' class='fnname'>build_int_truncate_or_bit_cast</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_value: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;int_type: T::<a class="type" href="../../inkwell/values/trait.IntMathValue.html#associatedtype.BaseType" title="type inkwell::values::I
<h1 id="example-8" class="section-header"><a href="#example-8">Example</a></h1>
<p>A logical left shift is an operation in which an integer value's bits are shifted left by N number of positions.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0000_0001</span> <span class="op">&lt;</span><span class="op">&lt;</span> <span class="number">0</span>, <span class="number">0b0000_0001</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0000_0001</span> <span class="op">&lt;</span><span class="op">&lt;</span> <span class="number">1</span>, <span class="number">0b0000_0010</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0000_0011</span> <span class="op">&lt;</span><span class="op">&lt;</span> <span class="number">2</span>, <span class="number">0b0000_1100</span>);</pre></div>
<p>In Rust, a function that could do this for 8bit values looks like:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">fn</span> <span class="ident">left_shift</span>(<span class="ident">value</span>: <span class="ident">u8</span>, <span class="ident">n</span>: <span class="ident">u8</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">u8</span> {
<span class="ident">value</span> <span class="op">&lt;</span><span class="op">&lt;</span> <span class="ident">n</span>
}</pre></div>
<p>And in Inkwell, the corresponding function would look roughly like:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="comment">// Setup</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;my_module&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i8_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i8_type</span>();
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i8_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i8_type</span>.<span class="ident">into</span>(), <span class="ident">i8_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="comment">// Function Definition</span>
<span class="kw">let</span> <span class="ident">function</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;left_shift&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_int_value</span>();
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">get_nth_param</span>(<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="ident">into_int_value</span>();
<span class="kw">let</span> <span class="ident">entry_block</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry_block</span>);
<span class="kw">let</span> <span class="ident">shift</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_left_shift</span>(<span class="ident">value</span>, <span class="ident">n</span>, <span class="string">&quot;left_shift&quot;</span>); <span class="comment">// value &lt;&lt; n</span>
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">shift</span>));</pre></div>
</div><h4 id='method.build_right_shift' class="method"><code id='build_right_shift.v'>pub fn <a href='#method.build_right_shift' class='fnname'>build_right_shift</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;sign_extend: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#889-901' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds an <code>IntValue</code> containing the result of a right shift instruction.</p>
<h1 id="example-9" class="section-header"><a href="#example-9">Example</a></h1>
<p>A right shift is an operation in which an integer value's bits are shifted right by N number of positions.
It may either be logical and have its leftmost N bit(s) filled with zeros or sign extended and filled with ones
if the leftmost bit was one.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="comment">//fix doc error about overflowing_literals</span>
<span class="comment">//rendered rfc: https://github.com/rust-lang/rfcs/blob/master/text/2438-deny-integer-literal-overflow-lint.md</span>
<span class="comment">//tracking issue: https://github.com/rust-lang/rust/issues/54502</span>
<span class="attribute">#![<span class="ident">allow</span>(<span class="ident">overflowing_literals</span>)]</span>
<span class="comment">// Logical Right Shift</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b1100_0000u8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">2</span>, <span class="number">0b0011_0000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0000_0010u8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">1</span>, <span class="number">0b0000_0001</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0000_1100u8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">2</span>, <span class="number">0b0000_0011</span>);
<span class="comment">// Sign Extended Right Shift</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b0100_0000i8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">2</span>, <span class="number">0b0001_0000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b1110_0000u8</span> <span class="kw">as</span> <span class="ident">i8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">1</span>, <span class="number">0b1111_0000u8</span> <span class="kw">as</span> <span class="ident">i8</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">0b1100_0000u8</span> <span class="kw">as</span> <span class="ident">i8</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="number">2</span>, <span class="number">0b1111_0000u8</span> <span class="kw">as</span> <span class="ident">i8</span>);</pre></div>
<p>In Rust, functions that could do this for 8bit values look like:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">fn</span> <span class="ident">logical_right_shift</span>(<span class="ident">value</span>: <span class="ident">u8</span>, <span class="ident">n</span>: <span class="ident">u8</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">u8</span> {
<span class="ident">value</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="ident">n</span>
}
<span class="kw">fn</span> <span class="ident">sign_extended_right_shift</span>(<span class="ident">value</span>: <span class="ident">i8</span>, <span class="ident">n</span>: <span class="ident">u8</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">i8</span> {
<span class="ident">value</span> <span class="op">&gt;</span><span class="op">&gt;</span> <span class="ident">n</span>
}</pre></div>
<p>Notice that, in Rust (and most other languages), whether or not a value is sign extended depends wholly on whether
or not the type is signed (ie an i8 is a signed 8 bit value). LLVM does not make this distinction for you.</p>
<p>In Inkwell, the corresponding functions would look roughly like:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="comment">// Setup</span>
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;my_module&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">i8_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i8_type</span>();
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i8_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i8_type</span>.<span class="ident">into</span>(), <span class="ident">i8_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="comment">// Function Definition</span>
<span class="kw">let</span> <span class="ident">function</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;right_shift&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_int_value</span>();
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">get_nth_param</span>(<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="ident">into_int_value</span>();
<span class="kw">let</span> <span class="ident">entry_block</span> <span class="op">=</span> <span class="ident">function</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry_block</span>);
<span class="comment">// Whether or not your right shift is sign extended (true) or logical (false) depends</span>
<span class="comment">// on the boolean input parameter:</span>
<span class="kw">let</span> <span class="ident">shift</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_right_shift</span>(<span class="ident">value</span>, <span class="ident">n</span>, <span class="bool-val">false</span>, <span class="string">&quot;right_shift&quot;</span>); <span class="comment">// value &gt;&gt; n</span>
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">shift</span>));</pre></div>
</div><h4 id='method.build_int_sub' class="method"><code id='build_int_sub.v'>pub fn <a href='#method.build_int_sub' class='fnname'>build_int_sub</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(&amp;self, lhs: T, rhs: T, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#904-912' title='goto source code'>[src]</a></h4><h4 id='method.build_int_nsw_sub' class="method"><code id='build_int_nsw_sub.v'>pub fn <a href='#method.build_int_nsw_sub' class='fnname'>build_int_nsw_sub</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#915-923' title='goto source code'>[src]</a></h4><h4 id='method.build_int_nuw_sub' class="method"><code id='build_int_nuw_sub.v'>pub fn <a href='#method.build_int_nuw_sub' class='fnname'>build_int_nuw_sub</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#927-935' title='goto source code'>[src]</a></h4><h4 id='method.build_float_sub' class="method"><code id='build_float_sub.v'>pub fn <a href='#method.build_float_sub' class='fnname'>build_float_sub</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.FloatMathValue.html" title="trait inkwell::values::FloatMathValue">FloatMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#938-946' title='goto source code'>[src]</a></h4><h4 id='method.build_int_mul' class="method"><code id='build_int_mul.v'>pub fn <a href='#method.build_int_mul' class='fnname'>build_int_mul</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(&amp;self, lhs: T, rhs: T, name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#949-957' title='goto source code'>[src]</a></h4><h4 id='method.build_int_nsw_mul' class="method"><code id='build_int_nsw_mul.v'>pub fn <a href='#method.build_int_nsw_mul' class='fnname'>build_int_nsw_mul</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;lhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;rhs: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; T</code><a class='srclink' href='../../src/inkwell/builder.rs.html#961-969' title='goto source code'>[src]</a></h4><h4 id='method.build_int_nuw_mul' class="method"><code id='build_int_nuw_mul.v'>pub fn <a href='#method.build_int_nuw_mul' class='fnname'>build_int_nuw_mul</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.IntMathValue.html" title="trait inkwell::values::IntMathValue">IntMathValue</a>&gt;(<br>&n
from a struct or array.</p>
<h1 id="example-10" class="section-header"><a href="#example-10">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;av&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">f32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">f32_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">struct_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">struct_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_type</span>.<span class="ident">into</span>(), <span class="ident">f32_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">array_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">array_type</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;av_fn&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="kw">let</span> <span class="ident">array_alloca</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_alloca</span>(<span class="ident">array_type</span>, <span class="string">&quot;array_alloca&quot;</span>);
<span class="kw">let</span> <span class="ident">array</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_load</span>(<span class="ident">array_alloca</span>, <span class="string">&quot;array_load&quot;</span>).<span class="ident">into_array_value</span>();
<span class="kw">let</span> <span class="ident">const_int1</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">2</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">const_int2</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">5</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">const_int3</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">6</span>, <span class="bool-val">false</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int1</span>, <span class="number">0</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int2</span>, <span class="number">1</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int3</span>, <span class="number">2</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int3</span>, <span class="number">3</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_extract_value</span>(<span class="ident">array</span>, <span class="number">0</span>, <span class="string">&quot;extract&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">is_int_value</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_extract_value</span>(<span class="ident">array</span>, <span class="number">1</span>, <span class="string">&quot;extract&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">is_int_value</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_extract_value</span>(<span class="ident">array</span>, <span class="number">2</span>, <span class="string">&quot;extract&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">is_int_value</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_extract_value</span>(<span class="ident">array</span>, <span class="number">3</span>, <span class="string">&quot;extract&quot;</span>).<span class="ident">is_none</span>());</pre></div>
</div><h4 id='method.build_insert_value' class="method"><code id='build_insert_value.v'>pub fn <a href='#method.build_insert_value' class='fnname'>build_insert_value</a>&lt;AV, BV&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;agg: AV, <br>&nbsp;&nbsp;&nbsp;&nbsp;value: BV, <br>&nbsp;&nbsp;&nbsp;&nbsp;index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../../inkwell/values/enum.AggregateValueEnum.html" title="enum inkwell::values::AggregateValueEnum">AggregateValueEnum</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;AV: <a class="trait" href="../../inkwell/values/trait.AggregateValue.html" title="trait inkwell::values::AggregateValue">AggregateValue</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;BV: <a class="trait" href="../../inkwell/values/trait.BasicValue.html" title="trait inkwell::values::BasicValue">BasicValue</a>,&nbsp;</span></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1237-1258' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds an insert value instruction which inserts a <code>BasicValue</code> into a struct
or array and returns the resulting aggregate value.</p>
<h1 id="example-11" class="section-header"><a href="#example-11">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;av&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">f32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">f32_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">struct_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">struct_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_type</span>.<span class="ident">into</span>(), <span class="ident">f32_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">array_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">array_type</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;av_fn&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="kw">let</span> <span class="ident">array_alloca</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_alloca</span>(<span class="ident">array_type</span>, <span class="string">&quot;array_alloca&quot;</span>);
<span class="kw">let</span> <span class="ident">array</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_load</span>(<span class="ident">array_alloca</span>, <span class="string">&quot;array_load&quot;</span>).<span class="ident">into_array_value</span>();
<span class="kw">let</span> <span class="ident">const_int1</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">2</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">const_int2</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">5</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">const_int3</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">6</span>, <span class="bool-val">false</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int1</span>, <span class="number">0</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int2</span>, <span class="number">1</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int3</span>, <span class="number">2</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">builder</span>.<span class="ident">build_insert_value</span>(<span class="ident">array</span>, <span class="ident">const_int3</span>, <span class="number">3</span>, <span class="string">&quot;insert&quot;</span>).<span class="ident">is_none</span>());</pre></div>
</div><h4 id='method.build_extract_element' class="method"><code id='build_extract_element.v'>pub fn <a href='#method.build_extract_element' class='fnname'>build_extract_element</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;vector: <a class="struct" href="../../inkwell/values/struct.VectorValue.html" title="struct inkwell::values::VectorValue">VectorValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;index: <a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="enum" href="../../inkwell/values/enum.BasicValueEnum.html" title="enum inkwell::values::BasicValueEnum">BasicValueEnum</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1284-1292' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds an extract element instruction which extracts a <code>BasicValueEnum</code>
from a vector.</p>
<h1 id="example-12" class="section-header"><a href="#example-12">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;av&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_zero</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">0</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">vec_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">vec_type</span>(<span class="number">2</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">vec_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;vec_fn&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">vector_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_vector_value</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="kw">let</span> <span class="ident">extracted</span> <span class="op">=</span> <span class="ident">builder</span>.<span class="ident">build_extract_element</span>(<span class="ident">vector_param</span>, <span class="ident">i32_zero</span>, <span class="string">&quot;insert&quot;</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">extracted</span>));</pre></div>
</div><h4 id='method.build_insert_element' class="method"><code id='build_insert_element.v'>pub fn <a href='#method.build_insert_element' class='fnname'>build_insert_element</a>&lt;V:&nbsp;<a class="trait" href="../../inkwell/values/trait.BasicValue.html" title="trait inkwell::values::BasicValue">BasicValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;vector: <a class="struct" href="../../inkwell/values/struct.VectorValue.html" title="struct inkwell::values::VectorValue">VectorValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;element: V, <br>&nbsp;&nbsp;&nbsp;&nbsp;index: <a class="struct" href="../../inkwell/values/struct.IntValue.html" title="struct inkwell::values::IntValue">IntValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.VectorValue.html" title="struct inkwell::values::VectorValue">VectorValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1319-1327' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds an insert element instruction which inserts a <code>BasicValue</code> into a vector
and returns the resulting vector.</p>
<h1 id="example-13" class="section-header"><a href="#example-13">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;av&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_zero</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">0</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">i32_seven</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">7</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">vec_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">vec_type</span>(<span class="number">2</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">vec_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;vec_fn&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">vector_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_vector_value</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_insert_element</span>(<span class="ident">vector_param</span>, <span class="ident">i32_seven</span>, <span class="ident">i32_zero</span>, <span class="string">&quot;insert&quot;</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.build_unreachable' class="method"><code id='build_unreachable.v'>pub fn <a href='#method.build_unreachable' class='fnname'>build_unreachable</a>(&amp;self) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1329-1335' title='goto source code'>[src]</a></h4><h4 id='method.build_fence' class="method"><code id='build_fence.v'>pub fn <a href='#method.build_fence' class='fnname'>build_fence</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;atomic_ordering: <a class="enum" href="../../inkwell/enum.AtomicOrdering.html" title="enum inkwell::AtomicOrdering">AtomicOrdering</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;num: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; <a class="struct" href="../../inkwell/values/struct.InstructionValue.html" title="struct inkwell::values::InstructionValue">InstructionValue</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1339-1347' title='goto source code'>[src]</a></h4><h4 id='method.build_is_null' class="method"><code id='build_is_null.v'>pub fn <a href='#method.build_is_null' class='fnname'>build_is_null</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.PointerMathValue.html" title="trait inkwell::values::PointerMathValue">PointerMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; &lt;&lt;T::<a class="type" href="../../inkwell/values/trait.PointerMathValue.html#associatedtype.BaseType" title="type inkwell::values::PointerMathValue::BaseType">BaseType</a> as <a class="trait" href="../../inkwell/types/trait.PointerMathType.html" title="trait inkwell::types::PointerMathType">PointerMathType</a>&gt;::<a class="type" href="../../inkwell/types/trait.PointerMathType.html#associatedtype.PtrConvType" title="type inkwell::types::PointerMathType::PtrConvType">PtrConvType</a> as <a class="trait" href="../../inkwell/types/trait.IntMathType.html" title="trait inkwell::types::IntMathType">IntMathType</a>&gt;::<a class="type" href="../../inkwell/types/trait.IntMathType.html#associatedtype.ValueType" title="type inkwell::types::IntMathType::ValueType">ValueType</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#1350-1358' title='goto source code'>[src]</a></h4><h4 id='method.build_is_not_null' class="method"><code id='build_is_not_null.v'>pub fn <a href='#method.build_is_not_null' class='fnname'>build_is_not_null</a>&lt;T:&nbsp;<a class="trait" href="../../inkwell/values/trait.PointerMathValue.html" title="trait inkwell::values::PointerMathValue">PointerMathValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: T, <br>&nbsp;&nbsp;&nbsp;&nbsp;name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a><br>) -&gt; &lt;&lt;T::<a class="type" href="../../inkwell/values/trait.PointerMathValue.html#associatedtype.BaseType" title="type inkwell::values::PointerMathValue::BaseType">BaseType</a> as <a class="trait" href="../../inkwell/types/trait.PointerMathType.html" title="trait inkwell::types::PointerMathType">PointerMathType</a>&gt;::<a class="type" href="../../inkwell/types/trait.PointerMathType.html#associatedtype.PtrConvType" title="type inkwell::types::PointerMathType::PtrConvType">PtrConvType</a> as <a class="trait" href="../../inkwell/types/trait.IntMathType.html" title="trait inkwell::types::IntMathType">IntMathType</a>&gt;::<a class="type" href="../../inkwell/types/trait.IntMathType.html#associatedtype.ValueType" title="type inkwell::types::IntMathType::ValueType">ValueType</a></code><a class='srclink' href='../../src/inkwell
<h1 id="example-14" class="section-header"><a href="#example-14">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">use</span> <span class="ident">inkwell</span>::{<span class="ident">AddressSpace</span>, <span class="ident">AtomicOrdering</span>, <span class="ident">AtomicRMWBinOp</span>};
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;rmw&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_seven</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">7</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">ptr_type</span>(<span class="ident">AddressSpace</span>::<span class="ident">Generic</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_ptr_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;rmw&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_atomicrmw</span>(<span class="ident">AtomicRMWBinOp</span>::<span class="ident">Add</span>, <span class="ident">i32_ptr_param</span>, <span class="ident">i32_seven</span>, <span class="ident">AtomicOrdering</span>::<span class="ident">Unordered</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);</pre></div>
</div><h4 id='method.build_cmpxchg' class="method"><code id='build_cmpxchg.v'>pub fn <a href='#method.build_cmpxchg' class='fnname'>build_cmpxchg</a>&lt;V:&nbsp;<a class="trait" href="../../inkwell/values/trait.BasicValue.html" title="trait inkwell::values::BasicValue">BasicValue</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;ptr: <a class="struct" href="../../inkwell/values/struct.PointerValue.html" title="struct inkwell::values::PointerValue">PointerValue</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;cmp: V, <br>&nbsp;&nbsp;&nbsp;&nbsp;new: V, <br>&nbsp;&nbsp;&nbsp;&nbsp;success: <a class="enum" href="../../inkwell/enum.AtomicOrdering.html" title="enum inkwell::AtomicOrdering">AtomicOrdering</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;failure: <a class="enum" href="../../inkwell/enum.AtomicOrdering.html" title="enum inkwell::AtomicOrdering">AtomicOrdering</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../../inkwell/values/struct.StructValue.html" title="struct inkwell::values::StructValue">StructValue</a>, &amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class='srclink' href='../../src/inkwell/builder.rs.html#1537-1566' title='goto source code'>[src]</a></h4><div class='docblock'><p>Builds a cmpxchg instruction. It allows you to atomically compare and replace memory.</p>
<h1 id="example-15" class="section-header"><a href="#example-15">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">inkwell</span>::<span class="ident">context</span>::<span class="ident">Context</span>;
<span class="kw">use</span> <span class="ident">inkwell</span>::{<span class="ident">AddressSpace</span>, <span class="ident">AtomicOrdering</span>};
<span class="kw">let</span> <span class="ident">context</span> <span class="op">=</span> <span class="ident">Context</span>::<span class="ident">create</span>();
<span class="kw">let</span> <span class="ident">module</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_module</span>(<span class="string">&quot;cmpxchg&quot;</span>);
<span class="kw">let</span> <span class="ident">void_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">void_type</span>();
<span class="kw">let</span> <span class="ident">i32_type</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">i32_type</span>();
<span class="kw">let</span> <span class="ident">i32_ptr_type</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">ptr_type</span>(<span class="ident">AddressSpace</span>::<span class="ident">Generic</span>);
<span class="kw">let</span> <span class="ident">fn_type</span> <span class="op">=</span> <span class="ident">void_type</span>.<span class="ident">fn_type</span>(<span class="kw-2">&amp;</span>[<span class="ident">i32_ptr_type</span>.<span class="ident">into</span>()], <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">fn_value</span> <span class="op">=</span> <span class="ident">module</span>.<span class="ident">add_function</span>(<span class="string">&quot;&quot;</span>, <span class="ident">fn_type</span>, <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">i32_ptr_param</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">get_first_param</span>().<span class="ident">unwrap</span>().<span class="ident">into_pointer_value</span>();
<span class="kw">let</span> <span class="ident">i32_seven</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">7</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">i32_eight</span> <span class="op">=</span> <span class="ident">i32_type</span>.<span class="ident">const_int</span>(<span class="number">8</span>, <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">entry</span> <span class="op">=</span> <span class="ident">fn_value</span>.<span class="ident">append_basic_block</span>(<span class="string">&quot;entry&quot;</span>);
<span class="kw">let</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">context</span>.<span class="ident">create_builder</span>();
<span class="ident">builder</span>.<span class="ident">position_at_end</span>(<span class="kw-2">&amp;</span><span class="ident">entry</span>);
<span class="ident">builder</span>.<span class="ident">build_cmpxchg</span>(<span class="ident">i32_ptr_param</span>, <span class="ident">i32_seven</span>, <span class="ident">i32_eight</span>, <span class="ident">AtomicOrdering</span>::<span class="ident">AcquireRelease</span>, <span class="ident">AtomicOrdering</span>::<span class="ident">Monotonic</span>);
<span class="ident">builder</span>.<span class="ident">build_return</span>(<span class="prelude-val">None</span>);</pre></div>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Drop' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-Drop' class='anchor'></a><a class='srclink' href='../../src/inkwell/builder.rs.html#1569-1575' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.drop' class="method hidden"><code id='drop.v'>fn <a href='https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop' class='fnname'>drop</a>(&amp;mut self)</code><a class='srclink' href='../../src/inkwell/builder.rs.html#1570-1574' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></p>
</div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/inkwell/builder.rs.html#17' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class='srclink' href='../../src/inkwell/builder.rs.html#17' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Sync' class='impl'><code class='in-band'>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Send' class='impl'><code class='in-band'>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Unpin' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-Unpin' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-UnwindSafe' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-UnwindSafe' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-RefUnwindSafe' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../inkwell/builder/struct.Builder.html" title="struct inkwell::builder::Builder">Builder</a></code><a href='#impl-RefUnwindSafe' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#543-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#545-547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#552-554' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#553' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#571-577' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#574-576' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#559-566' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#563-565' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><code id='borrow_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "inkwell";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>