Skip to content

arm64: lift sxtl, sxtl2, sshll, sshll2#5461

Closed
yrp604 wants to merge 1 commit into
Vector35:devfrom
yrp604:arm64-still-peter
Closed

arm64: lift sxtl, sxtl2, sshll, sshll2#5461
yrp604 wants to merge 1 commit into
Vector35:devfrom
yrp604:arm64-still-peter

Conversation

@yrp604
Copy link
Copy Markdown
Contributor

@yrp604 yrp604 commented May 26, 2024

Partially fixes #5417

Also superficial re-ordering of the tests to make it easier to add new tests.

With both PRs targeting #5417 we get this LLIL:

  41 @ 100003ea0  s1 = [x29 - 8 {var_18}].d
  42 @ 100003ea4  s0 = s1
  43 @ 100003ea8  v0.d[0] = sx.q(v0.s[0] u>> 0 << 0)
  44 @ 100003ea8  v0.d[1] = sx.q(v0.s[1] u>> 0 << 0)
  45 @ 100003eac  d1 = int.q(d0)
  46 @ 100003eb0  d0 = 10.0
  47 @ 100003eb4  d0 = d0 f+ d1
  48 @ 100003eb8  s0 = fconvert.s(d0)
  49 @ 100003ebc  x8 = sx.q([x29 - 8 {var_18}].d)
  50 @ 100003ec0  x9 = 0x2c
  51 @ 100003ec4  x9 = x8 * x9
  52 @ 100003ec8  x8 = &main::x
  53 @ 100003ecc  x8 = x8
  54 @ 100003ed0  x8 = x8 + x9
  55 @ 100003ed4  [x8 + 0x28].d = s0
  56 @ 100003ed8  [x29 - 0xc {var_1c_1}].d = 0
  57 @ 100003edc  goto 58 @ 0x100003ee0

and this HLIL:

  10 @ 100003ea0  int64_t v1
  11 @ 100003ea0  v1.d = var_18
  12 @ 100003ea4  v0.d = v1.d
  13 @ 100003eb8  v0.d = fconvert.s(10.0 f+ int.q((v0.d u>> 0 << 0):4.d u>> 0 << 0))
  14 @ 100003ed4  *(sx.q(var_18) * 0x2c + 0x100008028) = v0.d
  15 @ 100003ed8  int32_t var_1c_1 = 0

Finally, it looks like there are some other unlifted SHL variants that would probably follow the same template. Let me know if you've come across any of these and I can take a look.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@galenbwill galenbwill self-assigned this May 28, 2024
@galenbwill galenbwill self-requested a review May 28, 2024 17:18
@galenbwill galenbwill added Type: Enhancement Arch: ARM64 Issues with the AArch64 architecture plugin Lifting issues related to LLIL lifting labels May 28, 2024
@plafosse plafosse added this to the Elysium milestone May 28, 2024
@galenbwill
Copy link
Copy Markdown
Contributor

Closing PR because superseded by e3b91f9

@galenbwill galenbwill closed this Jul 3, 2024
galenbwill added a commit that referenced this pull request Jul 8, 2024
…, improved, and/or fixed

Merged #5461:
    Author: yrp <yrp604@protonmail.com>
    Date:   Sat May 25 21:00:26 2024 -0700

        arm64: lift sxtl, sxtl2, sshll, sshll2

Partial list of detailed changes squashed into this commit (see
https://github.com/Vector35/binaryninja-api/tree/arm64_improving_intrinsics
for detailed commit history):

* add lifting for sshll/sxtl

* reverted neon_intrinsics.cpp to restore scvtf intrinsics

* lifted sxtl/2, sshll, ushll, sshl, sshr, ushl, ushr, and changed the lifting of uxtl/2 to be consistent with sxtl/2

* reformatted arm64test.py and added tests for sxtl/2, sshll, ushll, sshl, sshr, ushl, ushr, and uxtl/2

 fix scvtf (unroll because no intrinsic) and fsub (missing register assignment) half-precision vector cases

* added preferIntrinsics setting to arm64

* added lifting for movn

* fixed incorrect int/float conversions for FMOV, made half-precision immediates survive the lift to M/HLIL

* fix missing break in SCVT; optimize MOVK

* improved preferIntrinsics

* fixed bad lifting introduced for movn

* fixed bad settings definition for preferIntrinsics

* added intrinsic definition for DUP from general register

* added direct lifting of scalar version of FADDP, and fixed intrinsics for vector version

* added direct lifting of scalar version of FABD, and fixed intrinsics for vector version

* fixes to test_gen.py: gets the correct encoding instead of sometimes getting fooled by the mnemonic

* fixed lifting of UCVTF; reviewed/fixed all intrinsics through SQXTUN

* reviewed/fixed remaining intrinsics after SQXTUN

* added lifting for FNMUL

* WIP intrinsics improvements

* WIP intrinsics improvements 2

* WIP intrinsics improvements: FCVT*_asisdmisc_R

* added B.AL, B.NV, CASP*

* direct lifting of scalar FSQRT instruction

* SETREG now elides setting of targeting zero registers

* fixed test_gen.py to correctly regenerate arm64test.py

* unroll vector MOV operations, USHL no longer uses intrinsic for scalars

* updated existing tests in arm64test.py for latest lifting changes

* fixed CASH* and CASB* incorrectly accessing temp register in comparison (resulting in comparing to NOP)

* lifting all variants of TBL as intrinsic

* fixes/improvements to test_gen.py

* lifting all variants of TBX as intrinsic

* added tests for CAS*, UMUL*, UADD*, FABD, FABS, FADDP, FMAX, FMAXNM, FMIN, FMINNM, FNEG, FNMUL, FCMEQ, FCMGE, FCMGT, FMLA, FMLS

* added tests for all aliases of SBFM
galenbwill added a commit that referenced this pull request Jul 8, 2024
…, improved, and/or fixed

Merged #5461:
    Author: yrp <yrp604@protonmail.com>
    Date:   Sat May 25 21:00:26 2024 -0700

        arm64: lift sxtl, sxtl2, sshll, sshll2

Partial list of detailed changes squashed into this commit (see
https://github.com/Vector35/binaryninja-api/tree/arm64_improving_intrinsics
for detailed commit history):

* add lifting for sshll/sxtl

* reverted neon_intrinsics.cpp to restore scvtf intrinsics

* lifted sxtl/2, sshll, ushll, sshl, sshr, ushl, ushr, and changed the lifting of uxtl/2 to be consistent with sxtl/2

* reformatted arm64test.py and added tests for sxtl/2, sshll, ushll, sshl, sshr, ushl, ushr, and uxtl/2

 fix scvtf (unroll because no intrinsic) and fsub (missing register assignment) half-precision vector cases

* added preferIntrinsics setting to arm64

* added lifting for movn

* fixed incorrect int/float conversions for FMOV, made half-precision immediates survive the lift to M/HLIL

* fix missing break in SCVT; optimize MOVK

* improved preferIntrinsics

* fixed bad lifting introduced for movn

* fixed bad settings definition for preferIntrinsics

* added intrinsic definition for DUP from general register

* added direct lifting of scalar version of FADDP, and fixed intrinsics for vector version

* added direct lifting of scalar version of FABD, and fixed intrinsics for vector version

* fixes to test_gen.py: gets the correct encoding instead of sometimes getting fooled by the mnemonic

* fixed lifting of UCVTF; reviewed/fixed all intrinsics through SQXTUN

* reviewed/fixed remaining intrinsics after SQXTUN

* added lifting for FNMUL

* WIP intrinsics improvements

* WIP intrinsics improvements 2

* WIP intrinsics improvements: FCVT*_asisdmisc_R

* added B.AL, B.NV, CASP*

* direct lifting of scalar FSQRT instruction

* SETREG now elides setting of targeting zero registers

* fixed test_gen.py to correctly regenerate arm64test.py

* unroll vector MOV operations, USHL no longer uses intrinsic for scalars

* updated existing tests in arm64test.py for latest lifting changes

* fixed CASH* and CASB* incorrectly accessing temp register in comparison (resulting in comparing to NOP)

* lifting all variants of TBL as intrinsic

* fixes/improvements to test_gen.py

* lifting all variants of TBX as intrinsic

* added tests for CAS*, UMUL*, UADD*, FABD, FABS, FADDP, FMAX, FMAXNM, FMIN, FMINNM, FNEG, FNMUL, FCMEQ, FCMGE, FCMGT, FMLA, FMLS

* added tests for all aliases of SBFM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: ARM64 Issues with the AArch64 architecture plugin Lifting issues related to LLIL lifting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lift commonly used arm64 floating point instructions scvtf and sxtl

4 participants