Skip to content

tricore: fixes #2474#2523

Merged
kabeor merged 7 commits intocapstone-engine:nextfrom
b1llow:tricore-fix2
Nov 1, 2024
Merged

tricore: fixes #2474#2523
kabeor merged 7 commits intocapstone-engine:nextfrom
b1llow:tricore-fix2

Conversation

@b1llow
Copy link
Copy Markdown
Contributor

@b1llow b1llow commented Oct 22, 2024

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

  • Removed the tricore td files as they will be updated in the llvm-capstone repository.
  • Updated LLVM version to llvm18.
  • Fixed tricore td files

ref capstone-engine/llvm-capstone#63

Test plan

...

Closing issues

closes #2474

@b1llow
Copy link
Copy Markdown
Contributor Author

b1llow commented Oct 22, 2024

I added the A15 register to the Defs attribute, but this only has implicit register modification information, and there is still no A15 in the operands meta information.

let Defs = [A15] in
...
cstool -d tc162 d800
 0  d8 00  ld.a a15, [sp]#0
        ID: 164 (ld.a)
        op_count: 1
                operands[0].type: IMM = 0x0
                        .access: READ
        Registers modified: a15
        Groups: HasV120_UP

cc @Rot127

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Oct 22, 2024

Mh, I think we can go the expensive way for now. If one of the implicit registers commonly used in the asm text (a15, a10 etc.) are in the implicit list, check if they are in the asm text (with strstr()). if yes, insert them at the correct position.

So basically:

  • a15 in implicit read/write?
  • If yes: Check if a15 in asm text
  • If yes: insert into details.

Same for the other registers like a10.

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Oct 22, 2024

Just had another idea. What if you add another operand class in the td files. For those registers.
You can assign a printing method to them. And a decoding method. For example: printImplicitA15(), printImplicitA10().
The decoding methods do nothing. And the print methods just adds the register to the details.
Do you think this would be easier?

@b1llow
Copy link
Copy Markdown
Contributor Author

b1llow commented Oct 23, 2024

Both PRs should be ready for review now. @Rot127

cc @XVilka

Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

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

It looks like the correct fix. Very nice! So far it only fixes the ld.a instruction.

But we need also the other ones (see comment below. Effectively, all instructions with operands in TriCoreGenAsmWriter.inc::AsmStrs).

Just an observation: We never use TriCoreGenInstrInfo.inc::TriCoreInstrTable::ImplicitOps. Maybe they are a way to a quick fix? E.g. you can save them in an MCInst field and after printing, check if those names appear in the asm text.

But they seem to miss D15 and the access information. So only a little bit useful.
Maybe it misses D15 because they have the same value as A15?

No idea on what commit I clicked. PR LGTM. Please just add more tests for each instruction fixed now.

  • Tests in test/issues/ or details
  • Add TriCore to .github/workflows/auto-sync.yaml with the other architectures.

Comment thread arch/TriCore/TriCoreGenAsmWriter.inc Outdated
@github-actions github-actions bot added the Github-files Github related files label Oct 24, 2024
@b1llow b1llow requested a review from Rot127 October 25, 2024 04:46
Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

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

Excellent! Thanks a lot.

Please just open an issue about the known access problems.

Comment thread tests/details/tricore.yaml
Comment thread tests/details/tricore.yaml
Copy link
Copy Markdown
Contributor

@XVilka XVilka left a comment

Choose a reason for hiding this comment

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

@Rot127 please take a look again, it looks good to merge, I think.

Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@kabeor kabeor left a comment

Choose a reason for hiding this comment

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

Thanks again!

@kabeor kabeor merged commit f6f9679 into capstone-engine:next Nov 1, 2024
kabeor added a commit that referenced this pull request Nov 24, 2024
* Update changelog for V6.0.0-Alpha1 (#2493)

* update version to v6-alpha1

* update bindings const values

* Update changelog for V6.0.0-Alpha1

* Remove irrelevant changes. (#2495)

* Fixing UB santizer, `LITBASE` and assert errors. (#2499)

* Update labeler with Xtensa and v6 files. (#2500)

* Add hard asserts to all SStream functions and memset MCInst. (#2501)

* Only trigger on released action. (#2497)

* Fix cstest build with Ninja (#2506)

* Tricore EA calculation (#2504)

* Update libcyaml dependency in cstest to 1.4.2 (#2508)

* AArch64: Replace vararg add_cs_detail by multiple concrete functions

Fixes UB caused by various mismatches on how these arguments are passed
and read. This became visible when running on PowerPC hosts with e.g.
`cstool -d aarch64 204862f8`.
Apart from the UB fix, this is meant to be a pure refactor.

Partially addresses #2458

* xtensa: Fix Branch Target (#2516)

* xtensa: Fix Branch Target

* auto-sync: fix byte pattern

* xtensa: add branch insn tests

* Revert "auto-sync: fix byte pattern"

This reverts commit cf8e870.

* Fix #2509. (#2510)

Compatibility headers should always include the header in the same dir.

* Fix stringop-truncation warning some compilers raise. (#2522)

* Add CC and VAS compatibility macros (#2525)

* Fix endianess issue during assignment. (#2528)

* This time actually fix big endian issue. (#2530)

* tricore: fixes #2474 (#2523)

* tricore: fix auto-sync tricore

* tricore: fixes TriCoreGenCSMappingInsnName.inc

* tricore: fixes

* tricore: try fix ld.a SC

* tricore: fixes all

* Add TriCore to .github/workflows/auto-sync.yaml

* Add TriCore details tests(a15, d15, a10|sp)

* Change CI to create Debian Package to Release (#2521)

* Updating CI to create Debian package and version is assigned by tag
version. Also updating release CI to not use end-of-life workflows

* Clear up usage of static libraries.

- Python bindings only use the dynamic lib. But built and copied the static ones sometimes nonetheless.
- Add toggles to build only static, static/dyn or only dynamic.

---------

Co-authored-by: Rot127 <unisono@quyllur.org>

* Rename build arguments: (#2534)

- BUILD_SHARED_LIBS -> CAPSTONE_BUILD_SHARED_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_MSVC_RUNTIME

* xtensa: update to espressif/llvm-project (#2533)

* fix coverity (#2546)

- cid 514642

- cid 514643

- cid 514644

- cid 514645

* Move debian package generation to a dispatch only workflow (#2543)

* Move deb package gen files int package/deb

* Fix basename check

* Make debian package generation dispatch only

* Python package building rework (#2538)

* - Refactored setup.py to remove hacks regarding packaging of wheels for different platforms, improve and cleanup the code
- Updated README.txt
- Removed old Makefile and build_wheel.sh scripts
- Created a new workflow that takes care of building and testing python packages for different platforms/architectures/python versions

* Added SPDX headers to the setup.py

* - cstest_py: Fixed positional argument since it doesn't accept a `required` flag. It turns to have a mandatory tests folder path
- integration_tests.py: Use pathlib to determine the required path
- GitHub action: Simplified the tests execution command

* GitHub Actions: Run python 3.8 (lowest) and 3.13 (current highest) for native runners only during testings and the rest during tag release

* GitHub Action:
- Fixed the cibw_build matrix element
- Added a step to prepare artifact name

* GitHub Action: Added run_tests.py script to run all tests during CI workflow

* - Added SPDX headers to the run_tests.py script and to the build-wheels-publish.yml workflow file
- Minor fixes to the workflow as pointed out in the PR review
- Updated MANIFEST.in to reflect the actual libraries built during python wheel creation process
- Use subprocess.run in place of os.system in run_tests.py script

* GitHub Action:
- Run qemu step only if non-native Linux runner
- Added arch:universal2 matrix element for macos-latest runner

* Python bindings: Refreshed the list of files needed to be copied for sdist archive

* GitHub Action: Commented out arch:x86 matrix elements

* GitHub Action: Run qemu step only if non-native Linux runner

* GitHub Action: Minor fixes

* Python bindings: Added missing .in pattern when collecting src files for sdist archive

* Auto-Sync reproducability + ARM update (#2532)

* fix xtensa DecodeMR23RegisterClass and add tests for MAC16 instru… (#2551)

* fix xtensa `DecodeMR23RegisterClass` and add tests for `MAC16` instructions

* revert

* Prepare for update (#2552)

* Bindings(chore): Fix DeprecationWarning

* Version(upgrade): update bindings const

* Fix(chore): Fix ARMCC_Invalid is not defined

* Update Changelog Version to 6.0.0-Alpha2 (#2553)

* Bindings(chore): Fix DeprecationWarning

* Version(upgrade): update bindings const

* Fix(chore): Fix ARMCC_Invalid is not defined

* Changelog: Update to version 6.0.0-Alpha2

---------

Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
Co-authored-by: Florian Märkl <info@florianmaerkl.de>
Co-authored-by: billow <billow.fun@gmail.com>
Co-authored-by: Andrew <afq2101@columbia.edu>
Co-authored-by: Rot127 <unisono@quyllur.org>
Co-authored-by: @Antelox <anteloxrce@gmail.com>
Rot127 added a commit to Rot127/capstone that referenced this pull request Mar 31, 2025
* Update changelog for V6.0.0-Alpha1 (capstone-engine#2493) (capstone-engine#2494)

* update version to v6-alpha1

* update bindings const values

* Update changelog for V6.0.0-Alpha1

* Remove irrelevant changes. (capstone-engine#2496)

* Fixing UB santizer, `LITBASE` and assert errors. (capstone-engine#2499)

* Update labeler with Xtensa and v6 files. (capstone-engine#2500)

* Add hard asserts to all SStream functions and memset MCInst. (capstone-engine#2501)

* Only trigger on released action. (capstone-engine#2497)

* Fix cstest build with Ninja (capstone-engine#2506)

* Tricore EA calculation (capstone-engine#2504)

* Update libcyaml dependency in cstest to 1.4.2 (capstone-engine#2508)

* AArch64: Replace vararg add_cs_detail by multiple concrete functions

Fixes UB caused by various mismatches on how these arguments are passed
and read. This became visible when running on PowerPC hosts with e.g.
`cstool -d aarch64 204862f8`.
Apart from the UB fix, this is meant to be a pure refactor.

Partially addresses capstone-engine#2458

* xtensa: Fix Branch Target (capstone-engine#2516)

* xtensa: Fix Branch Target

* auto-sync: fix byte pattern

* xtensa: add branch insn tests

* Revert "auto-sync: fix byte pattern"

This reverts commit cf8e870.

* Fix capstone-engine#2509. (capstone-engine#2510)

Compatibility headers should always include the header in the same dir.

* Fix stringop-truncation warning some compilers raise. (capstone-engine#2522)

* Add CC and VAS compatibility macros (capstone-engine#2525)

* Fix endianess issue during assignment. (capstone-engine#2528)

* This time actually fix big endian issue. (capstone-engine#2530)

* tricore: fixes capstone-engine#2474 (capstone-engine#2523)

* tricore: fix auto-sync tricore

* tricore: fixes TriCoreGenCSMappingInsnName.inc

* tricore: fixes

* tricore: try fix ld.a SC

* tricore: fixes all

* Add TriCore to .github/workflows/auto-sync.yaml

* Add TriCore details tests(a15, d15, a10|sp)

* Change CI to create Debian Package to Release (capstone-engine#2521)

* Updating CI to create Debian package and version is assigned by tag
version. Also updating release CI to not use end-of-life workflows

* Clear up usage of static libraries.

- Python bindings only use the dynamic lib. But built and copied the static ones sometimes nonetheless.
- Add toggles to build only static, static/dyn or only dynamic.

---------

Co-authored-by: Rot127 <unisono@quyllur.org>

* Rename build arguments: (capstone-engine#2534)

- BUILD_SHARED_LIBS -> CAPSTONE_BUILD_SHARED_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_MSVC_RUNTIME

* xtensa: update to espressif/llvm-project (capstone-engine#2533)

* fix coverity (capstone-engine#2546)

- cid 514642

- cid 514643

- cid 514644

- cid 514645

* Move debian package generation to a dispatch only workflow (capstone-engine#2543)

* Move deb package gen files int package/deb

* Fix basename check

* Make debian package generation dispatch only

* Python package building rework (capstone-engine#2538)

* - Refactored setup.py to remove hacks regarding packaging of wheels for different platforms, improve and cleanup the code
- Updated README.txt
- Removed old Makefile and build_wheel.sh scripts
- Created a new workflow that takes care of building and testing python packages for different platforms/architectures/python versions

* Added SPDX headers to the setup.py

* - cstest_py: Fixed positional argument since it doesn't accept a `required` flag. It turns to have a mandatory tests folder path
- integration_tests.py: Use pathlib to determine the required path
- GitHub action: Simplified the tests execution command

* GitHub Actions: Run python 3.8 (lowest) and 3.13 (current highest) for native runners only during testings and the rest during tag release

* GitHub Action:
- Fixed the cibw_build matrix element
- Added a step to prepare artifact name

* GitHub Action: Added run_tests.py script to run all tests during CI workflow

* - Added SPDX headers to the run_tests.py script and to the build-wheels-publish.yml workflow file
- Minor fixes to the workflow as pointed out in the PR review
- Updated MANIFEST.in to reflect the actual libraries built during python wheel creation process
- Use subprocess.run in place of os.system in run_tests.py script

* GitHub Action:
- Run qemu step only if non-native Linux runner
- Added arch:universal2 matrix element for macos-latest runner

* Python bindings: Refreshed the list of files needed to be copied for sdist archive

* GitHub Action: Commented out arch:x86 matrix elements

* GitHub Action: Run qemu step only if non-native Linux runner

* GitHub Action: Minor fixes

* Python bindings: Added missing .in pattern when collecting src files for sdist archive

* Auto-Sync reproducability + ARM update (capstone-engine#2532)

* fix xtensa DecodeMR23RegisterClass and add tests for MAC16 instru… (capstone-engine#2551)

* fix xtensa `DecodeMR23RegisterClass` and add tests for `MAC16` instructions

* revert

* Prepare for update (capstone-engine#2552)

* Bindings(chore): Fix DeprecationWarning

* Version(upgrade): update bindings const

* Fix(chore): Fix ARMCC_Invalid is not defined

* Update Changelog Version to 6.0.0-Alpha2 (capstone-engine#2553)

* Bindings(chore): Fix DeprecationWarning

* Version(upgrade): update bindings const

* Fix(chore): Fix ARMCC_Invalid is not defined

* Changelog: Update to version 6.0.0-Alpha2

---------

Co-authored-by: Wu ChenXu <kabeor00@gmail.com>
Co-authored-by: Florian Märkl <info@florianmaerkl.de>
Co-authored-by: billow <billow.fun@gmail.com>
Co-authored-by: Andrew <afq2101@columbia.edu>
Co-authored-by: @Antelox <anteloxrce@gmail.com>
@b1llow b1llow deleted the tricore-fix2 branch March 7, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tricore register 0 asserts

4 participants