pulp-platform / pulp-riscv-gnu-toolchain

Other
73 stars 51 forks source link

la tp,0' instruction and why it is not allowed in pulp-riscv compiler #14

Open dspg-arch1 opened 4 years ago

dspg-arch1 commented 4 years ago

we encountered an issue with `la tp,0' instruction

pulp-riscv compiler mark it as illegal.

taken from the spec(RISC-V Unprivileged ISA p.139): la rd, symbol (PIC ) auipc rd, delta[31 : 12] + delta[11] Load absolute address

page 20 - regarding AUIPC (add upper immediate to pc) instruction: command syntax is- U-immediate[31:12] dest AUIPC

The current PC can be obtained by setting the U-immediate to 0. Although a JAL +4 instruction could also be used to obtain the local PC (of the instruction following the JAL), it might cause pipeline breaks in simpler microarchitectures or pollute BTB structures in more complex microarchitectures.

so it seems like a correct synatx, but perhaps not implemented in ri5cy?