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

Why is sextend a part of the word interface? #4

Open
andres-erbsen-sifive opened this issue Jun 25, 2019 · 4 comments
Open

Why is sextend a part of the word interface? #4

andres-erbsen-sifive opened this issue Jun 25, 2019 · 4 comments

Comments

@andres-erbsen-sifive
Copy link
Contributor

@samuelgruetter

As sign extension goes from one word size to another word size, shouldn't it be a derived function from a word of one size to a word of another size?

@samuelgruetter
Copy link
Contributor

There are two sextend: The one you have in mind (which goes from one word size to another word size) and the one currently in here (which ignores the upper bits of the input word). Both have valid use cases.

@andres-erbsen-sifive
Copy link
Contributor Author

I understand, but why is it in the word interface?

@samuelgruetter
Copy link
Contributor

Would you prefer to implement sextend in terms of "more fundamental" operations like testbit, bitwise and, shift, etc? This should work, the question is just whether some day we care about performance of evaluating word expressions and find a super efficient word representation with a native sextend, then it would be better to have it in the interface. Not sure though how relevant that scenario is but that's what I had in mind when I was working on the interface.

@andres-erbsen-sifive
Copy link
Contributor Author

I think my main concern is that sextend does not seem like a natural word operation to me, in that its input is not clearly of the same type of as the output. Thus I would define it as an operation that does work on words, but is not a required part of the word interface.

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