-
Notifications
You must be signed in to change notification settings - Fork 248
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
Failed translating declaration due to error: Unsupported vector default initializer: Int x 4, kind: Some(Function { is_extern: true, is_inline: true, is_implicit: false, typ: CTypeId(10934), name: "MyGetIP_comp", parameters: [CDeclId(23294)], body: Some(CStmtId(23293)) })' #44
Comments
It seems like the call to Behind that one, though, is an even stranger error: and that also seems to be coming from the |
Also, are you using LLVM 6 or 7? A bunch of SIMD functions got moved to builtins in 7 |
|
Thanks, the problem seems to be the definition of #define _mm_extract_epi32(X, N) (__extension__ \
({ __v4si __a = (__v4si)(__m128i)(X); \
(int)__a[(N) & 3];})) The problem is twofold:
I'm going to see if it's possible for us to correctly translate this as is however it will nonetheless not be very pretty and wont be able to use the rust function OTOH, this will be much easier and nicer to support in LLVM 8 one day as it's just a builtin: #define _mm_extract_epi32(X, N) \
(int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N)) And that's easy enough to translate to the rust function. I'm not sure if this is helpful but a correct translation of #[cfg ( target_arch = "x86" )]
pub use std::arch::x86::{__m128i, _mm_sub_epi8, _mm_cmpeq_epi8,
_mm_loadu_si128, _mm_set_epi8, _mm_set1_epi8,
_mm_setzero_si128, _mm_store_si128,
_mm_movemask_epi8, _mm_lddqu_si128, _mm_hadd_epi16,
_mm_maddubs_epi16, _mm_shuffle_epi8, _mm_extract_epi32};
#[cfg ( target_arch = "x86_64" )]
pub use std::arch::x86_64::{__m128i, _mm_sub_epi8, _mm_cmpeq_epi8,
_mm_loadu_si128, _mm_set_epi8, _mm_set1_epi8,
_mm_setzero_si128, _mm_store_si128,
_mm_movemask_epi8, _mm_lddqu_si128,
_mm_hadd_epi16, _mm_maddubs_epi16,
_mm_shuffle_epi8, _mm_extract_epi32};
#[inline]
unsafe extern "C" fn MyGetIP_comp(mut str: *const libc::c_char) -> UINT32 {
//"192.167.1.3"
let mut input: __m128i = _mm_lddqu_si128(str as *const __m128i);
let mut zm: uint64_t =
_mm_movemask_epi8(_mm_cmpeq_epi8(input, _mm_setzero_si128())) as
uint64_t;
zm ^= zm.wrapping_sub(1i32 as libc::c_ulong);
input = _mm_sub_epi8(input, _mm_set1_epi8('0' as i32 as libc::c_char));
//...X...X.X.XX... (signs)
let mut cmp: __m128i = input;
//6792 - magic index
let mut mask: uint64_t = _mm_movemask_epi8(cmp) as uint64_t;
mask &= zm;
let mut hashmask: uint64_t =
perfecthash(mask as libc::c_uint) as uint64_t;
//10 -1 -1 -1 8 -1 -1 -1 6 5 4 -1 2 1 0 -1
let mut shuf: __m128i =
*(TBL.as_ptr() as *const __m128i).offset(hashmask as isize);
//3 0 0 0 | 1 0 0 0 | 7 6 1 0 | 2 9 1 0
let mut arr: __m128i = _mm_shuffle_epi8(input, shuf);
let mut coeffs: __m128i =
_mm_set_epi8(0i32 as libc::c_char, 100i32 as libc::c_char,
10i32 as libc::c_char, 1i32 as libc::c_char,
0i32 as libc::c_char, 100i32 as libc::c_char,
10i32 as libc::c_char, 1i32 as libc::c_char,
0i32 as libc::c_char, 100i32 as libc::c_char,
10i32 as libc::c_char, 1i32 as libc::c_char,
0i32 as libc::c_char, 100i32 as libc::c_char,
10i32 as libc::c_char, 1i32 as libc::c_char);
//3 0 | 1 0 | 67 100 | 92 100
let mut prod: __m128i = _mm_maddubs_epi16(coeffs, arr);
prod = _mm_hadd_epi16(prod, prod);
let mut imm: __m128i =
_mm_set_epi8(-1i32 as libc::c_char, -1i32 as libc::c_char,
-1i32 as libc::c_char, -1i32 as libc::c_char,
-1i32 as libc::c_char, -1i32 as libc::c_char,
-1i32 as libc::c_char, -1i32 as libc::c_char,
-1i32 as libc::c_char, -1i32 as libc::c_char,
-1i32 as libc::c_char, -1i32 as libc::c_char,
6i32 as libc::c_char, 4i32 as libc::c_char,
2i32 as libc::c_char, 0i32 as libc::c_char);
prod = _mm_shuffle_epi8(prod, imm);
return _mm_extract_epi32(prod, 0) as UINT32;
} |
@TheDan64 awesome, thanks! I actually needed this translated code. |
No problem! Also it seems like |
I've added support for |
Closing since the repo is now synced. Feel free to reopen. |
@TheDan64 what do you mean by not synced? What's the canonical repo URL? Perhaps it's worth mentioning in Github project description / README? |
Sorry, we should have been more clear. For various reasons, we've had to do development in a non-public github repository that we'd occasionally sync with this one (which is indeed the canonical repository for this project). Going forward, we should be able to do most development in public here. |
I used the following input:
a.zip
Here's the result:
Are there any plans to add support for this feature?
The text was updated successfully, but these errors were encountered: