__m128 / float32x4_t / float vector return arguments

Started by
1 comment, last by WitchLord 12 years, 11 months ago
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)

__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);

and now I have two functions registered to as
__m128 foo();
void bar(__m128 v);
and call:
bar(foo());

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."
Advertisement
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement