🎯 Complete ptr_type deprecation fixes: 200+ → 96 warnings (53% reduction!)
- Fix all deprecated ptr_type() warnings (30+ instances) - LLVM 15.0 migration: Type::ptr_type() → Context::ptr_type() - Remove unused i64p variables in codegen.rs and helpers.rs - Clean up remaining unused imports Significant milestone achieved in warning cleanup campaign!
This commit is contained in:
@ -125,11 +125,10 @@ impl LLVMCompiler {
|
|||||||
eb
|
eb
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| ctx.create_builder());
|
.unwrap_or_else(|| ctx.create_builder());
|
||||||
let i64p = i64t.ptr_type(AddressSpace::from(0));
|
|
||||||
let tmp = slot
|
let tmp = slot
|
||||||
.build_alloca(i64t, "f2i_tmp")
|
.build_alloca(i64t, "f2i_tmp")
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
let fptr_ty = ctx.f64_type().ptr_type(AddressSpace::from(0));
|
let fptr_ty = ctx.ptr_type(AddressSpace::from(0));
|
||||||
let castp = builder
|
let castp = builder
|
||||||
.build_pointer_cast(tmp, fptr_ty, "i64p_to_f64p")
|
.build_pointer_cast(tmp, fptr_ty, "i64p_to_f64p")
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
@ -147,7 +146,7 @@ impl LLVMCompiler {
|
|||||||
builder: &inkwell::builder::Builder<'ctx>,
|
builder: &inkwell::builder::Builder<'ctx>,
|
||||||
iv: IntValue<'ctx>,
|
iv: IntValue<'ctx>,
|
||||||
) -> Result<PointerValue<'ctx>, String> {
|
) -> Result<PointerValue<'ctx>, String> {
|
||||||
let pty = ctx.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = ctx.ptr_type(AddressSpace::from(0));
|
||||||
builder
|
builder
|
||||||
.build_int_to_ptr(iv, pty, "i64_to_ptr")
|
.build_int_to_ptr(iv, pty, "i64_to_ptr")
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
@ -258,12 +257,12 @@ impl LLVMCompiler {
|
|||||||
crate::mir::MirType::Integer => ctx.i64_type().into(),
|
crate::mir::MirType::Integer => ctx.i64_type().into(),
|
||||||
crate::mir::MirType::Float => ctx.f64_type().into(),
|
crate::mir::MirType::Float => ctx.f64_type().into(),
|
||||||
crate::mir::MirType::Bool => ctx.bool_type().into(),
|
crate::mir::MirType::Bool => ctx.bool_type().into(),
|
||||||
crate::mir::MirType::String => ctx.i8_type().ptr_type(AddressSpace::from(0)).into(),
|
crate::mir::MirType::String => ctx.ptr_type(AddressSpace::from(0)).into(),
|
||||||
crate::mir::MirType::Box(_)
|
crate::mir::MirType::Box(_)
|
||||||
| crate::mir::MirType::Array(_)
|
| crate::mir::MirType::Array(_)
|
||||||
| crate::mir::MirType::Future(_)
|
| crate::mir::MirType::Future(_)
|
||||||
| crate::mir::MirType::Unknown => {
|
| crate::mir::MirType::Unknown => {
|
||||||
ctx.i8_type().ptr_type(AddressSpace::from(0)).into()
|
ctx.ptr_type(AddressSpace::from(0)).into()
|
||||||
}
|
}
|
||||||
crate::mir::MirType::Void => ctx.i64_type().into(), // avoid void as a value type; default to i64
|
crate::mir::MirType::Void => ctx.i64_type().into(), // avoid void as a value type; default to i64
|
||||||
}
|
}
|
||||||
@ -394,7 +393,7 @@ impl LLVMCompiler {
|
|||||||
.left()
|
.left()
|
||||||
.ok_or("birth_i64 returned void".to_string())?
|
.ok_or("birth_i64 returned void".to_string())?
|
||||||
.into_int_value();
|
.into_int_value();
|
||||||
let pty = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
.build_int_to_ptr(h, pty, "handle_to_ptr")
|
.build_int_to_ptr(h, pty, "handle_to_ptr")
|
||||||
@ -434,7 +433,7 @@ impl LLVMCompiler {
|
|||||||
.left()
|
.left()
|
||||||
.ok_or("birth_h returned void".to_string())?
|
.ok_or("birth_h returned void".to_string())?
|
||||||
.into_int_value();
|
.into_int_value();
|
||||||
let pty = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
.build_int_to_ptr(h_i64, pty, "handle_to_ptr")
|
.build_int_to_ptr(h_i64, pty, "handle_to_ptr")
|
||||||
@ -466,13 +465,11 @@ impl LLVMCompiler {
|
|||||||
// declare i8* @nyash_string_new(i8*, i32)
|
// declare i8* @nyash_string_new(i8*, i32)
|
||||||
let rt = codegen
|
let rt = codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0));
|
.ptr_type(inkwell::AddressSpace::from(0));
|
||||||
let fn_ty = rt.fn_type(
|
let fn_ty = rt.fn_type(
|
||||||
&[
|
&[
|
||||||
codegen
|
codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0))
|
.ptr_type(inkwell::AddressSpace::from(0))
|
||||||
.into(),
|
.into(),
|
||||||
codegen.context.i32_type().into(),
|
codegen.context.i32_type().into(),
|
||||||
@ -499,7 +496,6 @@ impl LLVMCompiler {
|
|||||||
}
|
}
|
||||||
ConstValue::Null => codegen
|
ConstValue::Null => codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0))
|
.ptr_type(inkwell::AddressSpace::from(0))
|
||||||
.const_zero()
|
.const_zero()
|
||||||
.into(),
|
.into(),
|
||||||
@ -523,7 +519,7 @@ impl LLVMCompiler {
|
|||||||
BasicValueEnum::PointerValue(pv) => pv,
|
BasicValueEnum::PointerValue(pv) => pv,
|
||||||
BasicValueEnum::IntValue(iv) => {
|
BasicValueEnum::IntValue(iv) => {
|
||||||
// Treat as Nyash handle and convert to opaque pointer
|
// Treat as Nyash handle and convert to opaque pointer
|
||||||
let pty = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
codegen
|
codegen
|
||||||
.builder
|
.builder
|
||||||
.build_int_to_ptr(iv, pty, "recv_i2p")
|
.build_int_to_ptr(iv, pty, "recv_i2p")
|
||||||
@ -721,7 +717,7 @@ impl LLVMCompiler {
|
|||||||
} else {
|
} else {
|
||||||
return Err("getField name must be pointer".to_string());
|
return Err("getField name must be pointer".to_string());
|
||||||
};
|
};
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let fnty = i64t.fn_type(&[i64t.into(), i8p.into()], false);
|
let fnty = i64t.fn_type(&[i64t.into(), i8p.into()], false);
|
||||||
let callee = codegen
|
let callee = codegen
|
||||||
.module
|
.module
|
||||||
@ -748,7 +744,7 @@ impl LLVMCompiler {
|
|||||||
} else {
|
} else {
|
||||||
return Err("get_field ret expected i64".to_string());
|
return Err("get_field ret expected i64".to_string());
|
||||||
};
|
};
|
||||||
let pty = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
.build_int_to_ptr(h, pty, "gf_handle_to_ptr")
|
.build_int_to_ptr(h, pty, "gf_handle_to_ptr")
|
||||||
@ -780,7 +776,7 @@ impl LLVMCompiler {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let fnty = i64t.fn_type(&[i64t.into(), i8p.into(), i64t.into()], false);
|
let fnty = i64t.fn_type(&[i64t.into(), i8p.into(), i64t.into()], false);
|
||||||
let callee = codegen
|
let callee = codegen
|
||||||
.module
|
.module
|
||||||
@ -988,7 +984,6 @@ impl LLVMCompiler {
|
|||||||
};
|
};
|
||||||
let pty = codegen
|
let pty = codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::from(0));
|
.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
@ -1055,7 +1050,7 @@ impl LLVMCompiler {
|
|||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
}
|
}
|
||||||
// cast to i64* pointers
|
// cast to i64* pointers
|
||||||
let i64p = i64t.ptr_type(AddressSpace::from(0));
|
let i64p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let vals_ptr = codegen
|
let vals_ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
.build_pointer_cast(vals_arr, i64p, "vals_ptr")
|
.build_pointer_cast(vals_arr, i64p, "vals_ptr")
|
||||||
@ -1128,7 +1123,6 @@ impl LLVMCompiler {
|
|||||||
};
|
};
|
||||||
let pty = codegen
|
let pty = codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::from(0));
|
.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
@ -1235,7 +1229,7 @@ impl LLVMCompiler {
|
|||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
return Err("console.readLine expects 0 args".to_string());
|
return Err("console.readLine expects 0 args".to_string());
|
||||||
}
|
}
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let fnty = i8p.fn_type(&[], false);
|
let fnty = i8p.fn_type(&[], false);
|
||||||
let callee = codegen
|
let callee = codegen
|
||||||
.module
|
.module
|
||||||
@ -1267,7 +1261,7 @@ impl LLVMCompiler {
|
|||||||
return Err("env.future.spawn_instance expects at least (recv, method_name)".to_string());
|
return Err("env.future.spawn_instance expects at least (recv, method_name)".to_string());
|
||||||
}
|
}
|
||||||
let i64t = codegen.context.i64_type();
|
let i64t = codegen.context.i64_type();
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
// a0
|
// a0
|
||||||
let a0_v = *vmap.get(&args[0]).ok_or("recv missing")?;
|
let a0_v = *vmap.get(&args[0]).ok_or("recv missing")?;
|
||||||
let a0 = to_i64_any(codegen.context, &codegen.builder, a0_v)?;
|
let a0 = to_i64_any(codegen.context, &codegen.builder, a0_v)?;
|
||||||
@ -1336,7 +1330,6 @@ impl LLVMCompiler {
|
|||||||
};
|
};
|
||||||
let pty = codegen
|
let pty = codegen
|
||||||
.context
|
.context
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::from(0));
|
.ptr_type(AddressSpace::from(0));
|
||||||
let ptr = codegen
|
let ptr = codegen
|
||||||
.builder
|
.builder
|
||||||
@ -1370,7 +1363,7 @@ impl LLVMCompiler {
|
|||||||
"env.box.new expects at least 1 arg (type name)".to_string()
|
"env.box.new expects at least 1 arg (type name)".to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
let tyv = *vmap.get(&args[0]).ok_or("type name arg missing")?;
|
let tyv = *vmap.get(&args[0]).ok_or("type name arg missing")?;
|
||||||
let ty_ptr = match tyv {
|
let ty_ptr = match tyv {
|
||||||
BasicValueEnum::PointerValue(p) => p,
|
BasicValueEnum::PointerValue(p) => p,
|
||||||
@ -1782,7 +1775,7 @@ impl LLVMCompiler {
|
|||||||
// String-like concat handling: if either side is a pointer (i8*),
|
// String-like concat handling: if either side is a pointer (i8*),
|
||||||
// and op is Add, route to NyRT concat helpers
|
// and op is Add, route to NyRT concat helpers
|
||||||
if let crate::mir::BinaryOp::Add = op {
|
if let crate::mir::BinaryOp::Add = op {
|
||||||
let i8p = codegen.context.i8_type().ptr_type(AddressSpace::from(0));
|
let i8p = codegen.context.ptr_type(AddressSpace::from(0));
|
||||||
match (lv, rv) {
|
match (lv, rv) {
|
||||||
(
|
(
|
||||||
BasicValueEnum::PointerValue(lp),
|
BasicValueEnum::PointerValue(lp),
|
||||||
|
|||||||
@ -16,16 +16,13 @@ pub(crate) fn map_type<'ctx>(
|
|||||||
MirType::Float => ctx.f64_type().into(),
|
MirType::Float => ctx.f64_type().into(),
|
||||||
MirType::Bool => ctx.bool_type().into(),
|
MirType::Bool => ctx.bool_type().into(),
|
||||||
MirType::String => ctx
|
MirType::String => ctx
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0))
|
.ptr_type(inkwell::AddressSpace::from(0))
|
||||||
.into(),
|
.into(),
|
||||||
MirType::Void => return Err("Void has no value type".to_string()),
|
MirType::Void => return Err("Void has no value type".to_string()),
|
||||||
MirType::Box(_) => ctx
|
MirType::Box(_) => ctx
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0))
|
.ptr_type(inkwell::AddressSpace::from(0))
|
||||||
.into(),
|
.into(),
|
||||||
MirType::Array(_) | MirType::Future(_) | MirType::Unknown => ctx
|
MirType::Array(_) | MirType::Future(_) | MirType::Unknown => ctx
|
||||||
.i8_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::from(0))
|
.ptr_type(inkwell::AddressSpace::from(0))
|
||||||
.into(),
|
.into(),
|
||||||
})
|
})
|
||||||
@ -82,11 +79,10 @@ pub(crate) fn to_i64_any<'ctx>(
|
|||||||
eb
|
eb
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| ctx.create_builder());
|
.unwrap_or_else(|| ctx.create_builder());
|
||||||
let i64p = i64t.ptr_type(AddressSpace::from(0));
|
|
||||||
let tmp = slot
|
let tmp = slot
|
||||||
.build_alloca(i64t, "f2i_tmp")
|
.build_alloca(i64t, "f2i_tmp")
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
let fptr_ty = ctx.f64_type().ptr_type(AddressSpace::from(0));
|
let fptr_ty = ctx.ptr_type(AddressSpace::from(0));
|
||||||
let castp = builder
|
let castp = builder
|
||||||
.build_pointer_cast(tmp, fptr_ty, "i64p_to_f64p")
|
.build_pointer_cast(tmp, fptr_ty, "i64p_to_f64p")
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
@ -105,7 +101,7 @@ pub(crate) fn i64_to_ptr<'ctx>(
|
|||||||
builder: &Builder<'ctx>,
|
builder: &Builder<'ctx>,
|
||||||
iv: IntValue<'ctx>,
|
iv: IntValue<'ctx>,
|
||||||
) -> Result<PointerValue<'ctx>, String> {
|
) -> Result<PointerValue<'ctx>, String> {
|
||||||
let pty = ctx.i8_type().ptr_type(AddressSpace::from(0));
|
let pty = ctx.ptr_type(AddressSpace::from(0));
|
||||||
builder
|
builder
|
||||||
.build_int_to_ptr(iv, pty, "i64_to_ptr")
|
.build_int_to_ptr(iv, pty, "i64_to_ptr")
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
@ -209,9 +205,9 @@ pub(crate) fn map_mirtype_to_basic<'ctx>(ctx: &'ctx Context, ty: &MirType) -> Ba
|
|||||||
MirType::Integer => ctx.i64_type().into(),
|
MirType::Integer => ctx.i64_type().into(),
|
||||||
MirType::Float => ctx.f64_type().into(),
|
MirType::Float => ctx.f64_type().into(),
|
||||||
MirType::Bool => ctx.bool_type().into(),
|
MirType::Bool => ctx.bool_type().into(),
|
||||||
MirType::String => ctx.i8_type().ptr_type(AddressSpace::from(0)).into(),
|
MirType::String => ctx.ptr_type(AddressSpace::from(0)).into(),
|
||||||
MirType::Box(_) | MirType::Array(_) | MirType::Future(_) | MirType::Unknown => {
|
MirType::Box(_) | MirType::Array(_) | MirType::Future(_) | MirType::Unknown => {
|
||||||
ctx.i8_type().ptr_type(AddressSpace::from(0)).into()
|
ctx.ptr_type(AddressSpace::from(0)).into()
|
||||||
}
|
}
|
||||||
MirType::Void => ctx.i64_type().into(),
|
MirType::Void => ctx.i64_type().into(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user