From 2736a183e6122d153c45a5839d399108ad463b19 Mon Sep 17 00:00:00 2001 From: Vaivaswatha Nagaraj Date: Fri, 16 Aug 2024 09:07:45 +0530 Subject: [PATCH] rename use_def_lists.rs to value.rs --- pliron-llvm/src/from_llvm_ir.rs | 2 +- pliron-llvm/src/op_interfaces.rs | 2 +- pliron-llvm/src/ops.rs | 2 +- pliron-llvm/src/to_llvm_ir.rs | 2 +- src/basic_block.rs | 2 +- src/builtin/op_interfaces.rs | 2 +- src/irfmt/parsers.rs | 2 +- src/lib.rs | 2 +- src/operation.rs | 4 ++-- src/parsable.rs | 2 +- src/{use_def_lists.rs => value.rs} | 12 ++++++------ tests/common/mod.rs | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) rename src/{use_def_lists.rs => value.rs} (97%) diff --git a/pliron-llvm/src/from_llvm_ir.rs b/pliron-llvm/src/from_llvm_ir.rs index 72ca9d2..3112e87 100644 --- a/pliron-llvm/src/from_llvm_ir.rs +++ b/pliron-llvm/src/from_llvm_ir.rs @@ -20,7 +20,7 @@ use pliron::{ operation::Operation, r#type::{TypeObj, TypePtr}, result::Result, - use_def_lists::Value, + value::Value, }; use rustc_hash::{FxHashMap, FxHashSet}; use thiserror::Error; diff --git a/pliron-llvm/src/op_interfaces.rs b/pliron-llvm/src/op_interfaces.rs index d7b309f..0dae5ae 100644 --- a/pliron-llvm/src/op_interfaces.rs +++ b/pliron-llvm/src/op_interfaces.rs @@ -17,7 +17,7 @@ use pliron::{ operation::Operation, r#type::{TypeObj, Typed}, result::Result, - use_def_lists::Value, + value::Value, verify_err, }; diff --git a/pliron-llvm/src/ops.rs b/pliron-llvm/src/ops.rs index 6b3994e..bad1349 100644 --- a/pliron-llvm/src/ops.rs +++ b/pliron-llvm/src/ops.rs @@ -24,8 +24,8 @@ use pliron::{ parsable::Parsable, r#type::{TypeObj, TypePtr}, result::{Error, ErrorKind, Result}, - use_def_lists::Value, utils::vec_exns::VecExtns, + value::Value, verify_err, }; diff --git a/pliron-llvm/src/to_llvm_ir.rs b/pliron-llvm/src/to_llvm_ir.rs index ddb4421..aa2d933 100644 --- a/pliron-llvm/src/to_llvm_ir.rs +++ b/pliron-llvm/src/to_llvm_ir.rs @@ -25,7 +25,7 @@ use pliron::{ operation::Operation, r#type::{type_cast, Type, TypeObj, TypePtr, Typed}, result::Result, - use_def_lists::Value, + value::Value, }; use rustc_hash::FxHashMap; diff --git a/src/basic_block.rs b/src/basic_block.rs index 83af960..f1bf1d7 100644 --- a/src/basic_block.rs +++ b/src/basic_block.rs @@ -24,8 +24,8 @@ use crate::{ r#type::{TypeObj, Typed}, region::Region, result::Result, - use_def_lists::{DefNode, Value}, utils::vec_exns::VecExtns, + value::{DefNode, Value}, }; /// Argument to a [BasicBlock] diff --git a/src/builtin/op_interfaces.rs b/src/builtin/op_interfaces.rs index 527c6ae..56ff886 100644 --- a/src/builtin/op_interfaces.rs +++ b/src/builtin/op_interfaces.rs @@ -17,7 +17,7 @@ use crate::{ r#type::{TypeObj, TypePtr, Typed}, region::Region, result::Result, - use_def_lists::Value, + value::Value, verify_err, verify_error, }; diff --git a/src/irfmt/parsers.rs b/src/irfmt/parsers.rs index ce7842a..f390396 100644 --- a/src/irfmt/parsers.rs +++ b/src/irfmt/parsers.rs @@ -13,7 +13,7 @@ use crate::{ parsable::{Parsable, ParseResult, StateStream}, r#type::TypeObj, result::Result, - use_def_lists::Value, + value::Value, }; use combine::{ between, many1, diff --git a/src/lib.rs b/src/lib.rs index 5c0f687..c575add 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,5 +27,5 @@ pub mod result; pub mod storage_uniquer; pub mod r#type; pub mod uniqued_any; -pub mod use_def_lists; pub mod utils; +pub mod value; diff --git a/src/operation.rs b/src/operation.rs index 844565d..af1200d 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -24,8 +24,8 @@ use crate::{ r#type::{TypeObj, Typed}, region::Region, result::Result, - use_def_lists::{DefNode, DefTrait, DefUseParticipant, Use, UseNode, Value}, utils::vec_exns::VecExtns, + value::{DefNode, DefTrait, DefUseParticipant, Use, UseNode, Value}, verify_err, }; @@ -231,7 +231,7 @@ impl Operation { /// Does any result of this operation have a use? pub fn has_use(&self) -> bool { - self.results.iter().any(|res| res.def.has_use()) + self.results.iter().any(|res| res.def.is_used()) } /// Total number of uses (across all results). diff --git a/src/parsable.rs b/src/parsable.rs index 950eeb8..06244c4 100644 --- a/src/parsable.rs +++ b/src/parsable.rs @@ -15,7 +15,7 @@ use crate::{ op::op_impls, operation::Operation, result::{self, Result}, - use_def_lists::Value, + value::Value, }; use combine::{ easy::{self, Errors, ParseError}, diff --git a/src/use_def_lists.rs b/src/value.rs similarity index 97% rename from src/use_def_lists.rs rename to src/value.rs index 85950ba..174059b 100644 --- a/src/use_def_lists.rs +++ b/src/value.rs @@ -1,5 +1,5 @@ -//! # Use-Def and Def-Use Graph. -//! Like in LLVM, at the core of the IR infrastructure are SSA use-def chains. +//! # SSA [Value]s: Use-Def and Def-Use Graph. +//! At the core of the IR infrastructure are SSA use-def chains. //! Use-def and def-use chains are composed of four key structures: //! - [Value] describes a value definition, either a block argument, or an operation result. //! - [`Ptr`] describes a block definition. @@ -46,7 +46,7 @@ impl DefNode { } /// Does the definition have a use? - pub(crate) fn has_use(&self) -> bool { + pub(crate) fn is_used(&self) -> bool { !self.uses.is_empty() } @@ -138,8 +138,8 @@ impl Value { } /// Does this definition have any [Use]? - pub fn has_use(&self, ctx: &Context) -> bool { - self.get_defnode_ref(ctx).has_use() + pub fn is_used(&self, ctx: &Context) -> bool { + self.get_defnode_ref(ctx).is_used() } /// Replace uses of the underlying definition, that satisfy `pred`, with `other`. @@ -252,7 +252,7 @@ impl UseTrait for Value { impl Ptr { /// Does this block a predecessor? pub fn has_pred(&self, ctx: &Context) -> bool { - self.deref(ctx).preds.has_use() + self.deref(ctx).preds.is_used() } /// Number of predecessors to this block. diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 4bad02c..62aa5fc 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -26,7 +26,7 @@ use pliron::{ parsable::{self, IntoParseResult, Parsable, ParseResult, StateStream}, printable::{self, Printable}, result::Result, - use_def_lists::Value, + value::Value, }; use pliron_derive::def_op;