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

Initial implementation for folding pr.noparse #754

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion lib/vast/Dialect/Parser/Ops.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2024, Trail of Bits, Inc.

Check notice on line 1 in lib/vast/Dialect/Parser/Ops.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

Run clang-format on lib/vast/Dialect/Parser/Ops.cpp

File lib/vast/Dialect/Parser/Ops.cpp does not conform to Custom style guidelines. (lines 22)

#include "vast/Util/Warnings.hpp"

Expand All @@ -18,7 +18,17 @@
using fold_result_t = ::llvm::SmallVectorImpl< ::mlir::OpFoldResult >;

logical_result NoParse::fold(FoldAdaptor adaptor, fold_result_t &results) {
return mlir::failure();
auto change = mlir::failure();
auto op = getOperation();

for (auto [idx, operand] : llvm::reverse(llvm::enumerate(getOperands()))) {
if (auto noparse = mlir::dyn_cast< NoParse >(operand.getDefiningOp())) {
op->eraseOperand(idx);
change = mlir::success();
}
}

return change;
}

} // namespace vast::pr
2 changes: 2 additions & 0 deletions tools/vast-detect-parsers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ VAST_RELAX_WARNINGS
#include "mlir/InitAllDialects.h"
#include "mlir/Pass/PassOptions.h"
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
#include "mlir/Transforms/Passes.h"

#include <llvm/Support/FileSystem.h>
#include <llvm/Support/raw_ostream.h>
Expand Down Expand Up @@ -93,6 +94,7 @@ int main(int argc, char **argv) {
vast::registerParserConversionPasses();
vast::registerSarifPasses();
mlir::registerConversionPasses();
mlir::registerTransformsPasses();
registry.insert< vast::pr::ParserDialect >();

return mlir::asMainReturnCode(
Expand Down
Loading