Hi,
I'm working on the vector subscription patch in terms of GSoC 2010 project.
The patch basically does the following, if we have a vector subscription like:
#define vector __attribute__((vector_size(16)))
vector int a;
a[1] = 10;
then the code "a[1] = 10" is transformed into the code "*((int *)a + 1) = 10".
The problem however is, when we have a register-declared variable like:
register vector int a = {1,2,3,4};
It should be addressable, but register keyword disallows it. To solve
this problem I modify c-decl.c:start_decl like this:
Index: c-decl.c
===================================================================
--- c-decl.c (revision 160230)
+++ c-decl.c (working copy)
@@ -4071,6 +4071,11 @@
}
}
+ /* Vectors need to be addressable for subscripting to work,
+ so drop the qualifier. */
+ if (TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE)
+ C_DECL_REGISTER (decl) = 0;
+
if (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (decl)
&& DECL_UNINLINABLE (decl)
Which allows now to subscript register-declared variables.
But still I have an example that does not work:
struct vec_s {
vector short member;
};
int main () {
register struct vec_s v2;
v2.member[2] = 4;
return 0;
}
The question is should it work at all? And what would be the optimal
way to implement it?
--
Thank you,
Artem Shinkarov