Skip to content

Commit

Permalink
hl: Use type_list instead of ad-hoc struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
frabert committed Jul 25, 2023
1 parent bd6b10e commit 1141d59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
6 changes: 6 additions & 0 deletions include/vast/Dialect/HighLevel/HighLevelOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ namespace vast::hl
namespace vast::hl
{
FuncOp getCallee(CallOp call);

using funclike_ops = util::type_list<
hl::FuncOp,
hl::MethodOp,
hl::DtorOp
>;
}
22 changes: 1 addition & 21 deletions include/vast/Translation/CodeGenContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,36 +205,16 @@ namespace vast::cg
return symbol(dtordecls, mangled, "undeclared destructor '" + mangled.name + "'", with_error);
}

template< typename Op >
struct is_funclike {
static constexpr bool value = false;
};

template<>
struct is_funclike< hl::FuncOp > {
static constexpr bool value = true;
};

template<>
struct is_funclike< hl::MethodOp > {
static constexpr bool value = true;
};

template<>
struct is_funclike< hl::DtorOp > {
static constexpr bool value = true;
};

template< typename Op >
Op declare(mangled_name_ref mangled, auto vast_decl_builder) {
static_assert(hl::funclike_ops::contains< Op >, "Declaring unknown operation type");
if constexpr (std::is_same_v< Op, hl::FuncOp >) {
return declare< Op >(funcdecls, mangled, vast_decl_builder, mangled.name);
} else if constexpr (std::is_same_v< Op, hl::MethodOp >) {
return declare< Op >(methdecls, mangled, vast_decl_builder, mangled.name);
} else if constexpr (std::is_same_v< Op, hl::DtorOp >) {
return declare< Op >(dtordecls, mangled, vast_decl_builder, mangled.name);
}
static_assert(is_funclike< Op >::value, "Declaring unknown operation type");
}

mlir_value declare(const clang::VarDecl *decl, mlir_value vast_value) {
Expand Down

0 comments on commit 1141d59

Please sign in to comment.