Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Dec 5, 2023
1 parent b6e6432 commit 39dfa35
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions macro/src/dialect/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,20 +521,20 @@ impl<'a> Operation<'a> {
.collect()
}

pub fn from_definition(def: Record<'a>) -> Result<Self, Error> {
let dialect = def.def_value("opDialect")?;
let traits = Self::collect_traits(def)?;
pub fn from_definition(definition: Record<'a>) -> Result<Self, Error> {
let dialect = definition.def_value("opDialect")?;
let traits = Self::collect_traits(definition)?;
let has_trait = |name: &str| traits.iter().any(|r#trait| r#trait.has_name(name));

let arguments = Self::dag_constraints(def, "arguments")?;
let regions = Self::collect_regions(def)?;
let arguments = Self::dag_constraints(definition, "arguments")?;
let regions = Self::collect_regions(definition)?;
let (results, num_variable_length_results) = Self::collect_results(
def,
definition,
has_trait("::mlir::OpTrait::SameVariadicResultSize"),
has_trait("::mlir::OpTrait::AttrSizedResultSegments"),
)?;

let name = def.name()?;
let name = definition.name()?;
let class_name = if name.starts_with('_') {
name
} else if let Some(name) = name.split('_').nth(1) {
Expand All @@ -543,7 +543,7 @@ impl<'a> Operation<'a> {
} else {
name
};
let short_name = def.str_value("opName")?;
let short_name = definition.str_value("opName")?;

Ok(Self {
dialect,
Expand All @@ -558,23 +558,23 @@ impl<'a> Operation<'a> {
}
},
class_name,
successors: Self::collect_successors(def)?,
successors: Self::collect_successors(definition)?,
operands: Self::collect_operands(
&arguments,
has_trait("::mlir::OpTrait::SameVariadicOperandSize"),
has_trait("::mlir::OpTrait::AttrSizedOperandSegments"),
)?,
results,
attributes: Self::collect_attributes(&arguments)?,
derived_attributes: Self::collect_derived_attributes(def)?,
derived_attributes: Self::collect_derived_attributes(definition)?,
can_infer_type: traits.iter().any(|r#trait| {
(r#trait.has_name("::mlir::OpTrait::FirstAttrDerivedResultType")
|| r#trait.has_name("::mlir::OpTrait::SameOperandsAndResultType"))
&& num_variable_length_results == 0
|| r#trait.has_name("::mlir::InferTypeOpInterface::Trait") && regions.is_empty()
}),
summary: {
let summary = def.str_value("summary")?;
let summary = definition.str_value("summary")?;

if summary.is_empty() {
format!("[`{short_name}`]({class_name}) operation")
Expand All @@ -585,7 +585,7 @@ impl<'a> Operation<'a> {
)
}
},
description: unindent::unindent(def.str_value("description")?),
description: unindent::unindent(definition.str_value("description")?),
regions,
})
}
Expand Down

0 comments on commit 39dfa35

Please sign in to comment.