[−][src]Struct inkwell::targets::TargetMachine
Methods
impl TargetMachine
[src]
pub fn get_target(&self) -> Target
[src]
pub fn get_triple(&self) -> LLVMString
[src]
pub fn get_default_triple() -> LLVMString
[src]
Gets the default triple for the current system.
Example
use inkwell::targets::TargetMachine; use std::ffi::CString; let default_triple = TargetMachine::get_default_triple(); assert_eq!(*default_triple, *CString::new("x86_64-pc-linux-gnu").unwrap());
pub fn normalize_target_triple(triple: Either<&str, &CStr>) -> LLVMString
[src]
pub fn get_host_cpu_name() -> LLVMString
[src]
pub fn get_host_cpu_features() -> LLVMString
[src]
Gets a comma separated list of supported features by the host CPU.
Example Output
+sse2,+cx16,+sahf,-tbm
pub fn get_cpu(&self) -> LLVMString
[src]
pub fn get_feature_string(&self) -> &CStr
[src]
pub fn get_target_data(&self) -> TargetData
[src]
Create TargetData from this target machine
pub fn set_asm_verbosity(&self, verbosity: bool)
[src]
pub fn add_analysis_passes<T>(&self, pass_manager: &PassManager<T>)
[src]
pub fn write_to_memory_buffer(
&self,
module: &Module,
file_type: FileType
) -> Result<MemoryBuffer, LLVMString>
[src]
&self,
module: &Module,
file_type: FileType
) -> Result<MemoryBuffer, LLVMString>
Writes a TargetMachine
to a MemoryBuffer
.
Example
use inkwell::OptimizationLevel; use inkwell::context::Context; use inkwell::targets::{CodeModel, RelocMode, FileType, Target, TargetMachine, InitializationConfig}; Target::initialize_x86(&InitializationConfig::default()); let opt = OptimizationLevel::Default; let reloc = RelocMode::Default; let model = CodeModel::Default; let target = Target::from_name("x86-64").unwrap(); let target_machine = target.create_target_machine("x86_64-pc-linux-gnu", "x86-64", "+avx2", opt, reloc, model).unwrap(); let context = Context::create(); let module = context.create_module("my_module"); let void_type = context.void_type(); let fn_type = void_type.fn_type(&[], false); module.add_function("my_fn", fn_type, None); let buffer = target_machine.write_to_memory_buffer(&module, FileType::Assembly).unwrap();
pub fn write_to_file(
&self,
module: &Module,
file_type: FileType,
path: &Path
) -> Result<(), LLVMString>
[src]
&self,
module: &Module,
file_type: FileType,
path: &Path
) -> Result<(), LLVMString>
Saves a TargetMachine
to a file.
Example
use inkwell::OptimizationLevel; use inkwell::context::Context; use inkwell::targets::{CodeModel, RelocMode, FileType, Target, TargetMachine, InitializationConfig}; use std::path::Path; Target::initialize_x86(&InitializationConfig::default()); let opt = OptimizationLevel::Default; let reloc = RelocMode::Default; let model = CodeModel::Default; let path = Path::new("/tmp/some/path/main.asm"); let target = Target::from_name("x86-64").unwrap(); let target_machine = target.create_target_machine("x86_64-pc-linux-gnu", "x86-64", "+avx2", opt, reloc, model).unwrap(); let context = Context::create(); let module = context.create_module("my_module"); let void_type = context.void_type(); let fn_type = void_type.fn_type(&[], false); module.add_function("my_fn", fn_type, None); assert!(target_machine.write_to_file(&module, FileType::Object, &path).is_ok());
Trait Implementations
impl Drop for TargetMachine
[src]
impl Debug for TargetMachine
[src]
Auto Trait Implementations
impl !Sync for TargetMachine
impl !Send for TargetMachine
impl Unpin for TargetMachine
impl UnwindSafe for TargetMachine
impl RefUnwindSafe for TargetMachine
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,