contribute by: < oucs638 >
src/cfront.c
, so that the compiler can generate effective IR before codegen, and codegen can get more optimization space.Try to make riscv-codegen.c
can generate excutable multiplication and division instructions without RV32M.
__mul()
, __div()
, and __mod()
declartion in riscv.c
.Since shecc currently does not fully support preprocessor, can't use #ifdef ... #else ... #endif
.
if (var == 1) {}
.Try to use weak symbol, and check if the function exists before calling it.
riscv-codegen.c
make
.Try to add new compiler options.
+m
and -m
.riscv_m_extension
.__zero
is read-only and can not be changed, the instruction __addi(__zero, __zero, 0)
will have no effect on riscv. Therefore, it will be a nop
.Test after adding new compiler options.
/tests/mul_test.c
.Now, the code generator can generate executable multiplication code without M extension.
Try to use shift to rewrite part of the multiplication and division operations in src/cfront.c
, so that the compiler can generate effective IR before codegen, and codegen can get more optimization space.
src/cfront.c
that use multiplication operation.src/cfront.c
that use multiplication operation.valus * 10
and value * 16
can be rewritten:read_numeric_constant()
and In read_numeric_param()
.Source code has some issues that should be improved..
tests/mul_test.c
, it should update file tests/driver.sh
which perform the comprehensiveReplace riscv_m_extension
with use_m_ext
.
Update the file tests/driver.sh
Try to implement multiplication with out m extension.
mul
instruction.
mul
with follow code.mul_test
without m extension and run will have problem.