Add the fold functoin for value op
This commit is contained in:
parent
47a5def820
commit
7c868325b3
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue