tum-ei-eda / M2-ISA-R

CoreDSL2 Parser with backend to generate simulation code for the ETISS instruction set simulator
https://tum-ei-eda.github.io/M2-ISA-R/
Apache License 2.0
5 stars 6 forks source link

Nested static statements #5

Closed fpedd closed 2 years ago

fpedd commented 3 years ago

M2-ISA-R currently produces "nested" static statements by calling make_static() on statements that were already made static. This leads to code like this:

partInit.code() += "_illmask = " + std::to_string((1) << (" + std::to_string(32 - 1) + ")) + ";\n";

See 16e0bcb120a147d9375efd2e8368f67256114e81 for an extremely dirty fix.

wysiwyng commented 3 years ago

That fix is indeed extremely dirty. Do these nested static statements only happen with the builtins shrl, shll and shra? These functions currently don't support static expressions as their first argument. As a workaround, use the standard shifting operators << and >>.

fpedd commented 3 years ago

I have not tested anything beyond the vector CoreDSL. In there the only cases this happened seemed to be with the builtins. I will give the standard shifts a try.

If I can simply use the standard shifts then what is the reason behind the builtins anyways?

wysiwyng commented 3 years ago

The shift builtins allow explicit arithmetic or logical shifts. Apart from that, they do not provide any different functionality. They will be removed in CoreDSL 2.0, where only the standard shift operators are provided.

wysiwyng commented 3 years ago

I pushed a fix for this, please test and let me know whether this indeed fixes the problem.

fpedd commented 3 years ago

cfd3b6e93bacad47b343235ee75cd798096aad74 and b9579babcc0b3527d4c55589061e7e4b017c31f1 appear to have fixed the issue. Thank you very much. However, I would leave this issue open until I have conducted some actual tests.

wysiwyng commented 2 years ago

Did you get around to testing the fixes?

fpedd commented 2 years ago

Sorry for the late reply. I completely overlooked this. I haven't been using M2-ISA-R very much lately as I need to implement some more RVV instructions in order to use ETISS for my work. I am waiting for the M2-ISA-R support for CoreDSL 2 in order to avoid having to reimplement (or at least refactor) everything. Thus, I would close this issue for now and come back to it if I run into issues again.