/* * close an open GIF image */ int gifout_close_image() { /* make sure there's an image open */ if (!image_open) return GIFLIB_ERR_NIO; /* flush any remaining code */ if (old_code != NULL_CODE) PUT_CODE(old_code); /* output end of info code */ PUT_CODE(eoi_code); /* flush any extra bits */ while (work_bits > 0) { PUT_BYTE(work_data & 0xFF); work_data >>= 8; work_bits -= 8; } /* flush any extra bytes */ if (buf_idx > 0) write_data_block(buf_idx, buf, outs); /* trailing zero byte */ putc(0, outs); /* mark image as closed */ image_open = 0; /* done! */ return GIFLIB_SUCCESS; }
/* * write a row of pixels into the current image */ void gifout_put_row(int *row) //int *row; /* array of size img_width */ { int col; int idx; for (col=0; col<img_width; col++) { /* see if string is in table already */ idx = find_string_out(old_code, row[col]); if (idx != NULL_CODE) { /* found a match */ old_code = idx; } else { /* no match */ PUT_CODE(old_code); add_string_out(old_code, row[col]); old_code = row[col]; /* check for full string table */ if (table_size == STAB_SIZE) { /* output remaining code */ PUT_CODE(old_code); /* reset encoder */ put_clr_code(); } } } }
/* * write a pixel into the current image */ void gifout_put_pixel(int val) //int val; /* pixel color index */ { int idx; /* see if string is in table already */ idx = find_string_out(old_code, val); if (idx != NULL_CODE) { /* found a match */ old_code = idx; } else { /* no match */ PUT_CODE(old_code); add_string_out(old_code, val); old_code = val; /* check for full string table */ if (table_size == STAB_SIZE) { /* output remaining code */ PUT_CODE(old_code); /* reset encoder */ put_clr_code(); } } }
static void put_clr_code() { /* output clear code */ PUT_CODE(clr_code); /* reset raster data stream */ code_size = root_size + 1; code_mask = (1 << code_size) - 1; old_code = NULL_CODE; /* clear the string table */ reset_string_out(); }
rtx rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL) { rtx rt = ggc_alloc_zone_rtx_def_stat (&rtl_zone, RTX_CODE_SIZE (code) PASS_MEM_STAT); /* We want to clear everything up to the FLD array. Normally, this is one int, but we don't want to assume that and it isn't very portable anyway; this is. */ memset (rt, 0, RTX_HDR_SIZE); PUT_CODE (rt, code); #ifdef GATHER_STATISTICS rtx_alloc_counts[code]++; rtx_alloc_sizes[code] += RTX_CODE_SIZE (code); #endif return rt; }
static void canonicalize_address (rtx x) { for (;;) switch (GET_CODE (x)) { case ASHIFT: if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) < GET_MODE_BITSIZE (GET_MODE (x)) && INTVAL (XEXP (x, 1)) >= 0) { HOST_WIDE_INT shift = INTVAL (XEXP (x, 1)); PUT_CODE (x, MULT); XEXP (x, 1) = gen_int_mode (HOST_WIDE_INT_1 << shift, GET_MODE (x)); } x = XEXP (x, 0); break; case PLUS: if (GET_CODE (XEXP (x, 0)) == PLUS || GET_CODE (XEXP (x, 0)) == ASHIFT || GET_CODE (XEXP (x, 0)) == CONST) canonicalize_address (XEXP (x, 0)); x = XEXP (x, 1); break; case CONST: x = XEXP (x, 0); break; default: return; } }
static void process_rtx (rtx desc, int lineno) { switch (GET_CODE (desc)) { case DEFINE_INSN: queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno); break; case DEFINE_COND_EXEC: queue_pattern (desc, &define_cond_exec_tail, read_rtx_filename, lineno); break; case DEFINE_ATTR: queue_pattern (desc, &define_attr_tail, read_rtx_filename, lineno); break; case DEFINE_PREDICATE: case DEFINE_SPECIAL_PREDICATE: case DEFINE_CONSTRAINT: case DEFINE_REGISTER_CONSTRAINT: case DEFINE_MEMORY_CONSTRAINT: case DEFINE_ADDRESS_CONSTRAINT: queue_pattern (desc, &define_pred_tail, read_rtx_filename, lineno); break; case INCLUDE: process_include (desc, lineno); break; case DEFINE_INSN_AND_SPLIT: { const char *split_cond; rtx split; rtvec attr; int i; struct queue_elem *insn_elem; struct queue_elem *split_elem; /* Create a split with values from the insn_and_split. */ split = rtx_alloc (DEFINE_SPLIT); i = XVECLEN (desc, 1); XVEC (split, 0) = rtvec_alloc (i); while (--i >= 0) { XVECEXP (split, 0, i) = copy_rtx (XVECEXP (desc, 1, i)); remove_constraints (XVECEXP (split, 0, i)); } /* If the split condition starts with "&&", append it to the insn condition to create the new split condition. */ split_cond = XSTR (desc, 4); if (split_cond[0] == '&' && split_cond[1] == '&') { copy_rtx_ptr_loc (split_cond + 2, split_cond); split_cond = join_c_conditions (XSTR (desc, 2), split_cond + 2); } XSTR (split, 1) = split_cond; XVEC (split, 2) = XVEC (desc, 5); XSTR (split, 3) = XSTR (desc, 6); /* Fix up the DEFINE_INSN. */ attr = XVEC (desc, 7); PUT_CODE (desc, DEFINE_INSN); XVEC (desc, 4) = attr; /* Queue them. */ insn_elem = queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno); split_elem = queue_pattern (split, &other_tail, read_rtx_filename, lineno); insn_elem->split = split_elem; break; } default: queue_pattern (desc, &other_tail, read_rtx_filename, lineno); break; } }
static void process_rtx (rtx desc, int lineno) { switch (GET_CODE (desc)) { case DEFINE_INSN: queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno); break; case DEFINE_COND_EXEC: queue_pattern (desc, &define_cond_exec_tail, read_rtx_filename, lineno); break; case DEFINE_ATTR: queue_pattern (desc, &define_attr_tail, read_rtx_filename, lineno); break; case INCLUDE: process_include (desc, lineno); break; case DEFINE_INSN_AND_SPLIT: { const char *split_cond; rtx split; rtvec attr; int i; /* Create a split with values from the insn_and_split. */ split = rtx_alloc (DEFINE_SPLIT); i = XVECLEN (desc, 1); XVEC (split, 0) = rtvec_alloc (i); while (--i >= 0) { XVECEXP (split, 0, i) = copy_rtx (XVECEXP (desc, 1, i)); remove_constraints (XVECEXP (split, 0, i)); } /* If the split condition starts with "&&", append it to the insn condition to create the new split condition. */ split_cond = XSTR (desc, 4); if (split_cond[0] == '&' && split_cond[1] == '&') split_cond = concat (XSTR (desc, 2), split_cond, NULL); XSTR (split, 1) = split_cond; XVEC (split, 2) = XVEC (desc, 5); XSTR (split, 3) = XSTR (desc, 6); /* Fix up the DEFINE_INSN. */ attr = XVEC (desc, 7); PUT_CODE (desc, DEFINE_INSN); XVEC (desc, 4) = attr; /* Queue them. */ queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno); queue_pattern (split, &other_tail, read_rtx_filename, lineno); break; } default: queue_pattern (desc, &other_tail, read_rtx_filename, lineno); break; } }