Skip to content

Commit

Permalink
Improve intrinsic_suffix_for_type() to be switch-based
Browse files Browse the repository at this point in the history
(Harvested from #7471)
  • Loading branch information
steven-johnson committed Apr 1, 2023
1 parent 9f58631 commit 10124d3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/CodeGen_Xtensa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,27 @@ class HalideTypeSetHashFunction {

using HalideTypeSet = std::unordered_set<halide_type_t, HalideTypeSetHashFunction>;

std::string intrinsic_suffix_for_type(Type t) {
if (t.is_int() && (t.bits() == 8)) {
return "2NX8";
} else if (t.is_uint() && (t.bits() == 8)) {
return "2NX8U";
} else if (t.is_int() && (t.bits() == 16)) {
const char *intrinsic_suffix_for_type(const halide_type_t &t) {
switch (t.as_u32()) {
case halide_type_t(halide_type_float, 16).as_u32():
return "N_2XF32";
case halide_type_t(halide_type_float, 32).as_u32():
return "NXF16";
case halide_type_t(halide_type_int, 16).as_u32():
return "NX16";
} else if (t.is_uint() && (t.bits() == 16)) {
return "NX16U";
} else if (t.is_int() && (t.bits() == 32)) {
case halide_type_t(halide_type_int, 32).as_u32():
return "N_2X32";
} else if (t.is_uint() && (t.bits() == 32)) {
case halide_type_t(halide_type_int, 8).as_u32():
return "2NX8";
case halide_type_t(halide_type_uint, 16).as_u32():
return "NX16U";
case halide_type_t(halide_type_uint, 32).as_u32():
return "N_2X32U";
} else if (t.is_float() && (t.bits() == 32)) {
return "N_2XF32";
} else if (t.is_float() && (t.bits() == 16)) {
return "NXF16";
case halide_type_t(halide_type_uint, 8).as_u32():
return "2NX8U";
default:
return "";
}

return "";
}

class UsesDmaCopy : public IRGraphVisitor {
Expand Down

0 comments on commit 10124d3

Please sign in to comment.