-
Notifications
You must be signed in to change notification settings - Fork 123
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
Support pointer data types for sizeof operator #171
Conversation
I'm unable to reproduce broken pipe failure on my machine, and the snapshots I checked which are generated by |
Because this pull request involves size of pointers, I would like to ask a question. In the header file ( Thus, I hope to obtain an explanation about them through this opportunity. |
The Which I later realized value of |
@ChAoSUnItY , after fetching your latest changes, I try to build shecc and check the snapshots: $ make distclean && make ARCH=arm && tests/check-snapshots.sh
...
SHECC out/shecc-stage1.elf
SHECC out/shecc-stage2.elf $ make distclean && make ARCH=riscv && tests/check-snapshots.sh
...
SHECC out/shecc-stage1.elf
SHECC out/shecc-stage2.elf
Files /dev/fd/63 and /dev/fd/62 differ
Files /dev/fd/63 and /dev/fd/62 differ It seems that the snapshots differs when shecc uses RISC-V backend. Hope this information helps you. |
5a9aa0c
to
f7db9ba
Compare
Ok, I found the cause, apparently previously shecc's CI won't check snapshot on rv32 but only on arm32: Lines 55 to 59 in 18e005d
shecc/.github/workflows/main.yml Lines 6 to 27 in 18e005d
So currently the workaround is just not to run Should we later address this issue in another PR? @jserv |
f7db9ba
to
29b6e1a
Compare
That was a fault. Let's fix it in another pull request. |
23bb340
to
98d72ff
Compare
I will wrap up some additional changes introduced besides Previously, while using stage 2 compiler to compile division-related test suites in The former one was caused by improper stack alignment, while the later one was caused by missing edge case equality check, which is The change of total stack size of shecc itself has increased from 9225 to 9228. |
- Refactor test driver to make it capable of running different stage based on supplied stage number. - Refactor make rule "check" for checking stage 0 and stage 2. - Replace constant value 4 with PTR_SIZE to give appropriate corresponding target arch's pointer size. - Add sizeof test. - Introduce __SIZE_OF_PTR__ macro in lib/c.c. - Fix arm32 div/mod, this was caused by inproper stack alignment previously calculated in reg_alloc.c. - Fix rv32 div/mod, this was caused by missing approximating value equality checking.
98d72ff
to
10ef491
Compare
I defer to @vacantron for confirmation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank @ChAoSUnItY for contributing! |
Currently
sizeof
is only capable of parsing basic data types likeint
,char
, or user-defined data types likestruct
,enum
etc. But not able to parsing pointer type, thus, in this PR, by introducing a temporary workaround parsing 0 or more asterisk tokens, we now partially support pointer type forsizeof
operator (not including function pointer type yet).Additionally, since the result given by
HOST_PTR_SIZE
in stage 0 and stage 1/2 are different, so I make another test driver nameddriver-stage2.sh
for testing stage 2 shecc and adding correspondingsizeof
test to verify the implementation.