mie: arith: add support for querying the width of int/float types
This commit is contained in:
@@ -69,6 +69,20 @@ struct mie_type *mie_arith_float_get_type(struct mie_ctx *ctx, size_t bit_width)
|
|||||||
return (struct mie_type *)type;
|
return (struct mie_type *)type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t mie_arith_float_type_get_width(const struct mie_type *type)
|
||||||
|
{
|
||||||
|
if (strcmp(type->ty_def->ty_parent->d_name, "arith") != 0) {
|
||||||
|
return (size_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(type->ty_def->ty_name, "float") != 0) {
|
||||||
|
return (size_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct float_type *float_type = (const struct float_type *)type;
|
||||||
|
return float_type->f_width;
|
||||||
|
}
|
||||||
|
|
||||||
static enum mie_status print(
|
static enum mie_status print(
|
||||||
const struct mie_type_definition *def, const struct mie_type *ty,
|
const struct mie_type_definition *def, const struct mie_type *ty,
|
||||||
b_stream *out)
|
b_stream *out)
|
||||||
|
|||||||
@@ -61,6 +61,20 @@ struct mie_type *mie_arith_int_get_type(struct mie_ctx *ctx, size_t bit_width)
|
|||||||
return (struct mie_type *)type;
|
return (struct mie_type *)type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t mie_arith_int_type_get_width(const struct mie_type *type)
|
||||||
|
{
|
||||||
|
if (strcmp(type->ty_def->ty_parent->d_name, "arith") != 0) {
|
||||||
|
return (size_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(type->ty_def->ty_name, "int") != 0) {
|
||||||
|
return (size_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct int_type *int_type = (const struct int_type *)type;
|
||||||
|
return int_type->i_width;
|
||||||
|
}
|
||||||
|
|
||||||
static enum mie_status print(
|
static enum mie_status print(
|
||||||
const struct mie_type_definition *def, const struct mie_type *ty,
|
const struct mie_type_definition *def, const struct mie_type *ty,
|
||||||
b_stream *out)
|
b_stream *out)
|
||||||
|
|||||||
Reference in New Issue
Block a user