Skip to content

[mlir][mlir-link] Initial skeleton for an MLIR-linker #10

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

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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
7 changes: 7 additions & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Original file line number Diff line number Diff line change
@@ -1382,6 +1382,9 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
}
}];

let extraClassDefinition = [{
bool $cppClass::isDeclarationForLinkage() { return getInitializerRegion().empty(); }
}];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
let hasRegionVerifier = 1;
@@ -1629,6 +1632,10 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [

}];

let extraClassDefinition = [{
bool $cppClass::isDeclarationForLinkage() { return getBody().empty(); }
}];

let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
let hasRegionVerifier = 1;
6 changes: 1 addition & 5 deletions mlir/include/mlir/Interfaces/LinkageInterfaces.td
Original file line number Diff line number Diff line change
@@ -203,11 +203,7 @@ def GlobalValueLinkageOpInterface : OpInterface<"GlobalValueLinkageOpInterface">
}],
/*returnType=*/ "bool",
/*methodName=*/ "isDeclarationForLinkage",
/*args=*/ (ins),
/*methodBody=*/ [{}],
/*defaultImplementation=*/[{
return cast<SymbolOpInterface>($_op.getOperation()).isDeclaration();
}]
/*args=*/ (ins)
>,
InterfaceMethod<
/*desc=*/ "Returns linked name of the operation",
14 changes: 11 additions & 3 deletions mlir/include/mlir/Linker/IRMover.h
Original file line number Diff line number Diff line change
@@ -13,18 +13,26 @@

#include "mlir/Interfaces/LinkageInterfaces.h"

using llvm::Error;

namespace mlir {




class IRMover {
public:
IRMover(Operation *composite);

LinkableModuleOpInterface getComposite() { return composite; }
MLIRContext *getContext() { return composite->getContext(); }

private:
LinkableModuleOpInterface composite;
};
Error move(OwningOpRef<Operation *> src,
ArrayRef<Operation *> valuesToLink);

private:
LinkableModuleOpInterface composite;
};

} // namespace mlir

Loading