Add the fold functoin for value op

This commit is contained in:
Sameer Rahmani 2022-06-02 15:24:27 +01:00
parent 47a5def820
commit 7c868325b3
1 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,7 @@
*/
#include "serene/slir/dialect.h"
#include "serene/utils.h"
#include <llvm/Support/FormatVariadic.h>
#include <mlir/IR/Attributes.h>
@ -30,10 +31,16 @@ mlir::DataLayoutSpecInterface NsOp::getDataLayoutSpec() {
// Take the first and only (if present) attribute that implements the
// interface. This needs a linear search, but is called only once per data
// layout object construction that is used for repeated queries.
for (mlir::NamedAttribute attr : getOperation()->getAttrs())
if (auto spec = attr.getValue().dyn_cast<mlir::DataLayoutSpecInterface>())
for (mlir::NamedAttribute attr : getOperation()->getAttrs()) {
if (auto spec = attr.getValue().dyn_cast<mlir::DataLayoutSpecInterface>()) {
return spec;
}
}
return {};
}
mlir::OpFoldResult ValueOp::fold(llvm::ArrayRef<mlir::Attribute> operands) {
UNUSED(operands);
return value();
};
} // namespace serene::slir