starfive-tech / opensbi

Other
17 stars 17 forks source link

Minor optimization to sbi_strlen #2

Closed robertlipe closed 3 years ago

robertlipe commented 3 years ago

Minor optimization to sbi_strlen

There are algorthimically more clever ways to do strlen(), but the original implementation has a hot loop of 4 opcodes instead of 3. This changes the per-character body from: .L3: addi a5,a5,1 add a4,a0,a5 lbu a4,0(a4) bne a4,zero,.L3 to .L3: lbu a4,1(a5) addi a5,a5,1 bne a4,zero,.L3 While keeping the source CS101 level of complexity.

strnlen() could probably benefit from a similar change...

Originally from: https://github.com/starfive-tech/sft-riscv-opensbi/pull/2/files

pdp7 commented 3 years ago

@robertlipe sorry about this, @MichaelZhuxx and @tekkamanninja were cleaning up the opensbi branches and Fedora was deleted as this branch StarFive_VIC_7100 is now main default branch. Sorry for the trouble but please raise the PR against https://github.com/starfive-tech/opensbi/tree/StarFive_VIC_7100 and I will ask @MichaelZhuxx and @tekkamanninja to review it

MichaelZhuxx commented 3 years ago

@robertlipe that's my fault, please re-raise the PR. thanks.