Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance generic boundary #1192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taichi-ishitani
Copy link
Contributor

This PR is to enhance generic bound. Details are blow.

  • allow to use interface as generic bound
  • introduce a new generic bound inst to specify module/interface instance

Copy link

codspeed-hq bot commented Jan 8, 2025

CodSpeed Performance Report

Merging #1192 will not alter performance

Comparing taichi-ishitani:interface_on_generic_args (60cf6da) with master (f8d174a)

Summary

✅ 3 untouched benchmarks

@taichi-ishitani taichi-ishitani force-pushed the interface_on_generic_args branch 3 times, most recently from 631a4d5 to e7c90ff Compare January 10, 2025 00:06
* allow to use interface as generic bound
* introduce a new generic bound `inst` to specify module/interface instance
@taichi-ishitani taichi-ishitani force-pushed the interface_on_generic_args branch from e7c90ff to 60cf6da Compare January 10, 2025 01:52
@@ -210,12 +210,62 @@ impl VerylGrammarTrait for CheckType<'_> {
));
}
}
GenericBoundKind::Inst(proto) => {
let proto_match = if arg.is_resolvable() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At Rust 2024 (Rust 1.85), if-let chain will be stabilized.
After it, this large if chain can be re-written like below. So TODO comment may be useful to mark for re-writing.

if arg.is_resolvable()
  && let Ok(symbol) = ...
  && let SymbolKind::Instance(x) = ...
  && let Ok(x) = ...
  && let Some(ref x) = x.found.proto() {
  ...
} else {
  false
}

@@ -41,3 +42,9 @@ module Module55H::<W: const> {

let _a: StructH::<W> = 0;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this example is bit strange.
IF is bound by Interface55I, but Interface55I is not proto but specific type, so IF is always Interface55I.
Therefore I think generics is not required in this case.
How about adding proto interface support described at #963 like below?

proto interface PInterface {
    function FuncA(a: input logic, b: input logic) -> logic;
}

interface Interface55I for PInterface {
    function FuncA(a: input logic, b: input logic) -> logic {
        return 0;
    }
}

module Module55I::<IF: PInterface> {
    inst u: IF;
}

module X {
    inst u: Module55I::<Interface55I>;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants