Skip to main content

luaur_code_gen/methods/
ir_value_location_tracking_can_rematerialize_arguments.rs

1use crate::enums::ir_op_kind::IrOpKind;
2use crate::macros::op_a::op_a;
3use crate::records::ir_inst::IrInst;
4use crate::records::ir_value_location_tracking::IrValueLocationTracking;
5
6impl IrValueLocationTracking {
7    pub fn can_rematerialize_arguments(&mut self, inst: &mut IrInst) -> bool {
8        if self.can_be_rematerialized(inst.cmd) && op_a(inst).kind() == IrOpKind::Inst {
9            let function = unsafe { &mut *self.function };
10            let dep_inst = function.inst_op(op_a(inst));
11
12            if dep_inst.last_use != function.get_inst_index(inst) {
13                return true;
14            }
15        }
16
17        false
18    }
19}