Frank Heckenbach wrote:
Waldek Hebisch wrote:
I just noticed that hammer backend can not pass Pascal sets as arguments to functions (procedures). The problem should be easy to solve, but first somebody must decide how sets should be treated on hammer. Currently frontend treats sets as a sequence of longs, that should work, but on hammer SSE2 instructions would double efficiency for moderate and large sets. So the question is if we should just teach backend about our current strategy or should we try something more fancy?
If someone wants to optimize things using these special instructions, that can always be done (though it might be quite some work, since probably all of the routines in rts/sets.pas and the corresponding compiler support will have to be rewritten).
However, as you say, the current mechanism treats them as arrays of unsigned long (in C terms), so it should also work. (There's not so much special about it.) I don't know how it fails, but it might be a more general problem.
My point was that we must make an API decision. Easy one is to stick to current scheme. Hard one is to try to use SSE2. SSE2 requires 128 bit alignment and means that when passing set to functions they should go in SSE register.
I infer that Frank prefers easy way but I think that we need broader consensus there, especially since the backend code will affect other frontends (Modula2 and (defunct) Chill at least).
If we choose the easy way the following patch may work (there is a question if 128 bit set should go in a register pair, since Pascal runtime wants such set in memory anyway I choose memory):
--- gcc-3.3.orig/gcc/config/i386/i386.c Thu Apr 3 00:01:58 2003 +++ gcc-3.3/gcc/config/i386/i386.c Thu Jun 12 20:30:48 2003 @@ -1853,6 +1853,18 @@ } } } + else if (TREE_CODE (type) == SET_TYPE) + { + if (mode == DImode) + { + classes[0] = X86_64_INTEGER_CLASS; + return 1; + } + else if (mode == BLKmode) + return 0; + else + abort(); + } else abort ();