Merge main -> google

* 0c97a1c2 Merge pull request #3022 from rsuderman/google-to-main
* bf264f45 Merge branch 'main' into google-to-main
* 8524cb9b Split LLVM targets into subfolders to support CMake filtering. (#2960)
* 6e782113 Fixed Emulator Timeline Semaphore parameter name (#3019)
* aa8d1c0f Enable simple.mlir test for iree-benchmark-module on vulkan (#3016)
* 6db4e7bd [vulkan] Release timepoint fences more aggressively when possible (#2800)
* a1365d33 [vulkan] Do not request timeline semaphore if not available (#2904)
* a38c8905 Add more type support to model builder matmul benchmark. (#2977)
* a293ca7b Fix hyperlink to getting started docs on python page. (#3015)
* b022e70a Release inputs before closing the session. (#3004)
* f1678df2 Dynamicly register benchmark for entry_function with name BM_{entry_function} ..
* 6282700e Expand the tf_module_to_compiler_module API (#3009)
* f7e561a6 Merge pull request #3006 from rsuderman/google-to-main
* 8341d71c Explicitly insert dialects in conversion passes (#3002)
* b7c2b60e Fix format by changing to LLVM style (#3008)
* 4286f171 Merge branch 'main' into google-to-main
* f0a07f63 Allow iree.placeholder as an op between splittable ops. (#2999)
* 6bd3b1dc Use hidden visibility for all symbols by default (#2997)
* d6500826 VMLA Dynamic Iota support with Shape dialect work. (#2965)
* c724ee45 Add function to hide SavedModel roundtrip (#2995)
* 2fedce64 Merge pull request #2996
* c5f7030b Merge branch 'main' into google-to-main
* cf3211d9 [vulkan] Reset TimePointFence status when releasing back to pool (#2905)
* ebc6a833 Add lint action to check for tabs (#2984)
* 932339ce Merge pull request #2964 from silvasean/add-dynamic-dot-example
* df727ae3 Integrate MLIR-EmitC at iml130/mlir-emitc@560cd8c (#2990)
* e824d364 Refactor for explicit dialect registration (#2978)
* 38b7d2cf Allow ModelRunner to receive an array of extra symbols available during JITing..
* 264a97df Fuse linalg.tensor_reshape operations with hal.interface* operations. (#2973)
* 0e3c7373 Fold flow.tensor.update when all operands are constant (#2982)
* c7a21c2a Merge pull request #2983 from rsuderman/google-to-main
* fd55a860 Add a dynamically shaped mhlo.dot lowering example

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/3025 from rsuderman:main-to-google 0c97a1c2011347d47df22f3a9a0f726121d5a0b6
PiperOrigin-RevId: 328804964
diff --git a/bindings/python/pyiree/compiler/BUILD b/bindings/python/pyiree/compiler/BUILD
index d8550d7..dca46ed 100644
--- a/bindings/python/pyiree/compiler/BUILD
+++ b/bindings/python/pyiree/compiler/BUILD
@@ -42,8 +42,8 @@
 
     # Targets.
     "//iree/compiler/Dialect/HAL/Target/VMLA",
-    "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMAOT",
-    "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMIR",
+    "//iree/compiler/Dialect/HAL/Target/LLVM/AOT:LLVMAOT",
+    "//iree/compiler/Dialect/HAL/Target/LLVM/IR:LLVMIR",
     "//iree/compiler/Dialect/HAL/Target/VulkanSPIRV",
     "//iree/compiler/Dialect/VM/Target:init_targets",
     "//iree/compiler/Dialect/VM/Target/Bytecode",
diff --git a/bindings/python/pyiree/compiler/CMakeLists.txt b/bindings/python/pyiree/compiler/CMakeLists.txt
index d8ed6c1..b47cb6f 100644
--- a/bindings/python/pyiree/compiler/CMakeLists.txt
+++ b/bindings/python/pyiree/compiler/CMakeLists.txt
@@ -53,8 +53,8 @@
     iree::compiler::Dialect::VM::Transforms
     # Targets. Adopted from the Bazel variable COMPILER::DEPS.
     iree::compiler::Dialect::HAL::Target::VMLA
-    iree::compiler::Dialect::HAL::Target::LLVM::LLVMAOT
-    iree::compiler::Dialect::HAL::Target::LLVM::LLVMIR
+    iree::compiler::Dialect::HAL::Target::LLVM::AOT::LLVMAOT
+    iree::compiler::Dialect::HAL::Target::LLVM::IR::LLVMIR
     iree::compiler::Dialect::HAL::Target::VulkanSPIRV
     iree::compiler::Dialect::VM::Target::Bytecode
     iree::compiler::Dialect::VM::Target::init_targets
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/AOT/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/BUILD
new file mode 100644
index 0000000..f5c32e1
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/BUILD
@@ -0,0 +1,72 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content", "platform_trampoline_deps")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+# TODO(scotttodd): filter on IREE_TARGET_BACKEND_DYLIB-LLVM-AOT when it exists
+iree_cmake_extra_content(
+    content = """
+if(NOT ${IREE_TARGET_BACKEND_LLVM-IR})
+  return()
+endif()
+""",
+)
+
+cc_library(
+    name = "LLVMAOT",
+    srcs = [
+        "LLVMAOTTarget.cpp",
+    ],
+    hdrs = [
+        "LLVMAOTTarget.h",
+    ],
+    deps = [
+        ":LLVMAOTTargetLinker",
+        "//iree/compiler/Conversion/LinalgToLLVM",
+        "//iree/compiler/Dialect/HAL/Target",
+        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMIRPasses",
+        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMTargetOptions",
+        "//iree/schemas:dylib_executable_def_cc_fbs",
+        "@llvm-project//llvm:AArch64AsmParser",
+        "@llvm-project//llvm:AArch64CodeGen",
+        "@llvm-project//llvm:ARMAsmParser",
+        "@llvm-project//llvm:ARMCodeGen",
+        "@llvm-project//llvm:Core",
+        "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:X86AsmParser",
+        "@llvm-project//llvm:X86CodeGen",
+        "@llvm-project//mlir:TargetLLVMIR",
+    ],
+)
+
+cc_library(
+    name = "LLVMAOTTargetLinker",
+    hdrs = ["LLVMAOTTargetLinker.h"],
+    deps = platform_trampoline_deps("LLVMAOTTargetLinker", "compiler/Dialect/HAL/Target/LLVM/AOT"),
+)
+
+cc_library(
+    name = "LLVMAOTTargetLinker_hdrs",
+    hdrs = ["LLVMAOTTargetLinker.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMTargetOptions",
+    ],
+)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/AOT/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/CMakeLists.txt
new file mode 100644
index 0000000..bf21b5e
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/CMakeLists.txt
@@ -0,0 +1,66 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if(NOT ${IREE_TARGET_BACKEND_LLVM-IR})
+  return()
+endif()
+
+iree_add_all_subdirs()
+
+iree_cc_library(
+  NAME
+    LLVMAOT
+  HDRS
+    "LLVMAOTTarget.h"
+  SRCS
+    "LLVMAOTTarget.cpp"
+  DEPS
+    ::LLVMAOTTargetLinker
+    LLVMAArch64AsmParser
+    LLVMAArch64CodeGen
+    LLVMARMAsmParser
+    LLVMARMCodeGen
+    LLVMCore
+    LLVMSupport
+    LLVMX86AsmParser
+    LLVMX86CodeGen
+    MLIRTargetLLVMIR
+    iree::compiler::Conversion::LinalgToLLVM
+    iree::compiler::Dialect::HAL::Target
+    iree::compiler::Dialect::HAL::Target::LLVM::LLVMIRPasses
+    iree::compiler::Dialect::HAL::Target::LLVM::LLVMTargetOptions
+    iree::schemas::dylib_executable_def_cc_fbs
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    LLVMAOTTargetLinker
+  HDRS
+    "LLVMAOTTargetLinker.h"
+  DEPS
+    iree::compiler::Dialect::HAL::Target::LLVM::AOT::internal::LLVMAOTTargetLinker_internal
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    LLVMAOTTargetLinker_hdrs
+  HDRS
+    "LLVMAOTTargetLinker.h"
+  DEPS
+    iree::base::status
+    iree::compiler::Dialect::HAL::Target::LLVM::LLVMTargetOptions
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.cpp
similarity index 97%
rename from iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.cpp
index a55db32..9849d76 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.cpp
@@ -12,12 +12,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.h"
 
 #include <cstdlib>
 
 #include "iree/compiler/Conversion/LinalgToLLVM/Passes.h"
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTargetLinker.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTargetLinker.h"
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRPasses.h"
 #include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
 #include "iree/schemas/dylib_executable_def_generated.h"
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.h b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.h
similarity index 82%
rename from iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.h
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.h
index 305d543..5df2217 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.h
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.h
@@ -13,8 +13,8 @@
 // limitations under the License.
 //
 
-#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_H_
-#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_H_
+#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGET_H_
+#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGET_H_
 
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h"
 
@@ -32,4 +32,4 @@
 }  // namespace iree_compiler
 }  // namespace mlir
 
-#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_H_
+#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGET_H_
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTargetLinker.h b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTargetLinker.h
similarity index 84%
rename from iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTargetLinker.h
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTargetLinker.h
index 669f17c..d6d5220 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTargetLinker.h
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTargetLinker.h
@@ -13,8 +13,8 @@
 // limitations under the License.
 //
 
-#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_LINKER_H_
-#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_LINKER_H_
+#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGETLINKER_H_
+#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGETLINKER_H_
 
 #include <string>
 
@@ -38,4 +38,4 @@
 }  // namespace iree_compiler
 }  // namespace mlir
 
-#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_TARGET_LINKER_H_
+#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_AOT_LLVMAOTTARGETLINKER_H_
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/BUILD
similarity index 91%
rename from iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/BUILD
index 19c3372..6dadc26 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/BUILD
@@ -23,7 +23,7 @@
     srcs = ["LLVMAOTTargetLinker.cpp"],
     deps = [
         "//iree/base:status",
-        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMAOTTargetLinker_hdrs",
+        "//iree/compiler/Dialect/HAL/Target/LLVM/AOT:LLVMAOTTargetLinker_hdrs",
         "@llvm-project//llvm:Support",
     ],
 )
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/CMakeLists.txt
similarity index 90%
rename from iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/CMakeLists.txt
index b91dae5..01cb459 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/CMakeLists.txt
@@ -22,6 +22,6 @@
   DEPS
     LLVMSupport
     iree::base::status
-    iree::compiler::Dialect::HAL::Target::LLVM::LLVMAOTTargetLinker_hdrs
+    iree::compiler::Dialect::HAL::Target::LLVM::AOT::LLVMAOTTargetLinker_hdrs
   PUBLIC
 )
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/LLVMAOTTargetLinker.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/LLVMAOTTargetLinker.cpp
similarity index 97%
rename from iree/compiler/Dialect/HAL/Target/LLVM/internal/LLVMAOTTargetLinker.cpp
rename to iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/LLVMAOTTargetLinker.cpp
index 65d8e22..8acd2d6 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/LLVMAOTTargetLinker.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/LLVMAOTTargetLinker.cpp
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTargetLinker.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTargetLinker.h"
 
 #include "iree/base/status.h"
 #include "llvm/Support/ToolOutputFile.h"
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
index e0cbfb9..7c0a843 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content", "platform_trampoline_deps")
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
 
 package(
     default_visibility = ["//visibility:public"],
@@ -20,8 +20,7 @@
     licenses = ["notice"],  # Apache 2.0
 )
 
-# TODO(scotttodd): add 'common', 'JIT', 'AOT' subfolders to filter on
-#     IREE_TARGET_BACKEND_[DYLIB-LLVM-AOT|LLVM-IR]
+# TODO(scotttodd): also return if IREE_TARGET_BACKEND_DYLIB-LLVM-AOT is false
 iree_cmake_extra_content(
     content = """
 if(NOT ${IREE_TARGET_BACKEND_LLVM-IR})
@@ -31,55 +30,6 @@
 )
 
 cc_library(
-    name = "LLVMIR",
-    srcs = [
-        "LLVMIRTarget.cpp",
-    ],
-    hdrs = [
-        "LLVMIRTarget.h",
-    ],
-    deps = [
-        ":LLVMIRPasses",
-        ":LLVMTargetOptions",
-        "//iree/compiler/Conversion/LinalgToLLVM",
-        "//iree/compiler/Dialect/HAL/Target",
-        "//iree/schemas:llvmir_executable_def_cc_fbs",
-        "@llvm-project//llvm:Core",
-        "@llvm-project//llvm:Support",
-        # TODO(ataei): Link with native target dep.
-        "@llvm-project//llvm:X86CodeGen",
-        "@llvm-project//mlir:TargetLLVMIR",
-    ],
-)
-
-cc_library(
-    name = "LLVMAOT",
-    srcs = [
-        "LLVMAOTTarget.cpp",
-    ],
-    hdrs = [
-        "LLVMAOTTarget.h",
-    ],
-    deps = [
-        ":LLVMAOTTargetLinker",
-        ":LLVMIRPasses",
-        ":LLVMTargetOptions",
-        "//iree/compiler/Conversion/LinalgToLLVM",
-        "//iree/compiler/Dialect/HAL/Target",
-        "//iree/schemas:dylib_executable_def_cc_fbs",
-        "@llvm-project//llvm:AArch64AsmParser",
-        "@llvm-project//llvm:AArch64CodeGen",
-        "@llvm-project//llvm:ARMAsmParser",
-        "@llvm-project//llvm:ARMCodeGen",
-        "@llvm-project//llvm:Core",
-        "@llvm-project//llvm:Support",
-        "@llvm-project//llvm:X86AsmParser",
-        "@llvm-project//llvm:X86CodeGen",
-        "@llvm-project//mlir:TargetLLVMIR",
-    ],
-)
-
-cc_library(
     name = "LLVMIRPasses",
     srcs = [
         "LLVMIRPasses.cpp",
@@ -111,18 +61,3 @@
         "@llvm-project//llvm:Target",
     ],
 )
-
-cc_library(
-    name = "LLVMAOTTargetLinker",
-    hdrs = ["LLVMAOTTargetLinker.h"],
-    deps = platform_trampoline_deps("LLVMAOTTargetLinker", "compiler/Dialect/HAL/Target/LLVM"),
-)
-
-cc_library(
-    name = "LLVMAOTTargetLinker_hdrs",
-    hdrs = ["LLVMAOTTargetLinker.h"],
-    deps = [
-        ":LLVMTargetOptions",
-        "//iree/base:status",
-    ],
-)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
index 8a1d4e5..43b2e50 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
@@ -20,52 +20,6 @@
 
 iree_cc_library(
   NAME
-    LLVMIR
-  HDRS
-    "LLVMIRTarget.h"
-  SRCS
-    "LLVMIRTarget.cpp"
-  DEPS
-    ::LLVMIRPasses
-    ::LLVMTargetOptions
-    LLVMCore
-    LLVMSupport
-    LLVMX86CodeGen
-    MLIRTargetLLVMIR
-    iree::compiler::Conversion::LinalgToLLVM
-    iree::compiler::Dialect::HAL::Target
-    iree::schemas::llvmir_executable_def_cc_fbs
-  PUBLIC
-)
-
-iree_cc_library(
-  NAME
-    LLVMAOT
-  HDRS
-    "LLVMAOTTarget.h"
-  SRCS
-    "LLVMAOTTarget.cpp"
-  DEPS
-    ::LLVMAOTTargetLinker
-    ::LLVMIRPasses
-    ::LLVMTargetOptions
-    LLVMAArch64AsmParser
-    LLVMAArch64CodeGen
-    LLVMARMAsmParser
-    LLVMARMCodeGen
-    LLVMCore
-    LLVMSupport
-    LLVMX86AsmParser
-    LLVMX86CodeGen
-    MLIRTargetLLVMIR
-    iree::compiler::Conversion::LinalgToLLVM
-    iree::compiler::Dialect::HAL::Target
-    iree::schemas::dylib_executable_def_cc_fbs
-  PUBLIC
-)
-
-iree_cc_library(
-  NAME
     LLVMIRPasses
   HDRS
     "LLVMIRPasses.h"
@@ -94,24 +48,3 @@
     LLVMTarget
   PUBLIC
 )
-
-iree_cc_library(
-  NAME
-    LLVMAOTTargetLinker
-  HDRS
-    "LLVMAOTTargetLinker.h"
-  DEPS
-    iree::compiler::Dialect::HAL::Target::LLVM::internal::LLVMAOTTargetLinker_internal
-  PUBLIC
-)
-
-iree_cc_library(
-  NAME
-    LLVMAOTTargetLinker_hdrs
-  HDRS
-    "LLVMAOTTargetLinker.h"
-  DEPS
-    ::LLVMTargetOptions
-    iree::base::status
-  PUBLIC
-)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/IR/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/IR/BUILD
new file mode 100644
index 0000000..bbb82b0
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/IR/BUILD
@@ -0,0 +1,51 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_cmake_extra_content(
+    content = """
+if(NOT ${IREE_TARGET_BACKEND_LLVM-IR})
+  return()
+endif()
+""",
+)
+
+cc_library(
+    name = "LLVMIR",
+    srcs = [
+        "LLVMIRTarget.cpp",
+    ],
+    hdrs = [
+        "LLVMIRTarget.h",
+    ],
+    deps = [
+        "//iree/compiler/Conversion/LinalgToLLVM",
+        "//iree/compiler/Dialect/HAL/Target",
+        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMIRPasses",
+        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMTargetOptions",
+        "//iree/schemas:llvmir_executable_def_cc_fbs",
+        "@llvm-project//llvm:Core",
+        "@llvm-project//llvm:Support",
+        # TODO(ataei): Link with native target dep.
+        "@llvm-project//llvm:X86CodeGen",
+        "@llvm-project//mlir:TargetLLVMIR",
+    ],
+)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/IR/CMakeLists.txt
similarity index 60%
copy from iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
copy to iree/compiler/Dialect/HAL/Target/LLVM/IR/CMakeLists.txt
index b91dae5..6b1604f 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/IR/CMakeLists.txt
@@ -12,16 +12,28 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+if(NOT ${IREE_TARGET_BACKEND_LLVM-IR})
+  return()
+endif()
+
 iree_add_all_subdirs()
 
 iree_cc_library(
   NAME
-    LLVMAOTTargetLinker_internal
+    LLVMIR
+  HDRS
+    "LLVMIRTarget.h"
   SRCS
-    "LLVMAOTTargetLinker.cpp"
+    "LLVMIRTarget.cpp"
   DEPS
+    LLVMCore
     LLVMSupport
-    iree::base::status
-    iree::compiler::Dialect::HAL::Target::LLVM::LLVMAOTTargetLinker_hdrs
+    LLVMX86CodeGen
+    MLIRTargetLLVMIR
+    iree::compiler::Conversion::LinalgToLLVM
+    iree::compiler::Dialect::HAL::Target
+    iree::compiler::Dialect::HAL::Target::LLVM::LLVMIRPasses
+    iree::compiler::Dialect::HAL::Target::LLVM::LLVMTargetOptions
+    iree::schemas::llvmir_executable_def_cc_fbs
   PUBLIC
 )
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.cpp
similarity index 98%
rename from iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp
rename to iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.cpp
index 5bf71c4..87f32fd 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.cpp
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.h"
 
 #include "iree/compiler/Conversion/LinalgToLLVM/Passes.h"
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRPasses.h"
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.h b/iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.h
similarity index 82%
rename from iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.h
rename to iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.h
index 6a561be..46db6a9 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.h
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.h
@@ -13,8 +13,8 @@
 // limitations under the License.
 //
 
-#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_TARGET_H_
-#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_TARGET_H_
+#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_LLVMIRTARGET_H_
+#define IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_LLVMIRTARGET_H_
 
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h"
 
@@ -32,4 +32,4 @@
 }  // namespace iree_compiler
 }  // namespace mlir
 
-#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_TARGET_H_
+#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_LLVM_IR_LLVMIRTARGET_H_
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index f4792fe..c27bdf6 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -148,8 +148,8 @@
         "-DIREE_HAVE_VULKANSPIRV_TARGET",
     ],
     deps = [
-        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMAOT",
-        "//iree/compiler/Dialect/HAL/Target/LLVM:LLVMIR",
+        "//iree/compiler/Dialect/HAL/Target/LLVM/AOT:LLVMAOT",
+        "//iree/compiler/Dialect/HAL/Target/LLVM/IR:LLVMIR",
         "//iree/compiler/Dialect/HAL/Target/VMLA",
         "//iree/compiler/Dialect/HAL/Target/VulkanSPIRV",
     ],
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index 6918aa8..f3a33a5 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -21,9 +21,9 @@
 set(IREE_COMPILER_TARGET_COPTS "")
 # TODO(#2645): Move LLVMAOT target under DYLIB-LLVM-AOT flag
 if(${IREE_TARGET_BACKEND_LLVM-IR})
-  list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::LLVM::LLVMAOT)
+  list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::LLVM::AOT::LLVMAOT)
   list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_LLVMAOT_TARGET")
-  list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::LLVM::LLVMIR)
+  list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::LLVM::IR::LLVMIR)
   list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_LLVMIR_TARGET")
 endif()
 if(${IREE_TARGET_BACKEND_VMLA})
diff --git a/iree/tools/init_targets.cc b/iree/tools/init_targets.cc
index c0b4c4f..99df72c 100644
--- a/iree/tools/init_targets.cc
+++ b/iree/tools/init_targets.cc
@@ -15,10 +15,10 @@
 #include "iree/tools/init_targets.h"
 
 #ifdef IREE_HAVE_LLVMAOT_TARGET
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/AOT/LLVMAOTTarget.h"
 #endif
 #ifdef IREE_HAVE_LLVMIR_TARGET
-#include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.h"
+#include "iree/compiler/Dialect/HAL/Target/LLVM/IR/LLVMIRTarget.h"
 #endif
 #ifdef IREE_HAVE_VMLA_TARGET
 #include "iree/compiler/Dialect/HAL/Target/VMLA/VMLATarget.h"