From 9cbaa9d8604c1968783f4b2dab3edf8f7566d09c Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Wed, 18 Dec 2024 18:46:57 +0100 Subject: [PATCH] Update --- xrcf/src/convert/mlir_to_llvmir.rs | 1 + xrcf/src/ir/block.rs | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/xrcf/src/convert/mlir_to_llvmir.rs b/xrcf/src/convert/mlir_to_llvmir.rs index 8e467196..951d597a 100644 --- a/xrcf/src/convert/mlir_to_llvmir.rs +++ b/xrcf/src/convert/mlir_to_llvmir.rs @@ -362,6 +362,7 @@ fn determine_argument_pairs( return vec![]; } let callers = callers.unwrap(); + println!("callers: {:?}", callers.len()); let mut argument_pairs = vec![]; for caller in callers.iter() { let caller = caller.try_read().unwrap(); diff --git a/xrcf/src/ir/block.rs b/xrcf/src/ir/block.rs index 1f8747bb..b14b05ef 100644 --- a/xrcf/src/ir/block.rs +++ b/xrcf/src/ir/block.rs @@ -1,5 +1,6 @@ use crate::ir::BlockArgumentName; use crate::ir::GuardedOp; +use crate::ir::GuardedOpOperand; use crate::ir::GuardedOperation; use crate::ir::Op; use crate::ir::Operation; @@ -126,23 +127,26 @@ impl Block { let ops = predecessor.ops(); let ops = ops.try_read().unwrap(); for op in ops.iter() { - if let Some(label) = label { - let operation = op.operation(); - let operands = operation.operands().vec(); - let operands = operands.try_read().unwrap(); - for operand in operands.iter() { - let operand = operand.try_read().unwrap(); - let value = operand.value(); - let value = value.try_read().unwrap(); - if let Value::BlockLabel(block_label) = &*value { - if canonicalize_label(&block_label.name()) == canonicalize_label(&label) - { + let operation = op.operation(); + let operands = operation.operands().vec(); + let operands = operands.try_read().unwrap(); + for operand in operands.iter() { + let value = operand.value(); + let value = value.try_read().unwrap(); + if let Value::BlockPtr(block_ptr) = &*value { + let current = block_ptr.block(); + let current = &*current.try_read().unwrap(); + if std::ptr::eq(current, self) { + callers.push(op.clone()); + } + } else if let Value::BlockLabel(block_label) = &*value { + if let Some(label) = label { + let current = canonicalize_label(&block_label.name()); + if current == canonicalize_label(label) { callers.push(op.clone()); } } } - } else { - todo!("find via blockptr for this case but also previous case"); } } }