Skip to content

Commit 970fea7

Browse files
committed
Updated rustc version
1 parent d59698c commit 970fea7

File tree

14 files changed

+85
-154
lines changed

14 files changed

+85
-154
lines changed

cargo_tests/build_std/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
mycorrhiza = {path="../../mycorrhiza"}
10-
rand = "0.8.5"
9+
#mycorrhiza = {path="../../mycorrhiza"}
10+
#rand = "0.8.5"
1111
[workspace]
1212
[profile.release.build-override]
1313
codegen-units = 1

cilly/src/v2/c_exporter/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{collections::HashSet, io::Write, num::NonZero, path::Path};
55

66
use crate::{
77
asm::LINKER_RECOVER,
8+
cilnode::MethodKind,
89
config, typecheck,
910
utilis::{assert_unique, encode},
1011
BiMap, IString, MethodImpl,
@@ -88,13 +89,16 @@ impl CExporter {
8889
return Ok(());
8990
}
9091
let output = c_tpe(mref.output(asm), asm);
91-
let inputs = mref
92+
let mut inputs = mref
9293
.stack_inputs(asm)
9394
.iter()
9495
.map(|i| nonvoid_c_type(*i, asm))
9596
.intersperse(",".into())
9697
.collect::<String>();
97-
98+
if mref.kind() == MethodKind::Constructor {
99+
let owner = nonvoid_c_type(Type::ClassRef(mref.class()), asm);
100+
inputs = format!("{owner},{inputs}")
101+
}
98102
writeln!(method_decls, "{output} {method_name}({inputs});")
99103
}
100104
#[allow(clippy::too_many_arguments)]
@@ -820,7 +824,7 @@ impl CExporter {
820824
CILRoot::Branch(binfo) => {
821825
let (target, sub_target, cond) = binfo.as_ref();
822826
//let target = if *sub_target != 0 { sub_target } else { target };
823-
let label = branch_cond_to_name(*target, *sub_target, is_handler, has_handler);
827+
let label = branch_cond_to_name(*target, *sub_target, has_handler, is_handler);
824828
let Some(cond) = cond else {
825829
if next == Some(*target) && *sub_target == 0 {
826830
return Ok("".into());
@@ -908,7 +912,7 @@ impl CExporter {
908912
CILRoot::Call(info) => {
909913
let (method, args, _is_pure) = info.as_ref();
910914
let method = asm[*method].clone();
911-
let call_args = args
915+
let mut call_args = args
912916
.iter()
913917
.map(|arg| {
914918
format!(
@@ -925,6 +929,10 @@ impl CExporter {
925929
})
926930
.intersperse(",".into())
927931
.collect::<String>();
932+
if method.kind() == MethodKind::Constructor {
933+
let owner = nonvoid_c_type(Type::ClassRef(method.class()), asm);
934+
call_args = format!("*({owner}*)malloc(sizeof({owner})),{call_args}");
935+
}
928936
let method_name = mref_to_name(&method, asm);
929937
format!("{method_name}({call_args});")
930938
}

cilly/src/v2/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ fn add_macro() {
219219
pub fn branch_cond_to_name(
220220
target: u32,
221221
sub_target: u32,
222-
is_handler: bool,
223222
has_handler: bool,
223+
is_handler: bool,
224224
) -> String {
225225
if sub_target == 0 {
226226
format!("bb{}", target)

rustc_codegen_clr_call/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ extern crate rustc_driver;
44
extern crate rustc_middle;
55
extern crate rustc_target;
66
use cilly::FnSig;
7-
use rustc_abi::ExternAbi as TargetAbi;
7+
use rustc_abi::{CanonAbi, ExternAbi as TargetAbi};
88
use rustc_codegen_clr_ctx::MethodCompileCtx;
99
use rustc_codegen_clr_type::r#type::get_type;
1010
use rustc_middle::ty::{Instance, List, PseudoCanonicalInput, TyKind};
11-
use rustc_target::callconv::Conv;
1211
pub struct CallInfo {
1312
sig: FnSig,
1413
split_last_tuple: bool,
@@ -30,9 +29,9 @@ impl CallInfo {
3029
let conv = fn_abi.conv;
3130
#[allow(clippy::match_same_arms)]
3231
match conv {
33-
Conv::C | Conv::Rust => (),
32+
CanonAbi::C | CanonAbi::Rust => (),
3433
// TODO: check this is 100% correct!
35-
Conv::X86_64SysV => (),
34+
CanonAbi::X86(_) => (),
3635
_ => panic!("ERROR:calling using convention {conv:?} is not supported!"),
3736
}
3837
//assert!(!fn_abi.c_variadic);

rustc_codegen_clr_place/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn place_adress<'a>(place: &Place<'a>, ctx: &mut MethodCompileCtx<'a, '_>) -
9090
let layout = ctx.layout_of(place_ty);
9191
if layout.is_zst() {
9292
let place_type = ctx.type_from_cache(place_ty);
93-
return V1Node::V2(ctx.alloc_node(Const::USize(layout.align.pref.bytes())))
93+
return V1Node::V2(ctx.alloc_node(Const::USize(layout.align.abi.bytes())))
9494
.cast_ptr(ctx.nptr(place_type));
9595
}
9696
if place.projection.is_empty() {
@@ -123,7 +123,7 @@ pub fn place_address_raw<'a>(place: &Place<'a>, ctx: &mut MethodCompileCtx<'a, '
123123

124124
let layout = ctx.layout_of(place_ty);
125125
if layout.is_zst() {
126-
return V1Node::V2(ctx.alloc_node(Const::USize(layout.align.pref.bytes())));
126+
return V1Node::V2(ctx.alloc_node(Const::USize(layout.align.abi.bytes())));
127127
}
128128
if place.projection.is_empty() {
129129
V1Node::V2(local_adress(place.local.as_usize(), ctx.body(), ctx))

rustc_codegen_clr_type/src/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn enum_tag_info(r#enum: Layout<'_>, asm: &mut Assembly) -> (Type, u32) {
9999
Variants::Multiple { tag, tag_field, .. } => (
100100
scalr_to_type(*tag, asm),
101101
FieldOffsetIterator::from_fields_shape(r#enum.fields())
102-
.nth(*tag_field)
102+
.nth((*tag_field).into())
103103
.unwrap_or(0),
104104
),
105105
Variants::Empty => (Type::Void, 0),

rustc_codegen_clr_type/src/type.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn get_type<'tcx>(ty: Ty<'tcx>, ctx: &mut MethodCompileCtx<'tcx, '_>) -> Typ
286286
// Get the layout and size of this array
287287
let layout = ctx.layout_of(ty);
288288
let arr_size = layout.layout.size().bytes();
289-
let arr_align = layout.layout.align().pref.bytes();
289+
let arr_align = layout.layout.align().abi.bytes();
290290
// An array of this size can't be represented on the .NET side
291291
if std::convert::TryInto::<u32>::try_into(arr_size).is_err() {
292292
eprintln!(
@@ -557,10 +557,10 @@ pub fn closure_typedef(
557557
NonZeroU32::new(
558558
layout
559559
.align()
560-
.pref
560+
.abi
561561
.bytes()
562562
.try_into()
563-
.expect("Closure alignement exceeds 2^32"),
563+
.expect("Closure alignment exceeds 2^32"),
564564
)
565565
.unwrap(),
566566
),
@@ -622,7 +622,7 @@ fn struct_<'tcx>(
622622
layout
623623
.layout
624624
.align()
625-
.pref
625+
.abi
626626
.bytes()
627627
.try_into()
628628
.expect("Struct alignement exceeds 2^32"),
@@ -732,7 +732,7 @@ fn enum_<'tcx>(
732732
layout
733733
.layout
734734
.align()
735-
.pref
735+
.abi
736736
.bytes()
737737
.try_into()
738738
.expect("Enum alignement exceeds 2^32"),
@@ -781,7 +781,7 @@ fn union_<'tcx>(
781781
layout
782782
.layout
783783
.align()
784-
.pref
784+
.abi
785785
.bytes()
786786
.try_into()
787787
.expect("Union alignement exceeds 2^32"),
@@ -866,7 +866,7 @@ pub fn tuple_typedef(
866866
NonZeroU32::new(
867867
layout
868868
.align()
869-
.pref
869+
.abi
870870
.bytes()
871871
.try_into()
872872
.expect("Tuple alignement exceeds 2^32"),

rustc_codgen_clr_operand/src/static_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn add_static(def_id: DefId, ctx: &mut MethodCompileCtx<'_, '_>) -> Interned
3737
assert!(ty.is_sized(ctx.tcx(), TypingEnv::fully_monomorphized()));
3838
let symbol: String = ctx
3939
.tcx()
40-
.symbol_name(Instance::new(def_id, List::empty()))
40+
.symbol_name(Instance::new_raw(def_id, List::empty()))
4141
.to_string();
4242

4343
let sfld = ctx.add_static(

src/assembly.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ pub fn add_item<'tcx>(
401401
let alloc = tcx.eval_static_initializer(stotic).unwrap();
402402
let alloc_id = tcx.reserve_and_set_memory_alloc(alloc);
403403
let attrs = tcx.codegen_fn_attrs(stotic);
404-
let instance = rustc_middle::ty::Instance::new(stotic, rustc_middle::ty::List::empty());
404+
let instance =
405+
rustc_middle::ty::Instance::new_raw(stotic, rustc_middle::ty::List::empty());
405406
let mut ctx = MethodCompileCtx::new(tcx, None, instance, asm);
406407
let int8_ptr = ctx.nptr(Type::Int(Int::I8));
407408
let int8_ptr_ptr = ctx.nptr(int8_ptr);

src/function_sig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::codegen_error::CodegenError;
22
use cilly::{FnSig, Type};
3+
use rustc_abi::CanonAbi;
34
use rustc_abi::ExternAbi as TargetAbi;
45
use rustc_codegen_clr_ctx::MethodCompileCtx;
56
use rustc_codegen_clr_type::r#type::get_type;
67
use rustc_middle::ty::{Instance, List, Ty, TyCtxt, TyKind};
7-
use rustc_target::callconv::Conv;
88

99
/// Creates a `FnSig` from ` `. May not match the result of `sig_from_instance_`!
1010
/// Use ONLY for function pointers!
@@ -37,7 +37,7 @@ pub fn sig_from_instance_<'tcx>(
3737
};
3838
let conv = fn_abi.conv;
3939
match conv {
40-
Conv::Rust | Conv::C => (),
40+
CanonAbi::Rust | CanonAbi::C => (),
4141
_ => panic!("ERROR:calling using convention {conv:?} is not supported!"),
4242
}
4343
//assert!(!fn_abi.c_variadic);

0 commit comments

Comments
 (0)