Skip to content

Conversation

@harryrrah76
Copy link

@harryrrah76 harryrrah76 commented Aug 9, 2024

The PR has two parts.

The first part is a set of fixes found when converting the assembly generated by the LLVM main branch (using the Jul 25 18:49:38 commit, hash: 7304936479a7eb61adc9edcaf6ce56e4792590ad) to RVV 0.7.1. This has been tested with the riscv-gnu-toolchain XuanTie 10.2 using a simple saxpy program that uses OpenMP SIMD directives on the SG2042 RISC-V Testbed:

  • Removed some new z* extensions added by LLVM.
  • Fixed an issue with an extra comma being added when vm is empty in the whole register load/store/copy
  • Fixed a bug where vl*re32 and vl*64re didn't include the .v in the whole register load/store/copy
  • Fixed mistakingly interpreting the "#" as instruction[3] in whole register load/store/copy
  • Added code to remove uleb128 and .addrsig instructions from roll-backed assembly
  • Fixed the usage of addi instruction

The second part is a set of refactorings to improve readability and ease of maintenance:

  • Moved opcode mappings, whole register name store, extension removal and version change to separate yaml files instead of using lists and dictionaries in Python.
  • Improved the way tail/mask agnostic policy was disabled.

I'm happy to turn this into two separate PRs if preferred.

@harryrrah76 harryrrah76 changed the title add fixes for llvm-19+ assembly and refactor Add fixes for LLVM main branch assembly and refactor Aug 9, 2024
vd, vs2 = instruction[1], instruction[2]
vm = ", " + instruction[3] if len(instruction) > 3 else ""
newline = (
"\tvwaddu.vx, {VD}, {VS2}, x0{VM}\n" # unsigned widening add zero

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused why there are commas behind vwaddu.vx, maybe they are mistakes?
There is another problem here, when I use the original script vs2 can be '[reg]\n', the problem can be solved with letting vs2 be instruction[2].replace("\n","").

}
if name in remove_list:
newline = newline.replace("_" + attribute, "")
line_changed = True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These modified codes will turn former code into latter one, and it will cause gcc compilation error because there is no v0p7.

.attribute      5, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zve32f1p0_zve32x1p0_zvl32b1p0"
.attribute      5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_zicsr2p0"

This is what the original code will generate.

.attribute      5, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v0p7"

suggestion += "# Pick unused register e.g. t0\n"
suggestion += "#\taddi t0, " + AVL + '\n'
suggestion += "# " + temp + '\n'
suggestion += f"\taddi t0, x0, {AVL} \n"
Copy link

@BubbleSalt BubbleSalt Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems delete # is a mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants