コード例 #1
0
ファイル: nir_search.c プロジェクト: ashmew2/kolibriosSVN
static bool
match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
                 unsigned num_components, const uint8_t *swizzle,
                 struct match_state *state)
{
    if (instr->op != expr->opcode)
        return false;

    assert(!instr->dest.saturate);
    assert(nir_op_infos[instr->op].num_inputs > 0);

    /* If we have an explicitly sized destination, we can only handle the
     * identity swizzle.  While dot(vec3(a, b, c).zxy) is a valid
     * expression, we don't have the information right now to propagate that
     * swizzle through.  We can only properly propagate swizzles if the
     * instruction is vectorized.
     */
    if (nir_op_infos[instr->op].output_size != 0) {
        for (unsigned i = 0; i < num_components; i++) {
            if (swizzle[i] != i)
                return false;
        }
    }

    /* Stash off the current variables_seen bitmask.  This way we can
     * restore it prior to matching in the commutative case below.
     */
    unsigned variables_seen_stash = state->variables_seen;

    bool matched = true;
    for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
        if (!match_value(expr->srcs[i], instr, i, num_components,
                         swizzle, state)) {
            matched = false;
            break;
        }
    }

    if (matched)
        return true;

    if (nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_COMMUTATIVE) {
        assert(nir_op_infos[instr->op].num_inputs == 2);

        /* Restore the variables_seen bitmask.  If we don't do this, then we
         * could end up with an erroneous failure due to variables found in the
         * first match attempt above not matching those in the second.
         */
        state->variables_seen = variables_seen_stash;

        if (!match_value(expr->srcs[0], instr, 1, num_components,
                         swizzle, state))
            return false;

        return match_value(expr->srcs[1], instr, 0, num_components,
                           swizzle, state);
    } else {
        return false;
    }
}
コード例 #2
0
ファイル: ipv6.c プロジェクト: kwitaszczyk/freebsd
void
print_unreach6_code(struct buf_pr *bp, uint16_t code)
{
	char const *s = match_value(icmp6codes, code);

	if (s != NULL)
		bprintf(bp, "unreach6 %s", s);
	else
		bprintf(bp, "unreach6 %u", code);
}
コード例 #3
0
ファイル: ipv6.c プロジェクト: vkhromov/freebsd
void
print_unreach6_code(uint16_t code)
{
	char const *s = match_value(icmp6codes, code);

	if (s != NULL)
		printf("unreach6 %s", s);
	else
		printf("unreach6 %u", code);
}
コード例 #4
0
ファイル: tables.c プロジェクト: 2asoft/freebsd
void
table_print_type(char *tbuf, size_t size, uint8_t type, uint8_t tflags)
{
	const char *tname;
	int l;

	if ((tname = match_value(tabletypes, type)) == NULL)
		tname = "unknown";

	l = snprintf(tbuf, size, "%s", tname);
	tbuf += l;
	size -= l;

	switch(type) {
	case IPFW_TABLE_FLOW:
		if (tflags != 0) {
			*tbuf++ = ':';
			l--;
			print_flags_buffer(tbuf, size, flowtypecmds, tflags);
		}
		break;
	}
}
コード例 #5
0
ファイル: tables.c プロジェクト: 2asoft/freebsd
void
ipfw_list_ta(int ac, char *av[])
{
	ipfw_obj_lheader *olh;
	ipfw_ta_info *info;
	int error, i;
	const char *atype;

	error = table_do_get_algolist(&olh);
	if (error != 0)
		err(EX_OSERR, "Unable to request algorithm list");

	info = (ipfw_ta_info *)(olh + 1);
	for (i = 0; i < olh->count; i++) {
		if ((atype = match_value(tabletypes, info->type)) == NULL)
			atype = "unknown";
		printf("--- %s ---\n", info->algoname);
		printf(" type: %s\n refcount: %u\n", atype, info->refcnt);

		info = (ipfw_ta_info *)((caddr_t)info + olh->objsize);
	}

	free(olh);
}
コード例 #6
0
ファイル: tables.c プロジェクト: 2asoft/freebsd
/*
 * Prints table info struct @i in human-readable form.
 */
static int
table_show_info(ipfw_xtable_info *i, void *arg)
{
	const char *vtype;
	ipfw_ta_tinfo *tainfo;
	int afdata, afitem;
	struct ta_cldata d;
	char ttype[64], tvtype[64];

	table_print_type(ttype, sizeof(ttype), i->type, i->tflags);
	table_print_valheader(tvtype, sizeof(tvtype), i->vmask);

	printf("--- table(%s), set(%u) ---\n", i->tablename, i->set);
	if ((i->flags & IPFW_TGFLAGS_LOCKED) != 0)
		printf(" kindex: %d, type: %s, locked\n", i->kidx, ttype);
	else
		printf(" kindex: %d, type: %s\n", i->kidx, ttype);
	printf(" references: %u, valtype: %s\n", i->refcnt, tvtype);
	printf(" algorithm: %s\n", i->algoname);
	printf(" items: %u, size: %u\n", i->count, i->size);
	if (i->limit > 0)
		printf(" limit: %u\n", i->limit);

	/* Print algo-specific info if requested & set  */
	if (arg == NULL)
		return (0);

	if ((i->ta_info.flags & IPFW_TATFLAGS_DATA) == 0)
		return (0);
	tainfo = &i->ta_info;

	afdata = 0;
	afitem = 0;
	if (tainfo->flags & IPFW_TATFLAGS_AFDATA)
		afdata = 1;
	if (tainfo->flags & IPFW_TATFLAGS_AFITEM)
		afitem = 1;

	memset(&d, 0, sizeof(d));
	d.taclass = tainfo->taclass4;
	d.size = tainfo->size4;
	d.count = tainfo->count4;
	d.itemsize = tainfo->itemsize4;
	if (afdata == 0 && afitem != 0)
		d.itemsize6 = tainfo->itemsize6;
	else
		d.itemsize6 = d.itemsize;
	if ((vtype = match_value(tablealgoclass, d.taclass)) == NULL)
		vtype = "unknown";

	if (afdata == 0) {
		table_show_tainfo(i, &d, "", vtype);
	} else {
		table_show_tainfo(i, &d, "IPv4 ", vtype);
		memset(&d, 0, sizeof(d));
		d.taclass = tainfo->taclass6;
		if ((vtype = match_value(tablealgoclass, d.taclass)) == NULL)
			vtype = "unknown";
		d.size = tainfo->size6;
		d.count = tainfo->count6;
		d.itemsize = tainfo->itemsize6;
		d.itemsize6 = d.itemsize;
		table_show_tainfo(i, &d, "IPv6 ", vtype);
	}

	return (0);
}