OpenXiangShan / XiangShan

Open-source high-performance RISC-V processor
Other
4.45k stars 618 forks source link

Add format checking for XiangShan #3061

Open Yan-Muzi opened 2 weeks ago

Yan-Muzi commented 2 weeks ago

This PR uses Scalafmt to format XiangShan source code.

Mill has built-in support for Scalafmt, which reads .scalafmt.conf to check format and reformat. Current configuration mainly includes:

However, there is a small problem with when, elsewhen and otherwise. Scalafmt will treat them as function calls, which they are actually from the perspective of scala, instead of key words. This will lead to no space after them unlikely if or for.

Additionally, Scalafmt can be overridden or disabled in some specific regions. This allows more flexible control over how the code is formatted.

make check-format can check whether existing code is correctly formatted, and make reformat can reformat the code.

Format checking is also added to CI, but the CI will continue even if the checking fails.

XiangShanRobot commented 2 weeks ago
[Generated by IPC robot] commit: e95f196c0fd5d9b6282d30b063a2aea8d5367b95 commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
e95f196 1.808 0.447 2.043 1.187 2.938 2.508 2.291 0.921 1.369 1.441 3.454 2.658 2.399 2.932
master branch: commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
a7828dc 1.808 2.043 1.187 2.938 2.508 0.921 1.369 1.441 3.454 2.399 2.932
9f598f8
e975de6 1.808 0.447 2.043 1.187 2.938 2.508 2.291 0.921 1.369 1.441 3.454 2.658 2.399 2.932
ff9b84b 0.447 2.043 1.187 2.291 0.921 1.369 3.454 2.658 2.932
3bec463 1.808 0.447 2.043 1.187 2.938 2.508 2.291 0.921 1.369 1.441 3.454 2.658 2.399 2.932
2d12882 0.447 2.043 1.187 2.291 0.921 1.369 3.454 2.658 2.932
ef14270 1.827 0.448 2.048 1.190 2.938 2.508 2.289 0.932 1.369 1.410 3.445 2.672 2.398 2.932
5c5f442 1.827 0.448 2.048 1.190 2.938 2.508 2.289 0.932 1.369 1.410 3.445 2.672 2.398 2.932
d67c873 1.827 0.448 2.048 1.190 2.938 2.508 2.289 0.932 1.369 1.410 3.445 2.672 2.398 2.932
eastonman commented 2 weeks ago

The current format config fits my taste well. 🥰

XiangShanRobot commented 1 week ago
[Generated by IPC robot] commit: b4c5b5424d56d7e1958439c61919f2eee2c92770 commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
b4c5b54 1.809 0.452 2.052 1.196 2.951 2.499 2.198 0.930 1.377 1.407 3.436 2.653 2.398 2.941
master branch: commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
dd40a82 1.809 0.452 2.052 1.196 2.951 2.499 2.199 0.930 1.377 1.407 3.436 2.653 2.398 2.941
2a1dcaf 1.805 0.452 2.052 1.196 2.951 2.499 2.197 0.930 1.377 1.407 3.436 2.653 2.398 2.941
c08d352 1.809 0.452 2.052 1.196 2.951 2.499 2.197 0.930 1.377 1.407 3.436 2.653 2.398 2.941
87c5d21 1.805 0.452 2.052 1.196 2.951 2.499 2.199 0.930 1.377 1.407 3.436 2.653 2.398 2.941
864480f 1.809 0.452 2.052 1.196 2.951 2.499 2.199 0.930 1.377 1.407 3.436 2.653 2.398 2.941
69a3c27 1.805 0.452 2.052 1.196 2.951 2.499 2.197 0.930 1.377 1.407 3.436 2.653 2.398 2.941
a31db3f 1.805 0.452 2.052 1.196 2.951 2.499 2.197 0.930 1.377 1.407 3.436 2.653 2.398 2.941
5adc482 1.801 0.452 2.039 1.187 2.936 2.508 2.197 0.930 1.378 1.441 3.428 2.669 2.399 2.932
0d257fb 1.801 0.452 2.040 1.187 2.936 2.508 2.197 0.930 1.378 1.441 3.428 2.669 2.399 2.932
ba5ba1d 1.805 0.452 2.039 1.187 2.936 2.508 2.197 0.930 1.378 1.441 3.428 2.669 2.399 2.932