-static int AllocRegVar (const SymEntry* Sym, const type* tarray)
-/* Allocate a register variable with the given amount of storage. If the
- * allocation was successful, return the offset of the register variable in
- * the register bank (zero page storage). If there is no register space left,
- * return -1.
- */
-{
- /* Maybe register variables are disabled... */
- if (EnableRegVars) {
-
- /* Get the size of the variable */
- unsigned Size = SizeOf (tarray);
-
- /* Do we have space left? */
- if (RegOffs >= Size) {
-
- /* Space left. We allocate the variables from high to low addresses,
- * so the adressing is compatible with the saved values on stack.
- * This allows shorter code when saving/restoring the variables.
- */
- RegOffs -= Size;
- RegSyms [RegSymCount++] = Sym;
- return RegOffs;
- }
+ /* Save the current contents of the register variable on stack */
+ F_AllocLocalSpace (CurrentFunc);
+ g_save_regvars (Reg, Size);
+
+ /* Add the symbol to the symbol table. We do that now, because for register
+ ** variables the current stack pointer is implicitly used as location for
+ ** the save area.
+ */
+ Sym = AddLocalSym (Decl->Ident, Decl->Type, Decl->StorageClass, Reg);
+
+ /* Check for an optional initialization */
+ if (CurTok.Tok == TOK_ASSIGN) {
+
+ ExprDesc Expr;
+
+ /* Skip the '=' */
+ NextToken ();
+
+ /* Special handling for compound types */
+ if (IsCompound) {
+
+ /* Switch to read only data and define a label for the
+ ** initialization data.
+ */
+ unsigned InitLabel = AllocLabel (g_userodata);
+
+ /* Parse the initialization generating a memory image of the
+ ** data in the RODATA segment. The function does return the size
+ ** of the initialization data, which may be greater than the
+ ** actual size of the type, if the type is a structure with a
+ ** flexible array member that has been initialized. Since we must
+ ** know the size of the data in advance for register variables,
+ ** we cannot allow that here.
+ */
+ if (ParseInit (Sym->Type) != Size) {
+ Error ("Cannot initialize flexible array members of storage class `register'");
+ }
+
+ /* Generate code to copy this data into the variable space */
+ g_initregister (InitLabel, Reg, Size);
+
+ } else {
+
+ /* Parse the expression */
+ hie1 (&Expr);
+
+ /* Convert it to the target type */
+ TypeConversion (&Expr, Sym->Type);
+
+ /* Load the value into the primary */
+ LoadExpr (CF_NONE, &Expr);
+
+ /* Store the value into the variable */
+ g_putstatic (CF_REGVAR | TypeOf (Sym->Type), Reg, 0);
+
+ }
+
+ /* Mark the variable as referenced */
+ Sym->Flags |= SC_REF;