Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser type conversions #750

Merged
merged 24 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
58a1293
conv: Add unrealized conversion materialization helper.
xlauko Nov 19, 2024
b3999ee
core: Add arithmetic binary op interface.
xlauko Nov 20, 2024
2424432
hl: Annotate arithmetic operations with core trait.
xlauko Nov 20, 2024
95561f7
pr: Reconcile unrealized casts on the fly.
xlauko Nov 20, 2024
ad64dcb
pr: Let parser detector invoke standard conversions.
xlauko Nov 20, 2024
8d8a930
pr: Fix MaybeDataType predicate to include NoDataType.
xlauko Nov 20, 2024
d67a714
pr: Fix fclose model to expect nodata.
xlauko Nov 20, 2024
f388241
pr: Swap AnyDataType and MaybeDataType.
xlauko Nov 20, 2024
4e4b55f
pr: Resurrect type constraints.
xlauko Nov 20, 2024
d770373
pr: Add to_maybe cast.
xlauko Nov 20, 2024
5171843
conv: Make function signature conversion allow to reflect on index of…
xlauko Nov 22, 2024
b512ade
conv: Add parser function conversion.
xlauko Nov 22, 2024
d4556e5
pr: Add model for main function.
xlauko Nov 22, 2024
c165958
pr: Add parser decl.
xlauko Nov 22, 2024
06017f6
conv: Add param to parser decl conversion.
xlauko Nov 22, 2024
934fad2
pr: Add reference operation.
xlauko Nov 22, 2024
f42479c
hl: Fix scope annotations.
xlauko Nov 22, 2024
cfe9b0d
conv: Introduce decl ref converion to parser ref.
xlauko Nov 22, 2024
2bda66a
pr: Fix include.
xlauko Nov 22, 2024
df8f2b2
pr: Fix types for decl ref conversion.
xlauko Nov 22, 2024
c41da62
conv: Add return conversion pattern.
xlauko Nov 22, 2024
8f44b39
conv: Add non-parsing cmp conversion.
xlauko Nov 22, 2024
0b52fcd
conv: Simplify unrealized_materialization.
xlauko Nov 25, 2024
6f04dc7
tools: Remove obsolete detect-parsers.
xlauko Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
conv: Make function signature conversion allow to reflect on index of…
… argument.
  • Loading branch information
xlauko committed Nov 25, 2024
commit 51718437c51bc0afb19d4e4ba102b9837a4d2d06
12 changes: 10 additions & 2 deletions include/vast/Conversion/TypeConverters/TypeConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ namespace vast::conv::tc {
.template take_wrapped< maybe_type_t >();
}

maybe_type_t convert_arg_type(mlir_type t, unsigned long /* idx */) const {
xlauko marked this conversation as resolved.
Show resolved Hide resolved
return convert_type_to_type(t);
}

auto appender(types_t &out) const {
return [&](auto collection) {
out.insert(
Expand All @@ -178,8 +182,12 @@ namespace vast::conv::tc {

maybe_signature_conversion_t signature_conversion(const auto &inputs) const {
signature_conversion_t sc(inputs.size());
if (mlir::failed(self().convertSignatureArgs(inputs, sc))) {
return {};
for (auto [i, arg] : llvm::enumerate(inputs)) {
if (auto trg = self().convert_arg_type(arg, i)) {
sc.addInputs(i, *trg);
} else {
return {};
}
}
return { std::move(sc) };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ namespace vast::conv::tc {
return replace_impl(op, rewriter, tc);
}

logical_result replace(operation op, auto &rewriter) const {
auto tc = static_cast< const type_converter & >(*self().getTypeConverter());
return replace(op, rewriter, tc);
}

private:
const auto &self() const { return static_cast< const derived & >(*this); }

logical_result replace_impl(core::function_op_interface fn, auto &rewriter, const type_converter &tc) const {
auto old_type = fn.getFunctionType();
Expand Down Expand Up @@ -81,8 +75,8 @@ namespace vast::conv::tc {
}

void fixup_entry_block(mlir::Block &block, const type_converter &tc) const {
for (auto arg : block.getArguments()) {
auto trg = tc.convert_type_to_type(arg.getType());
for (auto [idx, arg] : llvm::enumerate(block.getArguments())) {
auto trg = tc.convert_arg_type(arg.getType(), idx);
VAST_CHECK(trg, "Type conversion failed: {0}", arg);
arg.setType(*trg);
}
Expand Down Expand Up @@ -114,7 +108,8 @@ namespace vast::conv::tc {
operation op, mlir::ArrayRef< mlir::Value >,
conversion_rewriter &rewriter
) const override {
return replace(op, rewriter);
auto tc = static_cast< const type_converter & >(*getTypeConverter());
return replace(op, rewriter, tc);
}
};

Expand Down