Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC: add support for arm64 (_M_ARM64) #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matbech
Copy link

@matbech matbech commented Jul 15, 2018

This adds support for arm64 on MSVC.

#define mul64x64_128(out,a,b) out.lo = ((uint64_t)(a))*(b); out.hi = __umulh(a, b);
// note: these are special purpose functions where shift is expected to be < 64 and != 0
#define shr128_pair(out,hi,lo,shift) out = ((lo) >> shift) | ((hi) << (64 - shift));
#define shl128_pair(out,hi,lo,shift) out = (lo) << shift;
Copy link

Choose a reason for hiding this comment

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

@matbech are you relay sure shl128_pair is correct?
Shouldn't it be implemented as

#define shl128_pair(out,hi,lo,shift) out = ((hi) << shift) | ((lo) >> (64 - shift));

https://docs.microsoft.com/en-us/cpp/intrinsics/shiftleft128?view=vs-2019 states

Shifts a 128-bit quantity, represented as two 64-bit quantities LowPart and HighPart, to the left by a number of bits specified by Shift and returns the high 64 bits of the result.

Copy link
Author

@matbech matbech Apr 29, 2020

Choose a reason for hiding this comment

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

You are correct, both macros are incorrect.

#define shr128_pair(out,high,low,shift) out.lo = ((low) >> shift) | ((high) << (64 - shift)); out.hi =  ((high) >> shift);
#define shl128_pair(out,high,low,shift) out.lo = (low) << shift; out.hi = ((high) << shift) | ((low) >> (64 - shift));

If you confirm that this works (I have no access to ARM64 at this time), I will make the changes to this PR.

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