示例#1
0
static boolean
check_register_usage(
   struct sanity_check_ctx *ctx,
   uint file,
   int index,
   const char *name,
   boolean indirect_access )
{
   if (!check_file_name( ctx, file ))
      return FALSE;

   if (indirect_access) {
      /* Note that 'index' is an offset relative to the value of the
       * address register.  No range checking done here.
       */
      if (!is_any_register_declared( ctx, file ))
         report_error( ctx, "%s: Undeclared %s register", file_names[file], name );
      ctx->regs_ind_used[file] = TRUE;
   }
   else {
      if (index < 0 || index >= MAX_REGISTERS) {
         report_error( ctx, "%s[%d]: Invalid %s index", file_names[file], index, name );
         return FALSE;
      }

      if (!is_register_declared( ctx, file, index ))
         report_error( ctx, "%s[%d]: Undeclared %s register", file_names[file], index, name );
      ctx->regs_used[file][index / BITS_IN_REG_FLAG] |= (1 << (index % BITS_IN_REG_FLAG));
   }
   return TRUE;
}
示例#2
0
static boolean
check_register_usage(
   struct sanity_check_ctx *ctx,
   scan_register *reg,
   const char *name,
   boolean indirect_access )
{
   if (!check_file_name( ctx, reg->file )) {
      FREE(reg);
      return FALSE;
   }

   if (indirect_access) {
      /* Note that 'index' is an offset relative to the value of the
       * address register.  No range checking done here.*/
      reg->indices[0] = 0;
      reg->indices[1] = 0;
      if (!is_any_register_declared( ctx, reg->file ))
         report_error( ctx, "%s: Undeclared %s register", file_names[reg->file], name );
      if (!is_ind_register_used(ctx, reg))
         cso_hash_insert(ctx->regs_ind_used, reg->file, reg);
      else
         FREE(reg);
   }
   else {
      if (!is_register_declared( ctx, reg )) {
         if (reg->dimensions == 2) {
            report_error( ctx, "%s[%d][%d]: Undeclared %s register", file_names[reg->file],
                          reg->indices[0], reg->indices[1], name );
         }
         else {
            report_error( ctx, "%s[%d]: Undeclared %s register", file_names[reg->file],
                          reg->indices[0], name );
         }
      }
      if (!is_register_used( ctx, reg ))
         cso_hash_insert(ctx->regs_used, scan_register_key(reg), reg);
      else
         FREE(reg);
   }
   return TRUE;
}