Skip to content

Xtensa Support#2380

Merged
kabeor merged 20 commits intocapstone-engine:nextfrom
b1llow:arch-xtensa
Sep 30, 2024
Merged

Xtensa Support#2380
kabeor merged 20 commits intocapstone-engine:nextfrom
b1llow:arch-xtensa

Conversation

@b1llow
Copy link
Copy Markdown
Contributor

@b1llow b1llow commented Jun 4, 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

...

Test plan

...

Closing issues

...

Comment thread arch/Xtensa/XtensaGenCSRegEnum.inc
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.

Please keep in mind the LITBASE mechanic Xtensa has.
No other disassembler seems to support it. So it would be nice if CS gives at least an option to take care of it.
See: https://youtu.be/QMO2vMBcx7Y?feature=shared&t=808

@XVilka
Copy link
Copy Markdown
Contributor

XVilka commented Jun 6, 2024

@imbillow what LLVM version you have used as a base for this PR? Mainstream LLVM 18? Or a fork from developers working on the Xtensa patches?

@b1llow
Copy link
Copy Markdown
Contributor Author

b1llow commented Jun 6, 2024

@imbillow what LLVM version you have used as a base for this PR? Mainstream LLVM 18? Or a fork from developers working on the Xtensa patches?

I'm using the auto-sync branch of llvm-capstone, I think it's llvm-18, I'm not sure.

commit 5943ec6923d64e63b9645aa230cd9b86bd63a51b (HEAD -> auto-sync, origin/auto-sync, origin/HEAD)
Author: Rot127 <unisono@quyllur.org>
Date:   Tue Jun 4 03:29:20 2024 -0500

    Add Alpha and LoongArch to the CI tests.

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Jun 6, 2024

It is LLVM 18. Please quickly diff the Target/Xtensa directories against each other. If there are vast differences, we can consider merging them earlier.

Comment thread suite/cstest/Makefile Outdated
@XVilka
Copy link
Copy Markdown
Contributor

XVilka commented Sep 24, 2024

@imbillow please rebase one more time

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.

Nice, almost done!
Except the few comments. Please add Xtensa to the .github/workflows/auto-sync.yml where the other archs are.
And of course fix the CI please.
Then we are ready to merge.

Comment thread include/capstone/xtensa.h Outdated
// generated content <XtensaGenCSFeatureEnum.inc> begin
// clang-format off

XTENSA_FEATURE_HASDENSITY = 128,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please clang-format the file.

Comment thread cs_priv.h Outdated
Comment thread suite/auto-sync/src/autosync/ASUpdater.py
Comment thread suite/auto-sync/src/autosync/MCUpdater.py
Comment thread tests/integration/test_litbase.c
Comment thread tests/integration/CMakeLists.txt Outdated
@XVilka

This comment was marked as resolved.

@XVilka

This comment was marked as resolved.

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Sep 26, 2024

@imbillow I fixed some issue while being at it: b1llow#1

Please check this issue here with test_litbase:

ctest --test-dir build --output-on-failure -R integration*
Internal ctest changing into directory: /home/user/repos/capstone/build
Test project /home/user/repos/capstone/build
...
    Start 11: integration_test_litbase
3/3 Test #11: integration_test_litbase .........Subprocess aborted***Exception:   0.16 sec
test_litbase: /home/user/repos/capstone/arch/Xtensa/XtensaInstPrinter.c:131: printL32RTarget: Assertion `(Value >= -262144 && Value <= -4) && "Invalid argument, value must be in ranges [-262144,-4]"' failed.

Also, it is weird. But in the CI it builds Xtensa without my edits. But it shouldn't because those macros don't exist. Or did you add them and I just overlooked them?

b1llow and others added 15 commits September 27, 2024 08:05
- fix MCExpr
- fix Xtensa_add_cs_detail
- add `add_cs_detail`
- add `MCExpr *MCOperand_getExpr(const MCOperand *MC)` `void printExpr(const MCExpr *E, SStream *O)`

autosync fix

- fix StreamOperation.py
- replace `report_fatal_error` with `CS_ASSERT`
- fix patch StreamOperation.py
- replace `assert` with `CS_ASSERT`
- fix AddCSDetail.py
- fix QualifiedIdentifier
@b1llow
Copy link
Copy Markdown
Contributor Author

b1llow commented Sep 27, 2024

The clang-tidy warnings are a false positive, because SRDecoderTable[i + 1] does not cause the array to go out of bounds if i + 1 < sizeof(SRDecoderTable) is satisfied.

@b1llow
Copy link
Copy Markdown
Contributor Author

b1llow commented Sep 27, 2024

Auto-Sync/check fix in capstone-engine/llvm-capstone#61

Comment thread arch/Xtensa/XtensaDisassembler.c Outdated
Comment thread arch/Xtensa/XtensaDisassembler.c Outdated
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.

@kabeor Your turn

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.

WoW, really cool, thanks!

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.

5 participants