diff --git a/crates/mun_codegen/Cargo.toml b/crates/mun_codegen/Cargo.toml index 6852f526c..945cc1e33 100644 --- a/crates/mun_codegen/Cargo.toml +++ b/crates/mun_codegen/Cargo.toml @@ -15,6 +15,7 @@ categories = ["Game development", "Mun"] [dependencies] abi = { version = "=0.2.0", path = "../mun_abi", package = "mun_abi" } hir = { version = "=0.2.0", path = "../mun_hir", package = "mun_hir" } +mun_codegen_macros = { path = "../mun_codegen_macros", package = "mun_codegen_macros" } mun_target = { version = "=0.2.0", path = "../mun_target" } mun_lld = { version = "=70.2.0", path = "../mun_lld" } failure = "0.1.7" @@ -23,6 +24,7 @@ md5="0.6.1" array-init="0.1.0" tempfile = "3" paste = "0.1.6" +parking_lot = "0.10" [dependencies.inkwell] git = "https://github.com/mun-lang/inkwell" @@ -31,7 +33,6 @@ features = ["llvm7-0"] [dev-dependencies] insta = "0.12.0" -parking_lot = "0.10" [build-dependencies] semver = "0.9.0" diff --git a/crates/mun_codegen/src/code_gen.rs b/crates/mun_codegen/src/code_gen.rs index d14c103f4..a60a65428 100644 --- a/crates/mun_codegen/src/code_gen.rs +++ b/crates/mun_codegen/src/code_gen.rs @@ -1,15 +1,14 @@ use crate::code_gen::linker::LinkerError; +use crate::value::{IrTypeContext, IrValueContext}; use crate::IrDatabase; use failure::Fail; use hir::{FileId, RelativePathBuf}; use inkwell::targets::TargetData; use inkwell::{ - module::{Linkage, Module}, + module::Module, passes::{PassManager, PassManagerBuilder}, targets::{CodeModel, FileType, InitializationConfig, RelocMode, Target, TargetMachine}, - types::StructType, - values::{BasicValue, GlobalValue, IntValue, PointerValue, UnnamedAddress}, - AddressSpace, OptimizationLevel, + OptimizationLevel, }; use mun_target::spec; use std::io::{self, Write}; @@ -152,10 +151,23 @@ impl<'a, D: IrDatabase> ModuleBuilder<'a, D> { .link_in_module(file.llvm_module.clone()) .map_err(|e| CodeGenerationError::ModuleLinkerError(e.to_string()))?; + let target_data = self.db.target_data(); + let type_context = IrTypeContext { + context: &self.assembly_module.get_context(), + target_data: target_data.as_ref(), + struct_types: Default::default(), + }; + + let value_context = IrValueContext { + type_context: &type_context, + context: type_context.context, + module: &self.assembly_module, + }; + // Generate the `get_info` method. symbols::gen_reflection_ir( self.db, - &self.assembly_module, + &value_context, &file.api, &group_ir.dispatch_table, &group_ir.type_table, @@ -202,86 +214,6 @@ fn optimize_module(module: &Module, optimization_lvl: OptimizationLevel) { module_pass_manager.run_on(module); } -/// Intern a string by constructing a global value. Looks something like this: -/// ```c -/// const char[] GLOBAL_ = "str"; -/// ``` -pub(crate) fn intern_string(module: &Module, string: &str, name: &str) -> PointerValue { - let value = module.get_context().const_string(string, true); - gen_global(module, &value, name).as_pointer_value() -} - -/// Construct a global from the specified value -pub(crate) fn gen_global(module: &Module, value: &dyn BasicValue, name: &str) -> GlobalValue { - let global = module.add_global(value.as_basic_value_enum().get_type(), None, name); - global.set_linkage(Linkage::Private); - global.set_constant(true); - global.set_unnamed_address(UnnamedAddress::Global); - global.set_initializer(value); - global -} - -/// Generates a global array from the specified list of strings -pub(crate) fn gen_string_array( - module: &Module, - strings: impl Iterator, - name: &str, -) -> PointerValue { - let str_type = module.get_context().i8_type().ptr_type(AddressSpace::Const); - - let mut strings = strings.peekable(); - if strings.peek().is_none() { - str_type.ptr_type(AddressSpace::Const).const_null() - } else { - let strings = strings - .map(|s| intern_string(module, &s, name)) - .collect::>(); - - let strings_ir = str_type.const_array(&strings); - gen_global(module, &strings_ir, "").as_pointer_value() - } -} - -/// Generates a global array from the specified list of struct pointers -pub(crate) fn gen_struct_ptr_array( - module: &Module, - ir_type: StructType, - ptrs: &[PointerValue], - name: &str, -) -> PointerValue { - if ptrs.is_empty() { - ir_type - .ptr_type(AddressSpace::Const) - .ptr_type(AddressSpace::Const) - .const_null() - } else { - let ptr_array_ir = ir_type.ptr_type(AddressSpace::Const).const_array(&ptrs); - - gen_global(module, &ptr_array_ir, name).as_pointer_value() - } -} - -/// Generates a global array from the specified list of integers -pub(crate) fn gen_u16_array( - module: &Module, - integers: impl Iterator, - name: &str, -) -> PointerValue { - let u16_type = module.get_context().i16_type(); - - let mut integers = integers.peekable(); - if integers.peek().is_none() { - u16_type.ptr_type(AddressSpace::Const).const_null() - } else { - let integers = integers - .map(|i| u16_type.const_int(i, false)) - .collect::>(); - - let array_ir = u16_type.const_array(&integers); - gen_global(module, &array_ir, name).as_pointer_value() - } -} - /// Create an inkwell TargetData from the target in the database pub(crate) fn target_data_query(db: &impl IrDatabase) -> Arc { Arc::new(TargetData::create(&db.target().data_layout)) diff --git a/crates/mun_codegen/src/code_gen/symbols.rs b/crates/mun_codegen/src/code_gen/symbols.rs index 9252e6bd8..bf578b168 100644 --- a/crates/mun_codegen/src/code_gen/symbols.rs +++ b/crates/mun_codegen/src/code_gen/symbols.rs @@ -1,136 +1,109 @@ -use crate::code_gen::{gen_global, gen_struct_ptr_array, intern_string}; +use crate::ir::types as ir; use crate::ir::{ - abi_types::{gen_abi_types, AbiTypes}, dispatch_table::{DispatchTable, DispatchableFunction}, function, type_table::TypeTable, }; use crate::type_info::TypeInfo; +use crate::value::{AsValue, CanInternalize, Global, IrValueContext, IterAsIrValue, Value}; use crate::IrDatabase; use hir::Ty; -use inkwell::{ - attributes::Attribute, - module::{Linkage, Module}, - values::{GlobalValue, PointerValue, StructValue}, - AddressSpace, -}; +use inkwell::{attributes::Attribute, module::Linkage, AddressSpace}; use std::collections::HashSet; +use std::ffi::CString; /// Construct a `MunFunctionPrototype` struct for the specified HIR function. fn gen_prototype_from_function( db: &D, - module: &Module, - types: &AbiTypes, + context: &IrValueContext, function: hir::Function, -) -> StructValue { +) -> ir::FunctionPrototype { + let module = context.module; let name = function.name(db).to_string(); - let name_ir = intern_string(&module, &name, &name); - let _visibility = match function.visibility(db) { - hir::Visibility::Public => 0, - _ => 1, - }; + // Internalize the name of the function prototype + let name_str = CString::new(name.clone()) + .expect("function prototype name is not a valid CString") + .intern(format!("fn_sig::<{}>::name", &name), context); + // Get the `ir::TypeInfo` pointer for the return type of the function let fn_sig = function.ty(db).callable_sig(db).unwrap(); - let ret_type_ir = gen_signature_return_type(db, module, types, fn_sig.ret().clone()); + let return_type = gen_signature_return_type(db, context, fn_sig.ret().clone()); - let param_types: Vec = fn_sig + // Construct an array of pointers to `ir::TypeInfo`s for the arguments of the prototype + let arg_types = fn_sig .params() .iter() .map(|ty| { TypeTable::get(module, &db.type_info(ty.clone())) - .unwrap() - .as_pointer_value() + .expect("expected a TypeInfo for a prototype argument but it was not found") + .as_value(context) }) - .collect(); - - let param_types = gen_struct_ptr_array( - module, - types.type_info_type, - ¶m_types, - &format!("fn_sig::<{}>::arg_types", name), - ); - let num_params = fn_sig.params().len(); - - let signature = types.function_signature_type.const_named_struct(&[ - param_types.into(), - ret_type_ir.into(), - module - .get_context() - .i16_type() - .const_int(num_params as u64, false) - .into(), - ]); - - types - .function_prototype_type - .const_named_struct(&[name_ir.into(), signature.into()]) + .into_const_private_pointer_or_null(format!("fn_sig::<{}>::arg_types", &name), context); + + ir::FunctionPrototype { + name: name_str.as_value(context), + signature: ir::FunctionSignature { + arg_types, + return_type, + num_arg_types: fn_sig.params().len() as u16, + }, + } } /// Construct a `MunFunctionPrototype` struct for the specified dispatch table function. fn gen_prototype_from_dispatch_entry( - module: &Module, - types: &AbiTypes, + context: &IrValueContext, function: &DispatchableFunction, -) -> StructValue { - let name_str = intern_string( - &module, - &function.prototype.name, - &format!("fn_sig::<{}>::name", function.prototype.name), - ); - // let _visibility = match function.visibility(db) { - // hir::Visibility::Public => 0, - // _ => 1, - // }; - let ret_type_ir = gen_signature_return_type_from_type_info( - module, - types, - function.prototype.ret_type.clone(), - ); - let param_types: Vec = function +) -> ir::FunctionPrototype { + let module = context.module; + + // Internalize the name of the function prototype + let name_str = CString::new(function.prototype.name.clone()) + .expect("function prototype name is not a valid CString") + .intern( + format!("fn_sig::<{}>::name", function.prototype.name), + context, + ); + + // Get the `ir::TypeInfo` pointer for the return type of the function + let return_type = + gen_signature_return_type_from_type_info(context, function.prototype.ret_type.clone()); + + // Construct an array of pointers to `ir::TypeInfo`s for the arguments of the prototype + let arg_types = function .prototype .arg_types .iter() .map(|type_info| { TypeTable::get(module, type_info) - .unwrap() - .as_pointer_value() + .expect("expected a TypeInfo for a prototype argument but it was not found") + .as_value(context) }) - .collect(); - let param_types = gen_struct_ptr_array( - module, - types.type_info_type, - ¶m_types, - &format!("{}_param_types", function.prototype.name), - ); - let num_params = function.prototype.arg_types.len(); - - let signature = types.function_signature_type.const_named_struct(&[ - param_types.into(), - ret_type_ir.into(), - module - .get_context() - .i16_type() - .const_int(num_params as u64, false) - .into(), - ]); - - types - .function_prototype_type - .const_named_struct(&[name_str.into(), signature.into()]) + .into_const_private_pointer_or_null( + format!("{}_param_types", function.prototype.name), + context, + ); + + ir::FunctionPrototype { + name: name_str.as_value(context), + signature: ir::FunctionSignature { + arg_types, + return_type, + num_arg_types: function.prototype.arg_types.len() as u16, + }, + } } -/// Given a function, construct a pointer to a `MunTypeInfo` global that represents the return type +/// Given a function, construct a pointer to a `ir::TypeInfo` global that represents the return type /// of the function; or `null` if the return type is empty. fn gen_signature_return_type( db: &D, - module: &Module, - types: &AbiTypes, + context: &IrValueContext, ret_type: Ty, -) -> PointerValue { +) -> Value<*const ir::TypeInfo> { gen_signature_return_type_from_type_info( - module, - types, + context, if ret_type.is_empty() { None } else { @@ -139,36 +112,33 @@ fn gen_signature_return_type( ) } -/// Given a function, construct a pointer to a `MunTypeInfo` global that represents the return type +/// Given a function, construct a pointer to a `ir::TypeInfo` global that represents the return type /// of the function; or `null` if the return type is empty. fn gen_signature_return_type_from_type_info( - module: &Module, - types: &AbiTypes, + context: &IrValueContext, ret_type: Option, -) -> PointerValue { - if let Some(ret_type) = ret_type { - TypeTable::get(module, &ret_type) - .unwrap() - .as_pointer_value() - } else { - types - .type_info_type - .ptr_type(AddressSpace::Const) - .const_null() - } +) -> Value<*const ir::TypeInfo> { + ret_type + .map(|info| { + TypeTable::get(context.module, &info) + .expect("could not find TypeInfo that should definitely be there") + .as_value(context) + }) + .unwrap_or_else(|| Value::null(context)) } /// Construct a global that holds a reference to all functions. e.g.: /// MunFunctionDefinition[] definitions = { ... } fn get_function_definition_array<'a, D: IrDatabase>( db: &D, - module: &Module, - types: &AbiTypes, + context: &IrValueContext, functions: impl Iterator, -) -> GlobalValue { - let function_infos: Vec = functions +) -> Global<[ir::FunctionDefinition]> { + let module = context.module; + functions .map(|f| { let name = f.name(db).to_string(); + // Get the function from the cloned module and modify the linkage of the function. let value = module // If a wrapper function exists, use that (required for struct types) @@ -179,17 +149,14 @@ fn get_function_definition_array<'a, D: IrDatabase>( value.set_linkage(Linkage::Private); // Generate the signature from the function - let prototype = gen_prototype_from_function(db, module, types, *f); - - // Generate the function info value - types.function_definition_type.const_named_struct(&[ - prototype.into(), - value.as_global_value().as_pointer_value().into(), - ]) + let prototype = gen_prototype_from_function(db, context, *f); + ir::FunctionDefinition { + prototype, + fn_ptr: Value::from_raw(value.as_global_value().as_pointer_value()), + } }) - .collect(); - let function_infos = types.function_definition_type.const_array(&function_infos); - gen_global(module, &function_infos, "fn.get_info.functions") + .as_value(context) + .into_const_private_global("fn.get_info.functions", context) } /// Generate the dispatch table information. e.g.: @@ -197,52 +164,34 @@ fn get_function_definition_array<'a, D: IrDatabase>( /// MunDispatchTable dispatchTable = { ... } /// ``` fn gen_dispatch_table( - module: &Module, - types: &AbiTypes, + context: &IrValueContext, dispatch_table: &DispatchTable, -) -> StructValue { - // Generate a vector with all the function signatures - let signatures: Vec = dispatch_table +) -> ir::DispatchTable { + let module = context.module; + + // Generate an internal array that holds all the function prototypes + let prototypes = dispatch_table .entries() .iter() - .map(|entry| gen_prototype_from_dispatch_entry(module, types, entry)) - .collect(); - - // Construct an IR array from the signatures - let signatures = gen_global( - module, - &types.function_signature_type.const_array(&signatures), - "fn.get_info.dispatchTable.signatures", - ); + .map(|entry| gen_prototype_from_dispatch_entry(context, entry)) + .into_const_private_pointer("fn.get_info.dispatchTable.signatures", context); // Get the pointer to the global table (or nullptr if no global table was defined). - let dispatch_table_ptr = dispatch_table + let fn_ptrs = dispatch_table .global_value() .map(|_g| // TODO: This is a hack, the passed module here is a clone of the module with which the // dispatch table was created. Because of this we have to lookup the dispatch table // global again. There is however not a `GlobalValue::get_name` method so I just // hardcoded the name here. - module.get_global("dispatchTable").unwrap().as_pointer_value()) - .unwrap_or_else(|| { - module - .get_context() - .void_type() - .fn_type(&[], false) - .ptr_type(AddressSpace::Const) - .ptr_type(AddressSpace::Generic) - .const_null() - }); - - types.dispatch_table_type.const_named_struct(&[ - signatures.as_pointer_value().into(), - dispatch_table_ptr.into(), - module - .get_context() - .i32_type() - .const_int(dispatch_table.entries().len() as u64, false) - .into(), - ]) + Value::from_raw(module.get_global("dispatchTable").unwrap().as_pointer_value())) + .unwrap_or_else(|| Value::null(context)); + + ir::DispatchTable { + prototypes, + fn_ptrs, + num_entries: dispatch_table.entries().len() as u32, + } } /// Constructs IR that exposes the types and symbols in the specified module. A function called @@ -250,59 +199,50 @@ fn gen_dispatch_table( /// for the ABI that `get_info` exposes. pub(super) fn gen_reflection_ir( db: &impl IrDatabase, - module: &Module, + context: &IrValueContext, api: &HashSet, dispatch_table: &DispatchTable, type_table: &TypeTable, ) { - // Get all the types - let abi_types = gen_abi_types(&module.get_context()); + let module = context.module; - let num_functions = api.len(); - let function_info = get_function_definition_array(db, module, &abi_types, api.iter()); + let num_functions = api.len() as u32; + let functions = get_function_definition_array(db, context, api.iter()); - let type_table_ir = if let Some(type_table) = module.get_global(TypeTable::NAME) { - type_table.as_pointer_value() - } else { - type_table.ty().ptr_type(AddressSpace::Const).const_null() - }; + // Get the TypeTable global + let types = TypeTable::find_global(module) + .map(|g| g.as_value(context)) + .unwrap_or_else(|| Value::null(context)); // Construct the module info struct - let module_info = abi_types.module_info_type.const_named_struct(&[ - intern_string(module, "", "module_info::path").into(), - function_info.as_pointer_value().into(), - module - .get_context() - .i32_type() - .const_int(num_functions as u64, false) - .into(), - type_table_ir.into(), - module - .get_context() - .i32_type() - .const_int(type_table.num_types() as u64, false) - .into(), - ]); + let module_info = ir::ModuleInfo { + path: CString::new("") + .unwrap() + .intern("module_info::path", context) + .as_value(context), + functions: functions.as_value(context), + num_functions, + types, + num_types: type_table.num_types() as u32, + }; // Construct the dispatch table struct - let dispatch_table = gen_dispatch_table(module, &abi_types, dispatch_table); + let dispatch_table = gen_dispatch_table(context, dispatch_table); // Construct the actual `get_info` function - gen_get_info_fn(db, module, &abi_types, module_info, dispatch_table); - gen_set_allocator_handle_fn(db, module); + gen_get_info_fn(db, context, module_info, dispatch_table); + gen_set_allocator_handle_fn(db, context); } /// Construct the actual `get_info` function. fn gen_get_info_fn( db: &impl IrDatabase, - module: &Module, - abi_types: &AbiTypes, - module_info: StructValue, - dispatch_table: StructValue, + context: &IrValueContext, + module_info: ir::ModuleInfo, + dispatch_table: ir::DispatchTable, ) { - let context = module.get_context(); let target = db.target(); - let str_type = context.i8_type().ptr_type(AddressSpace::Const); + let str_type = context.context.i8_type().ptr_type(AddressSpace::Generic); // Construct the return type of the `get_info` method. Depending on the C ABI this is either the // `MunAssemblyInfo` struct or void. On windows the return argument is passed back to the caller @@ -316,24 +256,22 @@ fn gen_get_info_fn( // MunModuleInfo get_info() { ... } // ``` let get_symbols_type = if target.options.is_like_windows { - context.void_type().fn_type( - &[abi_types - .assembly_info_type - .ptr_type(AddressSpace::Generic) - .into()], - false, - ) + Value::::get_ir_type(context.type_context) } else { - abi_types.assembly_info_type.fn_type(&[], false) + Value:: ir::AssemblyInfo>::get_ir_type(context.type_context) }; let get_symbols_fn = - module.add_function("get_info", get_symbols_type, Some(Linkage::DLLExport)); + context + .module + .add_function("get_info", get_symbols_type, Some(Linkage::DLLExport)); if target.options.is_like_windows { get_symbols_fn.add_attribute( inkwell::attributes::AttributeLoc::Param(0), - context.create_enum_attribute(Attribute::get_named_enum_kind_id("sret"), 1), + context + .context + .create_enum_attribute(Attribute::get_named_enum_kind_id("sret"), 1), ); } @@ -349,7 +287,10 @@ fn gen_get_info_fn( .unwrap() .into_pointer_value() } else { - builder.build_alloca(abi_types.assembly_info_type, "") + builder.build_alloca( + Value::::get_ir_type(context.type_context), + "", + ) }; // Get access to the structs internals @@ -360,15 +301,15 @@ fn gen_get_info_fn( unsafe { builder.build_struct_gep(result_ptr, 3, "num_dependencies") }; // Assign the struct values one by one. - builder.build_store(symbols_addr, module_info); - builder.build_store(dispatch_table_addr, dispatch_table); + builder.build_store(symbols_addr, module_info.as_value(context).value); + builder.build_store(dispatch_table_addr, dispatch_table.as_value(context).value); builder.build_store( dependencies_addr, - str_type.ptr_type(AddressSpace::Const).const_null(), + str_type.ptr_type(AddressSpace::Generic).const_null(), ); builder.build_store( num_dependencies_addr, - context.i32_type().const_int(0 as u64, false), + context.context.i32_type().const_int(0 as u64, false), ); // Construct the return statement of the function. @@ -379,20 +320,16 @@ fn gen_get_info_fn( } // Run the function optimizer on the generate function - function::create_pass_manager(&module, db.optimization_lvl()).run_on(&get_symbols_fn); + function::create_pass_manager(&context.module, db.optimization_lvl()).run_on(&get_symbols_fn); } -fn gen_set_allocator_handle_fn(db: &impl IrDatabase, module: &Module) { - let context = module.get_context(); - let allocator_handle_type = context.i8_type().ptr_type(AddressSpace::Generic); - - let set_allocator_handle_fn_type = context - .void_type() - .fn_type(&[allocator_handle_type.into()], false); - - let set_allocator_handle_fn = module.add_function( +/// Generates a method `void set_allocator_handle(void*)` that stores the argument into the global +/// `allocatorHandle`. This global is used internally to reference the allocator used by this +/// munlib. +fn gen_set_allocator_handle_fn(db: &impl IrDatabase, context: &IrValueContext) { + let set_allocator_handle_fn = context.module.add_function( "set_allocator_handle", - set_allocator_handle_fn_type, + Value::::get_ir_type(context.type_context), Some(Linkage::DLLExport), ); @@ -402,7 +339,7 @@ fn gen_set_allocator_handle_fn(db: &impl IrDatabase, module: &Module) { .append_basic_block(&set_allocator_handle_fn, "body"); builder.position_at_end(&body_ir); - if let Some(allocator_handle_global) = module.get_global("allocatorHandle") { + if let Some(allocator_handle_global) = context.module.get_global("allocatorHandle") { builder.build_store( allocator_handle_global.as_pointer_value(), set_allocator_handle_fn.get_nth_param(0).unwrap(), diff --git a/crates/mun_codegen/src/ir.rs b/crates/mun_codegen/src/ir.rs index 90a328e35..9af50e5d9 100644 --- a/crates/mun_codegen/src/ir.rs +++ b/crates/mun_codegen/src/ir.rs @@ -6,7 +6,6 @@ use inkwell::types::{ }; use inkwell::AddressSpace; -pub(crate) mod abi_types; pub mod adt; pub mod body; #[macro_use] @@ -17,6 +16,7 @@ pub mod function; mod intrinsics; pub mod ty; pub(crate) mod type_table; +pub mod types; /// Try to down cast an `AnyTypeEnum` into a `BasicTypeEnum`. fn try_convert_any_to_basic(ty: AnyTypeEnum) -> Option { @@ -173,24 +173,16 @@ impl_fundamental_ir_types!( impl IsIrType for usize { type Type = IntType; - fn ir_type(context: &Context, target: &TargetData) -> Self::Type { - match target.get_pointer_byte_size(None) { - 4 => ::ir_type(context, target), - 8 => ::ir_type(context, target), - _ => unimplemented!("unsupported pointer byte size"), - } + fn ir_type(_context: &Context, target: &TargetData) -> Self::Type { + target.ptr_sized_int_type(None) } } impl IsIrType for isize { type Type = IntType; - fn ir_type(context: &Context, target: &TargetData) -> Self::Type { - match target.get_pointer_byte_size(None) { - 4 => ::ir_type(context, target), - 8 => ::ir_type(context, target), - _ => unimplemented!("unsupported pointer byte size"), - } + fn ir_type(_context: &Context, target: &TargetData) -> Self::Type { + target.ptr_sized_int_type(None) } } @@ -200,21 +192,21 @@ pub trait IsPointerType { impl> IsPointerType for *const T { fn ir_type(context: &Context, target: &TargetData) -> PointerType { - T::ir_type(context, target).ptr_type(AddressSpace::Const) + T::ir_type(context, target).ptr_type(AddressSpace::Generic) } } // HACK: Manually add `*const TypeInfo` impl IsPointerType for *const TypeInfo { fn ir_type(context: &Context, _target: &TargetData) -> PointerType { - context.i8_type().ptr_type(AddressSpace::Const) + context.i8_type().ptr_type(AddressSpace::Generic) } } // HACK: Manually add `*const c_void` impl IsPointerType for *const std::ffi::c_void { fn ir_type(context: &Context, _target: &TargetData) -> PointerType { - context.i8_type().ptr_type(AddressSpace::Const) + context.i8_type().ptr_type(AddressSpace::Generic) } } diff --git a/crates/mun_codegen/src/ir/abi_types.rs b/crates/mun_codegen/src/ir/abi_types.rs deleted file mode 100644 index 2df1f21f2..000000000 --- a/crates/mun_codegen/src/ir/abi_types.rs +++ /dev/null @@ -1,152 +0,0 @@ -use inkwell::context::Context; -use inkwell::types::{ArrayType, IntType, StructType}; -use inkwell::AddressSpace; - -#[derive(Debug, PartialEq, Eq)] -pub(crate) struct AbiTypes { - pub guid_type: ArrayType, - pub type_group_type: IntType, - pub privacy_type: IntType, - pub type_info_type: StructType, - pub function_signature_type: StructType, - pub function_prototype_type: StructType, - pub function_definition_type: StructType, - pub struct_info_type: StructType, - pub module_info_type: StructType, - pub dispatch_table_type: StructType, - pub assembly_info_type: StructType, -} - -/// Returns an `AbiTypes` struct that contains references to all LLVM ABI types. -pub(crate) fn gen_abi_types(context: &Context) -> AbiTypes { - let str_type = context.i8_type().ptr_type(AddressSpace::Const); - - // Construct the `MunGuid` type - let guid_type = context.i8_type().array_type(16); - - // Construct the `MunTypeGroup` type - let type_group_type = context.i8_type(); - - // Construct the `MunPrivacy` enum - let privacy_type = context.i8_type(); - - // Construct the `MunTypeInfo` struct - let type_info_type = context.opaque_struct_type("struct.MunTypeInfo"); - type_info_type.set_body( - &[ - guid_type.into(), // guid - str_type.into(), // name - context.i32_type().into(), // size_in_bits - context.i8_type().into(), // alignment - type_group_type.into(), // group - ], - false, - ); - - let type_info_ptr_type = type_info_type.ptr_type(AddressSpace::Const); - - // Construct the `MunFunctionSignature` type - let function_signature_type = context.opaque_struct_type("struct.MunFunctionSignature"); - function_signature_type.set_body( - &[ - type_info_ptr_type.ptr_type(AddressSpace::Const).into(), // arg_types - type_info_ptr_type.into(), // return_type - context.i16_type().into(), // num_arg_types - ], - false, - ); - - // Construct the `MunFunctionSignature` type - let function_prototype_type = context.opaque_struct_type("struct.MunFunctionPrototype"); - function_prototype_type.set_body( - &[ - str_type.into(), // name - function_signature_type.into(), // signature - ], - false, - ); - - // Construct the `MunFunctionDefinition` struct - let function_definition_type = context.opaque_struct_type("struct.MunFunctionDefinition"); - function_definition_type.set_body( - &[ - function_prototype_type.into(), // prototype - context - .void_type() - .fn_type(&[], false) - .ptr_type(AddressSpace::Const) - .into(), // fn_ptr - ], - false, - ); - - // Construct the `MunStructInfo` struct - let struct_info_type = context.opaque_struct_type("struct.MunStructInfo"); - struct_info_type.set_body( - &[ - str_type.ptr_type(AddressSpace::Const).into(), // field_names - type_info_ptr_type.ptr_type(AddressSpace::Const).into(), // field_types - context.i16_type().ptr_type(AddressSpace::Const).into(), // field_offsets - context.i16_type().into(), // num_fields - context.i8_type().into(), // memory_kind - ], - false, - ); - - // Construct the `MunModuleInfo` struct - let module_info_type = context.opaque_struct_type("struct.MunModuleInfo"); - module_info_type.set_body( - &[ - str_type.into(), // path - function_definition_type - .ptr_type(AddressSpace::Const) - .into(), // functions - context.i32_type().into(), // num_functions - type_info_ptr_type.ptr_type(AddressSpace::Const).into(), // types - context.i32_type().into(), // num_types - ], - false, - ); - - // Construct the `MunDispatchTable` struct - let dispatch_table_type = context.opaque_struct_type("struct.MunDispatchTable"); - dispatch_table_type.set_body( - &[ - function_signature_type.ptr_type(AddressSpace::Const).into(), // signatures - context - .void_type() - .fn_type(&[], false) - .ptr_type(AddressSpace::Generic) - .ptr_type(AddressSpace::Const) - .into(), // fn_ptrs - context.i32_type().into(), // num_entries - ], - false, - ); - - // Construct the `MunAssemblyInfo` struct - let assembly_info_type = context.opaque_struct_type("struct.MunAssemblyInfo"); - assembly_info_type.set_body( - &[ - module_info_type.into(), - dispatch_table_type.into(), - str_type.ptr_type(AddressSpace::Const).into(), - context.i32_type().into(), - ], - false, - ); - - AbiTypes { - guid_type, - type_group_type, - privacy_type, - type_info_type, - function_signature_type, - function_prototype_type, - function_definition_type, - struct_info_type, - module_info_type, - dispatch_table_type, - assembly_info_type, - } -} diff --git a/crates/mun_codegen/src/ir/body.rs b/crates/mun_codegen/src/ir/body.rs index 57b4754d4..600661cc3 100644 --- a/crates/mun_codegen/src/ir/body.rs +++ b/crates/mun_codegen/src/ir/body.rs @@ -14,6 +14,8 @@ use inkwell::{ }; use std::{collections::HashMap, sync::Arc}; +use crate::ir::types as ir; +use crate::value::Global; use hir::ResolveBitness; use inkwell::basic_block::BasicBlock; use inkwell::values::{AggregateValueEnum, GlobalValue, PointerValue}; @@ -30,7 +32,7 @@ struct LoopInfo { pub(crate) struct ExternalGlobals { pub alloc_handle: Option, pub dispatch_table: Option, - pub type_table: Option, + pub type_table: Option>, } pub(crate) struct BodyIrGenerator<'a, 'b, D: IrDatabase> { @@ -382,7 +384,7 @@ impl<'a, 'b, D: IrDatabase> BodyIrGenerator<'a, 'b, D> { // HACK: We should be able to use pointers for built-in struct types like `TypeInfo` in intrinsics let type_info_ptr = self.builder.build_bitcast( type_info_ptr, - self.db.context().i8_type().ptr_type(AddressSpace::Const), + self.db.context().i8_type().ptr_type(AddressSpace::Generic), "type_info_ptr_to_i8_ptr", ); @@ -411,7 +413,7 @@ impl<'a, 'b, D: IrDatabase> BodyIrGenerator<'a, 'b, D> { object_ptr, struct_ir_ty .ptr_type(AddressSpace::Generic) - .ptr_type(AddressSpace::Const), + .ptr_type(AddressSpace::Generic), &format!("{}_ptr_ptr", hir_struct.name(self.db).to_string()), ) .into_pointer_value(); diff --git a/crates/mun_codegen/src/ir/file.rs b/crates/mun_codegen/src/ir/file.rs index d5a8b0dd1..b3d099604 100644 --- a/crates/mun_codegen/src/ir/file.rs +++ b/crates/mun_codegen/src/ir/file.rs @@ -1,5 +1,6 @@ use super::body::ExternalGlobals; use crate::ir::{function, type_table::TypeTable}; +use crate::value::Global; use crate::{CodeGenParams, IrDatabase}; use hir::{FileId, ModuleDef}; use inkwell::module::Module; @@ -74,7 +75,7 @@ pub(crate) fn ir_query(db: &impl IrDatabase, file_id: FileId) -> Arc { ExternalGlobals { alloc_handle, dispatch_table, - type_table, + type_table: type_table.map(|g| unsafe { Global::from_raw(g) }), } }; diff --git a/crates/mun_codegen/src/ir/file_group.rs b/crates/mun_codegen/src/ir/file_group.rs index ec9419923..bc9cb95a9 100644 --- a/crates/mun_codegen/src/ir/file_group.rs +++ b/crates/mun_codegen/src/ir/file_group.rs @@ -1,10 +1,10 @@ use super::{ - abi_types::{gen_abi_types, AbiTypes}, adt, dispatch_table::{DispatchTable, DispatchTableBuilder}, intrinsics, type_table::{TypeTable, TypeTableBuilder}, }; +use crate::value::{IrTypeContext, IrValueContext}; use crate::IrDatabase; use hir::ModuleDef; use inkwell::{module::Module, types::PointerType, values::UnnamedAddress, AddressSpace}; @@ -16,8 +16,6 @@ use std::{collections::BTreeMap, sync::Arc}; pub struct FileGroupIR { /// The LLVM module that contains the IR pub(crate) llvm_module: Module, - /// Contains references to all of the ABI's IR types. - pub(crate) abi_types: AbiTypes, /// The dispatch table pub(crate) dispatch_table: DispatchTable, /// The type table @@ -75,14 +73,18 @@ pub(crate) fn ir_query(db: &impl IrDatabase, file_id: hir::FileId) -> Arc Arc A TypeCtor::Struct(s) => { let struct_ty = db.struct_ty(s); match s.data(db).memory_kind { - hir::StructMemoryKind::GC => struct_ty.ptr_type(AddressSpace::Generic).ptr_type(AddressSpace::Const).into(), + hir::StructMemoryKind::GC => struct_ty.ptr_type(AddressSpace::Generic).ptr_type(AddressSpace::Generic).into(), hir::StructMemoryKind::Value if params.make_marshallable => - struct_ty.ptr_type(AddressSpace::Generic).ptr_type(AddressSpace::Const).into(), + struct_ty.ptr_type(AddressSpace::Generic).ptr_type(AddressSpace::Generic).into(), hir::StructMemoryKind::Value => struct_ty.into(), } } diff --git a/crates/mun_codegen/src/ir/type_table.rs b/crates/mun_codegen/src/ir/type_table.rs index 160f2403c..e78469c94 100644 --- a/crates/mun_codegen/src/ir/type_table.rs +++ b/crates/mun_codegen/src/ir/type_table.rs @@ -1,29 +1,21 @@ -use crate::code_gen::{ - gen_global, gen_string_array, gen_struct_ptr_array, gen_u16_array, intern_string, -}; -use crate::ir::{ - abi_types::AbiTypes, - dispatch_table::{DispatchTable, FunctionPrototype}, -}; +use super::types as ir; +use crate::ir::dispatch_table::{DispatchTable, FunctionPrototype}; use crate::type_info::{TypeGroup, TypeInfo}; +use crate::value::{AsValue, CanInternalize, Global, IrValueContext, IterAsIrValue, Value}; use crate::IrDatabase; use hir::{Body, ExprId, InferenceResult}; -use inkwell::{ - module::Module, - targets::TargetData, - types::ArrayType, - values::{GlobalValue, IntValue, PointerValue, StructValue}, - AddressSpace, -}; +use inkwell::module::Linkage; +use inkwell::{module::Module, targets::TargetData, types::ArrayType, values::PointerValue}; use std::collections::{BTreeSet, HashMap}; -use std::{convert::TryInto, mem, sync::Arc}; +use std::convert::TryInto; +use std::ffi::CString; +use std::{mem, sync::Arc}; /// A type table in IR is a list of pointers to unique type information that are used to generate /// function and struct information. #[derive(Debug, Clone, Eq, PartialEq)] pub struct TypeTable { type_info_to_index: HashMap, - entries: Vec, table_type: ArrayType, } @@ -31,6 +23,14 @@ impl TypeTable { /// The name of the TypeTable's LLVM `GlobalValue`. pub(crate) const NAME: &'static str = "global_type_table"; + /// Looks for a global symbol with the name of the TypeTable global in the specified `module`. + /// Returns the global value if it could be found, `None` otherwise. + pub fn find_global(module: &Module) -> Option> { + module + .get_global(Self::NAME) + .map(|g| unsafe { Global::from_raw(g) }) + } + /// Generates a `TypeInfo` lookup through the `TypeTable`, equivalent to something along the /// lines of: `type_table[i]`, where `i` is the index of the type and `type_table` is an array /// of `TypeInfo` pointers. @@ -38,7 +38,7 @@ impl TypeTable { &self, builder: &inkwell::builder::Builder, type_info: &TypeInfo, - table_ref: Option, + table_ref: Option>, ) -> PointerValue { let table_ref = table_ref.expect("no type table defined"); @@ -49,7 +49,7 @@ impl TypeTable { let ptr_to_type_info_ptr = unsafe { builder.build_struct_gep( - table_ref.as_pointer_value(), + table_ref.into(), index as u32, &format!("{}_ptr_ptr", type_info.name), ) @@ -60,18 +60,20 @@ impl TypeTable { } /// Retrieves the global `TypeInfo` IR value corresponding to `type_info`, if it exists. - pub fn get(module: &Module, type_info: &TypeInfo) -> Option { - module.get_global(&type_info_global_name(type_info)) + pub fn get(module: &Module, type_info: &TypeInfo) -> Option> { + module + .get_global(&type_info_global_name(type_info)) + .map(|g| unsafe { Global::from_raw(g) }) } /// Returns the number of types in the `TypeTable`. pub fn num_types(&self) -> usize { - self.entries.len() + self.table_type.len() as usize } /// Returns whether the type table is empty. pub fn is_empty(&self) -> bool { - self.entries.is_empty() + self.table_type.len() == 0 } /// Returns the IR type of the type table's global value, if it exists. @@ -81,29 +83,26 @@ impl TypeTable { } /// Used to build a `TypeTable` from HIR. -pub(crate) struct TypeTableBuilder<'a, D: IrDatabase> { +pub(crate) struct TypeTableBuilder<'a, 'ctx, 'm, D: IrDatabase> { db: &'a D, target_data: Arc, - module: &'a Module, - abi_types: &'a AbiTypes, + value_context: &'a IrValueContext<'a, 'ctx, 'm>, dispatch_table: &'a DispatchTable, entries: BTreeSet, // Use a `BTreeSet` to guarantee deterministically ordered output } -impl<'a, D: IrDatabase> TypeTableBuilder<'a, D> { +impl<'a, 'ctx, 'm, D: IrDatabase> TypeTableBuilder<'a, 'ctx, 'm, D> { /// Creates a new `TypeTableBuilder`. pub(crate) fn new<'f>( db: &'a D, - module: &'a Module, - abi_types: &'a AbiTypes, + value_context: &'a IrValueContext<'a, 'ctx, 'm>, intrinsics: impl Iterator, dispatch_table: &'a DispatchTable, ) -> Self { let mut builder = Self { db, target_data: db.target_data(), - module, - abi_types, + value_context, dispatch_table, entries: BTreeSet::new(), }; @@ -176,111 +175,127 @@ impl<'a, D: IrDatabase> TypeTableBuilder<'a, D> { fn gen_type_info( &self, - type_info_to_ir: &mut HashMap, + type_info_to_ir: &mut HashMap>, type_info: &TypeInfo, - ) -> GlobalValue { - let context = self.module.get_context(); - let guid_bytes_ir: [IntValue; 16] = array_init::array_init(|i| { - context - .i8_type() - .const_int(u64::from(type_info.guid.b[i]), false) - }); - let type_info_ir = self.abi_types.type_info_type.const_named_struct(&[ - context.i8_type().const_array(&guid_bytes_ir).into(), - intern_string( - self.module, - &type_info.name, - &format!("type_info::<{}>::name", type_info.name), - ) - .into(), - context - .i32_type() - .const_int(type_info.size.bit_size, false) - .into(), - context - .i8_type() - .const_int(type_info.size.alignment as u64, false) - .into(), - context - .i8_type() - .const_int(type_info.group.clone().into(), false) - .into(), - ]); - let type_info_ir = match type_info.group { - TypeGroup::FundamentalTypes => type_info_ir, + ) -> Global { + // If there is already an entry, return that. + if let Some(global) = type_info_to_ir.get(type_info) { + return *global; + } + + // Construct the header part of the abi::TypeInfo + let type_info_ir = ir::TypeInfo { + guid: type_info.guid, + name: CString::new(type_info.name.clone()) + .expect("typename is not a valid CString") + .intern( + format!("type_info::<{}>::name", type_info.name), + self.value_context, + ) + .as_value(self.value_context), + size_in_bits: type_info + .size + .bit_size + .try_into() + .expect("could not convert size in bits to smaller size"), + alignment: type_info + .size + .alignment + .try_into() + .expect("could not convert alignment to smaller size"), + group: type_info.group.to_abi_type(), + } + .as_value(self.value_context); + + // Build the global value for the ir::TypeInfo + let type_ir_name = type_info_global_name(type_info); + let global = match type_info.group { + TypeGroup::FundamentalTypes => { + type_info_ir.into_const_private_global(&type_ir_name, self.value_context) + } TypeGroup::StructTypes(s) => { + // In case of a struct the `Global` is actually a + // `Global<(ir::TypeInfo, ir::StructInfo)>`. We mask this value which is unsafe + // but correct from an ABI perspective. let struct_info_ir = self.gen_struct_info(type_info_to_ir, s); - context.const_struct(&[type_info_ir.into(), struct_info_ir.into()], false) + let compound_type_ir = (type_info_ir, struct_info_ir).as_value(self.value_context); + let compound_global = + compound_type_ir.into_const_private_global(&type_ir_name, self.value_context); + unsafe { Global::from_raw(compound_global.value) } } }; - gen_global( - self.module, - &type_info_ir, - &type_info_global_name(type_info), - ) + + // Insert the value in this case, so we don't recompute and generate multiple values. + type_info_to_ir.insert(type_info.clone(), global); + + global } fn gen_struct_info( &self, - type_info_to_ir: &mut HashMap, + type_info_to_ir: &mut HashMap>, hir_struct: hir::Struct, - ) -> StructValue { + ) -> Value { let struct_ir = self.db.struct_ty(hir_struct); let name = hir_struct.name(self.db).to_string(); let fields = hir_struct.fields(self.db); - let field_names = gen_string_array( - self.module, - fields.iter().map(|field| field.name(self.db).to_string()), - &format!("struct_info::<{}>::field_names", name), - ); - let field_types: Vec = fields + // Construct an array of field names (or null if there are no fields) + let field_names = fields + .iter() + .enumerate() + .map(|(idx, field)| { + CString::new(field.name(self.db).to_string()) + .expect("field name is not a valid CString") + .intern( + format!("struct_info::<{}>::field_names.{}", name, idx), + self.value_context, + ) + .as_value(self.value_context) + }) + .into_const_private_pointer_or_null( + format!("struct_info::<{}>::field_names", name), + self.value_context, + ); + + // Construct an array of field types (or null if there are no fields) + let field_types = fields .iter() .map(|field| { let field_type_info = self.db.type_info(field.ty(self.db)); - if let Some(ir_value) = type_info_to_ir.get(&field_type_info) { - *ir_value - } else { - let ir_value = self.gen_type_info(type_info_to_ir, &field_type_info); - type_info_to_ir.insert(field_type_info, ir_value); - ir_value - } - .as_pointer_value() + self.gen_type_info(type_info_to_ir, &field_type_info) + .as_value(self.value_context) }) - .collect(); - - let field_types = gen_struct_ptr_array( - self.module, - self.abi_types.type_info_type, - &field_types, - &format!("struct_info::<{}>::field_types", name), - ); - - let field_offsets = gen_u16_array( - self.module, - (0..fields.len()).map(|idx| { + .into_const_private_pointer_or_null( + format!("struct_info::<{}>::field_types", name), + self.value_context, + ); + + // Construct an array of field offsets (or null if there are no fields) + let field_offsets = fields + .iter() + .enumerate() + .map(|(idx, _)| { self.target_data .offset_of_element(&struct_ir, idx as u32) - .unwrap() - }), - &format!("struct_info::<{}>::field_offsets", name), - ); - - self.abi_types.struct_info_type.const_named_struct(&[ - field_names.into(), - field_types.into(), - field_offsets.into(), - self.module - .get_context() - .i16_type() - .const_int(fields.len() as u64, false) - .into(), - self.module - .get_context() - .i8_type() - .const_int(hir_struct.data(self.db).memory_kind.clone().into(), false) - .into(), - ]) + .unwrap() as u16 + }) + .into_const_private_pointer_or_null( + format!("struct_info::<{}>::field_offsets", name), + self.value_context, + ); + + ir::StructInfo { + field_names, + field_types, + field_offsets, + num_fields: fields + .len() + .try_into() + .expect("could not convert num_fields to smaller bit size"), + memory_kind: hir_struct.data(self.db).memory_kind.clone(), + } + .as_value(self.value_context) } /// Constructs a `TypeTable` from all *used* types. @@ -291,43 +306,33 @@ impl<'a, D: IrDatabase> TypeTableBuilder<'a, D> { let mut type_info_to_ir = HashMap::with_capacity(entries.len()); let mut type_info_to_index = HashMap::with_capacity(entries.len()); - let type_info_ptr_type = self.abi_types.type_info_type.ptr_type(AddressSpace::Const); - let table_type = type_info_ptr_type.array_type( - entries - .len() - .try_into() - .expect("expected a maximum of u32::MAX entries"), - ); - - let type_info_ptrs: Vec = entries + // Construct a list of all `ir::TypeInfo`s + let type_info_ptrs: Value<[*const ir::TypeInfo]> = entries .into_iter() .enumerate() .map(|(index, type_info)| { - let ptr = if let Some(ir_value) = type_info_to_ir.get(&type_info) { - *ir_value - } else { - let ir_value = self.gen_type_info(&mut type_info_to_ir, &type_info); - type_info_to_ir.insert(type_info.clone(), ir_value); - ir_value - } - .as_pointer_value(); - + let ptr = self + .gen_type_info(&mut type_info_to_ir, &type_info) + .as_value(self.value_context); type_info_to_index.insert(type_info, index); ptr }) - .collect(); + .as_value(self.value_context); + // If there are types, introduce a special global that contains all the TypeInfos if !type_info_ptrs.is_empty() { - let global = self.module.add_global(table_type, None, TypeTable::NAME); - - let type_info_ptrs_array = type_info_ptr_type.const_array(&type_info_ptrs); - global.set_initializer(&type_info_ptrs_array); + let _: Global<[*const ir::TypeInfo]> = type_info_ptrs.into_global( + TypeTable::NAME, + self.value_context, + true, + Linkage::External, + None, + ); }; TypeTable { type_info_to_index, - entries: type_info_ptrs, - table_type, + table_type: type_info_ptrs.get_type(), } } } diff --git a/crates/mun_codegen/src/ir/types.rs b/crates/mun_codegen/src/ir/types.rs new file mode 100644 index 000000000..4e0cd0d19 --- /dev/null +++ b/crates/mun_codegen/src/ir/types.rs @@ -0,0 +1,114 @@ +use crate::value::{AsValue, IrValueContext, SizedValueType, TransparentValue, Value}; +use mun_codegen_macros::{AsValue, TestIsAbiCompatible}; + +impl TransparentValue for abi::Guid { + type Target = [u8; 16]; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + self.b.as_value(context) + } +} + +impl TransparentValue for abi::Privacy { + type Target = u8; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + (*self as u8).as_value(context) + } +} + +impl TransparentValue for abi::TypeGroup { + type Target = u8; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + (*self as u8).as_value(context) + } +} + +impl TransparentValue for abi::StructMemoryKind { + type Target = u8; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + (self.clone() as u8).as_value(context) + } +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunTypeInfo"] +#[abi_type(abi::TypeInfo)] +pub struct TypeInfo { + pub guid: abi::Guid, + pub name: Value<*const u8>, + pub size_in_bits: u32, + pub alignment: u8, + pub group: abi::TypeGroup, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunFunctionSignature"] +#[abi_type(abi::FunctionSignature)] +pub struct FunctionSignature { + pub arg_types: Value<*const *const TypeInfo>, + pub return_type: Value<*const TypeInfo>, + pub num_arg_types: u16, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunFunctionPrototype"] +#[abi_type(abi::FunctionPrototype)] +pub struct FunctionPrototype { + pub name: Value<*const u8>, + pub signature: FunctionSignature, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunFunctionDefinition"] +#[abi_type(abi::FunctionDefinition)] +pub struct FunctionDefinition { + pub prototype: FunctionPrototype, + pub fn_ptr: Value<*const fn()>, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunStructInfo"] +#[abi_type(abi::StructInfo)] +pub struct StructInfo { + pub field_names: Value<*const *const u8>, + pub field_types: Value<*const *const TypeInfo>, + pub field_offsets: Value<*const u16>, + pub num_fields: u16, + pub memory_kind: abi::StructMemoryKind, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunModuleInfo"] +#[abi_type(abi::ModuleInfo)] +pub struct ModuleInfo { + pub path: Value<*const u8>, + pub functions: Value<*const FunctionDefinition>, + pub num_functions: u32, + pub types: Value<*const *const TypeInfo>, + pub num_types: u32, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunDispatchTable"] +#[abi_type(abi::DispatchTable)] +pub struct DispatchTable { + pub prototypes: Value<*const FunctionPrototype>, + pub fn_ptrs: Value<*mut *const fn()>, + pub num_entries: u32, +} + +#[derive(AsValue, TestIsAbiCompatible)] +#[ir_name = "struct.MunAssemblyInfo"] +#[abi_type(abi::AssemblyInfo)] +pub struct AssemblyInfo { + pub symbols: ModuleInfo, + pub dispatch_table: DispatchTable, + pub dependencies: Value<*const *const u8>, + pub num_dependencies: u32, +} + +#[cfg(test)] +mod test; diff --git a/crates/mun_codegen/src/ir/types/test.rs b/crates/mun_codegen/src/ir/types/test.rs new file mode 100644 index 000000000..acd223780 --- /dev/null +++ b/crates/mun_codegen/src/ir/types/test.rs @@ -0,0 +1,192 @@ +use crate::value::{ConcreteValueType, Value}; + +/// A trait implemented by a type to check if its values match its corresponding abi type (T). This +/// trait can be derived. e.g.: +/// +/// ```ignore,rust +/// #[derive(AsValue, TestIsAbiCompatible)] +/// #[ir_name = "struct.MunTypeInfo"] +/// #[abi_type(abi::TypeInfo)] +/// pub struct TypeInfo { } +/// ``` +/// +/// The procedural macro calls for every field: +/// +/// ```ignore,rust +/// self::test::AbiTypeHelper::from_value(&abi_value.) +/// .ir_type::<>() +/// .assert_compatible(, , ); +/// ``` +pub trait TestIsAbiCompatible { + /// Runs a test to see if the implementor is compatible with the specified abi type. + fn test(abi_value: &T); +} + +/// A trait that is implemented if a type is ABI compatible with `T`. +pub trait IsAbiCompatible {} + +/// A trait indicating that a type is *not* compatible. This is a helper trait used to determine +/// if a type is ABI compatible at runtime. By default this trait is implemented for all types. +pub trait IsNotAbiCompatible { + fn assert_compatible(&self, ir_type: &str, abi_type: &str, field_name: &str) { + panic!( + "the field '{}' on type '{}' is not compatible with the ABI version of the struct ({})", + field_name, ir_type, abi_type + ); + } +} +impl IsNotAbiCompatible for T {} + +/// Helper structs that allows extracting the type of a value. +pub struct AbiTypeHelper(std::marker::PhantomData); +pub struct AbiAndIrTypeHelper(std::marker::PhantomData, std::marker::PhantomData); + +impl AbiTypeHelper { + pub fn from_value(_: &T) -> Self { + Self(Default::default()) + } + + pub fn ir_type(&self) -> AbiAndIrTypeHelper { + AbiAndIrTypeHelper(Default::default(), Default::default()) + } +} + +impl> AbiAndIrTypeHelper { + pub fn assert_compatible(&self, _ir_type: &str, _abi_type: &str, _field_name: &str) {} +} + +impl IsAbiCompatible for u8 {} +impl IsAbiCompatible for u16 {} +impl IsAbiCompatible for u32 {} +impl IsAbiCompatible for abi::Guid {} +impl IsAbiCompatible for abi::TypeGroup {} +impl IsAbiCompatible for abi::StructMemoryKind {} +impl IsAbiCompatible<*const ::std::os::raw::c_char> for *const u8 {} +impl IsAbiCompatible<*const ::std::os::raw::c_void> for *const fn() {} +impl> IsAbiCompatible<*const S> for *const T {} +impl> IsAbiCompatible<*mut S> for *mut T {} +impl IsAbiCompatible for Value where T: IsAbiCompatible {} + +#[test] +#[cfg(test)] +fn test_type_info_abi_compatible() { + let abi_type = abi::TypeInfo { + guid: abi::Guid { + b: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + }, + name: std::ptr::null(), + size_in_bits: 0, + alignment: 0, + group: abi::TypeGroup::FundamentalTypes, + }; + + super::TypeInfo::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_function_signature_abi_compatible() { + let abi_type = abi::FunctionSignature { + arg_types: std::ptr::null(), + return_type: std::ptr::null(), + num_arg_types: 0, + }; + + super::FunctionSignature::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_function_prototype_abi_compatible() { + let abi_type = abi::FunctionPrototype { + name: std::ptr::null(), + signature: abi::FunctionSignature { + arg_types: std::ptr::null(), + return_type: std::ptr::null(), + num_arg_types: 0, + }, + }; + + super::FunctionPrototype::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_function_definition_abi_compatible() { + let abi_type = abi::FunctionDefinition { + prototype: abi::FunctionPrototype { + name: std::ptr::null(), + signature: abi::FunctionSignature { + arg_types: std::ptr::null(), + return_type: std::ptr::null(), + num_arg_types: 0, + }, + }, + fn_ptr: std::ptr::null(), + }; + + super::FunctionDefinition::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_struct_info_abi_compatible() { + let abi_type = abi::StructInfo { + field_names: std::ptr::null(), + field_types: std::ptr::null(), + field_offsets: std::ptr::null(), + num_fields: 0, + memory_kind: abi::StructMemoryKind::Value, + }; + + super::StructInfo::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_module_info_abi_compatible() { + let abi_type = abi::ModuleInfo { + path: std::ptr::null(), + functions: std::ptr::null(), + num_functions: 0, + types: std::ptr::null(), + num_types: 0, + }; + + super::ModuleInfo::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_dispatch_table_abi_compatible() { + let abi_type = abi::DispatchTable { + prototypes: std::ptr::null(), + fn_ptrs: std::ptr::null_mut(), + num_entries: 0, + }; + + super::DispatchTable::test(&abi_type); +} + +#[test] +#[cfg(test)] +fn test_assembly_info_abi_compatible() { + let abi_type = abi::AssemblyInfo { + symbols: abi::ModuleInfo { + path: std::ptr::null(), + functions: std::ptr::null(), + num_functions: 0, + types: std::ptr::null(), + num_types: 0, + }, + dispatch_table: abi::DispatchTable { + prototypes: std::ptr::null(), + fn_ptrs: std::ptr::null_mut(), + num_entries: 0, + }, + dependencies: std::ptr::null(), + num_dependencies: 0, + }; + + super::AssemblyInfo::test(&abi_type); +} diff --git a/crates/mun_codegen/src/lib.rs b/crates/mun_codegen/src/lib.rs index b9cf8cf18..fd03ee7fe 100644 --- a/crates/mun_codegen/src/lib.rs +++ b/crates/mun_codegen/src/lib.rs @@ -9,10 +9,12 @@ mod mock; #[cfg(test)] mod test; +pub mod value; + pub(crate) mod intrinsics; pub(crate) mod type_info; -pub use inkwell::{builder, context::Context, module::Module, values, OptimizationLevel}; +pub use inkwell::{builder::Builder, context::Context, module::Module, OptimizationLevel}; pub use crate::{ code_gen::ModuleBuilder, diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_f32.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_f32.snap index 7602d2420..97d4c9a0b 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_f32.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_f32.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: f32, b: f32) -> f32 { a + b }\npub fn subtract(a: f32 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define float @add(float, float) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"P\19b7\A8k\F2\81P\FB\83\F5P\B0\82!", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_f64.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_f64.snap index 40a2915e2..c6b90daef 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_f64.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_f64.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: f64, b: f64) -> f64 { a + b }\npub fn subtract(a: f64 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define double @add(double, double) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i128.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i128.snap index 79eaabced..b58a0e4af 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: i128, b: i128) -> i128 { a + b }\npub fn subtract(a: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @add(i128, i128) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i16.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i16.snap index 01db94dd7..e7b20b7e3 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: i16, b: i16) -> i16 { a + b }\npub fn subtract(a: i16 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @add(i16, i16) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i32.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i32.snap index c7d32d8fa..461e3c7c9 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: i32, b: i32) -> i32 { a + b }\npub fn subtract(a: i32 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @add(i32, i32) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i64.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i64.snap index f667ae492..6dacdbc83 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: i64, b: i64) -> i64 { a + b }\npub fn subtract(a: i64 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @add(i64, i64) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i8.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i8.snap index 19b107f1c..698f85a1a 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: i8, b: i8) -> i8 { a + b }\npub fn subtract(a: i8, b: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @add(i8, i8) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u128.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u128.snap index 99d8b1a4d..8bd60b7c4 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: u128, b: u128) -> u128 { a + b }\npub fn subtract(a: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @add(i128, i128) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u16.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u16.snap index acf9dff0a..8ffe59c1f 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: u16, b: u16) -> u16 { a + b }\npub fn subtract(a: u16 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @add(i16, i16) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u32.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u32.snap index 7317daf7c..474c8cba3 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: u32, b: u32) -> u32 { a + b }\npub fn subtract(a: u32 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @add(i32, i32) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u64.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u64.snap index c0f39f57a..62b015249 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: u64, b: u64) -> u64 { a + b }\npub fn subtract(a: u64 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @add(i64, i64) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u8.snap b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u8.snap index acc8bfe88..0da88e014 100644 --- a/crates/mun_codegen/src/snapshots/test__arithmetic_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__arithmetic_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a: u8, b: u8) -> u8 { a + b }\npub fn subtract(a: u8, b: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @add(i8, i8) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_bool.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_bool.snap index 0e65dfdfd..69ed6cc2e 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_bool.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_bool.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: bool, b: bool) -> bool {\n a &= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @assign_bitand(i1, i1) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i128.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i128.snap index 7cbd8588b..f3372122f 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: i128, b: i128) -> i128 {\n a &= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign_bitand(i128, i128) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i16.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i16.snap index aa2d8e4b6..dcb497344 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: i16, b: i16) -> i16 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign_bitand(i16, i16) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i32.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i32.snap index 80332af3a..eca27946f 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: i32, b: i32) -> i32 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign_bitand(i32, i32) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i64.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i64.snap index 256eac4b9..cd1c14e91 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: i64, b: i64) -> i64 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign_bitand(i64, i64) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i8.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i8.snap index ff3c5021d..c5974dede 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: i8, b: i8) -> i8 {\n a &= b;\n a\n}\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign_bitand(i8, i8) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u128.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u128.snap index 54788b2ce..f41fd8ae2 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: u128, b: u128) -> u128 {\n a &= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign_bitand(i128, i128) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u16.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u16.snap index 666b851a2..0a3915f09 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: u16, b: u16) -> u16 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign_bitand(i16, i16) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u32.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u32.snap index 9d6c9fae6..230b4e72a 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: u32, b: u32) -> u32 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign_bitand(i32, i32) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u64.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u64.snap index 69126daac..f0b25e61b 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: u64, b: u64) -> u64 {\n a &= b;\n a\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign_bitand(i64, i64) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u8.snap b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u8.snap index 4006f04f5..222c2a433 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_bit_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_bit_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_bitand(a: u8, b: u8) -> u8 {\n a &= b;\n a\n}\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign_bitand(i8, i8) { body: @@ -33,9 +33,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i128.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i128.snap index 3e9b617c8..9628f538f 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: i128, b: i128) -> i128 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign_leftshift(i128, i128) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i16.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i16.snap index 8ff47534c..4570b9e11 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: i16, b: i16) -> i16 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign_leftshift(i16, i16) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i32.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i32.snap index b21d5da4f..9d0a5b767 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: i32, b: i32) -> i32 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign_leftshift(i32, i32) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i64.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i64.snap index 72c0519c5..64c4209e5 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: i64, b: i64) -> i64 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign_leftshift(i64, i64) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i8.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i8.snap index a11f61f0a..12cba77fc 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: i8, b: i8) -> i8 {\n a <<= b;\n a\ ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign_leftshift(i8, i8) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u128.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u128.snap index fad552c29..ae356f084 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: u128, b: u128) -> u128 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign_leftshift(i128, i128) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u16.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u16.snap index 4b27791f5..da1de4609 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: u16, b: u16) -> u16 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign_leftshift(i16, i16) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u32.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u32.snap index 7bdedba6a..118001e28 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: u32, b: u32) -> u32 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign_leftshift(i32, i32) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u64.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u64.snap index 8852ebd91..13cff008e 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: u64, b: u64) -> u64 {\n a <<= b;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign_leftshift(i64, i64) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u8.snap b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u8.snap index 8e769ab28..6bf87f629 100644 --- a/crates/mun_codegen/src/snapshots/test__assign_shift_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__assign_shift_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign_leftshift(a: u8, b: u8) -> u8 {\n a <<= b;\n a\ ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign_leftshift(i8, i8) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_bool.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_bool.snap index f35cab24c..5b4ff5a54 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_bool.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_bool.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: bool, b: bool) -> bool {\n a = b;\n a\n}\n// ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @assign(i1, i1) { body: @@ -20,9 +20,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_f32.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_f32.snap index b3dfb32e0..36dd1f755 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_f32.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_f32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: f32, b: f32) -> f32 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define float @assign(float, float) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"P\19b7\A8k\F2\81P\FB\83\F5P\B0\82!", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_f64.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_f64.snap index 9106e0ef9..048889a52 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_f64.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_f64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: f64, b: f64) -> f64 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define double @assign(double, double) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_i128.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_i128.snap index 7f1a67a56..9aa9651d4 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: i128, b: i128) -> i128 {\n a = b;\n a\n}\npu ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign(i128, i128) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_i16.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_i16.snap index 487afd247..8a8e5b7d3 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: i16, b: i16) -> i16 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign(i16, i16) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_i32.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_i32.snap index 931124eba..a9ad895cc 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: i32, b: i32) -> i32 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign(i32, i32) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_i64.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_i64.snap index ddede7911..04128bff1 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: i64, b: i64) -> i64 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign(i64, i64) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_i8.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_i8.snap index eeb90991a..3d5f7559b 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: i8, b: i8) -> i8 {\n a = b;\n a\n}\npub fn a ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign(i8, i8) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_struct.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_struct.snap index cb8e55bea..f9802ed7a 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_struct.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_struct.snap @@ -6,14 +6,14 @@ expression: "struct(value) Value(i32, i32);\nstruct(gc) Heap(f64, f64);\n\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } %Value = type { i32, i32 } %Heap = type { double, double } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [7 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [7 x %struct.MunTypeInfo*] define %Value @assign_value(%Value, %Value) { body: @@ -22,27 +22,27 @@ body: ret %Value %1 } -define %Value* addrspace(4)* @assign_value_wrapper(%Value* addrspace(4)*, %Value* addrspace(4)*) { +define %Value** @assign_value_wrapper(%Value**, %Value**) { body: - %mem_ptr = load %Value*, %Value* addrspace(4)* %0 + %mem_ptr = load %Value*, %Value** %0 %deref = load %Value, %Value* %mem_ptr - %mem_ptr1 = load %Value*, %Value* addrspace(4)* %1 + %mem_ptr1 = load %Value*, %Value** %1 %deref2 = load %Value, %Value* %mem_ptr1 %assign_value = call %Value @assign_value(%Value %deref, %Value %deref2) - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %Value_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([7 x %struct.MunTypeInfo addrspace(4)*], [7 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 1) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %Value_ptr to i8 addrspace(4)* + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %Value_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([7 x %struct.MunTypeInfo*], [7 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 1) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %Value_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %Value_ptr_ptr = bitcast i8* addrspace(4)* %new to %Value* addrspace(4)* - %Value_mem_ptr = load %Value*, %Value* addrspace(4)* %Value_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %Value_ptr_ptr = bitcast i8** %new to %Value** + %Value_mem_ptr = load %Value*, %Value** %Value_ptr_ptr store %Value %assign_value, %Value* %Value_mem_ptr - ret %Value* addrspace(4)* %Value_ptr_ptr + ret %Value** %Value_ptr_ptr } -define %Heap* addrspace(4)* @assign_heap(%Heap* addrspace(4)*, %Heap* addrspace(4)*) { +define %Heap** @assign_heap(%Heap**, %Heap**) { body: - ret %Heap* addrspace(4)* %1 + ret %Heap** %1 } @@ -50,35 +50,35 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [6 x i8] c"Value\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" @"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" -@0 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 4] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"(3\1C%q\83\13+L\A6Q\F7\1DX\A6\9B", [6 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @0, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"(3\1C%q\83\13+L\A6Q\F7\1DX\A6\9B", [6 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } @"type_info::::name" = private unnamed_addr constant [5 x i8] c"Heap\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" -@"struct_info::::field_names.2" = private unnamed_addr constant [2 x i8] c"1\00" -@1 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.2"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"1\1CC\F80{\17\AFq\94\89\FB4\AC\A8\F3", [5 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @1, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"1\1CC\F80{\17\AFq\94\89\FB4\AC\A8\F3", [5 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" @"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } -@global_type_table = global [7 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@global_type_table = constant [7 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] @allocatorHandle = unnamed_addr global i8* null diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_u128.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_u128.snap index 3e96c575f..f333bf1c1 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: u128, b: u128) -> u128 {\n a = b;\n a\n}\npu ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @assign(i128, i128) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_u16.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_u16.snap index 96c37bc8d..8bacf4dff 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: u16, b: u16) -> u16 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @assign(i16, i16) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_u32.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_u32.snap index 69398e1db..4be7c38ec 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: u32, b: u32) -> u32 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @assign(i32, i32) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_u64.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_u64.snap index a17f6bf04..95ae29ee7 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: u64, b: u64) -> u64 {\n a = b;\n a\n}\npub f ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @assign(i64, i64) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__assignment_op_u8.snap b/crates/mun_codegen/src/snapshots/test__assignment_op_u8.snap index 4c9fee01c..eaf1969ba 100644 --- a/crates/mun_codegen/src/snapshots/test__assignment_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__assignment_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn assign(a: u8, b: u8) -> u8 {\n a = b;\n a\n}\npub fn a ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @assign(i8, i8) { body: @@ -50,9 +50,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_bool.snap b/crates/mun_codegen/src/snapshots/test__bit_op_bool.snap index 350346da1..7892e1668 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_bool.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_bool.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: bool) -> bool { !a }\npub fn bitand(a: bool, b: bool) ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @not(i1) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_i128.snap b/crates/mun_codegen/src/snapshots/test__bit_op_i128.snap index c5bf283ac..164207c0c 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: i128) -> i128 { !a }\npub fn bitand(a: i128, b: i128) ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @not(i128) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_i16.snap b/crates/mun_codegen/src/snapshots/test__bit_op_i16.snap index c83d9f1dc..302761196 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: i16) -> i16 { !a }\npub fn bitand(a: i16, b: i16) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @not(i16) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_i32.snap b/crates/mun_codegen/src/snapshots/test__bit_op_i32.snap index 038000f95..816215819 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: i32) -> i32 { !a }\npub fn bitand(a: i32, b: i32) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @not(i32) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_i64.snap b/crates/mun_codegen/src/snapshots/test__bit_op_i64.snap index 3b6c8e2a8..fa207f8c8 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: i64) -> i64 { !a }\npub fn bitand(a: i64, b: i64) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @not(i64) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_i8.snap b/crates/mun_codegen/src/snapshots/test__bit_op_i8.snap index 93b9694fb..d3df0c1ce 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: i8) -> i8 { !a }\npub fn bitand(a: i8, b: i8) -> i8 { ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @not(i8) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_u128.snap b/crates/mun_codegen/src/snapshots/test__bit_op_u128.snap index e419c6c06..094769110 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: u128) -> u128 { !a }\npub fn bitand(a: u128, b: u128) ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @not(i128) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_u16.snap b/crates/mun_codegen/src/snapshots/test__bit_op_u16.snap index 810ef05bf..0e18501ee 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: u16) -> u16 { !a }\npub fn bitand(a: u16, b: u16) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @not(i16) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_u32.snap b/crates/mun_codegen/src/snapshots/test__bit_op_u32.snap index 20aa00cb3..c17d27fc1 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: u32) -> u32 { !a }\npub fn bitand(a: u32, b: u32) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @not(i32) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_u64.snap b/crates/mun_codegen/src/snapshots/test__bit_op_u64.snap index 0ebeb90d4..cfee0f926 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: u64) -> u64 { !a }\npub fn bitand(a: u64, b: u64) -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @not(i64) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__bit_op_u8.snap b/crates/mun_codegen/src/snapshots/test__bit_op_u8.snap index 93339eeeb..c1b0fff63 100644 --- a/crates/mun_codegen/src/snapshots/test__bit_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__bit_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn not(a: u8) -> u8 { !a }\npub fn bitand(a: u8, b: u8) -> u8 { ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @not(i8) { body: @@ -39,9 +39,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_bool.snap b/crates/mun_codegen/src/snapshots/test__compare_op_bool.snap index 9b8fed05d..5aec586a4 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_bool.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_bool.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: bool, b: bool) -> bool { a == b }\npub fn not_equa ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @equals(i1, i1) { body: @@ -51,9 +51,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_f32.snap b/crates/mun_codegen/src/snapshots/test__compare_op_f32.snap index 9b25b26e5..9d6ab22df 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_f32.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_f32.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: f32, b: f32) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(float, float) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"P\19b7\A8k\F2\81P\FB\83\F5P\B0\82!", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_f64.snap b/crates/mun_codegen/src/snapshots/test__compare_op_f64.snap index 7ae0987e2..6424aa9b4 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_f64.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_f64.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: f64, b: f64) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(double, double) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_i128.snap b/crates/mun_codegen/src/snapshots/test__compare_op_i128.snap index 01089840f..c45e714c8 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: i128, b: i128) -> bool { a == b }\npub fn not_equa ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i128, i128) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_i16.snap b/crates/mun_codegen/src/snapshots/test__compare_op_i16.snap index 4378afc71..3a10992c3 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: i16, b: i16) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i16, i16) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_i32.snap b/crates/mun_codegen/src/snapshots/test__compare_op_i32.snap index 9662a0b45..383755874 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: i32, b: i32) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i32, i32) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_i64.snap b/crates/mun_codegen/src/snapshots/test__compare_op_i64.snap index cb68edddd..42225459b 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: i64, b: i64) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i64, i64) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_i8.snap b/crates/mun_codegen/src/snapshots/test__compare_op_i8.snap index 7f8e012c5..30f82c933 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: i8, b: i8) -> bool { a == b }\npub fn not_equal(a: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i8, i8) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_u128.snap b/crates/mun_codegen/src/snapshots/test__compare_op_u128.snap index 3c2dd217d..98fbdb93b 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: u128, b: u128) -> bool { a == b }\npub fn not_equa ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i128, i128) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_u16.snap b/crates/mun_codegen/src/snapshots/test__compare_op_u16.snap index 243336641..874b070a6 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: u16, b: u16) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i16, i16) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_u32.snap b/crates/mun_codegen/src/snapshots/test__compare_op_u32.snap index 755577b71..cafbe352a 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: u32, b: u32) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i32, i32) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_u64.snap b/crates/mun_codegen/src/snapshots/test__compare_op_u64.snap index eab50b0f9..e7377b87d 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: u64, b: u64) -> bool { a == b }\npub fn not_equal( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i64, i64) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__compare_op_u8.snap b/crates/mun_codegen/src/snapshots/test__compare_op_u8.snap index 89cbd4501..c02a71557 100644 --- a/crates/mun_codegen/src/snapshots/test__compare_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__compare_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn equals(a: u8, b: u8) -> bool { a == b }\npub fn not_equal(a: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [2 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [2 x %struct.MunTypeInfo*] define i1 @equals(i8, i8) { body: @@ -51,11 +51,11 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap b/crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap index 180181228..57fd82bac 100644 --- a/crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap @@ -6,9 +6,9 @@ expression: "pub fn main(a:i32) -> i32 {\n if a > 4 {\n return a;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main(i32) { body: @@ -28,9 +28,9 @@ if_merge: ; preds = %body ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__extern_fn.snap b/crates/mun_codegen/src/snapshots/test__extern_fn.snap index c74fd9683..876bcb58d 100644 --- a/crates/mun_codegen/src/snapshots/test__extern_fn.snap +++ b/crates/mun_codegen/src/snapshots/test__extern_fn.snap @@ -7,10 +7,10 @@ expression: "extern fn add(a:i32, b:i32) -> i32;\npub fn main() {\n add(3,4); source_filename = "main.mun" %DispatchTable = type { i32 (i32, i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define void @main() { body: @@ -25,10 +25,10 @@ body: source_filename = "group_name" %DispatchTable = type { i32 (i32, i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci.snap b/crates/mun_codegen/src/snapshots/test__fibonacci.snap index 53b40087a..efb0b5f36 100644 --- a/crates/mun_codegen/src/snapshots/test__fibonacci.snap +++ b/crates/mun_codegen/src/snapshots/test__fibonacci.snap @@ -7,10 +7,10 @@ expression: "pub fn fibonacci(n:i32) -> i32 {\n if n <= 1 {\n n\n } source_filename = "main.mun" %DispatchTable = type { i32 (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @fibonacci(i32) { body: @@ -38,12 +38,12 @@ if_merge: ; preds = %body, %else source_filename = "group_name" %DispatchTable = type { i32 (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable { i32 (i32)* @fibonacci } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] declare i32 @fibonacci(i32) diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap b/crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap index 9a0a8d61e..8cdf42e00 100644 --- a/crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap +++ b/crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap @@ -6,9 +6,9 @@ expression: "pub fn fibonacci(n:i32) -> i32 {\n let a = 0;\n let b = 1;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @fibonacci(i32) { body: @@ -35,9 +35,9 @@ if_merge: ; preds = %loop ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__field_crash.snap b/crates/mun_codegen/src/snapshots/test__field_crash.snap index c6d622969..2632b5d69 100644 --- a/crates/mun_codegen/src/snapshots/test__field_crash.snap +++ b/crates/mun_codegen/src/snapshots/test__field_crash.snap @@ -6,33 +6,33 @@ expression: "struct(gc) Foo { a: i32 };\n\npub fn main(c:i32) -> i32 {\n let ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } %Foo = type { i32 } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [5 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [5 x %struct.MunTypeInfo*] define i32 @main(i32) { body: - %b = alloca %Foo* addrspace(4)* + %b = alloca %Foo** %c = alloca i32 store i32 %0, i32* %c %c1 = load i32, i32* %c %add = add i32 %c1, 5 %init = insertvalue %Foo undef, i32 %add, 0 - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %Foo_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([5 x %struct.MunTypeInfo addrspace(4)*], [5 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 1) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %Foo_ptr to i8 addrspace(4)* + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %Foo_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([5 x %struct.MunTypeInfo*], [5 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 1) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %Foo_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %Foo_ptr_ptr = bitcast i8* addrspace(4)* %new to %Foo* addrspace(4)* - %Foo_mem_ptr = load %Foo*, %Foo* addrspace(4)* %Foo_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %Foo_ptr_ptr = bitcast i8** %new to %Foo** + %Foo_mem_ptr = load %Foo*, %Foo** %Foo_ptr_ptr store %Foo %init, %Foo* %Foo_mem_ptr - store %Foo* addrspace(4)* %Foo_ptr_ptr, %Foo* addrspace(4)** %b - %mem_ptr = load %Foo* addrspace(4)*, %Foo* addrspace(4)** %b - %deref = load %Foo*, %Foo* addrspace(4)* %mem_ptr + store %Foo** %Foo_ptr_ptr, %Foo*** %b + %mem_ptr = load %Foo**, %Foo*** %b + %deref = load %Foo*, %Foo** %mem_ptr %Foo.a = getelementptr inbounds %Foo, %Foo* %deref, i32 0, i32 0 %a = load i32, i32* %Foo.a ret i32 %a @@ -43,25 +43,25 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" -@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] -@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"a\00" +@"struct_info::::field_names" = private unnamed_addr constant [1 x i8*] [i8* @"struct_info::::field_names.0"] +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 0 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8*]* @"struct_info::::field_names", [1 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 0 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" @"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } -@global_type_table = global [5 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@global_type_table = constant [5 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] @allocatorHandle = unnamed_addr global i8* null diff --git a/crates/mun_codegen/src/snapshots/test__field_expr.snap b/crates/mun_codegen/src/snapshots/test__field_expr.snap index e6b23cb08..ca95dd9d6 100644 --- a/crates/mun_codegen/src/snapshots/test__field_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__field_expr.snap @@ -6,14 +6,14 @@ expression: "struct(value) Bar(f64, Foo);\nstruct(value) Foo { a: i32 };\n\nfn b ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i32 (%Foo)*, %Foo (%Bar)* } +%DispatchTable = type { i8** (i8*, i8*)*, i32 (%Foo)*, %Foo (%Bar)* } %Foo = type { i32 } %Bar = type { double, %Foo } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [7 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [7 x %struct.MunTypeInfo*] define %Foo @bar_1(%Bar) { body: @@ -39,9 +39,9 @@ body: ret i32 %foo_a } -define i32 @bar_1_foo_a_wrapper(%Bar* addrspace(4)*) { +define i32 @bar_1_foo_a_wrapper(%Bar**) { body: - %mem_ptr = load %Bar*, %Bar* addrspace(4)* %0 + %mem_ptr = load %Bar*, %Bar** %0 %deref = load %Bar, %Bar* %mem_ptr %bar_1_foo_a = call i32 @bar_1_foo_a(%Bar %deref) ret i32 %bar_1_foo_a @@ -57,21 +57,21 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i32 (%Foo)*, %Foo (%Bar)* } +%DispatchTable = type { i8** (i8*, i8*)*, i32 (%Foo)*, %Foo (%Bar)* } %Foo = type { i32 } %Bar = type { double, %Foo } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } -@dispatchTable = global %DispatchTable { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* null, i32 (%Foo)* @foo_a, %Foo (%Bar)* @bar_1 } +@dispatchTable = global %DispatchTable { i8** (i8*, i8*)* null, i32 (%Foo)* @foo_a, %Foo (%Bar)* @bar_1 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" -@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] -@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"a\00" +@"struct_info::::field_names" = private unnamed_addr constant [1 x i8*] [i8* @"struct_info::::field_names.0"] +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8*]* @"struct_info::::field_names", [1 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @@ -81,13 +81,13 @@ source_filename = "group_name" @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" @"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" -@1 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\FC8#Lvd)F\B1Q\06\8B\02pl\10", [4 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @1, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } -@global_type_table = global [7 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\FC8#Lvd)F\B1Q\06\8B\02pl\10", [4 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } +@global_type_table = constant [7 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>", %struct.MunTypeInfo* @"type_info::"] @allocatorHandle = unnamed_addr global i8* null declare i32 @foo_a(%Foo) diff --git a/crates/mun_codegen/src/snapshots/test__function_arguments.snap b/crates/mun_codegen/src/snapshots/test__function_arguments.snap index 33ee63441..5a5dcd00a 100644 --- a/crates/mun_codegen/src/snapshots/test__function_arguments.snap +++ b/crates/mun_codegen/src/snapshots/test__function_arguments.snap @@ -6,9 +6,9 @@ expression: "pub fn main(a:i32) -> i32 {\n a\n}" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main(i32) { body: @@ -20,9 +20,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__function_calls.snap b/crates/mun_codegen/src/snapshots/test__function_calls.snap index 21df6e506..3544e5bba 100644 --- a/crates/mun_codegen/src/snapshots/test__function_calls.snap +++ b/crates/mun_codegen/src/snapshots/test__function_calls.snap @@ -7,10 +7,10 @@ expression: "fn add_impl(a:i32, b:i32) -> i32 {\n a+b\n}\n\nfn add(a:i32, b:i source_filename = "main.mun" %DispatchTable = type { i32 (i32, i32)*, i32 (i32, i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @add_impl(i32, i32) { body: @@ -42,12 +42,12 @@ body: source_filename = "group_name" %DispatchTable = type { i32 (i32, i32)*, i32 (i32, i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable { i32 (i32, i32)* @add, i32 (i32, i32)* @add_impl } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] declare i32 @add(i32, i32) diff --git a/crates/mun_codegen/src/snapshots/test__gc_struct.snap b/crates/mun_codegen/src/snapshots/test__gc_struct.snap index b5bc190a9..c56c35056 100644 --- a/crates/mun_codegen/src/snapshots/test__gc_struct.snap +++ b/crates/mun_codegen/src/snapshots/test__gc_struct.snap @@ -6,38 +6,38 @@ expression: "struct(gc) Foo { a: i32, b: i32 };\n\npub fn foo() {\n let a = F ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } %Foo = type { i32, i32 } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [5 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [5 x %struct.MunTypeInfo*] define void @foo() { body: - %b5 = alloca %Foo* addrspace(4)* - %a = alloca %Foo* addrspace(4)* - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %Foo_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([5 x %struct.MunTypeInfo addrspace(4)*], [5 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 0) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %Foo_ptr to i8 addrspace(4)* + %b5 = alloca %Foo** + %a = alloca %Foo** + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %Foo_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([5 x %struct.MunTypeInfo*], [5 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 0) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %Foo_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %Foo_ptr_ptr = bitcast i8* addrspace(4)* %new to %Foo* addrspace(4)* - %Foo_mem_ptr = load %Foo*, %Foo* addrspace(4)* %Foo_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %Foo_ptr_ptr = bitcast i8** %new to %Foo** + %Foo_mem_ptr = load %Foo*, %Foo** %Foo_ptr_ptr store %Foo { i32 3, i32 4 }, %Foo* %Foo_mem_ptr - store %Foo* addrspace(4)* %Foo_ptr_ptr, %Foo* addrspace(4)** %a - %mem_ptr = load %Foo* addrspace(4)*, %Foo* addrspace(4)** %a - %deref = load %Foo*, %Foo* addrspace(4)* %mem_ptr + store %Foo** %Foo_ptr_ptr, %Foo*** %a + %mem_ptr = load %Foo**, %Foo*** %a + %deref = load %Foo*, %Foo** %mem_ptr %Foo.b = getelementptr inbounds %Foo, %Foo* %deref, i32 0, i32 1 %b = load i32, i32* %Foo.b %add = add i32 %b, 3 - %mem_ptr1 = load %Foo* addrspace(4)*, %Foo* addrspace(4)** %a - %deref2 = load %Foo*, %Foo* addrspace(4)* %mem_ptr1 + %mem_ptr1 = load %Foo**, %Foo*** %a + %deref2 = load %Foo*, %Foo** %mem_ptr1 %Foo.b3 = getelementptr inbounds %Foo, %Foo* %deref2, i32 0, i32 1 store i32 %add, i32* %Foo.b3 - %a4 = load %Foo* addrspace(4)*, %Foo* addrspace(4)** %a - store %Foo* addrspace(4)* %a4, %Foo* addrspace(4)** %b5 + %a4 = load %Foo**, %Foo*** %a + store %Foo** %a4, %Foo*** %b5 ret void } @@ -46,26 +46,26 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"a\00" @"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"b\00" -@0 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 4] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\03\FC\D1_\DB\DB\0AJ1r,\F0m\CBQ\D0", [4 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @0, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\03\FC\D1_\DB\DB\0AJ1r,\F0m\CBQ\D0", [4 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" @"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } -@global_type_table = global [5 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@global_type_table = constant [5 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] @allocatorHandle = unnamed_addr global i8* null diff --git a/crates/mun_codegen/src/snapshots/test__if_statement.snap b/crates/mun_codegen/src/snapshots/test__if_statement.snap index 85fd38ef4..f2c4314aa 100644 --- a/crates/mun_codegen/src/snapshots/test__if_statement.snap +++ b/crates/mun_codegen/src/snapshots/test__if_statement.snap @@ -6,9 +6,9 @@ expression: "pub fn foo(a:i32) -> i32 {\n let b = if a > 3 {\n let c = ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @foo(i32) { body: @@ -36,9 +36,9 @@ if_merge: ; preds = %else, %then ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__issue_128.snap b/crates/mun_codegen/src/snapshots/test__issue_128.snap index a41de1253..7c60bf969 100644 --- a/crates/mun_codegen/src/snapshots/test__issue_128.snap +++ b/crates/mun_codegen/src/snapshots/test__issue_128.snap @@ -7,10 +7,10 @@ expression: "// resources/script.mun\nextern fn thing(n: i32);\nextern fn print( source_filename = "main.mun" %DispatchTable = type { i32 (i32)*, void (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define void @main() { body: @@ -31,10 +31,10 @@ body: source_filename = "group_name" %DispatchTable = type { i32 (i32)*, void (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__issue_133.snap b/crates/mun_codegen/src/snapshots/test__issue_133.snap index e30912b79..9c25aed53 100644 --- a/crates/mun_codegen/src/snapshots/test__issue_133.snap +++ b/crates/mun_codegen/src/snapshots/test__issue_133.snap @@ -7,10 +7,10 @@ expression: "fn do_the_things(n: i32) -> i32 {\n n + 7\n}\n\npub fn main() {\ source_filename = "main.mun" %DispatchTable = type { i32 (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @do_the_things(i32) { body: @@ -31,12 +31,12 @@ body: source_filename = "group_name" %DispatchTable = type { i32 (i32)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable { i32 (i32)* @do_the_things } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] declare i32 @do_the_things(i32) diff --git a/crates/mun_codegen/src/snapshots/test__let_statement.snap b/crates/mun_codegen/src/snapshots/test__let_statement.snap index f85eab081..352858819 100644 --- a/crates/mun_codegen/src/snapshots/test__let_statement.snap +++ b/crates/mun_codegen/src/snapshots/test__let_statement.snap @@ -6,9 +6,9 @@ expression: "pub fn main(a:i32) -> i32 {\n let b = a+1\n b\n}" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main(i32) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__literal_types.snap b/crates/mun_codegen/src/snapshots/test__literal_types.snap index 01c7e0fdd..0ff8e6f8a 100644 --- a/crates/mun_codegen/src/snapshots/test__literal_types.snap +++ b/crates/mun_codegen/src/snapshots/test__literal_types.snap @@ -6,9 +6,9 @@ expression: "pub fn main(){\n let a = 123;\n let a = 123u8;\n let a = 1 ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define void @main() { body: @@ -61,9 +61,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__logic_op_bool.snap b/crates/mun_codegen/src/snapshots/test__logic_op_bool.snap index 94aec21f8..00327ee5d 100644 --- a/crates/mun_codegen/src/snapshots/test__logic_op_bool.snap +++ b/crates/mun_codegen/src/snapshots/test__logic_op_bool.snap @@ -6,9 +6,9 @@ expression: "pub fn and(a: bool, b: bool) -> bool {\n a && b\n}\npub fn or(a: ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @and(i1, i1) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__loop_break_expr.snap b/crates/mun_codegen/src/snapshots/test__loop_break_expr.snap index ceb0ed5b9..243180460 100644 --- a/crates/mun_codegen/src/snapshots/test__loop_break_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__loop_break_expr.snap @@ -6,9 +6,9 @@ expression: "pub fn foo(n:i32) -> i32 {\n loop {\n if n > 5 {\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @foo(i32) { body: @@ -37,9 +37,9 @@ if_merge6: ; preds = %if_merge ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_f32.snap b/crates/mun_codegen/src/snapshots/test__negate_op_f32.snap index 1a2a2e63f..fdfaeb79e 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_f32.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_f32.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: f32) -> f32 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define float @negate(float) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"P\19b7\A8k\F2\81P\FB\83\F5P\B0\82!", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_f64.snap b/crates/mun_codegen/src/snapshots/test__negate_op_f64.snap index 600f6e2ea..f8f0adab2 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_f64.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_f64.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: f64) -> f64 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define double @negate(double) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_i128.snap b/crates/mun_codegen/src/snapshots/test__negate_op_i128.snap index df6d8b7b3..d1fb0bbaa 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: i128) -> i128 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @negate(i128) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_i16.snap b/crates/mun_codegen/src/snapshots/test__negate_op_i16.snap index 8dff7a9cc..6fa10ebac 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: i16) -> i16 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @negate(i16) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_i32.snap b/crates/mun_codegen/src/snapshots/test__negate_op_i32.snap index aa915c226..4b829d5e0 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: i32) -> i32 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @negate(i32) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_i64.snap b/crates/mun_codegen/src/snapshots/test__negate_op_i64.snap index 46bfea38c..5620f7c7d 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: i64) -> i64 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @negate(i64) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__negate_op_i8.snap b/crates/mun_codegen/src/snapshots/test__negate_op_i8.snap index 2362e9ddf..712f07648 100644 --- a/crates/mun_codegen/src/snapshots/test__negate_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__negate_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn negate(a: i8) -> i8 { -a }" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @negate(i8) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__nested_private_fn.snap b/crates/mun_codegen/src/snapshots/test__nested_private_fn.snap index 4f403c3bc..318bf2086 100644 --- a/crates/mun_codegen/src/snapshots/test__nested_private_fn.snap +++ b/crates/mun_codegen/src/snapshots/test__nested_private_fn.snap @@ -7,10 +7,10 @@ expression: "fn nested_private_fn() -> i32 {\n 1\n}\n\nfn private_fn() -> i32 source_filename = "main.mun" %DispatchTable = type { i32 ()* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @nested_private_fn() { body: @@ -36,12 +36,12 @@ body: source_filename = "group_name" %DispatchTable = type { i32 ()* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable { i32 ()* @private_fn } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] declare i32 @private_fn() diff --git a/crates/mun_codegen/src/snapshots/test__nested_structs.snap b/crates/mun_codegen/src/snapshots/test__nested_structs.snap index ba2668fb8..04edb370f 100644 --- a/crates/mun_codegen/src/snapshots/test__nested_structs.snap +++ b/crates/mun_codegen/src/snapshots/test__nested_structs.snap @@ -6,30 +6,30 @@ expression: "struct(gc) GcStruct(f32, f32);\nstruct(value) ValueStruct(f32, f32) ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } %GcStruct = type { float, float } %ValueStruct = type { float, float } -%GcWrapper = type { %GcStruct* addrspace(4)*, %ValueStruct } -%ValueWrapper = type { %GcStruct* addrspace(4)*, %ValueStruct } +%GcWrapper = type { %GcStruct**, %ValueStruct } +%ValueWrapper = type { %GcStruct**, %ValueStruct } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [8 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [8 x %struct.MunTypeInfo*] -define %GcStruct* addrspace(4)* @new_gc_struct(float, float) { +define %GcStruct** @new_gc_struct(float, float) { body: %init = insertvalue %GcStruct undef, float %0, 0 %init3 = insertvalue %GcStruct %init, float %1, 1 - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %GcStruct_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([8 x %struct.MunTypeInfo addrspace(4)*], [8 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 5) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %GcStruct_ptr to i8 addrspace(4)* + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %GcStruct_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([8 x %struct.MunTypeInfo*], [8 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 5) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %GcStruct_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %GcStruct_ptr_ptr = bitcast i8* addrspace(4)* %new to %GcStruct* addrspace(4)* - %GcStruct_mem_ptr = load %GcStruct*, %GcStruct* addrspace(4)* %GcStruct_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %GcStruct_ptr_ptr = bitcast i8** %new to %GcStruct** + %GcStruct_mem_ptr = load %GcStruct*, %GcStruct** %GcStruct_ptr_ptr store %GcStruct %init3, %GcStruct* %GcStruct_mem_ptr - ret %GcStruct* addrspace(4)* %GcStruct_ptr_ptr + ret %GcStruct** %GcStruct_ptr_ptr } define %ValueStruct @new_value_struct(float, float) { @@ -39,68 +39,68 @@ body: ret %ValueStruct %init3 } -define %ValueStruct* addrspace(4)* @new_value_struct_wrapper(float, float) { +define %ValueStruct** @new_value_struct_wrapper(float, float) { body: %new_value_struct = call %ValueStruct @new_value_struct(float %0, float %1) - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %ValueStruct_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([8 x %struct.MunTypeInfo addrspace(4)*], [8 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 4) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %ValueStruct_ptr to i8 addrspace(4)* + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %ValueStruct_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([8 x %struct.MunTypeInfo*], [8 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 4) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %ValueStruct_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %ValueStruct_ptr_ptr = bitcast i8* addrspace(4)* %new to %ValueStruct* addrspace(4)* - %ValueStruct_mem_ptr = load %ValueStruct*, %ValueStruct* addrspace(4)* %ValueStruct_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %ValueStruct_ptr_ptr = bitcast i8** %new to %ValueStruct** + %ValueStruct_mem_ptr = load %ValueStruct*, %ValueStruct** %ValueStruct_ptr_ptr store %ValueStruct %new_value_struct, %ValueStruct* %ValueStruct_mem_ptr - ret %ValueStruct* addrspace(4)* %ValueStruct_ptr_ptr + ret %ValueStruct** %ValueStruct_ptr_ptr } -define %GcWrapper* addrspace(4)* @new_gc_wrapper(%GcStruct* addrspace(4)*, %ValueStruct) { +define %GcWrapper** @new_gc_wrapper(%GcStruct**, %ValueStruct) { body: %.fca.0.extract = extractvalue %ValueStruct %1, 0 %.fca.1.extract = extractvalue %ValueStruct %1, 1 - %init = insertvalue %GcWrapper undef, %GcStruct* addrspace(4)* %0, 0 + %init = insertvalue %GcWrapper undef, %GcStruct** %0, 0 %init3 = insertvalue %GcWrapper %init, %ValueStruct %1, 1 - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %GcWrapper_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([8 x %struct.MunTypeInfo addrspace(4)*], [8 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 0) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %GcWrapper_ptr to i8 addrspace(4)* + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %GcWrapper_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([8 x %struct.MunTypeInfo*], [8 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 0) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %GcWrapper_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %GcWrapper_ptr_ptr = bitcast i8* addrspace(4)* %new to %GcWrapper* addrspace(4)* - %GcWrapper_mem_ptr = load %GcWrapper*, %GcWrapper* addrspace(4)* %GcWrapper_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %GcWrapper_ptr_ptr = bitcast i8** %new to %GcWrapper** + %GcWrapper_mem_ptr = load %GcWrapper*, %GcWrapper** %GcWrapper_ptr_ptr store %GcWrapper %init3, %GcWrapper* %GcWrapper_mem_ptr - ret %GcWrapper* addrspace(4)* %GcWrapper_ptr_ptr + ret %GcWrapper** %GcWrapper_ptr_ptr } -define %GcWrapper* addrspace(4)* @new_gc_wrapper_wrapper(%GcStruct* addrspace(4)*, %ValueStruct* addrspace(4)*) { +define %GcWrapper** @new_gc_wrapper_wrapper(%GcStruct**, %ValueStruct**) { body: - %mem_ptr = load %ValueStruct*, %ValueStruct* addrspace(4)* %1 + %mem_ptr = load %ValueStruct*, %ValueStruct** %1 %deref = load %ValueStruct, %ValueStruct* %mem_ptr - %new_gc_wrapper = call %GcWrapper* addrspace(4)* @new_gc_wrapper(%GcStruct* addrspace(4)* %0, %ValueStruct %deref) - ret %GcWrapper* addrspace(4)* %new_gc_wrapper + %new_gc_wrapper = call %GcWrapper** @new_gc_wrapper(%GcStruct** %0, %ValueStruct %deref) + ret %GcWrapper** %new_gc_wrapper } -define %ValueWrapper @new_value_wrapper(%GcStruct* addrspace(4)*, %ValueStruct) { +define %ValueWrapper @new_value_wrapper(%GcStruct**, %ValueStruct) { body: %.fca.0.extract = extractvalue %ValueStruct %1, 0 %.fca.1.extract = extractvalue %ValueStruct %1, 1 - %init = insertvalue %ValueWrapper undef, %GcStruct* addrspace(4)* %0, 0 + %init = insertvalue %ValueWrapper undef, %GcStruct** %0, 0 %init3 = insertvalue %ValueWrapper %init, %ValueStruct %1, 1 ret %ValueWrapper %init3 } -define %ValueWrapper* addrspace(4)* @new_value_wrapper_wrapper(%GcStruct* addrspace(4)*, %ValueStruct* addrspace(4)*) { +define %ValueWrapper** @new_value_wrapper_wrapper(%GcStruct**, %ValueStruct**) { body: - %mem_ptr = load %ValueStruct*, %ValueStruct* addrspace(4)* %1 + %mem_ptr = load %ValueStruct*, %ValueStruct** %1 %deref = load %ValueStruct, %ValueStruct* %mem_ptr - %new_value_wrapper = call %ValueWrapper @new_value_wrapper(%GcStruct* addrspace(4)* %0, %ValueStruct %deref) - %new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) - %ValueWrapper_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([8 x %struct.MunTypeInfo addrspace(4)*], [8 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 2) - %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %ValueWrapper_ptr to i8 addrspace(4)* + %new_value_wrapper = call %ValueWrapper @new_value_wrapper(%GcStruct** %0, %ValueStruct %deref) + %new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) + %ValueWrapper_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([8 x %struct.MunTypeInfo*], [8 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 2) + %type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %ValueWrapper_ptr to i8* %allocator_handle = load i8*, i8** @allocatorHandle - %new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) - %ValueWrapper_ptr_ptr = bitcast i8* addrspace(4)* %new to %ValueWrapper* addrspace(4)* - %ValueWrapper_mem_ptr = load %ValueWrapper*, %ValueWrapper* addrspace(4)* %ValueWrapper_ptr_ptr + %new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) + %ValueWrapper_ptr_ptr = bitcast i8** %new to %ValueWrapper** + %ValueWrapper_mem_ptr = load %ValueWrapper*, %ValueWrapper** %ValueWrapper_ptr_ptr store %ValueWrapper %new_value_wrapper, %ValueWrapper* %ValueWrapper_mem_ptr - ret %ValueWrapper* addrspace(4)* %ValueWrapper_ptr_ptr + ret %ValueWrapper** %ValueWrapper_ptr_ptr } @@ -108,47 +108,47 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"GcWrapper\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" @"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" -@0 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] @"type_info::::name" = private unnamed_addr constant [9 x i8] c"GcStruct\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" -@"struct_info::::field_names.2" = private unnamed_addr constant [2 x i8] c"1\00" -@1 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.2"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"P\19b7\A8k\F2\81P\FB\83\F5P\B0\82!", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 4] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\B9)lg\01\95k@E\B4(\CB\CAGX\E1", [9 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @1, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\B9)lg\01\95k@E\B4(\CB\CAGX\E1", [9 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } @"type_info::::name" = private unnamed_addr constant [12 x i8] c"ValueStruct\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" -@"struct_info::::field_names.3" = private unnamed_addr constant [2 x i8] c"1\00" -@2 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.3"] -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 4] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"U0{\87\5C\04Q/\95!$\A2\F1\A9\F9W", [12 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @2, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"U0{\87\5C\04Q/\95!$\A2\F1\A9\F9W", [12 x i8]* @"type_info::::name", i32 64, i8 4, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"!\14\93\A7H1?90\B7\EA\DB0\82\A0\C7", [10 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @0, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"!\14\93\A7H1?90\B7\EA\DB0\82\A0\C7", [10 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [13 x i8] c"ValueWrapper\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" -@"struct_info::::field_names.4" = private unnamed_addr constant [2 x i8] c"1\00" -@3 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.4"] -@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"@j\D8\CD~-\12\87|A\E8\DBp\EC}\AA", [13 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8 addrspace(4)*]* @3, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"@j\D8\CD~-\12\87|A\E8\DBp\EC}\AA", [13 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [2 x i8*]* @"struct_info::::field_names", [2 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } @"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" @"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } -@global_type_table = global [8 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@global_type_table = constant [8 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] @allocatorHandle = unnamed_addr global i8* null diff --git a/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap b/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap index ae20ba2c8..f47239f06 100644 --- a/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap @@ -6,9 +6,9 @@ expression: "pub fn main(a:i32) -> i32 {\n if a > 4 {\n return a;\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main(i32) { body: @@ -28,9 +28,9 @@ else: ; preds = %body ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__return_expr.snap b/crates/mun_codegen/src/snapshots/test__return_expr.snap index 1788aa7b2..ee10b5e74 100644 --- a/crates/mun_codegen/src/snapshots/test__return_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__return_expr.snap @@ -6,9 +6,9 @@ expression: "pub fn main() -> i32 {\n return 5;\n let a = 3; // Nothing re ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main() { body: @@ -20,9 +20,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__return_type.snap b/crates/mun_codegen/src/snapshots/test__return_type.snap index 75bb8e59e..4a5463d27 100644 --- a/crates/mun_codegen/src/snapshots/test__return_type.snap +++ b/crates/mun_codegen/src/snapshots/test__return_type.snap @@ -6,9 +6,9 @@ expression: "pub fn main() -> i32 {\n 0\n}" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @main() { body: @@ -20,9 +20,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shadowing.snap b/crates/mun_codegen/src/snapshots/test__shadowing.snap index 7f7921397..c19e3e142 100644 --- a/crates/mun_codegen/src/snapshots/test__shadowing.snap +++ b/crates/mun_codegen/src/snapshots/test__shadowing.snap @@ -6,9 +6,9 @@ expression: "pub fn foo(a:i32) -> i32 {\n let a = a+1;\n {\n let a ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @foo(i32) { body: @@ -30,9 +30,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_i128.snap b/crates/mun_codegen/src/snapshots/test__shift_op_i128.snap index 5bf640cf9..eea28f7c2 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_i128.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_i128.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: i128, b: i128) -> i128 { a << b }\npub fn right ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @leftshift(i128, i128) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::i128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\BDkp\09RRM\EBc\02\A0\DB47\A7\E3", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_i16.snap b/crates/mun_codegen/src/snapshots/test__shift_op_i16.snap index 63c12189b..da1b36bf4 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_i16.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_i16.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: i16, b: i16) -> i16 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @leftshift(i16, i16) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\05\CD|\F8Bv\D8\B1\E8\8B\8C\D8\8D\B5\89\B0", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_i32.snap b/crates/mun_codegen/src/snapshots/test__shift_op_i32.snap index 85b103f57..8decc4d03 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_i32.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_i32.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: i32, b: i32) -> i32 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @leftshift(i32, i32) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_i64.snap b/crates/mun_codegen/src/snapshots/test__shift_op_i64.snap index 8a3bc82fb..3d2c08248 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_i64.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_i64.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: i64, b: i64) -> i64 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @leftshift(i64, i64) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_i8.snap b/crates/mun_codegen/src/snapshots/test__shift_op_i8.snap index 3e8835df7..28bbb2eab 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_i8.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_i8.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: i8, b: i8) -> i8 { a << b }\npub fn rightshift( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @leftshift(i8, i8) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::i8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\C4\B1Z\E7\12\B1\91q\F1\0B\80U\FC\A6\0F", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_u128.snap b/crates/mun_codegen/src/snapshots/test__shift_op_u128.snap index dc8898e0e..985f17aa9 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_u128.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_u128.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: u128, b: u128) -> u128 { a << b }\npub fn right ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i128 @leftshift(i128, i128) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::u128\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\E67\1BU\E9k\95\93d\14}\1C\96S\95\F0", [11 x i8]* @"type_info::::name", i32 128, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_u16.snap b/crates/mun_codegen/src/snapshots/test__shift_op_u16.snap index 69855f7d2..eb0a9e649 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_u16.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_u16.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: u16, b: u16) -> u16 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i16 @leftshift(i16, i16) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u16\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"0\01\BC\BBK\E0\F2\7F&l\01\CD|q\F2\B3", [10 x i8]* @"type_info::::name", i32 16, i8 2, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_u32.snap b/crates/mun_codegen/src/snapshots/test__shift_op_u32.snap index b14d858a0..a629c77f9 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_u32.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_u32.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: u32, b: u32) -> u32 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @leftshift(i32, i32) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"daz5d\A6\BE\88\81=&Y\A1+\C6\1D", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_u64.snap b/crates/mun_codegen/src/snapshots/test__shift_op_u64.snap index 0f32df540..543c81c4e 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_u64.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_u64.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: u64, b: u64) -> u64 { a << b }\npub fn rightshi ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i64 @leftshift(i64, i64) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::u64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A6\E7g \D1\8B\1Aq`\1F\1E\07\BB5@q", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__shift_op_u8.snap b/crates/mun_codegen/src/snapshots/test__shift_op_u8.snap index 00e187380..1315e67db 100644 --- a/crates/mun_codegen/src/snapshots/test__shift_op_u8.snap +++ b/crates/mun_codegen/src/snapshots/test__shift_op_u8.snap @@ -6,9 +6,9 @@ expression: "pub fn leftshift(a: u8, b: u8) -> u8 { a << b }\npub fn rightshift( ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i8 @leftshift(i8, i8) { body: @@ -27,9 +27,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [9 x i8] c"core::u8\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\A0y\A7S\B6(n\F7f&H\E1\F9\AD\04>", [9 x i8]* @"type_info::::name", i32 8, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__struct_test.snap b/crates/mun_codegen/src/snapshots/test__struct_test.snap index d43953d09..965b9fa7c 100644 --- a/crates/mun_codegen/src/snapshots/test__struct_test.snap +++ b/crates/mun_codegen/src/snapshots/test__struct_test.snap @@ -6,15 +6,15 @@ expression: "struct(value) Bar(f64, i32, bool, Foo);\nstruct(value) Foo { a: i32 ; ModuleID = 'main.mun' source_filename = "main.mun" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } %Baz = type {} %Bar = type { double, i32, i1, %Foo } %Foo = type { i32 } @allocatorHandle = external global i8* @dispatchTable = external global %DispatchTable -@global_type_table = external global [9 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [9 x %struct.MunTypeInfo*] define void @foo() { body: @@ -38,23 +38,23 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } -%struct.MunStructInfo = type { i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8** (i8*, i8*)* } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } +%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } @dispatchTable = global %DispatchTable zeroinitializer @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" -@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] -@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"a\00" +@"struct_info::::field_names" = private unnamed_addr constant [1 x i8*] [i8* @"struct_info::::field_names.0"] +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"8\AD\C9\D9Y\D2\AA::name", i32 32, i8 4, i8 1 }, %struct.MunStructInfo { [1 x i8*]* @"struct_info::::field_names", [1 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } @"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" @"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Baz\00" -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c">\1A\BC\E5\C9\D3n\D8\8C?\86\22\FA\0DtV", [4 x i8]* @"type_info::::name", i32 0, i8 1, i8 1 }, %struct.MunStructInfo { i8 addrspace(4)* addrspace(4)* null, %struct.MunTypeInfo addrspace(4)* addrspace(4)* null, i16 addrspace(4)* null, i16 0, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c">\1A\BC\E5\C9\D3n\D8\8C?\86\22\FA\0DtV", [4 x i8]* @"type_info::::name", i32 0, i8 1, i8 1 }, %struct.MunStructInfo { i8** null, %struct.MunTypeInfo** null, i16* null, i16 0, i8 1 } } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @@ -62,16 +62,16 @@ source_filename = "group_name" @"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" @"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } @"type_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" -@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.0" = private unnamed_addr constant [2 x i8] c"0\00" @"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" @"struct_info::::field_names.2" = private unnamed_addr constant [2 x i8] c"2\00" @"struct_info::::field_names.3" = private unnamed_addr constant [2 x i8] c"3\00" -@1 = private unnamed_addr constant [4 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1", i8 addrspace(4)* @"struct_info::::field_names.2", i8 addrspace(4)* @"struct_info::::field_names.3"] -@"struct_info::::field_types" = private unnamed_addr constant [4 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_names" = private unnamed_addr constant [4 x i8*] [i8* @"struct_info::::field_names.0", i8* @"struct_info::::field_names.1", i8* @"struct_info::::field_names.2", i8* @"struct_info::::field_names.3"] +@"struct_info::::field_types" = private unnamed_addr constant [4 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::"] @"struct_info::::field_offsets" = private unnamed_addr constant [4 x i16] [i16 0, i16 8, i16 12, i16 16] -@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\D6\CA\E2\C3Ht\09\EA\AEh\E50L\F7\EE\B5", [4 x i8]* @"type_info::::name", i32 192, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8 addrspace(4)*]* @1, [4 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [4 x i16]* @"struct_info::::field_offsets", i16 4, i8 1 } } +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\D6\CA\E2\C3Ht\09\EA\AEh\E50L\F7\EE\B5", [4 x i8]* @"type_info::::name", i32 192, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8*]* @"struct_info::::field_names", [4 x %struct.MunTypeInfo*]* @"struct_info::::field_types", [4 x i16]* @"struct_info::::field_offsets", i16 4, i8 1 } } @"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" @"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } -@global_type_table = global [9 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@global_type_table = constant [9 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] @allocatorHandle = unnamed_addr global i8* null diff --git a/crates/mun_codegen/src/snapshots/test__true_is_true.snap b/crates/mun_codegen/src/snapshots/test__true_is_true.snap index 59039f13c..98dc7d2d6 100644 --- a/crates/mun_codegen/src/snapshots/test__true_is_true.snap +++ b/crates/mun_codegen/src/snapshots/test__true_is_true.snap @@ -6,9 +6,9 @@ expression: "pub fn test_true() -> bool {\n true\n}\n\npub fn test_false() -> ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i1 @test_true() { body: @@ -25,9 +25,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__update_operators.snap b/crates/mun_codegen/src/snapshots/test__update_operators.snap index 4f14461dd..47c4257ca 100644 --- a/crates/mun_codegen/src/snapshots/test__update_operators.snap +++ b/crates/mun_codegen/src/snapshots/test__update_operators.snap @@ -6,9 +6,9 @@ expression: "pub fn add(a:i32, b:i32) -> i32 {\n let result = a\n result += b\ ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @add(i32, i32) { body: @@ -45,9 +45,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__update_parameter.snap b/crates/mun_codegen/src/snapshots/test__update_parameter.snap index bf3fabd46..562b374ec 100644 --- a/crates/mun_codegen/src/snapshots/test__update_parameter.snap +++ b/crates/mun_codegen/src/snapshots/test__update_parameter.snap @@ -6,9 +6,9 @@ expression: "pub fn add_three(a:i32) -> i32 {\n a += 3;\n a\n}" ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define i32 @add_three(i32) { body: @@ -21,9 +21,9 @@ body: ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/snapshots/test__void_return.snap b/crates/mun_codegen/src/snapshots/test__void_return.snap index 83c0957de..9686b3592 100644 --- a/crates/mun_codegen/src/snapshots/test__void_return.snap +++ b/crates/mun_codegen/src/snapshots/test__void_return.snap @@ -7,10 +7,10 @@ expression: "fn bar() {\n let a = 3;\n}\npub fn foo(a:i32) {\n let c = bar source_filename = "main.mun" %DispatchTable = type { void ()* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = external global %DispatchTable -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define void @bar() { body: @@ -30,12 +30,12 @@ body: source_filename = "group_name" %DispatchTable = type { void ()* } -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @dispatchTable = global %DispatchTable { void ()* @bar } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] declare void @bar() diff --git a/crates/mun_codegen/src/snapshots/test__while_expr.snap b/crates/mun_codegen/src/snapshots/test__while_expr.snap index 831a7f1e3..10e194850 100644 --- a/crates/mun_codegen/src/snapshots/test__while_expr.snap +++ b/crates/mun_codegen/src/snapshots/test__while_expr.snap @@ -6,9 +6,9 @@ expression: "pub fn foo(n:i32) {\n while n<3 {\n n += 1;\n };\n\n ; ModuleID = 'main.mun' source_filename = "main.mun" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } -@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*] +@global_type_table = external global [1 x %struct.MunTypeInfo*] define void @foo(i32) { body: @@ -32,9 +32,9 @@ whilecond3: ; preds = %whilecond ; ModuleID = 'group_name' source_filename = "group_name" -%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } @"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i32\00" @"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::::name", i32 32, i8 4, i8 0 } -@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@global_type_table = constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::"] diff --git a/crates/mun_codegen/src/type_info.rs b/crates/mun_codegen/src/type_info.rs index 125d7d6a4..d091da03a 100644 --- a/crates/mun_codegen/src/type_info.rs +++ b/crates/mun_codegen/src/type_info.rs @@ -21,6 +21,15 @@ impl From for u64 { } } +impl TypeGroup { + pub fn to_abi_type(&self) -> abi::TypeGroup { + match self { + TypeGroup::FundamentalTypes => abi::TypeGroup::FundamentalTypes, + TypeGroup::StructTypes(_) => abi::TypeGroup::StructTypes, + } + } +} + #[derive(Clone, Debug, Eq, PartialEq)] pub struct TypeSize { // The size of the type in bits diff --git a/crates/mun_codegen/src/value/array_value.rs b/crates/mun_codegen/src/value/array_value.rs new file mode 100644 index 000000000..d4fc1b50d --- /dev/null +++ b/crates/mun_codegen/src/value/array_value.rs @@ -0,0 +1,196 @@ +use crate::value::{ + AddressableType, AsValue, ConcreteValueType, IrTypeContext, IrValueContext, PointerValueType, + SizedValueType, TypeValue, Value, ValueType, +}; +use inkwell::types::{BasicType, PointerType}; +use inkwell::AddressSpace; + +impl ConcreteValueType for [T] { + type Value = inkwell::values::ArrayValue; +} + +impl PointerValueType for [T] { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + T::get_ptr_type(context, address_space) + } +} + +impl> AddressableType for [T] {} +impl> AddressableType<[I]> for [T] {} + +macro_rules! impl_array( + ($($size:expr),+) => { + $( + impl ConcreteValueType for [T; $size] { + type Value = inkwell::values::ArrayValue; + } + + impl SizedValueType for [T; $size] + where + <::Value as ValueType>::Type: ConstArrayType, + { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::ArrayType { + T::get_ir_type(context).array_type($size) + } + } + + impl PointerValueType for [T; $size] { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + T::get_ptr_type(context, address_space) + } + } + + impl> AsValue<[E; $size]> for [T; $size] + where + E::Value: ConstArrayValue + { + fn as_value(&self, context: &IrValueContext) -> Value<[E; $size]> { + let element_ir_type = E::get_ir_type(context.type_context); + let values: [E::Value; $size] = + array_init::from_iter(self.iter().map(|e| e.as_value(context).value)) + .expect("unable to construct sized array"); + let value = E::Value::const_array(values.as_ref(), &element_ir_type); + Value::from_raw(value) + } + } + + impl> AsValue<[E]> for [T; $size] + where + E::Value: ConstArrayValue + { + fn as_value(&self, context: &IrValueContext) -> Value<[E]> { + let element_ir_type = E::get_ir_type(context.type_context); + let values: [E::Value; $size] = + array_init::from_iter(self.iter().map(|e| e.as_value(context).value)) + .expect("unable to construct sized array"); + let value = E::Value::const_array(values.as_ref(), &element_ir_type); + Value::from_raw(value) + } + } + )+ + } +); + +impl_array!( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 36, 0x40, 0x80, 0x100 +); + +impl> AsValue<[E]> for &[T] +where + E::Value: ConstArrayValue, +{ + fn as_value(&self, context: &IrValueContext) -> Value<[E]> { + let element_type = E::get_ir_type(context.type_context); + let elements: Vec = self.iter().map(|v| v.as_value(context).value).collect(); + let value = ConstArrayValue::const_array(&elements, &element_type); + Value::from_raw(value) + } +} + +pub trait IterAsIrValue>: IntoIterator { + /// Returns a `Value<[E]>` that contains all values converted to `Value`. + fn as_value(self, context: &IrValueContext) -> Value<[E]>; + + /// Constructs a const private global and returns a pointer to it. + fn into_const_private_pointer>( + self, + name: S, + context: &IrValueContext, + ) -> Value<*const E> + where + *const E: ConcreteValueType, + E: AddressableType, + Self: Sized, + { + self.as_value(context) + .into_const_private_global(name, context) + .as_value(context) + } + + /// Constructs a const private global and returns a pointer to it. If the iterator is empty a + /// null pointer is returned. + fn into_const_private_pointer_or_null>( + self, + name: S, + context: &IrValueContext, + ) -> Value<*const E> + where + *const E: SizedValueType, + E: AddressableType, + Self: Sized, + E::Value: ConstArrayValue, + { + let mut iter = self.into_iter().peekable(); + if iter.peek().is_some() { + iter.as_value(context) + .into_const_private_global(name, context) + .as_value(context) + } else { + Value::null(context) + } + } +} + +impl, I: IntoIterator> IterAsIrValue for I +where + E::Value: ConstArrayValue, +{ + fn as_value(self, context: &IrValueContext) -> Value<[E]> { + let element_type = E::get_ir_type(context.type_context); + let elements: Vec = self + .into_iter() + .map(|v| v.as_value(context).value) + .collect(); + let value = ConstArrayValue::const_array(&elements, &element_type); + Value::from_raw(value) + } +} + +/// A helper trait that enables the creation of a const LLVM array for a type. +pub trait ConstArrayType: BasicType + Sized + TypeValue { + fn const_array(&self, values: &[::Value]) -> inkwell::values::ArrayValue; +} + +/// A helper trait that enables the creation of a const LLVM array for a type. +pub trait ConstArrayValue: ValueType { + fn const_array(values: &[Self], ir_type: &Self::Type) -> inkwell::values::ArrayValue; +} + +impl + ?Sized> Value { + /// Returns the number of elements in the array. + pub fn len(self) -> usize { + self.value.get_type().len() as usize + } + + /// Returns true if the value represents an empty array. + pub fn is_empty(self) -> bool { + self.value.get_type().len() == 0 + } +} + +macro_rules! impl_array_type { + ($($inkwell_type:ty => $inkwell_value:ty),+) => { + $( + impl ConstArrayType for $inkwell_type { + fn const_array(&self, values: &[::Value]) -> inkwell::values::ArrayValue { + <$inkwell_type>::const_array(self, values) + } + } + + impl ConstArrayValue for $inkwell_value { + fn const_array(values: &[Self], ir_type: &Self::Type) -> inkwell::values::ArrayValue { + Self::Type::const_array(ir_type, values) + } + } + )* + }; +} + +impl_array_type!( + inkwell::types::IntType => inkwell::values::IntValue, + inkwell::types::FloatType => inkwell::values::FloatValue, + inkwell::types::ArrayType => inkwell::values::ArrayValue, + inkwell::types::VectorType => inkwell::values::VectorValue, + inkwell::types::StructType => inkwell::values::StructValue, + inkwell::types::PointerType => inkwell::values::PointerValue +); diff --git a/crates/mun_codegen/src/value/float_value.rs b/crates/mun_codegen/src/value/float_value.rs new file mode 100644 index 000000000..320d542cc --- /dev/null +++ b/crates/mun_codegen/src/value/float_value.rs @@ -0,0 +1,54 @@ +use super::{ + AsValue, ConcreteValueType, IrTypeContext, IrValueContext, PointerValueType, SizedValueType, + Value, +}; +use crate::value::AddressableType; +use inkwell::{types::PointerType, AddressSpace}; + +impl ConcreteValueType for f32 { + type Value = inkwell::values::FloatValue; +} + +impl ConcreteValueType for f64 { + type Value = inkwell::values::FloatValue; +} + +impl SizedValueType for f32 { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::FloatType { + context.context.f32_type() + } +} +impl SizedValueType for f64 { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::FloatType { + context.context.f64_type() + } +} + +impl PointerValueType for f32 { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(AddressSpace::Generic)) + } +} +impl PointerValueType for f64 { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(AddressSpace::Generic)) + } +} + +impl AddressableType for f32 {} +impl AddressableType for f64 {} + +impl AsValue for f32 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context).const_float(*self as f64), + ) + } +} +impl AsValue for f64 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context).const_float(*self), + ) + } +} diff --git a/crates/mun_codegen/src/value/function_value.rs b/crates/mun_codegen/src/value/function_value.rs new file mode 100644 index 000000000..c619b58c3 --- /dev/null +++ b/crates/mun_codegen/src/value/function_value.rs @@ -0,0 +1,79 @@ +use super::{ConcreteValueType, IrTypeContext, PointerValueType, SizedValueType, ValueType}; +use inkwell::types::BasicType; + +macro_rules! into_function_info_impl { + ($( + fn($($T:ident),*) -> $R:ident; + )+) => { + $( + impl<$R:ConcreteValueType, $($T:ConcreteValueType,)*> ConcreteValueType for fn($($T,)*) -> $R { + type Value = inkwell::values::FunctionValue; + } + impl<$R:SizedValueType + 'static, $($T:SizedValueType,)*> SizedValueType for fn($($T,)*) -> $R + where + <::Value as ValueType>::Type: inkwell::types::BasicType, + $( + <$T::Value as ValueType>::Type: inkwell::types::BasicType + ),* + { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::FunctionType { + // This is a bit of a dirty hack. The problem is that in this specific case we + // want the type () to be represented as void in LLVM. + if std::any::TypeId::of::<$R>() == std::any::TypeId::of::<()>() { + context.context.void_type().fn_type( + &[ + $( + $T::get_ir_type(context).as_basic_type_enum() + ),* + ], + false + ) + } else { + $R::get_ir_type(context).fn_type( + &[ + $( + $T::get_ir_type(context).as_basic_type_enum() + ),* + ], + false + ) + } + } + } + + impl<$R:SizedValueType + 'static, $($T:SizedValueType,)*> PointerValueType for fn($($T,)*) -> $R + where + <::Value as ValueType>::Type: inkwell::types::BasicType, + $( + <$T::Value as ValueType>::Type: inkwell::types::BasicType + ),* + { + fn get_ptr_type( + context: &IrTypeContext, + address_space: Option, + ) -> inkwell::types::PointerType + { + debug_assert!( + address_space.is_none() || address_space == Some(inkwell::AddressSpace::Generic), + "Functions can only live in generic address space" + ); + Self::get_ir_type(context).ptr_type(inkwell::AddressSpace::Generic) + } + } + )+ + } +} + +into_function_info_impl! { + fn() -> R; + fn(A) -> R; + fn(A, B) -> R; + fn(A, B, C) -> R; + fn(A, B, C, D) -> R; + fn(A, B, C, D, E) -> R; + fn(A, B, C, D, E, F) -> R; + fn(A, B, C, D, E, F, G) -> R; + fn(A, B, C, D, E, F, G, H) -> R; + fn(A, B, C, D, E, F, G, H, I) -> R; + fn(A, B, C, D, E, F, G, H, I, J) -> R; +} diff --git a/crates/mun_codegen/src/value/global.rs b/crates/mun_codegen/src/value/global.rs new file mode 100644 index 000000000..a55505364 --- /dev/null +++ b/crates/mun_codegen/src/value/global.rs @@ -0,0 +1,149 @@ +use super::{ + AsValue, ConcreteValueType, IrTypeContext, IrValueContext, PointerValueType, SizedValueType, + Value, ValueType, +}; +use crate::value::AddressableType; +use inkwell::{ + module::Linkage, + types::PointerType, + values::{BasicValueEnum, PointerValue, UnnamedAddress}, + AddressSpace, +}; +use std::marker::PhantomData; + +/// Represents a typed global value. A `Global` can be constructed from any `Value` that can +/// be converted to a [`inkwell::values::BasicValueEnum`]. +/// +/// Globals can be used to store data inside an inkwell context which can be referenced from code. +/// +/// Like `Value` a `Global` is typed on the type of data that it stores. +pub struct Global { + pub value: inkwell::values::GlobalValue, + data: PhantomData, +} + +impl Clone for Global { + fn clone(&self) -> Self { + Global { + value: self.value, + data: self.data, + } + } +} + +impl Copy for Global {} + +impl Global { + /// Creates a `Global` from an underlying value. + /// + /// # Safety + /// + /// There is no guarantee that the passed value actually represents the type `T`. Sometimes this + /// can however be very useful. This method is marked as unsafe since there is also no way to + /// check the correctness. + pub unsafe fn from_raw(value: inkwell::values::GlobalValue) -> Self { + Global { + value, + data: Default::default(), + } + } +} + +impl ConcreteValueType for *const Global { + type Value = inkwell::values::PointerValue; +} + +impl SizedValueType for *const Global { + fn get_ir_type(context: &IrTypeContext) -> ::Type { + T::get_ptr_type(context, None) + } +} + +impl PointerValueType for *const Global { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + debug_assert!( + address_space.is_none() || address_space == Some(AddressSpace::Generic), + "Globals can only live in generic address space" + ); + T::get_ptr_type(context, None) + } +} + +impl AsValue<*const I> for Global +where + *const I: ConcreteValueType, + T: AddressableType, +{ + fn as_value(&self, _context: &IrValueContext) -> Value<*const I> { + Value::from_raw(self.value.as_pointer_value()) + } +} + +impl Value +where + T::Value: Into, +{ + pub fn into_global>( + self, + name: S, + context: &IrValueContext, + is_const: bool, + linkage: Linkage, + unnamed_addr: Option, + ) -> Global { + // NOTE: No support for address spaces + let address_space = None; + + let initializer = self.value.into(); + let global = + context + .module + .add_global(initializer.get_type(), address_space, name.as_ref()); + global.set_linkage(linkage); + global.set_constant(is_const); + global.set_initializer(&initializer); + if let Some(addr) = unnamed_addr { + global.set_unnamed_address(addr); + } + Global { + value: global, + data: Default::default(), + } + } + + /// Converts self into a private const global. A private const global always has Private linkage + /// so its only accessible from the module it's defined in. Its address is globally + /// insignificant because the linker can rename it. + /// + /// This is useful for constant values that require dynamic sizing like arrays or strings but + /// still need to be referenced in the code. We can't use const arrays here because the size + /// must be constant in the type. + /// + /// e.g. in the following case: + /// ```c + /// const char str[] = "foobar" + /// ``` + /// + /// The type of `str` is a 'dynamically' sized array which makes the type `const char*`. Not, + /// `const char[6]`. We use a const private to store the array and create a pointer from that + /// value. + pub fn into_const_private_global>( + self, + name: S, + context: &IrValueContext, + ) -> Global { + self.into_global( + name, + context, + true, + Linkage::Private, + Some(UnnamedAddress::Global), + ) + } +} + +impl Into for Global { + fn into(self) -> PointerValue { + self.value.as_pointer_value() + } +} diff --git a/crates/mun_codegen/src/value/int_value.rs b/crates/mun_codegen/src/value/int_value.rs new file mode 100644 index 000000000..9527f34cc --- /dev/null +++ b/crates/mun_codegen/src/value/int_value.rs @@ -0,0 +1,112 @@ +use super::{ + AddressableType, AsValue, ConcreteValueType, IrTypeContext, IrValueContext, PointerValueType, + SizedValueType, Value, +}; +use inkwell::AddressSpace; + +macro_rules! impl_as_int_ir_value { + ($($ty:ty => $context_fun:ident()),*) => { + $( + impl ConcreteValueType for $ty { + type Value = inkwell::values::IntValue; + } + + impl SizedValueType for $ty { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::IntType { + context.context.$context_fun() + } + } + + impl PointerValueType for $ty { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> inkwell::types::PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(AddressSpace::Generic)) + } + } + + impl AddressableType<$ty> for $ty {} + )* + } +} + +impl_as_int_ir_value!( + i8 => i8_type(), + i16 => i16_type(), + i32 => i32_type(), + i64 => i64_type(), + u8 => i8_type(), + u16 => i16_type(), + u32 => i32_type(), + u64 => i64_type() +); + +impl AsValue for u8 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, false), + ) + } +} + +impl AsValue for u16 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, false), + ) + } +} + +impl AsValue for u32 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, false), + ) + } +} + +impl AsValue for u64 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, false), + ) + } +} + +impl AsValue for i8 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, true), + ) + } +} + +impl AsValue for i16 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, true), + ) + } +} + +impl AsValue for i32 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, true), + ) + } +} + +impl AsValue for i64 { + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw( + ::get_ir_type(context.type_context) + .const_int(*self as u64, true), + ) + } +} diff --git a/crates/mun_codegen/src/value/mod.rs b/crates/mun_codegen/src/value/mod.rs new file mode 100644 index 000000000..e1fb3834f --- /dev/null +++ b/crates/mun_codegen/src/value/mod.rs @@ -0,0 +1,321 @@ +///! This module provides constructs to enable type safe handling of inkwell types. +mod array_value; +mod float_value; +mod function_value; +mod global; +mod int_value; +mod pointer_value; +mod string; +mod tuple_value; + +use inkwell::context::Context; +use inkwell::module::Module; +use inkwell::targets::TargetData; + +pub use array_value::IterAsIrValue; +pub use global::Global; +pub use string::CanInternalize; + +use inkwell::types::{PointerType, StructType}; +use inkwell::values::BasicValueEnum; +use inkwell::AddressSpace; +use parking_lot::RwLock; +use std::any::TypeId; +use std::collections::HashMap; +use std::fmt::Debug; +use std::hash::Hash; + +/// Represents a generic inkwell value. This is a wrapper around inkwell types that enforces type +/// safety in the Rust compiler. Rust values that can be converted to inkwell types can be +/// represented as a value. e.g. `Value`. Internally this holds an `inkwell::values::IntValue` +/// but we maintain the information that it's actually a `u32` value. +/// +/// There are several ways to enable a type to be used as a `Value` type through the `AsValue` +/// trait. +/// +/// - Implement the [`TransparentValue`] trait which converts the implementor into another +/// `Value` type. Internally the inkwell value is taken from the inner type but a `Value` +/// is returned. This allows transparent composition. e.g.: +/// +/// ```rust +/// # use mun_codegen::value::{AsValue, IrValueContext, TransparentValue, Value}; +/// struct Foo { +/// value: u32, +/// bar: f32, +/// } +/// +/// impl TransparentValue for Foo { +/// type Target = (u32, f32); +/// +/// fn as_target_value(&self, context: &IrValueContext) -> Value { +/// (self.value, self.bar).as_value(context) +/// } +/// } +/// ``` +/// +/// This will result in an anonymous LLVM type: `type { u32, f32 }` +/// +/// - Auto derive the `AsValue` trait e.g.: +/// ```ignore +/// #[macro_use] extern crate mun_codegen_macros; +/// +/// #[derive(AsValue)] +/// #[ir_name = "Foo"] +/// struct Foo { +/// value: u32, +/// bar: f32 +/// } +/// ``` +/// +/// This will result in a _named_ LLVM type: `%Foo = type { u32, f32 }` +/// +/// - You can also add completely custom support by implementing the [`ConcreteValueType`] and +/// [`AsValue`] traits. Optionally you might also want to implement the [`SizedValueType`] and +/// [`PointerValueType`] traits. +pub struct Value { + pub value: T::Value, +} + +/// When implemented enables the conversion from a value to a `Value`. +pub trait AsValue { + /// Creates a `Value` from an instance. + fn as_value(&self, context: &IrValueContext) -> Value; +} + +/// A `TransparentValue` is something that can be represented as a `Value` but which is actually +/// a rewritten version of another type. +pub trait TransparentValue { + type Target: ConcreteValueType + ?Sized; + + /// Converts the instance to the target value + fn as_target_value(&self, context: &IrValueContext) -> Value; +} + +/// The context in which an `IrType` operates. +pub struct IrTypeContext<'ctx> { + pub context: &'ctx Context, + pub target_data: &'ctx TargetData, + pub struct_types: RwLock>, +} + +/// The context in which an `IrValue` exists. +pub struct IrValueContext<'t, 'ctx, 'm> { + pub type_context: &'t IrTypeContext<'ctx>, + pub context: &'ctx Context, + pub module: &'m Module, +} + +/// A trait that represents that a concrete type can be used as `Value` type generic. A type must +/// implement this trait to be able to be represented as a `Value`. +pub trait ConcreteValueType { + type Value: ValueType; +} + +/// If we take a pointer of value T, which type can it return? This trait dictates that. +pub trait AddressableType {} + +/// A trait implemented for types that can determine the IR type of a value without an instance. +pub trait SizedValueType: ConcreteValueType + Sized { + /// Returns the IR type of a value of this type. + fn get_ir_type( + context: &IrTypeContext, + ) -> <::Value as ValueType>::Type; +} + +/// A trait that returns the pointer type of the specified value. +pub trait PointerValueType: ConcreteValueType { + /// Returns the pointer type of the value + fn get_ptr_type( + context: &IrTypeContext, + address_space: Option, + ) -> inkwell::types::PointerType; +} + +/// A trait that enables the conversion from an inkwell type to a corresponding value type. (e.g. +/// IntType -> IntValue) +pub trait TypeValue { + type Value: inkwell::values::AnyValue; +} + +/// A trait that enables the conversion from an inkwell value to a corresponding type. (e.g. +/// IntValue -> IntType) +pub trait ValueType: Clone + Debug + Copy + Eq + PartialEq + Hash { + type Type: inkwell::types::AnyType; + + /// Returns the type of the value + fn get_type(&self) -> Self::Type; +} + +/// A trait that is implemented for types that can also be represented as a pointer. +pub trait AddressableTypeValue: TypeValue { + fn ptr_type(&self, address_space: AddressSpace) -> inkwell::types::PointerType; +} + +/// A macro that implements basic traits for inkwell types. +macro_rules! impl_value_type_value { + ($($ty:ty => $val:ty),+) => { + $( + impl TypeValue for $ty { + type Value = $val; + } + impl ValueType for $val { + type Type = $ty; + + fn get_type(&self) -> Self::Type { + self.get_type() + } + } + )* + } +} + +impl_value_type_value! ( + inkwell::types::IntType => inkwell::values::IntValue, + inkwell::types::FloatType => inkwell::values::FloatValue, + inkwell::types::ArrayType => inkwell::values::ArrayValue, + inkwell::types::VectorType => inkwell::values::VectorValue, + inkwell::types::StructType => inkwell::values::StructValue, + inkwell::types::PointerType => inkwell::values::PointerValue, + inkwell::types::FunctionType => inkwell::values::FunctionValue +); + +macro_rules! impl_addressable_type_values { + ($($ty:ty),+) => { + $( + impl AddressableTypeValue for $ty { + fn ptr_type(&self, address_space: AddressSpace) -> inkwell::types::PointerType { + self.ptr_type(address_space) + } + } + )* + } +} + +impl_addressable_type_values!( + inkwell::types::IntType, + inkwell::types::FloatType, + inkwell::types::ArrayType, + inkwell::types::VectorType, + inkwell::types::StructType, + inkwell::types::PointerType, + inkwell::types::FunctionType +); + +impl Value { + /// Returns the type of the value. + pub fn get_type(&self) -> ::Type { + ::get_type(&self.value) + } + + /// Constructs a `Value` from an inkwell value. + pub(super) fn from_raw(value: T::Value) -> Value { + Value { value } + } +} + +impl Value { + /// Returns the inkwell type of this `Value`. + pub fn get_ir_type(context: &IrTypeContext) -> ::Type { + T::get_ir_type(context) + } +} + +impl AsValue for Value { + fn as_value(&self, _context: &IrValueContext) -> Value { + *self + } +} + +impl Clone for Value { + fn clone(&self) -> Self { + Value { value: self.value } + } +} + +impl Copy for Value {} + +impl PartialEq for Value { + fn eq(&self, other: &Self) -> bool { + self.value == other.value + } +} + +impl Eq for Value {} + +impl Hash for Value { + fn hash(&self, state: &mut H) { + self.value.hash(state) + } +} + +impl std::fmt::Debug for Value { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self.value) + } +} + +impl Into for Value +where + T::Value: Into, +{ + fn into(self) -> BasicValueEnum { + self.value.into() + } +} + +pub trait AsValueInto { + fn as_value_into(&self, context: &IrValueContext) -> T; +} + +impl AsValueInto for Value +where + T::Value: Into, +{ + fn as_value_into(&self, _context: &IrValueContext) -> I { + self.value.into() + } +} + +impl> AsValueInto for T +where + T::Value: Into, +{ + fn as_value_into(&self, context: &IrValueContext) -> I { + self.as_value(context).value.into() + } +} + +// A `TransparentValue` can also be represented by a `Value`. +impl ConcreteValueType for T { + type Value = ::Value; +} + +// A `TransparentValue` is sized if the target is also sized. +impl SizedValueType for T +where + T::Target: SizedValueType, +{ + fn get_ir_type(context: &IrTypeContext) -> ::Type { + T::Target::get_ir_type(context) + } +} + +// If the target of the transparent value can statically return a pointer type, so can we. +impl PointerValueType for T +where + T::Target: PointerValueType, +{ + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + T::Target::get_ptr_type(context, address_space) + } +} + +// Transparent values can also be represented as `Value`. +impl AsValue for T +where + T: TransparentValue, +{ + fn as_value(&self, context: &IrValueContext) -> Value { + Value::from_raw(self.as_target_value(context).value) + } +} diff --git a/crates/mun_codegen/src/value/pointer_value.rs b/crates/mun_codegen/src/value/pointer_value.rs new file mode 100644 index 000000000..299fea889 --- /dev/null +++ b/crates/mun_codegen/src/value/pointer_value.rs @@ -0,0 +1,45 @@ +use crate::value::{ + AddressableType, ConcreteValueType, IrTypeContext, IrValueContext, PointerValueType, + SizedValueType, Value, +}; +use inkwell::types::PointerType; +use inkwell::AddressSpace; + +impl ConcreteValueType for *const T { + type Value = inkwell::values::PointerValue; +} +impl ConcreteValueType for *mut T { + type Value = inkwell::values::PointerValue; +} + +impl SizedValueType for *const T { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::PointerType { + T::get_ptr_type(context, None) + } +} +impl SizedValueType for *mut T { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::PointerType { + T::get_ptr_type(context, None) + } +} +impl PointerValueType for *mut T { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(AddressSpace::Generic)) + } +} +impl PointerValueType for *const T { + fn get_ptr_type(context: &IrTypeContext, address_space: Option) -> PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(AddressSpace::Generic)) + } +} + +impl> Value { + /// Constructs a `null` pointer of type `T` + pub fn null(context: &IrValueContext) -> Self { + Value::from_raw(T::get_ir_type(context.type_context).const_null()) + } +} + +impl AddressableType<*const T> for *const T where *const T: ConcreteValueType {} + +impl AddressableType<*mut T> for *mut T where *mut T: ConcreteValueType {} diff --git a/crates/mun_codegen/src/value/string.rs b/crates/mun_codegen/src/value/string.rs new file mode 100644 index 000000000..ff41bf5c5 --- /dev/null +++ b/crates/mun_codegen/src/value/string.rs @@ -0,0 +1,60 @@ +use super::{AsValue, Global, IrValueContext, TransparentValue, Value}; +use crate::value::AddressableType; +use std::ffi::{CStr, CString}; + +/// Enables internalizing certain data structures like strings. +pub trait CanInternalize { + type Type; + + /// Internalizes the instance into a global value. + fn intern>(&self, name: S, context: &IrValueContext) -> Global; +} + +impl CanInternalize for str { + type Type = String; + + fn intern>(&self, name: S, context: &IrValueContext) -> Global { + unsafe { + Global::from_raw( + self.as_bytes() + .as_value(context) + .into_const_private_global(name, context) + .value, + ) + } + } +} + +impl CanInternalize for CStr { + type Type = CString; + + fn intern>(&self, name: S, context: &IrValueContext) -> Global { + unsafe { + Global::from_raw( + self.to_bytes_with_nul() + .as_value(context) + .into_const_private_global(name, context) + .value, + ) + } + } +} + +impl TransparentValue for CString { + type Target = [u8]; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + self.as_bytes_with_nul().as_value(context) + } +} + +impl TransparentValue for String { + type Target = [u8]; + + fn as_target_value(&self, context: &IrValueContext) -> Value { + self.as_bytes().as_value(context) + } +} + +impl AddressableType for CString {} +impl AddressableType for String {} diff --git a/crates/mun_codegen/src/value/tuple_value.rs b/crates/mun_codegen/src/value/tuple_value.rs new file mode 100644 index 000000000..a6dd41ab1 --- /dev/null +++ b/crates/mun_codegen/src/value/tuple_value.rs @@ -0,0 +1,58 @@ +use super::{ + AsValue, AsValueInto, ConcreteValueType, IrTypeContext, IrValueContext, SizedValueType, Value, + ValueType, +}; + +macro_rules! tuple_impls { + ( $( $name:ident )* ) => { + /// Every tuple that contains values that can be converted to BasicValueEnum can be + /// represented by a tuple + impl<$($name: AsValueInto),*> ConcreteValueType for ($($name,)*) { + type Value = inkwell::values::StructValue; + } + + /// Every tuple that contains values that can be converted to BasicValueEnum and which are + /// sized, are also sized. + impl<$($name: AsValueInto + SizedValueType),*> SizedValueType for ($($name,)*) + where + $( + <<$name as ConcreteValueType>::Value as ValueType>::Type: Into + ,)* + { + fn get_ir_type(context: &IrTypeContext) -> inkwell::types::StructType { + context.context.struct_type(&[ + $($name::get_ir_type(context).into(),)* + ], false) + } + } + + impl<$($name: AsValueInto),*> AsValue<($($name,)*)> for ($($name,)*) { + #[allow(unused_variables)] + fn as_value(&self, context: &IrValueContext) -> Value { + #[allow(non_snake_case)] + let ($($name,)*) = self; + Value::from_raw( + context.context.const_struct(&[ + $( + $name.as_value_into(context) + ,)*], + false) + ) + } + } + }; +} + +tuple_impls! {} +tuple_impls! { A } +tuple_impls! { A B } +tuple_impls! { A B C } +tuple_impls! { A B C D } +tuple_impls! { A B C D E } +tuple_impls! { A B C D E F } +tuple_impls! { A B C D E F G } +tuple_impls! { A B C D E F G H } +tuple_impls! { A B C D E F G H I } +tuple_impls! { A B C D E F G H I J } +tuple_impls! { A B C D E F G H I J K } +tuple_impls! { A B C D E F G H I J K L } diff --git a/crates/mun_codegen_macros/Cargo.toml b/crates/mun_codegen_macros/Cargo.toml new file mode 100644 index 000000000..97b96ac1e --- /dev/null +++ b/crates/mun_codegen_macros/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "mun_codegen_macros" +version = "0.1.0" +authors = ["The Mun Team "] +edition = "2018" + +[lib] +proc-macro = true + +[dependencies] +syn="1.0" +quote="1.0" diff --git a/crates/mun_codegen_macros/src/lib.rs b/crates/mun_codegen_macros/src/lib.rs new file mode 100644 index 000000000..936638bfe --- /dev/null +++ b/crates/mun_codegen_macros/src/lib.rs @@ -0,0 +1,206 @@ +#![cfg_attr(tarpaulin, skip)] + +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, Attribute, Data, DeriveInput, Lit, Meta, NestedMeta, Path}; + +/// This procedural macro implements the `AsValue` trait as well as several required other traits. +/// All of these traits enable creating an `inkwell::values::StructValue` from a generic struct, as +/// long as all fields of the struct also implement `AsValue`. +#[proc_macro_derive(AsValue, attributes(ir_name))] +pub fn as_value_derive(input: TokenStream) -> TokenStream { + // Parse Phase + let derive_input = parse_macro_input!(input as DeriveInput); + let struct_data = match derive_input.data { + Data::Struct(data) => data, + Data::Union(_) => panic!("#[derive(AsValue)] is only defined for structs, not for unions!"), + Data::Enum(_) => panic!("#[derive(AsValue)] is only defined for structs, not for enums!"), + }; + + // Parse the `[ir_name = ".."]` part + let mut ir_name = String::new(); + for attr in derive_input + .attrs + .iter() + .filter(|a| a.path.get_ident().map(|i| *i == "ir_name").unwrap_or(false)) + .map(Attribute::parse_meta) + .filter_map(|x| x.ok()) + { + if let Meta::NameValue(meta_name_value) = attr { + match meta_name_value.lit { + Lit::Str(lit_str) => { + ir_name = lit_str.value(); + } + _ => { + panic!("ir_name must be a string"); + } + }; + } + } + + // Get the typename of the struct we're working with + let ident = &derive_input.ident; + + // Generate a list of all field types + let field_types_tuple = struct_data.fields.iter().map(|f| { + let ty = &f.ty; + quote! { + #ty + } + }); + + // Generate a list of where clauses that ensure that we can cast each field to an + // `inkwell::types::BasicTypeEnum` + let field_types = struct_data.fields.iter().map(|f| { + let ty = &f.ty; + quote! { + Into::::into(<#ty>::get_ir_type(context)) + } + }); + + // Generate a list of where clauses that ensure that we can cast each field to an + // `inkwell::values::BasicTypeValue` + let field_types_values = struct_data.fields.iter().enumerate().map(|(idx, f)| { + let name = f.ident.as_ref().map(|i| quote! { #i }).unwrap_or_else(|| quote! { #idx }); + quote! { + crate::value::AsValueInto::::as_value_into(&self. #name, context) + } + }); + + // Generate Phase + (quote! { + impl crate::value::ConcreteValueType for #ident { + type Value = inkwell::values::StructValue; + } + + impl crate::value::SizedValueType for #ident { + fn get_ir_type(context: &crate::value::IrTypeContext) -> inkwell::types::StructType { + let key = (#ir_name, std::any::TypeId::of::<(#(#field_types_tuple),*)>()); + let struct_types = context.struct_types.upgradable_read(); + let value = match struct_types.get(&key) { + Some(value) => { + return *value; + } + None => { + let mut struct_types = parking_lot::RwLockUpgradableReadGuard::upgrade(struct_types); + let struct_ty = context.context.opaque_struct_type(key.0); + struct_types.insert(key, struct_ty); + struct_ty + } + }; + value.set_body(&[ + #(#field_types),* + ], false); + value + } + } + + impl crate::value::PointerValueType for #ident { + fn get_ptr_type(context: &crate::value::IrTypeContext, address_space: Option) -> inkwell::types::PointerType { + Self::get_ir_type(context).ptr_type(address_space.unwrap_or(inkwell::AddressSpace::Generic)) + } + } + + impl crate::value::AsValue<#ident> for #ident { + fn as_value(&self, context: &crate::value::IrValueContext) -> crate::value::Value { + let struct_type = Self::get_ir_type(context.type_context); + crate::value::Value::from_raw(struct_type.const_named_struct(&[ + #(#field_types_values),* + ])) + } + } + + impl crate::value::AddressableType<#ident> for #ident {} + }).into() +} + +/// A procedural macro that implements the `TestIsAbiCompatible` trait for a struct. This +/// implementation enables testing for every field of a struct whether its abi type is compatible +/// with the current implementation. +#[proc_macro_derive(TestIsAbiCompatible, attributes(abi_type))] +pub fn is_abi_compatible_derive(input: TokenStream) -> TokenStream { + // Parse Phase + let derive_input = parse_macro_input!(input as DeriveInput); + let struct_data = match derive_input.data { + Data::Struct(data) => data, + Data::Union(_) => { + panic!("#[derive(IsAbiCompatible)] is only defined for structs, not for unions!") + } + Data::Enum(_) => { + panic!("#[derive(IsAbiCompatible)] is only defined for structs, not for enums!") + } + }; + + // Parse the [abi_type(...)] part + let mut abi_type_name: Option = None; + for attr in derive_input + .attrs + .iter() + .filter(|a| { + a.path + .get_ident() + .map(|i| *i == "abi_type") + .unwrap_or(false) + }) + .map(Attribute::parse_meta) + .filter_map(|x| x.ok()) + { + if let Meta::List(meta_list) = attr { + if meta_list.nested.len() != 1 { + panic!("expected abi_type to be a single path") + } else if let NestedMeta::Meta(Meta::Path(p)) = meta_list.nested.first().unwrap() { + abi_type_name = Some(p.clone()); + } + } else { + panic!("expected abi_type to be path got: {:?}", attr) + } + } + + let abi_type = if let Some(tokens) = abi_type_name { + tokens + } else { + panic!("#[derive(IsAbiCompatible)] required abi_type to be defined") + }; + + // Construct the abi type path string + let abi_type_name = abi_type + .segments + .iter() + .map(|s| format!("{}", s.ident)) + .collect::>() + .join("::"); + + // Get the type and name of the struct we're implementing this for + let struct_type = &derive_input.ident; + let struct_type_name = format!("{}", struct_type); + + // Generate code for every field to test its compatibility + let field_types = struct_data.fields.iter().map(|f| { + let ty = &f.ty; + let name = f.ident.as_ref().unwrap().to_string(); + let ident = f.ident.as_ref().unwrap(); + quote! { + self::test::AbiTypeHelper::from_value(&abi_value.#ident) + .ir_type::<#ty>() + .assert_compatible(#struct_type_name, #abi_type_name, #name); + } + }); + + // Generate Phase + (quote! { + #[cfg(test)] + impl self::test::TestIsAbiCompatible<#abi_type> for #struct_type { + fn test(abi_value: &#abi_type) { + use self::test::*; + #(#field_types)* + } + } + + #[cfg(test)] + impl self::test::IsAbiCompatible<#abi_type> for #struct_type {} + + #[cfg(test)] + impl self::test::IsAbiCompatible<#struct_type> for #struct_type {} + }) + .into() +}