 
 ! The ABI for passing structs by value is pretty messed up
 "void*" c-type clone "__stack_value" define-primitive-type
-T{ stack-regs } "__stack_value" c-type set-c-type-reg-class
-
-: struct-types&offset ( ctype -- pairs )
-    c-type struct-type-fields [
+T{ stack-params } "__stack_value" c-type set-c-type-reg-class
+
+: struct-types&offset ( struct-type -- pairs )
+    struct-type-fields [
         dup slot-spec-type swap slot-spec-offset 2array
     ] map ;
 


: flatten-large-struct ( type -- )
    heap-size cell align
    cell /i "__stack_value" <repetition> % ;

M: struct-type flatten-value-type ( type -- seq )
    dup c-size 16 > [
        flatten-large-struct
    ] [
        struct-types&offset split-struct [
            [ c-type c-type-reg-class ] map
            T{ int-regs } swap member? "void*" "double" ? ,
        ] each
    ] if ;

cpu.x86.architecture cpu.x86.intrinsics cpu.x86.sse2
cpu.x86.allot cpu.architecture kernel kernel.private math
namespaces sequences generator.registers generator.fixup system
alien alien.compiler alien.structs slots splitting math.functions ;
IN: cpu.x86.64

PREDICATE: x86-backend amd64-backend
