Skip to content

Commit

Permalink
Merge branch 'main' into blockext
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Dec 3, 2024
2 parents 279764c + dbc305b commit 74ef0e4
Show file tree
Hide file tree
Showing 32 changed files with 118 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
.cargo
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion macro/src/dialect/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Parse for DialectInput {
}

Ok(Self {
name: name.ok_or(input.error("dialect name required"))?,
name: name.ok_or_else(|| input.error("dialect name required"))?,
table_gen,
td_file,
include_directories: includes,
Expand Down
14 changes: 7 additions & 7 deletions macro/src/dialect/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ impl<'a> Operation<'a> {
&self.name
}

pub fn can_infer_type(&self) -> bool {
pub const fn can_infer_type(&self) -> bool {
self.can_infer_type
}

pub fn dialect_name(&self) -> &str {
pub const fn dialect_name(&self) -> &str {
self.dialect_name
}

pub fn operation_name(&self) -> &str {
pub const fn operation_name(&self) -> &str {
self.operation_name
}

Expand Down Expand Up @@ -153,7 +153,7 @@ impl<'a> Operation<'a> {
&self.description
}

pub fn constructor_identifier(&self) -> &Ident {
pub const fn constructor_identifier(&self) -> &Ident {
&self.constructor_identifier
}

Expand Down Expand Up @@ -227,7 +227,7 @@ impl<'a> Operation<'a> {
.chain(self.required_attributes().map(convert))
}

fn collect_successors(definition: Record<'a>) -> Result<Vec<Successor>, Error> {
fn collect_successors(definition: Record<'a>) -> Result<Vec<Successor<'a>>, Error> {
definition
.dag_value("successors")?
.args()
Expand All @@ -242,7 +242,7 @@ impl<'a> Operation<'a> {
.collect()
}

fn collect_regions(definition: Record<'a>) -> Result<Vec<Region>, Error> {
fn collect_regions(definition: Record<'a>) -> Result<Vec<Region<'a>>, Error> {
definition
.dag_value("regions")?
.args()
Expand Down Expand Up @@ -307,7 +307,7 @@ impl<'a> Operation<'a> {
definition: Record<'a>,
same_size: bool,
attribute_sized: bool,
) -> Result<(Vec<OperationResult>, usize), Error> {
) -> Result<(Vec<OperationResult<'a>>, usize), Error> {
Self::collect_elements(
&Self::dag_constraints(definition, "results")?
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions macro/src/dialect/operation/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ impl<'a> Attribute<'a> {
})
}

pub fn set_identifier(&self) -> &Ident {
pub const fn set_identifier(&self) -> &Ident {
&self.set_identifier
}

pub fn remove_identifier(&self) -> &Ident {
pub const fn remove_identifier(&self) -> &Ident {
&self.remove_identifier
}

Expand Down
6 changes: 3 additions & 3 deletions macro/src/dialect/operation/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ impl<'a> OperationBuilder<'a> {
}
}

pub fn operation(&self) -> &Operation {
pub const fn operation(&self) -> &Operation {
self.operation
}

pub fn identifier(&self) -> &Ident {
pub const fn identifier(&self) -> &Ident {
&self.identifier
}

pub fn type_state(&self) -> &TypeState {
pub const fn type_state(&self) -> &TypeState {
&self.type_state
}

Expand Down
2 changes: 1 addition & 1 deletion macro/src/dialect/operation/builder/type_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct TypeState {
}

impl TypeState {
pub fn new(
pub const fn new(
results: Vec<String>,
operands: Vec<String>,
regions: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion macro/src/dialect/operation/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> Region<'a> {
})
}

pub fn is_variadic(&self) -> bool {
pub const fn is_variadic(&self) -> bool {
self.variadic
}
}
Expand Down
2 changes: 1 addition & 1 deletion macro/src/dialect/operation/successor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> Successor<'a> {
})
}

pub fn is_variadic(&self) -> bool {
pub const fn is_variadic(&self) -> bool {
self.variadic
}
}
Expand Down
8 changes: 4 additions & 4 deletions macro/src/dialect/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ impl Type {
}
}

pub fn is_optional(&self) -> bool {
pub const fn is_optional(&self) -> bool {
self.optional
}

pub fn is_variadic(&self) -> bool {
pub const fn is_variadic(&self) -> bool {
self.variadic
}

// TODO Support variadic-of-variadic.
#[allow(unused)]
pub fn is_variadic_of_variadic(&self) -> bool {
pub const fn is_variadic_of_variadic(&self) -> bool {
self.variadic_of_variadic
}

pub fn is_unfixed(&self) -> bool {
pub const fn is_unfixed(&self) -> bool {
self.is_variadic() || self.is_optional()
}
}
2 changes: 1 addition & 1 deletion macro/src/dialect/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn sanitize_name(name: &str) -> Result<Ident, Error> {

// Try to parse the string as an ident, and prefix the identifier
// with "r#" if it is not a valid identifier.
Ok(syn::parse_str::<Ident>(&name).unwrap_or(format_ident!("r#{}", name)))
Ok(syn::parse_str::<Ident>(&name).unwrap_or_else(|_| format_ident!("r#{}", name)))
}

pub fn sanitize_documentation(string: &str) -> Result<String, Error> {
Expand Down
8 changes: 4 additions & 4 deletions melior/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ impl<'c> ContextRef<'c> {
}
}

impl<'c> PartialEq for ContextRef<'c> {
impl PartialEq for ContextRef<'_> {
fn eq(&self, other: &Self) -> bool {
unsafe { mlirContextEqual(self.raw, other.raw) }
}
}

impl<'c> PartialEq<Context> for ContextRef<'c> {
impl PartialEq<Context> for ContextRef<'_> {
fn eq(&self, other: &Context) -> bool {
self == &other.to_ref()
}
}

impl<'c> Eq for ContextRef<'c> {}
impl Eq for ContextRef<'_> {}

#[cfg(test)]
mod tests {
Expand Down Expand Up @@ -320,7 +320,7 @@ mod tests {
fn context_to_ref() {
let ctx = Context::new();
let ctx_ref = ctx.to_ref();
let ctx_ref_to_ref: &Context = unsafe { &ctx_ref.to_ref() };
let ctx_ref_to_ref: &Context = unsafe { ctx_ref.to_ref() };

assert_eq!(&ctx_ref, ctx_ref_to_ref);
}
Expand Down
4 changes: 2 additions & 2 deletions melior/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Diagnostic<'c> {
phantom: PhantomData<&'c ()>,
}

impl<'c> Diagnostic<'c> {
impl Diagnostic<'_> {
pub fn location(&self) -> Location {
unsafe { Location::from_raw(mlirDiagnosticGetLocation(self.raw)) }
}
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<'c> Diagnostic<'c> {
}
}

impl<'a> Display for Diagnostic<'a> {
impl Display for Diagnostic<'_> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
let mut data = (formatter, Ok(()));

Expand Down
4 changes: 2 additions & 2 deletions melior/src/dialect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ impl<'c> Dialect<'c> {
}
}

impl<'c> PartialEq for Dialect<'c> {
impl PartialEq for Dialect<'_> {
fn eq(&self, other: &Self) -> bool {
unsafe { mlirDialectEqual(self.raw, other.raw) }
}
}

impl<'c> Eq for Dialect<'c> {}
impl Eq for Dialect<'_> {}

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion melior/src/dialect/llvm/load_store_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'c> LoadStoreOptions<'c> {
}

/// Sets TBAA metadata.
pub fn tbaa(mut self, tbaa: ArrayAttribute<'c>) -> Self {
pub const fn tbaa(mut self, tbaa: ArrayAttribute<'c>) -> Self {
self.tbaa = Some(tbaa);
self
}
Expand Down
8 changes: 4 additions & 4 deletions melior/src/ir/affine_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ impl<'c> AffineMap<'c> {
}
}

impl<'c> PartialEq for AffineMap<'c> {
impl PartialEq for AffineMap<'_> {
fn eq(&self, other: &Self) -> bool {
unsafe { mlirAffineMapEqual(self.raw, other.raw) }
}
}

impl<'c> Eq for AffineMap<'c> {}
impl Eq for AffineMap<'_> {}

impl<'c> Display for AffineMap<'c> {
impl Display for AffineMap<'_> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
let mut data = (formatter, Ok(()));

Expand All @@ -67,7 +67,7 @@ impl<'c> Display for AffineMap<'c> {
}
}

impl<'c> Debug for AffineMap<'c> {
impl Debug for AffineMap<'_> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
Display::fmt(self, formatter)
}
Expand Down
8 changes: 4 additions & 4 deletions melior/src/ir/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ impl<'c> AttributeLike<'c> for Attribute<'c> {
}
}

impl<'c> PartialEq for Attribute<'c> {
impl PartialEq for Attribute<'_> {
fn eq(&self, other: &Self) -> bool {
unsafe { mlirAttributeEqual(self.raw, other.raw) }
}
}

impl<'c> Eq for Attribute<'c> {}
impl Eq for Attribute<'_> {}

impl<'c> Display for Attribute<'c> {
impl Display for Attribute<'_> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
let mut data = (formatter, Ok(()));

Expand All @@ -116,7 +116,7 @@ impl<'c> Display for Attribute<'c> {
}
}

impl<'c> Debug for Attribute<'c> {
impl Debug for Attribute<'_> {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
Display::fmt(self, formatter)
}
Expand Down
Loading

0 comments on commit 74ef0e4

Please sign in to comment.