2024-04-09 11:05:04 +00: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 = "All `build_*` methods return a `Result<_, BuilderError>` type containing either the returned value or some error. Those methods all may return `BuilderError::UnsetPosition` if a `position_*` method has not yet been called, in addition to any other possibility." > < title > Builder in inkwell::builder - Rust< / title > < link rel = "preload" as = "font" type = "font/woff2" crossorigin href = "../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2" > < link rel = "preload" as = "font" type = "font/woff2" crossorigin href = "../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2" > < link rel = "preload" as = "font" type = "font/woff2" crossorigin href = "../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2" > < link rel = "preload" as = "font" type = "font/woff2" crossorigin href = "../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2" > < link rel = "preload" as = "font" type = "font/woff2" crossorigin href = "../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2" > < link rel = "stylesheet" href = "../../static.files/normalize-76eba96aa4d2e634.css" > < link rel = "stylesheet" href = "../../static.files/rustdoc-5bc39a1768837dd0.css" > < meta name = "rustdoc-vars" data-root-path = "../../" data-static-root-path = "../../static.files/" data-current-crate = "inkwell" data-themes = "" data-resource-suffix = "" data-rustdoc-version = "1.77.1 (7cf61ebde 2024-03-27)" data-channel = "1.77.1" data-search-js = "search-dd67cee4cfa65049.js" data-settings-js = "settings-4313503d2e1961c2.js" > < script src = "../../static.files/storage-4c98445ec4002617.js" > < / script > < script defer src = "sidebar-items.js" > < / script > < script defer src = "../../static.files/main-48f368f3872407c8.js" > < / script > < noscript > < link rel = "stylesheet" href = "../../static.files/noscript-04d5337699b92874.css" > < / noscript > < link rel = "alternate icon" type = "image/png" href = "../../static.files/favicon-16x16-8b506e7a72182f1c.png" > < link rel = "alternate icon" type = "image/png" href = "../../static.files/favicon-32x32-422f7d1d52889060.png" > < link rel = "icon" type = "image/svg+xml" href = "../../static.files/favicon-2c020d218678b618.svg" > < / head > < body class = "rustdoc struct" > <!-- [if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif] --> < nav class = "mobile-topbar" > < button class = "sidebar-menu-toggle" title = "show sidebar" > < / button > < / nav > < nav class = "sidebar" > < div class = "sidebar-crate" > < h2 > < a href = "../../inkwell/index.html" > inkwell< / a > < span class = "version" > 0.4.0< / span > < / h2 > < / div > < h2 class = "location" > < a href = "#" > Builder< / a > < / h2 > < div class = "sidebar-elems" > < section > < h3 > < a href = "#implementations" > Methods< / a > < / h3 > < ul class = "block method" > < li > < a href = "#method.as_mut_ptr" > as_mut_ptr< / a > < / li > < li > < a href = "#method.build_address_space_cast" > build_address_space_cast< / a > < / li > < li > < a href = "#method.build_aggregate_return" > build_aggregate_return< / a > < / li > < li > < a href = "#method.build_alloca" > build_alloca< / a > < / li > < li > < a href = "#method.build_and" > build_and< / a > < / li > < li > < a href = "#method.build_array_alloca" > build_array_alloca< / a > < / li > < li > < a href = "#method.build_array_malloc" > build_array_malloc< / a > < / li > < li > < a href = "#method.build_atomicrmw" > build_atomicrmw< / a > < / li > < li > < a href = "#method.build_bit_cast" > build_bit_cast< / a > < / li > < li > < a href = "#method.build_call" > build_call< / a > < / li > < li > < a href = "#method.build_cast" > build_cast< / a > < / li > < li > < a href = "#method.build_cmpxchg" > build_cmpxchg< / a > < / li > < li > < a href = "#method.build_conditional_branch" > build_conditional_branch< / a > < / li > < li > < a href = "#method.build_direct_call" > build_direct_call< / a > < / li > < li > < a href = "#method.build_direct_invoke" > build_direct_invoke< / a > < / li > < li > < a href = "#method.build_extract_element" > build_extract_element< / a > < / li > < li > < a href = "#method.build_extract_value" > build_extract_value< / a > < / li > < li > < a href = "#method.build_fence" > build_fence< / a > < / li > < li > < a href = "#method.build_float_add" > build_float_add< / a > < / li > < li > < a href = "#method.build_float_cast" > build_float_cast< / a > < /
2024-02-13 06:38:44 +00:00
< main > < div class = "width-limiter" > < nav class = "sub" > < form class = "search-form" > < span > < / span > < div id = "sidebar-button" tabindex = "-1" > < a href = "../../inkwell/all.html" title = "show sidebar" > < / a > < / div > < input class = "search-input" name = "search" aria-label = "Run search in the documentation" autocomplete = "off" spellcheck = "false" placeholder = "Click or press ‘ S’ to search, ‘ ?’ for more options…" type = "search" > < div id = "help-button" tabindex = "-1" > < a href = "../../help.html" title = "help" > ?< / a > < / div > < div id = "settings-menu" tabindex = "-1" > < a href = "../../settings.html" title = "settings" > < img width = "22" height = "22" alt = "Change settings" src = "../../static.files/wheel-7b819b6101059cd0.svg" > < / a > < / div > < / form > < / nav > < section id = "main-content" class = "content" > < div class = "main-heading" > < h1 > Struct < a href = "../index.html" > inkwell< / a > ::< wbr > < a href = "index.html" > builder< / a > ::< wbr > < a class = "struct" href = "#" > Builder< / a > < button id = "copy-path" title = "Copy item path to clipboard" > < img src = "../../static.files/clipboard-7571035ce49a181d.svg" width = "19" height = "18" alt = "Copy item path" > < / button > < / h1 > < span class = "out-of-band" > < a class = "src" href = "../../src/inkwell/builder.rs.html#91-95" > source< / a > · < button id = "toggle-all-docs" title = "collapse all docs" > [< span > − < / span > ]< / button > < / span > < / div > < pre class = "rust item-decl" > < code > pub struct Builder< 'ctx> { < span class = "comment" > /* private fields */< / span > }< / code > < / pre > < details class = "toggle top-doc" open > < summary class = "hideme" > < span > Expand description< / span > < / summary > < div class = "docblock" > < p > All < code > build_*< / code > methods return a < code > Result< _, BuilderError> < / code > type containing either the returned value or some error.
Those methods all may return < code > BuilderError::UnsetPosition< / code > if a < code > position_*< / code > method has not yet been called, in addition
to any other possibility.< / p >
2024-04-09 11:05:04 +00:00
< / div > < / details > < h2 id = "implementations" class = "section-header" > Implementations< a href = "#implementations" class = "anchor" > §< / a > < / h2 > < div id = "implementations-list" > < details class = "toggle implementors-toggle" open > < summary > < section id = "impl-Builder%3C'ctx%3E" class = "impl" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#100-3443" > source< / a > < a href = "#impl-Builder%3C'ctx%3E" class = "anchor" > §< / a > < h3 class = "code-header" > impl< 'ctx> < a class = "struct" href = "struct.Builder.html" title = "struct inkwell::builder::Builder" > Builder< / a > < 'ctx> < / h3 > < / section > < / summary > < div class = "impl-items" > < section id = "method.new" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#101-109" > source< / a > < h4 class = "code-header" > pub unsafe fn < a href = "#method.new" class = "fn" > new< / a > (builder: < a class = "type" href = "../../llvm_sys/prelude/type.LLVMBuilderRef.html" title = "type llvm_sys::prelude::LLVMBuilderRef" > LLVMBuilderRef< / a > ) -> Self< / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.as_mut_ptr" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#112-114" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.as_mut_ptr" class = "fn" > as_mut_ptr< / a > (& self) -> < a class = "type" href = "../../llvm_sys/prelude/type.LLVMBuilderRef.html" title = "type llvm_sys::prelude::LLVMBuilderRef" > LLVMBuilderRef< / a > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Acquires the underlying raw pointer belonging to this < code > Builder< / code > type.< / p >
2024-02-13 06:38:44 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_return" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#140-152" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_return" class = "fn" > build_return< / a > (
& self,
2024-04-09 10:18:33 +00:00
value: < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title = "enum core::option::Option" > Option< / a > < & dyn < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a function return instruction. It should be provided with < code > None< / code > if the return type
2024-02-13 06:38:44 +00:00
is void otherwise < code > Some(& value)< / code > should be provided.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example" > < a class = "doc-anchor" href = "#example" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // A simple function which returns its argument:
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > arg_types = [i32_type.into()];
< span class = "kw" > let < / span > fn_type = i32_type.fn_type(< span class = "kw-2" > & < / span > arg_types, < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_arg = fn_value.get_first_param().unwrap();
builder.position_at_end(entry);
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > i32_arg)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_aggregate_return" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#177-188" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_aggregate_return" class = "fn" > build_aggregate_return< / a > (
& self,
values: & [< a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> ]
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a function return instruction for a return type which is an aggregate type (ie structs and arrays).
2024-02-13 06:38:44 +00:00
It is not necessary to use this over < code > build_return< / code > but may be more convenient to use.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-1" > < a class = "doc-anchor" href = "#example-1" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // This builds a simple function which returns a struct (tuple) of two ints.
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_three = i32_type.const_int(< span class = "number" > 3< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > i32_seven = i32_type.const_int(< span class = "number" > 7< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > struct_type = context.struct_type(< span class = "kw-2" > & < / span > [i32_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_type = struct_type.fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry);
builder.build_aggregate_return(< span class = "kw-2" > & < / span > [i32_three.into(), i32_seven.into()]).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_call" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#258-268" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_call" class = "fn" > build_call< / a > (
& self,
function: < a class = "struct" href = "../values/struct.FunctionValue.html" title = "struct inkwell::values::FunctionValue" > FunctionValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicMetadataValueEnum.html" title = "enum inkwell::values::BasicMetadataValueEnum" > BasicMetadataValueEnum< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a function call instruction. Alias for < a href = "struct.Builder.html#method.build_direct_call" title = "method inkwell::builder::Builder::build_direct_call" > Builder::build_direct_call< / a > .< / p >
2024-02-13 06:38:44 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_direct_call" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#299-309" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_direct_call" class = "fn" > build_direct_call< / a > (
& self,
function: < a class = "struct" href = "../values/struct.FunctionValue.html" title = "struct inkwell::values::FunctionValue" > FunctionValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicMetadataValueEnum.html" title = "enum inkwell::values::BasicMetadataValueEnum" > BasicMetadataValueEnum< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a function call instruction. The function being called is known at compile time. If
2024-02-13 06:38:44 +00:00
you want to call a function pointer, see < a href = "struct.Builder.html#method.build_indirect_call" title = "method inkwell::builder::Builder::build_indirect_call" > Builder::build_indirect_call< / a > .< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-2" > < a class = "doc-anchor" href = "#example-2" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // A simple function which calls itself:
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > fn_type = i32_type.fn_type(< span class = "kw-2" > & < / span > [i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_arg = fn_value.get_first_param().unwrap();
< span class = "kw" > let < / span > md_string = context.metadata_string(< span class = "string" > "a metadata"< / span > );
builder.position_at_end(entry);
< span class = "kw" > let < / span > ret_val = builder.build_call(fn_value, < span class = "kw-2" > & < / span > [i32_arg.into(), md_string.into()], < span class = "string" > "call"< / span > ).unwrap()
.try_as_basic_value()
.left()
.unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > ret_val)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_indirect_call" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#342-353" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_indirect_call" class = "fn" > build_indirect_call< / a > (
& self,
function_type: < a class = "struct" href = "../types/struct.FunctionType.html" title = "struct inkwell::types::FunctionType" > FunctionType< / a > < 'ctx> ,
function_pointer: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicMetadataValueEnum.html" title = "enum inkwell::values::BasicMetadataValueEnum" > BasicMetadataValueEnum< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Call a function pointer. Because a pointer does not carry a type, the type of the function
2024-02-13 06:38:44 +00:00
must be specified explicitly.< / p >
< p > See < a href = "../context/struct.Context.html#method.create_inline_asm" title = "method inkwell::context::Context::create_inline_asm" > Context::create_inline_asm< / a > for a practical example. Basic usage looks like this:< / p >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // A simple function which calls itself:
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > fn_type = i32_type.fn_type(< span class = "kw-2" > & < / span > [i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_arg = fn_value.get_first_param().unwrap();
< span class = "kw" > let < / span > md_string = context.metadata_string(< span class = "string" > "a metadata"< / span > );
builder.position_at_end(entry);
< span class = "kw" > let < / span > function_pointer = fn_value.as_global_value().as_pointer_value();
< span class = "kw" > let < / span > ret_val = builder.build_indirect_call(fn_value.get_type(), function_pointer, < span class = "kw-2" > & < / span > [i32_arg.into(), md_string.into()], < span class = "string" > "call"< / span > ).unwrap()
.try_as_basic_value()
.left()
.unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > ret_val)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_invoke" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#589-601" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_invoke" class = "fn" > build_invoke< / a > (
& self,
function: < a class = "struct" href = "../values/struct.FunctionValue.html" title = "struct inkwell::values::FunctionValue" > FunctionValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> ],
then_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
catch_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > An invoke is similar to a normal function call, but used to
2024-02-13 06:38:44 +00:00
call functions that may throw an exception, and then respond to the exception.< / p >
< p > When the called function returns normally, the < code > then< / code > block is evaluated next. If instead
the function threw an exception, the < code > catch< / code > block is entered. The first non-phi
instruction of the catch block must be a < code > landingpad< / code > instruction. See also
< a href = "struct.Builder.html#method.build_landing_pad" title = "method inkwell::builder::Builder::build_landing_pad" > < code > Builder::build_landing_pad< / code > < / a > .< / p >
< p > The < a href = "crate::passes::PassManager::add_prune_eh_pass" > < code > add_prune_eh_pass< / code > < / a > turns an invoke into a call when the called function is
guaranteed to never throw an exception.< / p >
< p > This example catches C++ exceptions of type < code > int< / code > , and returns < code > 0< / code > if an exceptions is thrown.
For usage of a cleanup landing pad and the < code > resume< / code > instruction, see < a href = "struct.Builder.html#method.build_resume" title = "method inkwell::builder::Builder::build_resume" > < code > Builder::build_resume< / code > < / a > < / p >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > f32_type = context.f32_type();
< span class = "kw" > let < / span > fn_type = f32_type.fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > );
< span class = "comment" > // we will pretend this function can throw an exception
< / span > < span class = "kw" > let < / span > function = module.add_function(< span class = "string" > "bomb"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > basic_block = context.append_basic_block(function, < span class = "string" > "entry"< / span > );
builder.position_at_end(basic_block);
< span class = "kw" > let < / span > pi = f32_type.const_float(::std::f64::consts::PI);
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > pi)).unwrap();
< span class = "kw" > let < / span > function2 = module.add_function(< span class = "string" > "wrapper"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > basic_block2 = context.append_basic_block(function2, < span class = "string" > "entry"< / span > );
builder.position_at_end(basic_block2);
< span class = "kw" > let < / span > then_block = context.append_basic_block(function2, < span class = "string" > "then_block"< / span > );
< span class = "kw" > let < / span > catch_block = context.append_basic_block(function2, < span class = "string" > "catch_block"< / span > );
< span class = "kw" > let < / span > call_site = builder.build_invoke(function, < span class = "kw-2" > & < / span > [], then_block, catch_block, < span class = "string" > "get_pi"< / span > ).unwrap();
{
builder.position_at_end(then_block);
< span class = "comment" > // in the then_block, the `call_site` value is defined and can be used
< / span > < span class = "kw" > let < / span > result = call_site.try_as_basic_value().left().unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > result)).unwrap();
}
{
builder.position_at_end(catch_block);
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i32_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > null = i8_ptr_type.const_zero();
< span class = "kw" > let < / span > res = builder.build_landing_pad(exception_type, personality_function, < span class = "kw-2" > & < / span > [null.into()], < span class = "bool-val" > false< / span > , < span class = "string" > "res"< / span > ).unwrap();
< span class = "comment" > // we handle the exception by returning a default value
< / span > builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > f32_type.const_zero())).unwrap();
}< / code > < / pre > < / div >
< / div > < / details > < section id = "method.build_direct_invoke" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#604-623" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_direct_invoke" class = "fn" > build_direct_invoke< / a > (
& self,
function: < a class = "struct" href = "../values/struct.FunctionValue.html" title = "struct inkwell::values::FunctionValue" > FunctionValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> ],
then_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
catch_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_indirect_invoke" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#626-646" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_indirect_invoke" class = "fn" > build_indirect_invoke< / a > (
2024-02-13 06:38:44 +00:00
& self,
function_type: < a class = "struct" href = "../types/struct.FunctionType.html" title = "struct inkwell::types::FunctionType" > FunctionType< / a > < 'ctx> ,
function_pointer: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
args: & [< a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> ],
then_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
catch_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.CallSiteValue.html" title = "struct inkwell::values::CallSiteValue" > CallSiteValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_landing_pad" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#824-862" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_landing_pad" class = "fn" > build_landing_pad< / a > < T> (
2024-02-13 06:38:44 +00:00
& self,
exception_type: T,
personality_function: < a class = "struct" href = "../values/struct.FunctionValue.html" title = "struct inkwell::values::FunctionValue" > FunctionValue< / a > < 'ctx> ,
clauses: & [< a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
is_cleanup: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.bool.html" > bool< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < div class = "where" > where
2024-02-13 06:38:44 +00:00
T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> ,< / div > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Landing pads are places where control flow jumps to if a < a href = "struct.Builder.html#method.build_invoke" title = "method inkwell::builder::Builder::build_invoke" > < code > Builder::build_invoke< / code > < / a > triggered an exception.
The landing pad will match the exception against its < em > clauses< / em > . Depending on the clause
that is matched, the exception can then be handled, or resumed after some optional cleanup,
causing the exception to bubble up.< / p >
< p > Exceptions in LLVM are designed based on the needs of a C++ compiler, but can be used more generally.
Here are some specific examples of landing pads. For a full example of handling an exception, see < a href = "struct.Builder.html#method.build_invoke" title = "method inkwell::builder::Builder::build_invoke" > < code > Builder::build_invoke< / code > < / a > .< / p >
< ul >
< li > < strong > cleanup< / strong > : a cleanup landing pad is always visited when unwinding the stack.
A cleanup is extra code that needs to be run when unwinding a scope. C++ destructors are a typical example.
In a language with reference counting, the cleanup block can decrement the refcount of values in scope.
The < a href = "struct.Builder.html#method.build_resume" title = "method inkwell::builder::Builder::build_resume" > < code > Builder::build_resume< / code > < / a > function has a full example using a cleanup lading pad.< / li >
< / ul >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // make the cleanup landing pad
< / span > < span class = "kw" > let < / span > res = builder.build_landing_pad( exception_type, personality_function, < span class = "kw-2" > & < / span > [], < span class = "bool-val" > true< / span > , < span class = "string" > "res"< / span > ).unwrap();< / code > < / pre > < / div >
< ul >
< li > < strong > catch all< / strong > : An implementation of the C++ < code > catch(...)< / code > , which catches all exceptions.
A catch clause with a NULL pointer value will match anything.< / li >
< / ul >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // make a null pointer of type i8
< / span > < span class = "kw" > let < / span > null = i8_ptr_type.const_zero();
< span class = "comment" > // make the catch all landing pad
< / span > < span class = "kw" > let < / span > res = builder.build_landing_pad(exception_type, personality_function, < span class = "kw-2" > & < / span > [null.into()], < span class = "bool-val" > false< / span > , < span class = "string" > "res"< / span > ).unwrap();< / code > < / pre > < / div >
< ul >
< li > < strong > catch a type of exception< / strong > : Catch a specific type of exception. The example uses C++’ s type info.< / li >
< / ul >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::values::BasicValue;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // link in the C++ type info for the `int` type
< / span > < span class = "kw" > let < / span > type_info_int = module.add_global(i8_ptr_type, < span class = "prelude-val" > Some< / span > (AddressSpace::default()), < span class = "string" > "_ZTIi"< / span > );
type_info_int.set_linkage(Linkage::External);
< span class = "comment" > // make the catch landing pad
< / span > < span class = "kw" > let < / span > clause = type_info_int.as_basic_value_enum();
< span class = "kw" > let < / span > res = builder.build_landing_pad(exception_type, personality_function, < span class = "kw-2" > & < / span > [clause], < span class = "bool-val" > false< / span > , < span class = "string" > "res"< / span > ).unwrap();< / code > < / pre > < / div >
< ul >
< li > < strong > filter< / strong > : A filter clause encodes that only some types of exceptions are valid at this
point. A filter clause is made by constructing a clause from a constant array.< / li >
< / ul >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > use < / span > inkwell::values::AnyValue;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // link in the C++ type info for the `int` type
< / span > < span class = "kw" > let < / span > type_info_int = module.add_global(i8_ptr_type, < span class = "prelude-val" > Some< / span > (AddressSpace::default()), < span class = "string" > "_ZTIi"< / span > );
type_info_int.set_linkage(Linkage::External);
< span class = "comment" > // make the filter landing pad
< / span > < span class = "kw" > let < / span > filter_pattern = i8_ptr_type.const_array(< span class = "kw-2" > & < / span > [type_info_int.as_any_value_enum().into_pointer_value()]);
< span class = "kw" > let < / span > res = builder.build_landing_pad(exception_type, personality_function, < span class = "kw-2" > & < / span > [filter_pattern.into()], < span class = "bool-val" > false< / span > , < span class = "string" > "res"< / span > ).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_resume" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#935-942" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_resume" class = "fn" > build_resume< / a > < V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
& self,
value: V
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Resume propagation of an existing (in-flight) exception whose unwinding was interrupted with a landingpad instruction.< / p >
2024-02-13 06:38:44 +00:00
< p > This example uses a cleanup landing pad. A cleanup is extra code that needs to be run when
unwinding a scope. C++ destructors are a typical example. In a language with reference counting,
the cleanup block can decrement the refcount of values in scope.< / p >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::module::Linkage;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "sum"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > f32_type = context.f32_type();
< span class = "kw" > let < / span > fn_type = f32_type.fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > );
< span class = "comment" > // we will pretend this function can throw an exception
< / span > < span class = "kw" > let < / span > function = module.add_function(< span class = "string" > "bomb"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > basic_block = context.append_basic_block(function, < span class = "string" > "entry"< / span > );
builder.position_at_end(basic_block);
< span class = "kw" > let < / span > pi = f32_type.const_float(::std::f64::consts::PI);
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > pi)).unwrap();
< span class = "kw" > let < / span > function2 = module.add_function(< span class = "string" > "wrapper"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > basic_block2 = context.append_basic_block(function2, < span class = "string" > "entry"< / span > );
builder.position_at_end(basic_block2);
< span class = "kw" > let < / span > then_block = context.append_basic_block(function2, < span class = "string" > "then_block"< / span > );
< span class = "kw" > let < / span > catch_block = context.append_basic_block(function2, < span class = "string" > "catch_block"< / span > );
< span class = "kw" > let < / span > call_site = builder.build_invoke(function, < span class = "kw-2" > & < / span > [], then_block, catch_block, < span class = "string" > "get_pi"< / span > ).unwrap();
{
builder.position_at_end(then_block);
< span class = "comment" > // in the then_block, the `call_site` value is defined and can be used
< / span > < span class = "kw" > let < / span > result = call_site.try_as_basic_value().left().unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > result)).unwrap();
}
{
builder.position_at_end(catch_block);
< span class = "comment" > // the personality function used by C++
< / span > < span class = "kw" > let < / span > personality_function = {
< span class = "kw" > let < / span > name = < span class = "string" > "__gxx_personality_v0"< / span > ;
< span class = "kw" > let < / span > linkage = < span class = "prelude-val" > Some< / span > (Linkage::External);
module.add_function(name, context.i64_type().fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > ), linkage)
};
< span class = "comment" > // type of an exception in C++
< / span > < span class = "kw" > let < / span > i8_ptr_type = context.i32_type().ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > exception_type = context.struct_type(< span class = "kw-2" > & < / span > [i8_ptr_type.into(), i32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // make the landing pad; must give a concrete type to the slice
< / span > < span class = "kw" > let < / span > res = builder.build_landing_pad( exception_type, personality_function, < span class = "kw-2" > & < / span > [], < span class = "bool-val" > true< / span > , < span class = "string" > "res"< / span > ).unwrap();
< span class = "comment" > // do cleanup ...
< / span > builder.build_resume(res).unwrap();
}< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_gep" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#974-998" > source< / a > < h4 class = "code-header" > pub unsafe fn < a href = "#method.build_gep" class = "fn" > build_gep< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
pointee_ty: T,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
ordered_indexes: & [< a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < 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 >
2024-02-13 06:38:44 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_in_bounds_gep" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1032-1056" > source< / a > < h4 class = "code-header" > pub unsafe fn < a href = "#method.build_in_bounds_gep" class = "fn" > build_in_bounds_gep< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
pointee_ty: T,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
ordered_indexes: & [< a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ],
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < 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 >
2024-02-13 06:38:44 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_struct_gep" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1155-1190" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_struct_gep" class = "fn" > build_struct_gep< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
pointee_ty: T,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
index: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a GEP instruction on a struct pointer. Returns < code > Err< / code > < code > BuilderError::GEPPointee< / code > or < code > BuilderError::GEPIndex< / code > if input < code > PointerValue< / code > doesn’ t
2024-02-13 06:38:44 +00:00
point to a struct or if index is out of bounds.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-3" > < a class = "doc-anchor" href = "#example-3" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "struct_gep"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_ty = context.i32_type();
< span class = "kw" > let < / span > i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > field_types = < span class = "kw-2" > & < / span > [i32_ty.into(), i32_ty.into()];
< span class = "kw" > let < / span > struct_ty = context.struct_type(field_types, < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > struct_ptr_ty = struct_ty.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_ty.into(), struct_ptr_ty.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > ""< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry);
< span class = "kw" > let < / span > i32_ptr = fn_value.get_first_param().unwrap().into_pointer_value();
< span class = "kw" > let < / span > struct_ptr = fn_value.get_last_param().unwrap().into_pointer_value();
< span class = "macro" > assert!< / span > (builder.build_struct_gep(i32_ty, i32_ptr, < span class = "number" > 0< / span > , < span class = "string" > "struct_gep"< / span > ).is_err());
< span class = "macro" > assert!< / span > (builder.build_struct_gep(i32_ty, i32_ptr, < span class = "number" > 10< / span > , < span class = "string" > "struct_gep"< / span > ).is_err());
< span class = "macro" > assert!< / span > (builder.build_struct_gep(struct_ty, struct_ptr, < span class = "number" > 0< / span > , < span class = "string" > "struct_gep"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_struct_gep(struct_ty, struct_ptr, < span class = "number" > 1< / span > , < span class = "string" > "struct_gep"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_struct_gep(struct_ty, struct_ptr, < span class = "number" > 2< / span > , < span class = "string" > "struct_gep"< / span > ).is_err());< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_ptr_diff" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1266-1289" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_ptr_diff" class = "fn" > build_ptr_diff< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
pointee_ty: T,
lhs_ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
rhs_ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an instruction which calculates the difference of two pointers.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-4" > < a class = "doc-anchor" href = "#example-4" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "comment" > // Builds a function which diffs two pointers
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_type.into(), i32_ptr_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_ptr_param1 = fn_value.get_first_param().unwrap().into_pointer_value();
< span class = "kw" > let < / span > i32_ptr_param2 = fn_value.get_nth_param(< span class = "number" > 1< / span > ).unwrap().into_pointer_value();
builder.position_at_end(entry);
builder.build_ptr_diff(i32_ptr_type, i32_ptr_param1, i32_ptr_param2, < span class = "string" > "diff"< / span > ).unwrap();
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();< / code > < / pre > < / div >
< / div > < / details > < section id = "method.build_phi" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1296-1304" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_phi" class = "fn" > build_phi< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
type_: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PhiValue.html" title = "struct inkwell::values::PhiValue" > PhiValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_store" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1331-1342" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_store" class = "fn" > build_store< / a > < V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
value: V
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < 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 >
2024-03-27 11:12:16 +00:00
< h5 id = "example-5" > < a class = "doc-anchor" href = "#example-5" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "comment" > // Builds a function which takes an i32 pointer and stores a 7 in it.
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > i32_seven = i32_type.const_int(< span class = "number" > 7< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value();
builder.position_at_end(entry);
builder.build_store(i32_ptr_param, i32_seven).unwrap();
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_load" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1407-1428" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_load" class = "fn" > build_load< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
pointee_ty: T,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a load2 instruction. It allows you to retrieve a value of type < code > T< / code > from a pointer to a type < code > T< / code > .< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-6" > < a class = "doc-anchor" href = "#example-6" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "comment" > // Builds a function which takes an i32 pointer and returns the pointed at i32.
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "ret"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > fn_type = i32_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "ret"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value();
builder.position_at_end(entry);
< span class = "kw" > let < / span > pointee = builder.build_load(i32_type, i32_ptr_param, < span class = "string" > "load2"< / span > ).unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > pointee)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < section id = "method.build_alloca" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1431-1439" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_alloca" class = "fn" > build_alloca< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
ty: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_array_alloca" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1442-1456" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_array_alloca" class = "fn" > build_array_alloca< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ty: T,
size: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_memcpy" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1469-1504" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_memcpy" class = "fn" > build_memcpy< / a > (
2024-02-13 06:38:44 +00:00
& self,
dest: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
dest_align_bytes: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
2024-02-13 06:38:44 +00:00
src: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
src_align_bytes: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
2024-02-13 06:38:44 +00:00
size: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Build a < a href = "https://llvm.org/docs/LangRef.html#llvm-memcpy-intrinsic" > memcpy< / a > instruction.< / p >
2024-02-13 06:38:44 +00:00
< p > Alignment arguments are specified in bytes, and should always be
both a power of 2 and under 2^64.< / p >
< p > The final argument should be a pointer-sized integer.< / p >
< p > Returns an < code > Err(BuilderError::AlignmentError)< / code > if the source or destination alignments are not a power of 2.< / p >
< p > < a href = "https://thedan64.github.io/inkwell/inkwell/targets/struct.TargetData.html#method.ptr_sized_int_type_in_context" > < code > TargetData::ptr_sized_int_type_in_context< / code > < / a > will get you one of those.< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_memmove" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1517-1552" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_memmove" class = "fn" > build_memmove< / a > (
& self,
dest: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
dest_align_bytes: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
2024-02-13 06:38:44 +00:00
src: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
src_align_bytes: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
2024-02-13 06:38:44 +00:00
size: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Build a < a href = "http://llvm.org/docs/LangRef.html#llvm-memmove-intrinsic" > memmove< / a > instruction.< / p >
2024-02-13 06:38:44 +00:00
< p > Alignment arguments are specified in bytes, and should always be
both a power of 2 and under 2^64.< / p >
< p > The final argument should be a pointer-sized integer.< / p >
< p > Returns an < code > Err(BuilderError::AlignmentError)< / code > if the source or destination alignments are not a power of 2 under 2^64.< / p >
< p > < a href = "https://thedan64.github.io/inkwell/inkwell/targets/struct.TargetData.html#method.ptr_sized_int_type_in_context" > < code > TargetData::ptr_sized_int_type_in_context< / code > < / a > will get you one of those.< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_memset" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1565-1592" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_memset" class = "fn" > build_memset< / a > (
& self,
dest: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
dest_align_bytes: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
2024-02-13 06:38:44 +00:00
val: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
size: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Build a < a href = "http://llvm.org/docs/LangRef.html#llvm-memset-intrinsics" > memset< / a > instruction.< / p >
2024-02-13 06:38:44 +00:00
< p > Alignment arguments are specified in bytes, and should always be
both a power of 2 and under 2^64.< / p >
< p > The final argument should be a pointer-sized integer.< / p >
< p > Returns an < code > Err(BuilderError::AlignmentError)< / code > if the source alignment is not a power of 2 under 2^64.< / p >
< p > < a href = "https://thedan64.github.io/inkwell/inkwell/targets/struct.TargetData.html#method.ptr_sized_int_type_in_context" > < code > TargetData::ptr_sized_int_type_in_context< / code > < / a > will get you one of those.< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_malloc" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1596-1612" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_malloc" class = "fn" > build_malloc< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
ty: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Returns < code > Err(BuilderError::AlignmentError)< / code > if the type is unsized.< / p >
2024-02-13 06:38:44 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_array_malloc" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1616-1638" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_array_malloc" class = "fn" > build_array_malloc< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
& self,
ty: T,
size: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Returns < code > Err(BuilderError::AlignmentError)< / code > if the type is unsized.< / p >
2024-02-13 06:38:44 +00:00
< / div > < / details > < section id = "method.build_free" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1641-1646" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_free" class = "fn" > build_free< / a > (
& self,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.insert_instruction" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1648-1659" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.insert_instruction" class = "fn" > insert_instruction< / a > (
2024-02-13 06:38:44 +00:00
& self,
instruction: & < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title = "enum core::option::Option" > Option< / a > < & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a > >
)< / h4 > < / section > < section id = "method.get_insert_block" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1661-1663" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.get_insert_block" class = "fn" > get_insert_block< / a > (& self) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title = "enum core::option::Option" > Option< / a > < < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> > < / h4 > < / section > < section id = "method.build_int_unsigned_div" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1668-1676" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_unsigned_div" class = "fn" > build_int_unsigned_div< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_signed_div" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1680-1688" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_signed_div" class = "fn" > build_int_signed_div< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_exact_signed_div" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1692-1706" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_exact_signed_div" class = "fn" > build_int_exact_signed_div< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_unsigned_rem" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1710-1718" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_unsigned_rem" class = "fn" > build_int_unsigned_rem< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_signed_rem" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1722-1730" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_signed_rem" class = "fn" > build_int_signed_rem< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_s_extend" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1732-1752" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_s_extend" class = "fn" > build_int_s_extend< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_address_space_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1755-1775" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_address_space_cast" class = "fn" > build_address_space_cast< / a > (
2024-02-13 06:38:44 +00:00
& self,
ptr_val: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
ptr_type: < a class = "struct" href = "../types/struct.PointerType.html" title = "struct inkwell::types::PointerType" > PointerType< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
2024-04-09 11:05:04 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_bit_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1805-1817" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_bit_cast" class = "fn" > build_bit_cast< / a > < T, V> (
2024-02-13 06:38:44 +00:00
& self,
val: V,
ty: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < div class = "where" > where
2024-02-13 06:38:44 +00:00
T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> ,
V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> ,< / div > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a bitcast instruction. A bitcast reinterprets the bits of one value
into a value of another type which has the same bit width.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-7" > < a class = "doc-anchor" href = "#example-7" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::AddressSpace;
< span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "bc"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > f32_type = context.f32_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > arg_types = [i32_type.into()];
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > arg_types, < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "bc"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_arg = fn_value.get_first_param().unwrap();
builder.position_at_end(entry);
2024-04-09 11:05:04 +00:00
builder.build_bit_cast(i32_arg, f32_type, < span class = "string" > "i32tof32"< / span > ).unwrap();
2024-02-13 06:38:44 +00:00
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();
< span class = "macro" > assert!< / span > (module.verify().is_ok());< / code > < / pre > < / div >
< / div > < / details > < section id = "method.build_int_s_extend_or_bit_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1819-1839" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_s_extend_or_bit_cast" class = "fn" > build_int_s_extend_or_bit_cast< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_z_extend" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1841-1861" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_z_extend" class = "fn" > build_int_z_extend< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_z_extend_or_bit_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1863-1883" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_z_extend_or_bit_cast" class = "fn" > build_int_z_extend_or_bit_cast< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_truncate" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1885-1906" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_truncate" class = "fn" > build_int_truncate< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_truncate_or_bit_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1908-1929" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_truncate_or_bit_cast" class = "fn" > build_int_truncate_or_bit_cast< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int_value: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_rem" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1931-1939" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_rem" class = "fn" > build_float_rem< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_to_unsigned_int" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1942-1963" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_to_unsigned_int" class = "fn" > build_float_to_unsigned_int< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
float: T,
int_type: < T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.MathConvType" title = "type inkwell::types::FloatMathType::MathConvType" > MathConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.MathConvType" title = "type inkwell::types::FloatMathType::MathConvType" > MathConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_to_signed_int" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1965-1986" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_to_signed_int" class = "fn" > build_float_to_signed_int< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
float: T,
int_type: < T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.MathConvType" title = "type inkwell::types::FloatMathType::MathConvType" > MathConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.MathConvType" title = "type inkwell::types::FloatMathType::MathConvType" > MathConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_unsigned_int_to_float" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#1989-2010" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_unsigned_int_to_float" class = "fn" > build_unsigned_int_to_float< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int: T,
float_type: < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.MathConvType" title = "type inkwell::types::IntMathType::MathConvType" > MathConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.MathConvType" title = "type inkwell::types::IntMathType::MathConvType" > MathConvType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.ValueType" title = "type inkwell::types::FloatMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_signed_int_to_float" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2012-2033" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_signed_int_to_float" class = "fn" > build_signed_int_to_float< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int: T,
float_type: < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.MathConvType" title = "type inkwell::types::IntMathType::MathConvType" > MathConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.MathConvType" title = "type inkwell::types::IntMathType::MathConvType" > MathConvType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.ValueType" title = "type inkwell::types::FloatMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_trunc" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2035-2055" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_trunc" class = "fn" > build_float_trunc< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
float: T,
float_type: T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_ext" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2057-2077" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_ext" class = "fn" > build_float_ext< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
float: T,
float_type: T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2079-2099" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_cast" class = "fn" > build_float_cast< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
float: T,
float_type: T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2102-2122" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_cast" class = "fn" > build_int_cast< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_int_cast_sign_flag" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2126-2148" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_cast_sign_flag" class = "fn" > build_int_cast_sign_flag< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int: T,
int_type: T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
is_signed: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.bool.html" > bool< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Like < code > build_int_cast< / code > , but respects the signedness of the type being cast to.< / p >
2024-02-13 06:38:44 +00:00
< / div > < / details > < section id = "method.build_float_div" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2150-2158" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_div" class = "fn" > build_float_div< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_add" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2161-2169" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_add" class = "fn" > build_int_add< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nsw_add" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2173-2178" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nsw_add" class = "fn" > build_int_nsw_add< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nuw_add" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2182-2190" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nuw_add" class = "fn" > build_int_nuw_add< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_add" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2193-2201" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_add" class = "fn" > build_float_add< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_xor" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2204-2212" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_xor" class = "fn" > build_xor< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_and" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2215-2223" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_and" class = "fn" > build_and< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_or" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2226-2234" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_or" class = "fn" > build_or< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_left_shift" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2279-2287" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_left_shift" class = "fn" > build_left_shift< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an < code > IntValue< / code > containing the result of a logical left shift instruction.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-8" > < a class = "doc-anchor" href = "#example-8" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< 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" > < code > < span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b0000_0001 < / span > < < < span class = "number" > 0< / span > , < span class = "number" > 0b0000_0001< / span > );
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b0000_0001 < / span > < < < span class = "number" > 1< / span > , < span class = "number" > 0b0000_0010< / span > );
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b0000_0011 < / span > < < < span class = "number" > 2< / span > , < span class = "number" > 0b0000_1100< / span > );< / code > < / 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" > < code > < span class = "kw" > fn < / span > left_shift(value: u8, n: u8) -> u8 {
value < < n
}< / code > < / pre > < / div >
< p > And in Inkwell, the corresponding function would look roughly like:< / p >
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // Setup
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "my_module"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i8_type = context.i8_type();
< span class = "kw" > let < / span > fn_type = i8_type.fn_type(< span class = "kw-2" > & < / span > [i8_type.into(), i8_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // Function Definition
< / span > < span class = "kw" > let < / span > function = module.add_function(< span class = "string" > "left_shift"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > value = function.get_first_param().unwrap().into_int_value();
< span class = "kw" > let < / span > n = function.get_nth_param(< span class = "number" > 1< / span > ).unwrap().into_int_value();
< span class = "kw" > let < / span > entry_block = context.append_basic_block(function, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry_block);
< span class = "kw" > let < / span > shift = builder.build_left_shift(value, n, < span class = "string" > "left_shift"< / span > ).unwrap(); < span class = "comment" > // value < < n
< / span > builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > shift)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_right_shift" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2353-2373" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_right_shift" class = "fn" > build_right_shift< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
sign_extend: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.bool.html" > bool< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an < code > IntValue< / code > containing the result of a right shift instruction.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-9" > < a class = "doc-anchor" href = "#example-9" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< 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" > < code > < span class = "comment" > //fix doc error about overflowing_literals
//rendered rfc: https://github.com/rust-lang/rfcs/blob/master/text/2438-deny-integer-literal-overflow-lint.md
//tracking issue: https://github.com/rust-lang/rust/issues/54502
< / span > < span class = "attr" > #![allow(overflowing_literals)]
< / span > < span class = "comment" > // Logical Right Shift
< / span > < span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b1100_0000u8 < / span > > > < span class = "number" > 2< / span > , < span class = "number" > 0b0011_0000< / span > );
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b0000_0010u8 < / span > > > < span class = "number" > 1< / span > , < span class = "number" > 0b0000_0001< / span > );
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b0000_1100u8 < / 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 = "number" > 0b0100_0000i8 < / span > > > < span class = "number" > 2< / span > , < span class = "number" > 0b0001_0000< / span > );
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b1110_0000u8 < / span > < span class = "kw" > as < / span > i8 > > < span class = "number" > 1< / span > , < span class = "number" > 0b1111_0000u8 < / span > < span class = "kw" > as < / span > i8);
< span class = "macro" > assert_eq!< / span > (< span class = "number" > 0b1100_0000u8 < / span > < span class = "kw" > as < / span > i8 > > < span class = "number" > 2< / span > , < span class = "number" > 0b1111_0000u8 < / span > < span class = "kw" > as < / span > i8);< / code > < / 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" > < code > < span class = "kw" > fn < / span > logical_right_shift(value: u8, n: u8) -> u8 {
value > > n
}
< span class = "kw" > fn < / span > sign_extended_right_shift(value: i8, n: u8) -> i8 {
value > > n
}< / code > < / 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" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "comment" > // Setup
< / span > < span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "my_module"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > i8_type = context.i8_type();
< span class = "kw" > let < / span > fn_type = i8_type.fn_type(< span class = "kw-2" > & < / span > [i8_type.into(), i8_type.into()], < span class = "bool-val" > false< / span > );
< span class = "comment" > // Function Definition
< / span > < span class = "kw" > let < / span > function = module.add_function(< span class = "string" > "right_shift"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > value = function.get_first_param().unwrap().into_int_value();
< span class = "kw" > let < / span > n = function.get_nth_param(< span class = "number" > 1< / span > ).unwrap().into_int_value();
< span class = "kw" > let < / span > entry_block = context.append_basic_block(function, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry_block);
< span class = "comment" > // Whether or not your right shift is sign extended (true) or logical (false) depends
// on the boolean input parameter:
< / span > < span class = "kw" > let < / span > shift = builder.build_right_shift(value, n, < span class = "bool-val" > false< / span > , < span class = "string" > "right_shift"< / span > ).unwrap(); < span class = "comment" > // value > > n
< / span > builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > shift)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < section id = "method.build_int_sub" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2376-2384" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_sub" class = "fn" > build_int_sub< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nsw_sub" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2387-2395" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nsw_sub" class = "fn" > build_int_nsw_sub< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nuw_sub" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2399-2407" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nuw_sub" class = "fn" > build_int_nuw_sub< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_sub" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2410-2418" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_sub" class = "fn" > build_float_sub< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_mul" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2421-2429" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_mul" class = "fn" > build_int_mul< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nsw_mul" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2433-2441" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nsw_mul" class = "fn" > build_int_nsw_mul< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nuw_mul" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2445-2453" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nuw_mul" class = "fn" > build_int_nuw_mul< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_mul" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2456-2464" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_mul" class = "fn" > build_float_mul< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2466-2488" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_cast" class = "fn" > build_cast< / a > < T: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> , V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
op: < a class = "enum" href = "../values/enum.InstructionOpcode.html" title = "enum inkwell::values::InstructionOpcode" > InstructionOpcode< / a > ,
from_value: V,
to_type: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_pointer_cast" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2491-2505" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_pointer_cast" class = "fn" > build_pointer_cast< / a > < T: < a class = "trait" href = "../values/trait.PointerMathValue.html" title = "trait inkwell::values::PointerMathValue" > PointerMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
from: T,
to: T::< a class = "associatedtype" href = "../values/trait.PointerMathValue.html#associatedtype.BaseType" title = "type inkwell::values::PointerMathValue::BaseType" > BaseType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_compare" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2511-2533" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_compare" class = "fn" > build_int_compare< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
op: < a class = "enum" href = "../enum.IntPredicate.html" title = "enum inkwell::IntPredicate" > IntPredicate< / a > ,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_compare" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2537-2561" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_compare" class = "fn" > build_float_compare< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
op: < a class = "enum" href = "../enum.FloatPredicate.html" title = "enum inkwell::FloatPredicate" > FloatPredicate< / a > ,
lhs: T,
rhs: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.FloatMathValue.html#associatedtype.BaseType" title = "type inkwell::values::FloatMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.FloatMathType.html" title = "trait inkwell::types::FloatMathType" > FloatMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.FloatMathType.html#associatedtype.MathConvType" title = "type inkwell::types::FloatMathType::MathConvType" > MathConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_unconditional_branch" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2563-2573" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_unconditional_branch" class = "fn" > build_unconditional_branch< / a > (
2024-02-13 06:38:44 +00:00
& self,
destination_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_conditional_branch" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2575-2594" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_conditional_branch" class = "fn" > build_conditional_branch< / a > (
2024-02-13 06:38:44 +00:00
& self,
comparison: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
then_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
else_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx>
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_indirect_branch" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2596-2611" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_indirect_branch" class = "fn" > build_indirect_branch< / a > < BV: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
address: BV,
destinations: & [< a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ]
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_neg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2614-2622" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_neg" class = "fn" > build_int_neg< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
value: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nsw_neg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2626-2634" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nsw_neg" class = "fn" > build_int_nsw_neg< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
value: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_nuw_neg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2637-2645" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_nuw_neg" class = "fn" > build_int_nuw_neg< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
value: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_float_neg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2648-2656" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_float_neg" class = "fn" > build_float_neg< / a > < T: < a class = "trait" href = "../values/trait.FloatMathValue.html" title = "trait inkwell::values::FloatMathValue" > FloatMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
value: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_not" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2659-2667" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_not" class = "fn" > build_not< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
value: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.position_at" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2674-2678" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.position_at" class = "fn" > position_at< / a > (
2024-02-13 06:38:44 +00:00
& self,
basic_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
instruction: & < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx>
)< / h4 > < / section > < / summary > < div class = "docblock" > < p > Set the position of the builder to after an instruction.< / p >
< p > Be sure to call one of the < code > position_*< / code > methods or all < code > build_*< / code > methods will return < code > Err(BuilderError::UnsetPosition)< / code > .< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.position_before" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2683-2687" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.position_before" class = "fn" > position_before< / a > (& self, instruction: & < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> )< / h4 > < / section > < / summary > < div class = "docblock" > < p > Set the position of the builder to before an instruction.< / p >
< p > Be sure to call one of the < code > position_*< / code > methods or all < code > build_*< / code > methods will return < code > Err(BuilderError::UnsetPosition)< / code > .< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.position_at_end" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2692-2698" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.position_at_end" class = "fn" > position_at_end< / a > (& self, basic_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> )< / h4 > < / section > < / summary > < div class = "docblock" > < p > Set the position of the builder to the end of a basic block.< / p >
< p > Be sure to call one of the < code > position_*< / code > methods or all < code > build_*< / code > methods will return < code > Err(BuilderError::UnsetPosition)< / code > .< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_extract_value" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2758-2781" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_extract_value" class = "fn" > build_extract_value< / a > < AV: < a class = "trait" href = "../values/trait.AggregateValue.html" title = "trait inkwell::values::AggregateValue" > AggregateValue< / a > < 'ctx> > (
& self,
agg: AV,
2024-04-09 10:18:33 +00:00
index: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an extract value instruction which extracts a < code > BasicValueEnum< / code >
2024-02-13 06:38:44 +00:00
from a struct or array.< / p >
< p > Returns < code > Err(BuilderError::ExtractOutOfRange)< / code > if the provided index is out of bounds of the aggregate value length.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-10" > < a class = "doc-anchor" href = "#example-10" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::builder::BuilderError;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "av"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > f32_type = context.f32_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > struct_type = context.struct_type(< span class = "kw-2" > & < / span > [i32_type.into(), f32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > array_type = i32_type.array_type(< span class = "number" > 3< / span > );
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "av_fn"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry);
< span class = "kw" > let < / span > array_alloca = builder.build_alloca(array_type, < span class = "string" > "array_alloca"< / span > ).unwrap();
< span class = "attr" > #[cfg(any(
feature = < span class = "string" > "llvm4-0"< / span > ,
feature = < span class = "string" > "llvm5-0"< / span > ,
feature = < span class = "string" > "llvm6-0"< / span > ,
feature = < span class = "string" > "llvm7-0"< / span > ,
feature = < span class = "string" > "llvm8-0"< / span > ,
feature = < span class = "string" > "llvm9-0"< / span > ,
feature = < span class = "string" > "llvm10-0"< / span > ,
feature = < span class = "string" > "llvm11-0"< / span > ,
feature = < span class = "string" > "llvm12-0"< / span > ,
feature = < span class = "string" > "llvm13-0"< / span > ,
feature = < span class = "string" > "llvm14-0"
< / span > ))]
< / span > < span class = "kw" > let < / span > array = builder.build_load(array_alloca, < span class = "string" > "array_load"< / span > ).unwrap().into_array_value();
2024-04-09 11:05:04 +00:00
< span class = "attr" > #[cfg(any(feature = < span class = "string" > "llvm15-0"< / span > , feature = < span class = "string" > "llvm16-0"< / span > , feature = < span class = "string" > "llvm17-0"< / span > , feature = < span class = "string" > "llvm18-0"< / span > ))]
2024-02-13 06:38:44 +00:00
< / span > < span class = "kw" > let < / span > array = builder.build_load(i32_type, array_alloca, < span class = "string" > "array_load"< / span > ).unwrap().into_array_value();
< span class = "kw" > let < / span > const_int1 = i32_type.const_int(< span class = "number" > 2< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > const_int2 = i32_type.const_int(< span class = "number" > 5< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > const_int3 = i32_type.const_int(< span class = "number" > 6< / span > , < span class = "bool-val" > false< / span > );
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int1, < span class = "number" > 0< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int2, < span class = "number" > 1< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int3, < span class = "number" > 2< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int3, < span class = "number" > 3< / span > , < span class = "string" > "insert"< / span > ).is_err_and(|e| e == BuilderError::ExtractOutOfRange));
< span class = "macro" > assert!< / span > (builder.build_extract_value(array, < span class = "number" > 0< / span > , < span class = "string" > "extract"< / span > ).unwrap().is_int_value());
< span class = "macro" > assert!< / span > (builder.build_extract_value(array, < span class = "number" > 1< / span > , < span class = "string" > "extract"< / span > ).unwrap().is_int_value());
< span class = "macro" > assert!< / span > (builder.build_extract_value(array, < span class = "number" > 2< / span > , < span class = "string" > "extract"< / span > ).unwrap().is_int_value());
< span class = "macro" > assert!< / span > (builder.build_extract_value(array, < span class = "number" > 3< / span > , < span class = "string" > "extract"< / span > ).is_err_and(|e| e == BuilderError::ExtractOutOfRange));< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_insert_value" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2836-2872" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_insert_value" class = "fn" > build_insert_value< / a > < AV, BV> (
& self,
agg: AV,
value: BV,
2024-04-09 10:18:33 +00:00
index: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.u32.html" > u32< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.AggregateValueEnum.html" title = "enum inkwell::values::AggregateValueEnum" > AggregateValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < div class = "where" > where
2024-02-13 06:38:44 +00:00
AV: < a class = "trait" href = "../values/trait.AggregateValue.html" title = "trait inkwell::values::AggregateValue" > AggregateValue< / a > < 'ctx> ,
BV: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> ,< / div > < / h4 > < / section > < / summary > < 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 >
< p > Returns < code > Err(BuilderError::ExtractOutOfRange)< / code > if the provided index is out of bounds of the aggregate value length.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-11" > < a class = "doc-anchor" href = "#example-11" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::builder::BuilderError;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "av"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > f32_type = context.f32_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > struct_type = context.struct_type(< span class = "kw-2" > & < / span > [i32_type.into(), f32_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > array_type = i32_type.array_type(< span class = "number" > 3< / span > );
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "av_fn"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
builder.position_at_end(entry);
< span class = "kw" > let < / span > array_alloca = builder.build_alloca(array_type, < span class = "string" > "array_alloca"< / span > ).unwrap();
< span class = "attr" > #[cfg(any(
feature = < span class = "string" > "llvm4-0"< / span > ,
feature = < span class = "string" > "llvm5-0"< / span > ,
feature = < span class = "string" > "llvm6-0"< / span > ,
feature = < span class = "string" > "llvm7-0"< / span > ,
feature = < span class = "string" > "llvm8-0"< / span > ,
feature = < span class = "string" > "llvm9-0"< / span > ,
feature = < span class = "string" > "llvm10-0"< / span > ,
feature = < span class = "string" > "llvm11-0"< / span > ,
feature = < span class = "string" > "llvm12-0"< / span > ,
feature = < span class = "string" > "llvm13-0"< / span > ,
feature = < span class = "string" > "llvm14-0"
< / span > ))]
< / span > < span class = "kw" > let < / span > array = builder.build_load(array_alloca, < span class = "string" > "array_load"< / span > ).unwrap().into_array_value();
2024-04-09 11:05:04 +00:00
< span class = "attr" > #[cfg(any(feature = < span class = "string" > "llvm15-0"< / span > , feature = < span class = "string" > "llvm16-0"< / span > , feature = < span class = "string" > "llvm17-0"< / span > , feature = < span class = "string" > "llvm18-0"< / span > ))]
2024-02-13 06:38:44 +00:00
< / span > < span class = "kw" > let < / span > array = builder.build_load(i32_type, array_alloca, < span class = "string" > "array_load"< / span > ).unwrap().into_array_value();
< span class = "kw" > let < / span > const_int1 = i32_type.const_int(< span class = "number" > 2< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > const_int2 = i32_type.const_int(< span class = "number" > 5< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > const_int3 = i32_type.const_int(< span class = "number" > 6< / span > , < span class = "bool-val" > false< / span > );
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int1, < span class = "number" > 0< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int2, < span class = "number" > 1< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int3, < span class = "number" > 2< / span > , < span class = "string" > "insert"< / span > ).is_ok());
< span class = "macro" > assert!< / span > (builder.build_insert_value(array, const_int3, < span class = "number" > 3< / span > , < span class = "string" > "insert"< / span > ).is_err_and(|e| e == BuilderError::ExtractOutOfRange));< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_extract_element" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2898-2919" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_extract_element" class = "fn" > build_extract_element< / a > (
& self,
vector: < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> ,
index: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an extract element instruction which extracts a < code > BasicValueEnum< / code >
2024-02-13 06:38:44 +00:00
from a vector.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-12" > < a class = "doc-anchor" href = "#example-12" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "av"< / span > );
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_zero = i32_type.const_int(< span class = "number" > 0< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > vec_type = i32_type.vec_type(< span class = "number" > 2< / span > );
< span class = "kw" > let < / span > fn_type = i32_type.fn_type(< span class = "kw-2" > & < / span > [vec_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "vec_fn"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > vector_param = fn_value.get_first_param().unwrap().into_vector_value();
builder.position_at_end(entry);
< span class = "kw" > let < / span > extracted = builder.build_extract_element(vector_param, i32_zero, < span class = "string" > "insert"< / span > ).unwrap();
builder.build_return(< span class = "prelude-val" > Some< / span > (< span class = "kw-2" > & < / span > extracted)).unwrap();< / code > < / pre > < / div >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_insert_element" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2946-2969" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_insert_element" class = "fn" > build_insert_element< / a > < V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
& self,
vector: < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> ,
element: V,
index: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an insert element instruction which inserts a < code > BasicValue< / code > into a vector
2024-02-13 06:38:44 +00:00
and returns the resulting vector.< / p >
2024-03-27 11:12:16 +00:00
< h5 id = "example-13" > < a class = "doc-anchor" href = "#example-13" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "av"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_zero = i32_type.const_int(< span class = "number" > 0< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > i32_seven = i32_type.const_int(< span class = "number" > 7< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > vec_type = i32_type.vec_type(< span class = "number" > 2< / span > );
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [vec_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "vec_fn"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > vector_param = fn_value.get_first_param().unwrap().into_vector_value();
builder.position_at_end(entry);
builder.build_insert_element(vector_param, i32_seven, i32_zero, < span class = "string" > "insert"< / span > ).unwrap();
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();< / code > < / pre > < / div >
2024-04-09 10:18:33 +00:00
< / div > < / details > < section id = "method.build_unreachable" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2971-2978" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_unreachable" class = "fn" > build_unreachable< / a > (& self) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_fence" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2982-2996" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_fence" class = "fn" > build_fence< / a > (
2024-02-13 06:38:44 +00:00
& self,
atomic_ordering: < a class = "enum" href = "../enum.AtomicOrdering.html" title = "enum inkwell::AtomicOrdering" > AtomicOrdering< / a > ,
2024-04-09 10:18:33 +00:00
num: < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.i32.html" > i32< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_is_null" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#2999-3012" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_is_null" class = "fn" > build_is_null< / a > < T: < a class = "trait" href = "../values/trait.PointerMathValue.html" title = "trait inkwell::values::PointerMathValue" > PointerMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ptr: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.PointerMathValue.html#associatedtype.BaseType" title = "type inkwell::values::PointerMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.PointerMathType.html" title = "trait inkwell::types::PointerMathType" > PointerMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.PointerMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::PointerMathType::PtrConvType" > PtrConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_is_not_null" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3015-3028" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_is_not_null" class = "fn" > build_is_not_null< / a > < T: < a class = "trait" href = "../values/trait.PointerMathValue.html" title = "trait inkwell::values::PointerMathValue" > PointerMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ptr: T,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.PointerMathValue.html#associatedtype.BaseType" title = "type inkwell::values::PointerMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.PointerMathType.html" title = "trait inkwell::types::PointerMathType" > PointerMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.PointerMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::PointerMathType::PtrConvType" > PtrConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_int_to_ptr" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3031-3053" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_int_to_ptr" class = "fn" > build_int_to_ptr< / a > < T: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
int: T,
ptr_type: < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::IntMathType::PtrConvType" > PtrConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.IntMathValue.html#associatedtype.BaseType" title = "type inkwell::values::IntMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::IntMathType::PtrConvType" > PtrConvType< / a > as < a class = "trait" href = "../types/trait.PointerMathType.html" title = "trait inkwell::types::PointerMathType" > PointerMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.PointerMathType.html#associatedtype.ValueType" title = "type inkwell::types::PointerMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_ptr_to_int" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3056-3078" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_ptr_to_int" class = "fn" > build_ptr_to_int< / a > < T: < a class = "trait" href = "../values/trait.PointerMathValue.html" title = "trait inkwell::values::PointerMathValue" > PointerMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ptr: T,
int_type: < T::< a class = "associatedtype" href = "../values/trait.PointerMathValue.html#associatedtype.BaseType" title = "type inkwell::values::PointerMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.PointerMathType.html" title = "trait inkwell::types::PointerMathType" > PointerMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.PointerMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::PointerMathType::PtrConvType" > PtrConvType< / a > ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < < T::< a class = "associatedtype" href = "../values/trait.PointerMathValue.html#associatedtype.BaseType" title = "type inkwell::values::PointerMathValue::BaseType" > BaseType< / a > as < a class = "trait" href = "../types/trait.PointerMathType.html" title = "trait inkwell::types::PointerMathType" > PointerMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.PointerMathType.html#associatedtype.PtrConvType" title = "type inkwell::types::PointerMathType::PtrConvType" > PtrConvType< / a > as < a class = "trait" href = "../types/trait.IntMathType.html" title = "trait inkwell::types::IntMathType" > IntMathType< / a > < 'ctx> > ::< a class = "associatedtype" href = "../types/trait.IntMathType.html#associatedtype.ValueType" title = "type inkwell::types::IntMathType::ValueType" > ValueType< / a > , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.clear_insertion_position" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3080-3082" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.clear_insertion_position" class = "fn" > clear_insertion_position< / a > (& self)< / h4 > < / section > < section id = "method.build_switch" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3087-3110" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_switch" class = "fn" > build_switch< / a > (
2024-02-13 06:38:44 +00:00
& self,
value: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
else_block: < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> ,
cases: & [(< a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> , < a class = "struct" href = "../basic_block/struct.BasicBlock.html" title = "struct inkwell::basic_block::BasicBlock" > BasicBlock< / a > < 'ctx> )]
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.InstructionValue.html" title = "struct inkwell::values::InstructionValue" > InstructionValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_select" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3113-3135" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_select" class = "fn" > build_select< / a > < BV: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> , IMV: < a class = "trait" href = "../values/trait.IntMathValue.html" title = "trait inkwell::values::IntMathValue" > IntMathValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
condition: IMV,
then: BV,
else_: BV,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_global_string" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3138-3147" > source< / a > < h4 class = "code-header" > pub unsafe fn < a href = "#method.build_global_string" class = "fn" > build_global_string< / a > (
2024-02-13 06:38:44 +00:00
& self,
2024-04-09 10:18:33 +00:00
value: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.GlobalValue.html" title = "struct inkwell::values::GlobalValue" > GlobalValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_global_string_ptr" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3151-3160" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_global_string_ptr" class = "fn" > build_global_string_ptr< / a > (
2024-02-13 06:38:44 +00:00
& self,
2024-04-09 10:18:33 +00:00
value: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a > ,
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.GlobalValue.html" title = "struct inkwell::values::GlobalValue" > GlobalValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_shuffle_vector" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3163-3185" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_shuffle_vector" class = "fn" > build_shuffle_vector< / a > (
2024-02-13 06:38:44 +00:00
& self,
left: < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> ,
right: < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> ,
mask: < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> ,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.VectorValue.html" title = "struct inkwell::values::VectorValue" > VectorValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < section id = "method.build_va_arg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3190-3211" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_va_arg" class = "fn" > build_va_arg< / a > < BT: < a class = "trait" href = "../types/trait.BasicType.html" title = "trait inkwell::types::BasicType" > BasicType< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
list: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
type_: BT,
2024-04-09 10:18:33 +00:00
name: & < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.str.html" > str< / a >
2024-04-09 11:05:04 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "enum" href = "../values/enum.BasicValueEnum.html" title = "enum inkwell::values::BasicValueEnum" > BasicValueEnum< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_atomicrmw" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3240-3283" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_atomicrmw" class = "fn" > build_atomicrmw< / a > (
2024-02-13 06:38:44 +00:00
& self,
op: < a class = "enum" href = "../enum.AtomicRMWBinOp.html" title = "enum inkwell::AtomicRMWBinOp" > AtomicRMWBinOp< / a > ,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
value: < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> ,
ordering: < a class = "enum" href = "../enum.AtomicOrdering.html" title = "enum inkwell::AtomicOrdering" > AtomicOrdering< / a >
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.IntValue.html" title = "struct inkwell::values::IntValue" > IntValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds an atomicrmw instruction. It allows you to atomically modify memory.< / p >
2024-02-13 06:38:44 +00:00
< p > May return of the following errors:< / p >
< ul >
< li > < code > Err(BuilderError::BitwidthError)< / code > if the bitwidth of the value is not a power of 2 and less than 8< / li >
< li > < code > Err(BuilderError:PointeeTypeMismatch)< / code > if the pointee type does not match the value’ s type< / li >
< / ul >
2024-03-27 11:12:16 +00:00
< h5 id = "example-14" > < a class = "doc-anchor" href = "#example-14" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::{AddressSpace, AtomicOrdering, AtomicRMWBinOp};
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "rmw"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_seven = i32_type.const_int(< span class = "number" > 7< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > "rmw"< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > i32_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value();
< span class = "kw" > let < / span > builder = context.create_builder();
builder.position_at_end(entry);
builder.build_atomicrmw(AtomicRMWBinOp::Add, i32_ptr_param, i32_seven, AtomicOrdering::Unordered).unwrap();
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();< / code > < / pre > < / div >
2024-04-09 11:05:04 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.build_cmpxchg" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3318-3384" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.build_cmpxchg" class = "fn" > build_cmpxchg< / a > < V: < a class = "trait" href = "../values/trait.BasicValue.html" title = "trait inkwell::values::BasicValue" > BasicValue< / a > < 'ctx> > (
2024-02-13 06:38:44 +00:00
& self,
ptr: < a class = "struct" href = "../values/struct.PointerValue.html" title = "struct inkwell::values::PointerValue" > PointerValue< / a > < 'ctx> ,
cmp: V,
new: V,
success: < a class = "enum" href = "../enum.AtomicOrdering.html" title = "enum inkwell::AtomicOrdering" > AtomicOrdering< / a > ,
failure: < a class = "enum" href = "../enum.AtomicOrdering.html" title = "enum inkwell::AtomicOrdering" > AtomicOrdering< / a >
2024-04-09 10:18:33 +00:00
) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < < a class = "struct" href = "../values/struct.StructValue.html" title = "struct inkwell::values::StructValue" > StructValue< / a > < 'ctx> , < a class = "enum" href = "enum.BuilderError.html" title = "enum inkwell::builder::BuilderError" > BuilderError< / a > > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Builds a cmpxchg instruction. It allows you to atomically compare and replace memory.< / p >
2024-02-13 06:38:44 +00:00
< p > May return one of the following errors:< / p >
< ul >
< li > < code > Err(BuilderError::PointeeTypeMismatch)< / code > if the pointer does not point to an element of the value type< / li >
< li > < code > Err(BuilderError::ValueTypeMismatch)< / code > if the value to compare and the new values are not of the same type, or if
the value does not have a pointer or integer type< / li >
< li > < code > Err(BuilderError::OrderingError)< / code > if the following conditions are not satisfied:
< ul >
< li > Both success and failure orderings are not Monotonic or stronger< / li >
< li > The failure ordering is stronger than the success ordering< / li >
< li > The failure ordering is release or acquire release< / li >
< / ul >
< / li >
< / ul >
2024-03-27 11:12:16 +00:00
< h5 id = "example-15" > < a class = "doc-anchor" href = "#example-15" > §< / a > Example< / h5 >
2024-02-13 06:38:44 +00:00
< div class = "example-wrap" > < pre class = "rust rust-example-rendered" > < code > < span class = "kw" > use < / span > inkwell::context::Context;
< span class = "kw" > use < / span > inkwell::{AddressSpace, AtomicOrdering};
< span class = "kw" > let < / span > context = Context::create();
< span class = "kw" > let < / span > module = context.create_module(< span class = "string" > "cmpxchg"< / span > );
< span class = "kw" > let < / span > void_type = context.void_type();
< span class = "kw" > let < / span > i32_type = context.i32_type();
< span class = "kw" > let < / span > i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
< span class = "kw" > let < / span > fn_type = void_type.fn_type(< span class = "kw-2" > & < / span > [i32_ptr_type.into()], < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > fn_value = module.add_function(< span class = "string" > ""< / span > , fn_type, < span class = "prelude-val" > None< / span > );
< span class = "kw" > let < / span > i32_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value();
< span class = "kw" > let < / span > i32_seven = i32_type.const_int(< span class = "number" > 7< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > i32_eight = i32_type.const_int(< span class = "number" > 8< / span > , < span class = "bool-val" > false< / span > );
< span class = "kw" > let < / span > entry = context.append_basic_block(fn_value, < span class = "string" > "entry"< / span > );
< span class = "kw" > let < / span > builder = context.create_builder();
builder.position_at_end(entry);
builder.build_cmpxchg(i32_ptr_param, i32_seven, i32_eight, AtomicOrdering::AcquireRelease, AtomicOrdering::Monotonic).unwrap();
builder.build_return(< span class = "prelude-val" > None< / span > ).unwrap();< / code > < / pre > < / div >
2024-04-09 11:05:04 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.set_current_debug_location" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3401-3406" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.set_current_debug_location" class = "fn" > set_current_debug_location< / a > (& self, location: < a class = "struct" href = "../debug_info/struct.DILocation.html" title = "struct inkwell::debug_info::DILocation" > DILocation< / a > < 'ctx> )< / h4 > < / section > < / summary > < div class = "docblock" > < p > Set the debug info source location of the instruction currently pointed at by the builder< / p >
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.get_current_debug_location" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3411-3422" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.get_current_debug_location" class = "fn" > get_current_debug_location< / a > (& self) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title = "enum core::option::Option" > Option< / a > < < a class = "struct" href = "../debug_info/struct.DILocation.html" title = "struct inkwell::debug_info::DILocation" > DILocation< / a > < 'ctx> > < / h4 > < / section > < / summary > < div class = "docblock" > < p > Get the debug info source location of the instruction currently pointed at by the builder,
2024-02-13 06:38:44 +00:00
if available.< / p >
2024-04-09 11:05:04 +00:00
< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.unset_current_debug_location" class = "method" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3437-3442" > source< / a > < h4 class = "code-header" > pub fn < a href = "#method.unset_current_debug_location" class = "fn" > unset_current_debug_location< / a > (& self)< / h4 > < / section > < / summary > < div class = "docblock" > < p > Unset the debug info source location of the instruction currently pointed at by the
2024-02-13 06:38:44 +00:00
builder. If there isn’ t any debug info, this is a no-op.< / p >
2024-04-09 11:05:04 +00:00
< / div > < / details > < / div > < / details > < / div > < h2 id = "trait-implementations" class = "section-header" > Trait Implementations< a href = "#trait-implementations" class = "anchor" > §< / a > < / h2 > < div id = "trait-implementations-list" > < details class = "toggle implementors-toggle" open > < summary > < section id = "impl-Debug-for-Builder%3C'ctx%3E" class = "impl" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#87" > source< / a > < a href = "#impl-Debug-for-Builder%3C'ctx%3E" class = "anchor" > §< / a > < h3 class = "code-header" > impl< 'ctx> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/fmt/trait.Debug.html" title = "trait core::fmt::Debug" > Debug< / a > for < a class = "struct" href = "struct.Builder.html" title = "struct inkwell::builder::Builder" > Builder< / a > < 'ctx> < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.fmt" class = "method trait-impl" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#87" > source< / a > < a href = "#method.fmt" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/fmt/trait.Debug.html#tymethod.fmt" class = "fn" > fmt< / a > (& self, f: & mut < a class = "struct" href = "https://doc.rust-lang.org/1.77.1/core/fmt/struct.Formatter.html" title = "struct core::fmt::Formatter" > Formatter< / a > < '_> ) -> < a class = "type" href = "https://doc.rust-lang.org/1.77.1/core/fmt/type.Result.html" title = "type core::fmt::Result" > Result< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > Formats the value using the given formatter. < a href = "https://doc.rust-lang.org/1.77.1/core/fmt/trait.Debug.html#tymethod.fmt" > Read more< / a > < / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" open > < summary > < section id = "impl-Drop-for-Builder%3C'_%3E" class = "impl" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3454-3460" > source< / a > < a href = "#impl-Drop-for-Builder%3C'_%3E" class = "anchor" > §< / a > < h3 class = "code-header" > impl < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/ops/drop/trait.Drop.html" title = "trait core::ops::drop::Drop" > Drop< / a > for < a class = "struct" href = "struct.Builder.html" title = "struct inkwell::builder::Builder" > Builder< / a > < '_> < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.drop" class = "method trait-impl" > < a class = "src rightside" href = "../../src/inkwell/builder.rs.html#3455-3459" > source< / a > < a href = "#method.drop" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/ops/drop/trait.Drop.html#tymethod.drop" class = "fn" > drop< / a > (& mut self)< / h4 > < / section > < / summary > < div class = 'docblock' > Executes the destructor for this type. < a href = "https://doc.rust-lang.org/1.77.1/core/ops/drop/trait.Drop.html#tymethod.drop" > Read more< / a > < / div > < / details > < / div > < / details > < / div > < h2 id = "synthetic-implementations" class = "section-header" > Auto Trait Implementations< a href = "#synthetic-implementations" class = "anchor" > §< / a > < / h2 > < div id = "synthetic-implementations-list" > < section id = "impl-RefUnwindSafe-for-Builder%3C'ctx%3E" class = "impl" > < a href = "#impl-RefUnwindSafe-for-Builder%3C'ctx%3E" class = "anchor" > §< / a > < h3 class = "code-header" > impl< 'ctx> !< a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title = "trait core::panic::unwind_safe::RefUnwindSafe" > RefUnwindSafe< / a > for < a class = "struct" href = "struct.Builder.html" title = "struct inkwell::builder::Builder" > Builder< / a > < 'ctx> < / h3 > < / section > < section id = "impl-Send-for-Builder%3C'ctx%3E" class = "impl" > < a href = "#impl-Send-for-Builder%3C'ctx%3E" class = "anchor" > §< / a > < h3 class = "code-header" > impl< 'ctx> !< a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/marker/trait.Send.html" title = "trait core::marker::Send" > Send< / a > for < a class = "struct" href = "struct.Builder.html" title = "struct inkwell::builder::Builder" > Builder< / a > < 'ctx> < / h3 > < / section > < section id = "impl-Sync-for-Builder%3C'ctx%3E" class = "impl" > < a href = "#impl-Sync-for-Builder%3C'ctx%3E" class = "anchor" > §< / a > < h3 class = "cod
2024-04-09 10:18:33 +00:00
T: 'static + ?< a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/marker/trait.Sized.html" title = "trait core::marker::Sized" > Sized< / a > ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.type_id" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/any.rs.html#141" > source< / a > < a href = "#method.type_id" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/any/trait.Any.html#tymethod.type_id" class = "fn" > type_id< / a > (& self) -> < a class = "struct" href = "https://doc.rust-lang.org/1.77.1/core/any/struct.TypeId.html" title = "struct core::any::TypeId" > TypeId< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > Gets the < code > TypeId< / code > of < code > self< / code > . < a href = "https://doc.rust-lang.org/1.77.1/core/any/trait.Any.html#tymethod.type_id" > Read more< / a > < / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-Borrow%3CT%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/borrow.rs.html#208" > source< / a > < a href = "#impl-Borrow%3CT%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.Borrow.html" title = "trait core::borrow::Borrow" > Borrow< / a > < T> for T< div class = "where" > where
T: ?< a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/marker/trait.Sized.html" title = "trait core::marker::Sized" > Sized< / a > ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.borrow" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/borrow.rs.html#210" > source< / a > < a href = "#method.borrow" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.Borrow.html#tymethod.borrow" class = "fn" > borrow< / a > (& self) -> < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.reference.html" > & T< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > Immutably borrows from an owned value. < a href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.Borrow.html#tymethod.borrow" > Read more< / a > < / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-BorrowMut%3CT%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/borrow.rs.html#216" > source< / a > < a href = "#impl-BorrowMut%3CT%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.BorrowMut.html" title = "trait core::borrow::BorrowMut" > BorrowMut< / a > < T> for T< div class = "where" > where
T: ?< a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/marker/trait.Sized.html" title = "trait core::marker::Sized" > Sized< / a > ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.borrow_mut" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/borrow.rs.html#217" > source< / a > < a href = "#method.borrow_mut" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class = "fn" > borrow_mut< / a > (& mut self) -> < a class = "primitive" href = "https://doc.rust-lang.org/1.77.1/std/primitive.reference.html" > & mut T< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > Mutably borrows from an owned value. < a href = "https://doc.rust-lang.org/1.77.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" > Read more< / a > < / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-From%3CT%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#764" > source< / a > < a href = "#impl-From%3CT%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html" title = "trait core::convert::From" > From< / a > < T> for T< / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.from" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#767" > source< / a > < a href = "#method.from" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html#tymethod.from" class = "fn" > from< / a > (t: T) -> T< / h4 > < / section > < / summary > < div class = "docblock" > < p > Returns the argument unchanged.< / p >
< / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-Into%3CU%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#747-749" > source< / a > < a href = "#impl-Into%3CU%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T, U> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.Into.html" title = "trait core::convert::Into" > Into< / a > < U> for T< div class = "where" > where
U: < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html" title = "trait core::convert::From" > From< / a > < T> ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle method-toggle" open > < summary > < section id = "method.into" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#757" > source< / a > < a href = "#method.into" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.Into.html#tymethod.into" class = "fn" > into< / a > (self) -> U< / h4 > < / section > < / summary > < div class = "docblock" > < p > Calls < code > U::from(self)< / code > .< / p >
2024-02-13 06:38:44 +00:00
< p > That is, this conversion is whatever the implementation of
2024-04-09 10:18:33 +00:00
< code > < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html" title = "trait core::convert::From" > From< / a > < T> for U< / code > chooses to do.< / p >
< / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-TryFrom%3CU%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#804-806" > source< / a > < a href = "#impl-TryFrom%3CU%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T, U> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html" title = "trait core::convert::TryFrom" > TryFrom< / a > < U> for T< div class = "where" > where
U: < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.Into.html" title = "trait core::convert::Into" > Into< / a > < T> ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle" open > < summary > < section id = "associatedtype.Error-1" class = "associatedtype trait-impl" > < a href = "#associatedtype.Error-1" class = "anchor" > §< / a > < h4 class = "code-header" > type < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html#associatedtype.Error" class = "associatedtype" > Error< / a > = < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/convert/enum.Infallible.html" title = "enum core::convert::Infallible" > Infallible< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > The type returned in the event of a conversion error.< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.try_from" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#811" > source< / a > < a href = "#method.try_from" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html#tymethod.try_from" class = "fn" > try_from< / a > (value: U) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < T, < T as < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html" title = "trait core::convert::TryFrom" > TryFrom< / a > < U> > ::< a class = "associatedtype" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html#associatedtype.Error" title = "type core::convert::TryFrom::Error" > Error< / a > > < / h4 > < / section > < / summary > < div class = 'docblock' > Performs the conversion.< / div > < / details > < / div > < / details > < details class = "toggle implementors-toggle" > < summary > < section id = "impl-TryInto%3CU%3E-for-T" class = "impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#789-791" > source< / a > < a href = "#impl-TryInto%3CU%3E-for-T" class = "anchor" > §< / a > < h3 class = "code-header" > impl< T, U> < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryInto.html" title = "trait core::convert::TryInto" > TryInto< / a > < U> for T< div class = "where" > where
U: < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html" title = "trait core::convert::TryFrom" > TryFrom< / a > < T> ,< / div > < / h3 > < / section > < / summary > < div class = "impl-items" > < details class = "toggle" open > < summary > < section id = "associatedtype.Error" class = "associatedtype trait-impl" > < a href = "#associatedtype.Error" class = "anchor" > §< / a > < h4 class = "code-header" > type < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryInto.html#associatedtype.Error" class = "associatedtype" > Error< / a > = < U as < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html" title = "trait core::convert::TryFrom" > TryFrom< / a > < T> > ::< a class = "associatedtype" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html#associatedtype.Error" title = "type core::convert::TryFrom::Error" > Error< / a > < / h4 > < / section > < / summary > < div class = 'docblock' > The type returned in the event of a conversion error.< / div > < / details > < details class = "toggle method-toggle" open > < summary > < section id = "method.try_into" class = "method trait-impl" > < a class = "src rightside" href = "https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#796" > source< / a > < a href = "#method.try_into" class = "anchor" > §< / a > < h4 class = "code-header" > fn < a href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryInto.html#tymethod.try_into" class = "fn" > try_into< / a > (self) -> < a class = "enum" href = "https://doc.rust-lang.org/1.77.1/core/result/enum.Result.html" title = "enum core::result::Result" > Result< / a > < U, < U as < a class = "trait" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html" title = "trait core::convert::TryFrom" > TryFrom< / a > < T> > ::< a class = "associatedtype" href = "https://doc.rust-lang.org/1.77.1/core/convert/trait.TryFrom.html#associatedtype.Error" title = "type core::convert::TryFrom::Error" > Error< / a > > < / h4 > < / section > < / summary > < div class = 'docblock' > Performs the conversion.< / div > < / details > < / div > < / details > < / div > < / section > < / div > < / main > < / body > < / html >