Skip to content

Commit

Permalink
conv:tc: Improve codestyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkorenc committed Nov 15, 2023
1 parent 83e556b commit 5143074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
16 changes: 7 additions & 9 deletions include/vast/Conversion/TypeConverters/HLToStd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,26 @@ namespace vast::conv::tc {
self_t &self() { return static_cast< self_t & >(*this); }

public:

auto convert_fn_type()
{
auto convert_fn_type() {
return [&](core::FunctionType t) -> maybe_type_t {
// To be consistent with how others use the conversion, we
// do not convert input types directly.
auto signature_conversion = self().signature_conversion(t.getInputs());

auto results = self().convert_types_to_types(t.getResults());

if (!signature_conversion || !results)
if (!signature_conversion || !results) {
return {};
}

return { core::FunctionType::get(
t.getContext(),
signature_conversion->getConvertedTypes(), *results, t.isVarArg()) };
t.getContext(), signature_conversion->getConvertedTypes(), *results,
t.isVarArg()
) };
};
}

void init() {
self().addConversion(convert_fn_type());
}
void init() { self().addConversion(convert_fn_type()); }
};

struct HLToStd
Expand Down
12 changes: 5 additions & 7 deletions include/vast/Conversion/TypeConverters/TypeConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ namespace vast::conv::tc {
return { out };
}

maybe_signature_conversion_t signature_conversion(const auto &inputs)
{
maybe_signature_conversion_t signature_conversion(const auto &inputs) {
signature_conversion_t sc(inputs.size());
if (mlir::failed(self().convertSignatureArgs(inputs, sc)))
if (mlir::failed(self().convertSignatureArgs(inputs, sc))) {
return {};
}
return { std::move(sc) };
}

Expand All @@ -125,16 +125,14 @@ namespace vast::conv::tc {
// * types of attributes
// types of arguments are result types of a different op.
return [this](operation op) {
auto res = self().isLegal(op->getResults().getTypes());
auto res = self().isLegal(op->getResults().getTypes());
auto attrs = contains_subtype(op->getAttrDictionary(), self().get_is_illegal());
return res && !attrs;
};
}

auto get_is_illegal() {
return [this](mlir_type type) {
return !this->self().isLegal(type);
};
return [this](mlir_type type) { return !this->self().isLegal(type); };
}

mcontext_t &get_context() { return self().mctx; }
Expand Down

0 comments on commit 5143074

Please sign in to comment.