Adding an `vmvx-inline` target that avoids lowering to the vm dialect.
This will allow the VMVX IR to be inlined into the host module that is
not yet in the vm dialect form.
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/VMVXTarget.cpp b/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/VMVXTarget.cpp
index 9cc9f42..3b34043 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/VMVXTarget.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/VMVXTarget.cpp
@@ -172,11 +172,57 @@
}
};
+class VMVXInlineTargetBackend final : public TargetBackend {
+ public:
+ VMVXInlineTargetBackend() = default;
+
+ std::string name() const override { return "vmvx-inline"; }
+
+ void getDependentDialects(DialectRegistry ®istry) const override {
+ registry
+ .insert<IREE::Codegen::IREECodegenDialect, IREE::VMVX::VMVXDialect>();
+ }
+
+ IREE::HAL::DeviceTargetAttr getDefaultDeviceTarget(
+ MLIRContext *context) const override {
+ Builder b(context);
+ SmallVector<NamedAttribute> configItems;
+
+ configItems.emplace_back(b.getStringAttr("executable_targets"),
+ getExecutableTargets(context));
+
+ auto configAttr = b.getDictionaryAttr(configItems);
+ return IREE::HAL::DeviceTargetAttr::get(
+ context, b.getStringAttr(deviceID()), configAttr);
+ }
+
+ void buildTranslationPassPipeline(OpPassManager &passManager) override {
+ IREE::VMVX::buildVMVXTransformPassPipeline(passManager);
+ }
+
+ private:
+ ArrayAttr getExecutableTargets(MLIRContext *context) const {
+ SmallVector<Attribute> targetAttrs;
+ // This is where we would multiversion.
+ targetAttrs.push_back(getExecutableTarget(context));
+ return ArrayAttr::get(context, targetAttrs);
+ }
+
+ IREE::HAL::ExecutableTargetAttr getExecutableTarget(
+ MLIRContext *context) const {
+ return IREE::HAL::ExecutableTargetAttr::get(context, "vmvx-inline",
+ "vmvx-ir");
+ }
+};
+
void registerVMVXTargetBackends() {
// #hal.device.target<"vmvx", ...
// #hal.executable.target<"vmvx", ...
- static TargetBackendRegistration registration(
+ static TargetBackendRegistration registration0(
"vmvx", [=]() { return std::make_shared<VMVXTargetBackend>(); });
+ static TargetBackendRegistration registration1("vmvx-inline", [=]() {
+ return std::make_shared<VMVXInlineTargetBackend>();
+ });
}
} // namespace HAL
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/test/smoketest.mlir b/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/test/smoketest.mlir
index 8770050..8f7f660 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/test/smoketest.mlir
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/VMVX/test/smoketest.mlir
@@ -50,7 +50,6 @@
// CHECK-NEXT: vm.func private @add_dispatch_0(
// CHECK-SAME: %[[SCRATCHPAD:.+]]: !vm.buffer, %[[CONSTANTS:.+]]: !vm.buffer,
// CHECK-SAME: %[[BINDINGS:.+]]: !vm.list<!vm.buffer>
-// CHECK-DAG: %c16 = vm.const.i32 16
// CHECK-DAG: %zero = vm.const.i32.zero
// CHECK-DAG: %c1 = vm.const.i32 1
// CHECK-DAG: %c2 = vm.const.i32 2