Sign in to follow this  
virious

__m128 / float32x4_t / float vector return arguments

Recommended Posts

virious    182
Hello, question from the friend of mine:
"Hi

Is there any possibility to modify AS calling stubs to allow proper handling of '__m128 / float32x4_t / float vector' return argument ?
Example:
(x86)

[code]__m128 SomeFoo() { __m128 r; return r; }

AS_REG_OBJECT2("__m128", __m128, sizeof(__m128), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA)
as->RegisterObjectBehaviour("__m128", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(__m128_DefaultConstructor), asCALL_CDECL_OBJLAST);
as->RegisterObjectBehaviour("__m128", asBEHAVE_CONSTRUCT, "void f(const __m128 &in)", asFUNCTION(__m128_CopyConstructor), asCALL_CDECL_OBJLAST);[/code]
and now I have two functions registered to as
[code]__m128 foo();
void bar(__m128 v);
and call:
bar(foo());[/code]
but at bar i get total crap -- bar expects arg0 in xmm0 but gets it on the stack (foo returns arg by stack not in xmm0 - so this part is ok on x86)

on ARM (float32x4_t maps to NEON registers)
there is a crap with both returning and setting as arg.

For now I didnt tested this for PPC (ps3 cell, xbox360 xenos) but probably there will be also crap.

I have a bunch of functions that i need to register to AS but they all return float vector types, and i want to avoid production of tons of stubs just to convert return types to structs."

Share this post


Link to post
Share on other sites
WitchLord    4678
The possibility exists. It requires implementing support for this type in the native calling convention code. First of all, AngelScript would need to know that the type is actually a float vector, so a flag like asOBJ_APP_FLOATVECTOR needs to be introduced. Then the code in the as_callfunc_???.cpp modules needs to be updated to properly handle this type.

Share this post


Link to post
Share on other sites
WitchLord    4678
I recommend taking a look at the autowrapper add-on. They ought to work even with the __m128 type, and would avoid having to implement the wrapper functions by hand.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this