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

Should the builder cache types? #14

Closed
MaikKlein opened this issue Jul 19, 2017 · 2 comments
Closed

Should the builder cache types? #14

MaikKlein opened this issue Jul 19, 2017 · 2 comments

Comments

@MaikKlein
Copy link

MaikKlein commented Jul 19, 2017

For example:

    let void = b.type_void();
    let void1 = b.type_void();

results in

%2 = OpTypeVoid
%3 = OpTypeVoid

I expected just:

%2 = OpTypeVoid

Should the builder cache types? Or should duplicate instructions be removed in a later stage?

@antiagainst
Copy link
Collaborator

antiagainst commented Jul 19, 2017

The SPIR-V spec requires that "Non-structure types (scalars, vectors, arrays, etc.) with the same operand parameterization cannot be type aliases." So it is actually invalid to have two <result-id>s for the void type.

However, it is arguable whether this kind of "semantic" validation checks should happen in mr::Builder. mr::Builder is designed to be low-level with little sanity check. It is intended to be used by some higher level builder actually. (Sorry about this maybe unnecessary layers and abstractions.) Besides, SPIR-V spec 2.16 contains a bunch of validation rules. If we enable this one, what about the others?

I am planning a higher level builder (#5) and started writing code for it, but cannot find time for it right now. We'll definitely need a type cache there. ;-P

@MaikKlein
Copy link
Author

Okay sorry I haven't completely read the spec yet, I should probably do that now.

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

No branches or pull requests

2 participants