Skip to content

Commit

Permalink
conv:tc: Add converter for mlir(builtin) string attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko committed Dec 15, 2023
1 parent 8805b6a commit 0ffc181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/vast/Conversion/TypeConverters/TypeConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,14 @@ namespace vast::conv::tc {
.template take_wrapped< maybe_attr_t >();
};
}

auto convert_string_attr(auto &type_converter) {
return [&type_converter](mlir::StringAttr attr) -> maybe_attr_t {
if (auto t = type_converter.convertType(attr.getType())) {
return mlir::StringAttr::get(attr.getValue(), t);
} else {
return {};
}
};
}
} // namespace vast::conv::tc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ VAST_UNRELAX_WARNINGS

#include "vast/Conversion/Common/Patterns.hpp"
#include "vast/Conversion/TypeConverters/DataLayout.hpp"
#include "vast/Conversion/TypeConverters/TypeConverter.hpp"
#include "vast/Dialect/HighLevel/HighLevelDialect.hpp"
#include "vast/Dialect/HighLevel/HighLevelOps.hpp"

#include "vast/Util/Common.hpp"

Expand Down Expand Up @@ -57,6 +59,7 @@ namespace vast::conv::tc {
mlir::AttrTypeReplacer replacer;
replacer.addReplacement(conv::tc::convert_type_attr(tc));
replacer.addReplacement(conv::tc::convert_data_layout_attrs(tc));
replacer.addReplacement(conv::tc::convert_string_attr(tc));

replacer.addReplacement([&](mlir_type t) { return tc.convert_type_to_type(t); }
);
Expand Down

0 comments on commit 0ffc181

Please sign in to comment.