Skip to content

Commit 7a131b8

Browse files
committed
Removed few unused IR nodes
1 parent 1da2e18 commit 7a131b8

File tree

6 files changed

+27
-50
lines changed

6 files changed

+27
-50
lines changed

cilly/src/bin/linker/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,14 @@ fn main() {
339339
MethodKind::Constructor,
340340
vec![].into(),
341341
);
342+
let arg0 = cilly::cil_node::CILNode::V2(asm.alloc_node(CILNode::LdArg(0)));
342343
MethodImpl::MethodBody {
343344
blocks: vec![cilly::BasicBlock::from_v1(
344345
&cilly::basic_block::BasicBlock::new(
345346
vec![cilly::cil_root::CILRoot::Throw(
346347
cilly::cil_node::CILNode::NewObj(Box::new(
347348
cilly::cil_node::CallOpArgs {
348-
args: Box::new([conv_usize!(
349-
cilly::cil_node::CILNode::LDArg(0)
350-
)]),
349+
args: Box::new([conv_usize!(arg0)]),
351350
site: asm.alloc_methodref(exception_ctor),
352351
is_pure: IsPure::NOT,
353352
},

cilly/src/cil_node.rs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::cilnode::MethodKind;
44
use crate::v2::method::LocalDef;
55

66
use crate::FieldDesc;
7-
use crate::IntoAsmIndex;
87
use crate::{
98
call,
109
cil_root::CILRoot,
@@ -27,12 +26,7 @@ pub enum CILNode {
2726
V2(Interned<crate::v2::CILNode>),
2827
/// Loads the value of local variable number `n`.
2928
LDLoc(u32),
30-
/// Loads the value of argument number `n`.
31-
LDArg(u32),
32-
/// Loads the address of local variable number `n`.
33-
LDLocA(u32),
34-
/// Loads the address of argument number `n`.
35-
LDArgA(u32),
29+
3630
/// A black box that prevents the bulit-in optimization engine from doing any optimizations.
3731
BlackBox(Box<Self>),
3832
/// Loads the value of a static variable described by the descripstor.
@@ -136,7 +130,7 @@ pub enum CILNode {
136130
CallVirt(Box<CallOpArgs>),
137131
LdcF64(HashableF64),
138132
LdcF32(HashableF32),
139-
133+
140134
ConvU8(Box<Self>),
141135
ConvU16(Box<Self>),
142136
ConvU32(Box<Self>),
@@ -160,8 +154,7 @@ pub enum CILNode {
160154
Gt(Box<Self>, Box<Self>),
161155
/// Compares two operands, returning true if lhs < rhs. Unsigned for intigers, unordered(in respect to NaNs) for floats.
162156
GtUn(Box<Self>, Box<Self>),
163-
LoadAddresOfTMPLocal,
164-
LoadTMPLocal,
157+
165158
LDFtn(Interned<MethodRef>),
166159
LDTypeToken(Box<Type>),
167160
NewObj(Box<CallOpArgs>),
@@ -374,7 +367,7 @@ impl CILNode {
374367
destination_addr: Self,
375368
val_desc: Interned<FieldDesc>,
376369
flag_desc: Interned<FieldDesc>,
377-
) -> [CILRoot;2] {
370+
) -> [CILRoot; 2] {
378371
// Set the value of the result.
379372
let set_val = CILRoot::SetField {
380373
addr: Box::new(destination_addr.clone()),
@@ -385,16 +378,18 @@ impl CILNode {
385378
let val = CILNode::LDField {
386379
addr: Box::new(destination_addr.clone()),
387380
field: val_desc,
388-
}
389-
;
381+
};
390382

391383
let cmp = CILNode::Eq(val.into(), expected.into());
392384

393-
[set_val,CILRoot::SetField {
394-
addr: Box::new(destination_addr.clone()),
395-
value: Box::new(cmp),
396-
desc: flag_desc,
397-
}]
385+
[
386+
set_val,
387+
CILRoot::SetField {
388+
addr: Box::new(destination_addr.clone()),
389+
value: Box::new(cmp),
390+
desc: flag_desc,
391+
},
392+
]
398393
}
399394
#[track_caller]
400395
pub fn cast_ptr(self, new_ptr: Type) -> Self {
@@ -427,11 +422,8 @@ impl CILNode {
427422
Self::GetException=>(),
428423
Self::LocAlloc{..}=>(),
429424
Self::LocAllocAligned {..}=>(),
430-
Self::CastPtr { val, new_ptr: _ }=>val.allocate_tmps(curr_loc, locals),
431-
Self::LDLoc(_) |
432-
Self::LDArg(_) |
433-
Self::LDLocA(_)|
434-
Self::LDArgA(_) => (),
425+
Self::CastPtr { val, new_ptr: _ }=>val.allocate_tmps(curr_loc, locals),
426+
Self::LDLoc(_) => (),
435427
Self::BlackBox(inner) => inner.allocate_tmps(curr_loc, locals),
436428
Self::LDIndI8 { ptr }|
437429
Self::LDIndBool { ptr }|
@@ -494,10 +486,6 @@ impl CILNode {
494486
//Self::Volatile(_) => todo!(),
495487
Self::Neg(val) |
496488
Self::Not(val) =>val.allocate_tmps(curr_loc, locals),
497-
498-
499-
Self::LoadAddresOfTMPLocal => *self = Self::LDLocA(curr_loc.expect("Temporary local referenced when none present")),
500-
Self::LoadTMPLocal =>*self = Self::LDLoc(curr_loc.expect("Temporary local referenced when none present")),
501489
Self::LDFtn(_) => (),
502490
Self::LDTypeToken(_) =>(),
503491

cilly/src/cil_root.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ pub enum CILRoot {
8888
value: Box<CILNode>,
8989
desc: Interned<FieldDesc>,
9090
},
91-
SetTMPLocal {
92-
value: CILNode,
93-
},
91+
9492
CpBlk {
9593
dst: Box<CILNode>,
9694
src: Box<CILNode>,
@@ -340,13 +338,6 @@ impl CILRoot {
340338
.for_each(|arg| arg.allocate_tmps(curr_loc, locals));
341339
}
342340

343-
Self::SetTMPLocal { value } => {
344-
value.allocate_tmps(curr_loc, locals);
345-
*self = Self::STLoc {
346-
local: curr_loc.expect("Referenced a tmp local when none present!"),
347-
tree: value.clone(),
348-
};
349-
}
350341
Self::SetStaticField { descr: _, value } => value.allocate_tmps(curr_loc, locals),
351342
Self::JumpingPad { .. } => (),
352343
};

cilly/src/utilis.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,16 @@ pub fn get_environ(asm: &mut Assembly) -> Interned<MethodRef> {
239239
MethodKind::Instance,
240240
vec![].into(),
241241
);
242-
let key = call!(asm.alloc_methodref(get_key), [CILNode::LDLocA(keyval)]);
242+
let kv = CILNode::V2(asm.alloc_node(crate::v2::CILNode::LdLocA(keyval)));
243+
let key = call!(asm.alloc_methodref(get_key), [kv.clone()]);
243244
let mref = MethodRef::new(
244245
keyval_tpe,
245246
asm.alloc_string("get_Value"),
246247
sig,
247248
MethodKind::Instance,
248249
vec![].into(),
249250
);
250-
let value = call!(asm.alloc_methodref(mref), [CILNode::LDLocA(keyval)]);
251+
let value = call!(asm.alloc_methodref(mref), [kv]);
251252
let concat = MethodRef::new(
252253
ClassRef::string(asm),
253254
asm.alloc_string("Concat"),

cilly/src/v2/cilnode.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,8 @@ impl CILNode {
351351
pub fn from_v1(v1: &V1Node, asm: &mut Assembly) -> Self {
352352
match v1 {
353353
// Varaible access
354-
V1Node::LDArg(arg) => CILNode::LdArg(*arg),
355354
V1Node::LDLoc(arg) => CILNode::LdLoc(*arg),
356-
V1Node::LDArgA(arg) => CILNode::LdArgA(*arg),
357-
V1Node::LDLocA(arg) => CILNode::LdLocA(*arg),
355+
358356
// Ptr deref
359357
V1Node::LDIndBool { ptr } => {
360358
let ptr = Self::from_v1(ptr, asm);

src/assembly.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ pub fn add_fn<'tcx, 'asm, 'a: 'asm>(
217217
continue;
218218
}
219219
let arg_field = field_descrptor(repacked_ty, arg_id.try_into().unwrap(), ctx);
220-
220+
let arg = spread_arg.as_u32() - 1 + u32::try_from(arg_id).unwrap();
221+
let arg = CILNode::V2(ctx.alloc_node(cilly::v2::CILNode::LdArg(arg)));
222+
let repacked = CILNode::V2(ctx.alloc_node(cilly::v2::CILNode::LdLocA(repacked)));
221223
repack_cil.push(
222224
CILRoot::SetField {
223-
addr: Box::new(CILNode::LDLocA(repacked)),
224-
value: Box::new(CILNode::LDArg(
225-
spread_arg.as_u32() - 1 + u32::try_from(arg_id).unwrap(),
226-
)),
225+
addr: Box::new(repacked),
226+
value: Box::new(arg),
227227
desc: (arg_field),
228228
}
229229
.into(),

0 commit comments

Comments
 (0)