|
@@ -154,34 +154,31 @@ void gen_vector_ctor_impl(FILE *stream, size_t n, Type_Def type_def)
|
|
fprintf(stream, "}\n");
|
|
fprintf(stream, "}\n");
|
|
}
|
|
}
|
|
|
|
|
|
-void gen_vector_scalar_ctor_sig(FILE *stream, size_t n, Type_Def type_def)
|
|
|
|
|
|
+void gen_vector_scalar_ctor(FILE *stream, Stmt stmt, size_t n, Type_Def type_def)
|
|
{
|
|
{
|
|
Short_String vector_type = make_vector_type(n, type_def);
|
|
Short_String vector_type = make_vector_type(n, type_def);
|
|
Short_String vector_prefix = make_vector_prefix(n, type_def);
|
|
Short_String vector_prefix = make_vector_prefix(n, type_def);
|
|
Short_String name = shortf("%s%s", vector_prefix.cstr, type_def.suffix);
|
|
Short_String name = shortf("%s%s", vector_prefix.cstr, type_def.suffix);
|
|
static_assert(VECTOR_MAX_SIZE >= 1, "The vector size is too short for this code");
|
|
static_assert(VECTOR_MAX_SIZE >= 1, "The vector size is too short for this code");
|
|
gen_func_sig(stream, vector_type.cstr, name.cstr, type_def.name, vector_comps, 1);
|
|
gen_func_sig(stream, vector_type.cstr, name.cstr, type_def.name, vector_comps, 1);
|
|
-}
|
|
|
|
-
|
|
|
|
-void gen_vector_scalar_ctor_decl(FILE *stream, size_t n, Type_Def type_def)
|
|
|
|
-{
|
|
|
|
- gen_vector_scalar_ctor_sig(stream, n, type_def);
|
|
|
|
- fprintf(stream, ";\n");
|
|
|
|
-}
|
|
|
|
|
|
|
|
-void gen_vector_scalar_ctor_impl(FILE *stream, size_t n, Type_Def type_def)
|
|
|
|
-{
|
|
|
|
- gen_vector_scalar_ctor_sig(stream, n, type_def);
|
|
|
|
- fprintf(stream, "\n");
|
|
|
|
- fprintf(stream, "{\n");
|
|
|
|
- fprintf(stream, " return %s(", make_vector_prefix(n, type_def).cstr);
|
|
|
|
- for (size_t i = 0; i < n; ++i) {
|
|
|
|
- if (i > 0) fprintf(stream, ", ");
|
|
|
|
- static_assert(VECTOR_MAX_SIZE >= 1, "The vector size is too short for this code");
|
|
|
|
- fprintf(stream, "%s", vector_comps[0]);
|
|
|
|
|
|
+ if (stmt == STMT_DECL) {
|
|
|
|
+ fprintf(stream, ";\n");
|
|
|
|
+ } else if (stmt == STMT_IMPL) {
|
|
|
|
+ fprintf(stream, "\n");
|
|
|
|
+ fprintf(stream, "{\n");
|
|
|
|
+ fprintf(stream, " return %s(", make_vector_prefix(n, type_def).cstr);
|
|
|
|
+ for (size_t i = 0; i < n; ++i) {
|
|
|
|
+ if (i > 0) fprintf(stream, ", ");
|
|
|
|
+ static_assert(VECTOR_MAX_SIZE >= 1, "The vector size is too short for this code");
|
|
|
|
+ fprintf(stream, "%s", vector_comps[0]);
|
|
|
|
+ }
|
|
|
|
+ fprintf(stream, ");\n");
|
|
|
|
+ fprintf(stream, "}\n");
|
|
|
|
+ } else {
|
|
|
|
+ assert(0 && "unreachable");
|
|
|
|
+ exit(69);
|
|
}
|
|
}
|
|
- fprintf(stream, ");\n");
|
|
|
|
- fprintf(stream, "}\n");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void gen_vector_op(FILE *stream, Stmt stmt, size_t n, Type_Def type_def, Op_Def op_def)
|
|
void gen_vector_op(FILE *stream, Stmt stmt, size_t n, Type_Def type_def, Op_Def op_def)
|
|
@@ -615,7 +612,7 @@ int main()
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
gen_vector_printf_macros(stream, n, type_defs[type]);
|
|
gen_vector_printf_macros(stream, n, type_defs[type]);
|
|
gen_vector_ctor_decl(stream, n, type_defs[type]);
|
|
gen_vector_ctor_decl(stream, n, type_defs[type]);
|
|
- gen_vector_scalar_ctor_decl(stream, n, type_defs[type]);
|
|
|
|
|
|
+ gen_vector_scalar_ctor(stream, STMT_DECL, n, type_defs[type]);
|
|
for (size_t src_n = VECTOR_MIN_SIZE; src_n <= VECTOR_MAX_SIZE; ++src_n) {
|
|
for (size_t src_n = VECTOR_MIN_SIZE; src_n <= VECTOR_MAX_SIZE; ++src_n) {
|
|
for (Type src_type = 0; src_type < COUNT_TYPES; ++src_type) {
|
|
for (Type src_type = 0; src_type < COUNT_TYPES; ++src_type) {
|
|
if (src_n != n || src_type != type) {
|
|
if (src_n != n || src_type != type) {
|
|
@@ -668,7 +665,7 @@ int main()
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
gen_vector_ctor_impl(stream, n, type_defs[type]);
|
|
gen_vector_ctor_impl(stream, n, type_defs[type]);
|
|
fputc('\n', stream);
|
|
fputc('\n', stream);
|
|
- gen_vector_scalar_ctor_impl(stream, n, type_defs[type]);
|
|
|
|
|
|
+ gen_vector_scalar_ctor(stream, STMT_IMPL, n, type_defs[type]);
|
|
fputc('\n', stream);
|
|
fputc('\n', stream);
|
|
for (size_t src_n = VECTOR_MIN_SIZE; src_n <= VECTOR_MAX_SIZE; ++src_n) {
|
|
for (size_t src_n = VECTOR_MIN_SIZE; src_n <= VECTOR_MAX_SIZE; ++src_n) {
|
|
for (Type src_type = 0; src_type < COUNT_TYPES; ++src_type) {
|
|
for (Type src_type = 0; src_type < COUNT_TYPES; ++src_type) {
|