+| // variable has initializer (not a struct or array)
+T@p
+- var = value
++ *var = SMPI_VARINIT_GLOBAL_AND_SET(var, T, value)
+;
+//| // array of specified size
+//T@p // FIXME: matches, but complains if more than one decl on a line...
+//- var[size]
+//+ *var[size] = SMPI_VARINIT_GLOBAL_ARRAY(T, size)
+//;
+//| // array of specified size with initializer
+//T@p // FIXME: how to match initializer?
+//- var[size] = { ... }
+//+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... })
+//;
+//| // array without specified size, but with initializer
+//T@p // FIXME: how to match initializer? how to figure out size?
+//- var[] = { ... }
+//+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... }) // size = ?
+//;
+//| struct with initializer?
+)
+
+// rewrite access to global variables based on name, but avoid the declaration
+// and local variables that might have the same name
+@rewriteglobalaccess@
+type T;
+local idexpression lvar;
+identifier globalvardecl.var;
+@@
+<...
+( // local variable
+lvar
+| // rewrite access
++SMPI_VARGET_GLOBAL(
+var