CMake support for iree::compiler::Dialect

In the Bazel configuration `iree-translate` depends on `"//iree/compiler/Dialect/VM/Target/Bytecode"`. This further pulls in several other dependencies. Right now, the build fails witt

```
[ 96%] Building VMEnums.h.inc...
mlir-tblgen: Unknown command line argument '-gen-iree-vm-op-encoder-defs'.  Try: '../../../../../third_party/llvm-project/llvm/bin/mlir-tblgen --help'
mlir-tblgen: Did you mean '--gen-op-interface-defs'?
make[2]: *** [iree/compiler/Dialect/VM/IR/CMakeFiles/iree_compiler_Dialect_VM_IR_IR.dir/build.make:72: iree/compiler/Dialect/VM/IR/VMOpEncoder.cpp.inc] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:29821: iree/compiler/Dialect/VM/IR/CMakeFiles/iree_compiler_Dialect_VM_IR_IR.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
```

This is because `iree-tblgen` has to be run and not `mlir-tblgen`. Within this context I noticed the comment "Runs iree-tablegen to produce some artifacts." in `iree_tablegen_library`. So is there a way to exec `iree-tblgen` instead of `mlir-tblgen` which I have overlooked or is the comment wrong? If the latter is true, do we need *another* `iree_tablegen_library` function which really runs `iree-tblgen` or do somebody sees a simple way how to fix this?

Closes #165

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/165 from marbre:cmake-4 dbacc0aed2aa0de1b540b3fa4de53721f6355963
PiperOrigin-RevId: 284992923
diff --git a/build_tools/cmake/iree_tablegen_library.cmake b/build_tools/cmake/iree_tablegen_library.cmake
index 705e214..55e72e6 100644
--- a/build_tools/cmake/iree_tablegen_library.cmake
+++ b/build_tools/cmake/iree_tablegen_library.cmake
@@ -21,7 +21,7 @@
   cmake_parse_arguments(
     _RULE
     "TESTONLY"
-    "NAME"
+    "NAME;TBLGEN"
     "SRCS;OUTS"
     ${ARGN}
   )
@@ -31,6 +31,12 @@
     iree_package_name(_PACKAGE_NAME)
     set(_NAME "${_PACKAGE_NAME}_${_RULE_NAME}")
 
+    if(${_RULE_TBLGEN} MATCHES "IREE")
+      set(_TBLGEN "IREE")
+    else()
+      set(_TBLGEN "MLIR")
+    endif()
+
     set(LLVM_TARGET_DEFINITIONS ${_RULE_SRCS})
     set(_INCLUDE_DIRS ${IREE_COMMON_INCLUDE_DIRS})
     list(APPEND _INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
@@ -41,7 +47,7 @@
       list(REMOVE_AT _RULE_OUTS 0)
       list(GET _RULE_OUTS 0 _FILE)
       list(REMOVE_AT _RULE_OUTS 0)
-      tablegen(MLIR ${_FILE} ${_COMMAND} ${_INCLUDE_DIRS})
+      tablegen(${_TBLGEN} ${_FILE} ${_COMMAND} ${_INCLUDE_DIRS})
       list(APPEND _OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${_FILE})
     endwhile()
     add_custom_target(${_NAME}_target DEPENDS ${_OUTPUTS})
diff --git a/iree/compiler/CMakeLists.txt b/iree/compiler/CMakeLists.txt
index 0a42596..d929bc2 100644
--- a/iree/compiler/CMakeLists.txt
+++ b/iree/compiler/CMakeLists.txt
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+add_subdirectory(Dialect)
 add_subdirectory(IR)
 add_subdirectory(Serialization)
 add_subdirectory(Transforms)
diff --git a/iree/compiler/Dialect/CMakeLists.txt b/iree/compiler/Dialect/CMakeLists.txt
new file mode 100644
index 0000000..5cb3c3e
--- /dev/null
+++ b/iree/compiler/Dialect/CMakeLists.txt
@@ -0,0 +1,51 @@
+# Copyright 2019 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.
+
+add_subdirectory(Flow/Analysis)
+add_subdirectory(Flow/Conversion/HLOToFlow)
+add_subdirectory(Flow/Conversion/StandardToFlow)
+add_subdirectory(Flow/IR)
+add_subdirectory(Flow/Transforms)
+add_subdirectory(Flow/Utils)
+
+add_subdirectory(HAL/Conversion/FlowToHAL)
+add_subdirectory(HAL/Conversion/HALToVM)
+add_subdirectory(HAL/IR)
+add_subdirectory(HAL/Target)
+add_subdirectory(HAL/Transforms)
+add_subdirectory(HAL/Utils)
+
+add_subdirectory(VM/Analysis)
+add_subdirectory(VM/IR)
+add_subdirectory(VM/Target/Bytecode)
+add_subdirectory(VM/Tools)
+add_subdirectory(VM/Transforms)
+
+iree_cc_library(
+  NAME
+    Dialect
+  HDRS
+    "IREEDialect.h"
+    "Traits.h"
+    "Types.h"
+  SRCS
+    "IREEDialect.cpp"
+  DEPS
+    LLVMSupport
+    MLIRIR
+    MLIRParser
+    MLIRSupport
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt b/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt
new file mode 100644
index 0000000..f2a52c3
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Analysis
+  HDRS
+    "Dispatchability.h"
+  SRCS
+    "Dispatchability.cpp"
+    "DispatchabilityTest.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::Flow::IR
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransforms
+    tensorflow::mlir_xla
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt
new file mode 100644
index 0000000..d3f67b4
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    HLOToFlow
+  HDRS
+    "ConvertHLOToFlow.h"
+  SRCS
+    "ConvertHLOToFlow.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::Flow::IR
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRTransforms
+    tensorflow::mlir_xla
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt
new file mode 100644
index 0000000..98bc7d9
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    StandardToFlow
+  HDRS
+    "ConvertStandardToFlow.h"
+  SRCS
+    "ConvertStandardToFlow.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::Flow::IR
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/Flow/IR/CMakeLists.txt b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
new file mode 100644
index 0000000..2537e62
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
@@ -0,0 +1,75 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    IR
+  HDRS
+    "FlowDialect.h"
+    "FlowEnums.h.inc"
+    "FlowOpInterface.h.inc"
+    "FlowOps.h"
+    "FlowOps.h.inc"
+    "FlowTypes.h"
+  SRCS
+    "FlowDialect.cpp"
+    "FlowEnums.cpp.inc"
+    "FlowOpFolders.cpp"
+    "FlowOpInterface.cpp.inc"
+    "FlowOps.cpp"
+    "FlowOps.cpp.inc"
+    "FlowTypes.cpp"
+  DEPS
+    FlowEnumsGen
+    FlowOpInterfaceGen
+    FlowOpsGen
+    iree::compiler::Dialect
+    LLVMSupport
+    MLIRIR
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransformUtils
+  ALWAYSLINK
+  PUBLIC
+)
+
+iree_tablegen_library(
+  NAME
+    FlowEnumsGen
+  SRCS
+    FlowBase.td
+  OUTS
+    -gen-enum-decls FlowEnums.h.inc
+    -gen-enum-defs FlowEnums.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    FlowOpInterfaceGen
+  SRCS
+    FlowBase.td
+  OUTS
+    -gen-op-interface-decls FlowOpInterface.h.inc
+    -gen-op-interface-defs FlowOpInterface.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    FlowOpsGen
+  SRCS
+    FlowOps.td
+  OUTS
+    -gen-op-decls FlowOps.h.inc
+    -gen-op-defs FlowOps.cpp.inc
+)
diff --git a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
new file mode 100644
index 0000000..0ba3d67
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
@@ -0,0 +1,50 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Transforms
+  HDRS
+    "Passes.h"
+  SRCS
+    "AssignExecutableWorkloads.cpp"
+    "DispatchabilityAnalysis.cpp"
+    "FlattenTuplesInCFG.cpp"
+    "FoldCompatibleDispatchRegions.cpp"
+    "FormStreams.cpp"
+    "IdentifyDispatchRegions.cpp"
+    "IdentifyReductionRegions.cpp"
+    "OutlineDispatchRegions.cpp"
+    "OutlineReductionRegions.cpp"
+    "Passes.cpp"
+    "PrePostPartitioningConversion.cpp"
+    "RematerializeDispatchConstants.cpp"
+  DEPS
+    iree::compiler::Dialect::Flow::Analysis
+    iree::compiler::Dialect::Flow::Conversion::HLOToFlow
+    iree::compiler::Dialect::Flow::Conversion::StandardToFlow
+    iree::compiler::Dialect::Flow::IR
+    iree::compiler::Dialect::Flow::Utils
+    iree::compiler::Utils
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransformUtils
+    MLIRTransforms
+    tensorflow::mlir_xla
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt b/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt
new file mode 100644
index 0000000..83df7d4
--- /dev/null
+++ b/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Utils
+  HDRS
+    "DispatchUtils.h"
+    "WorkloadUtils.h"
+  SRCS
+    "DispatchUtils.cpp"
+    "WorkloadUtils.cpp"
+  DEPS
+    iree::compiler::Dialect::Flow::IR
+    LLVMSupport
+    MLIRIR
+    MLIRStandardOps
+    MLIRSupport
+    tensorflow::mlir_xla
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt
new file mode 100644
index 0000000..5ece09f
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    FlowToHAL
+  HDRS
+    "ConvertFlowToHAL.h"
+  SRCS
+    "ConvertFlowToHAL.cpp"
+    "ConvertStreamOps.cpp"
+    "ConvertStructuralOps.cpp"
+    "ConvertTensorOps.cpp"
+    "ConvertVariableOps.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::Flow::IR
+    iree::compiler::Dialect::HAL::IR
+    iree::compiler::Dialect::HAL::Target::ExecutableTarget
+    iree::compiler::Dialect::HAL::Utils
+    iree::compiler::Dialect::HAL::IR
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt
new file mode 100644
index 0000000..fa4ce25
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    HALtoVM
+  HDRS
+    "ConvertHALToVM.h"
+  SRCS
+    "ConvertHALToVM.cpp"
+    "ConvertHALToVMPass.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::HAL::IR
+    iree::compiler::Dialect::VM::IR
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/IR/CMakeLists.txt b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
new file mode 100644
index 0000000..8721d08
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
@@ -0,0 +1,75 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    IR
+  HDRS
+    "HALDialect.h"
+    "HALEnums.h.inc"
+    "HALOpInterface.h.inc"
+    "HALOps.h"
+    "HALOps.h.inc"
+    "HALTypes.h"
+  SRCS
+    "HALDialect.cpp"
+    "HALEnums.cpp.inc"
+    "HALOpFolders.cpp"
+    "HALOpInterface.cpp.inc"
+    "HALOps.cpp"
+    "HALOps.cpp.inc"
+    "HALTypes.cpp"
+  DEPS
+    HALEnumsGen
+    HALOpInterfaceGen
+    HALOpsGen
+    iree::compiler::Dialect
+    LLVMSupport
+    MLIRIR
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransformUtils
+  ALWAYSLINK
+  PUBLIC
+)
+
+iree_tablegen_library(
+  NAME
+    HALEnumsGen
+  SRCS
+    HALBase.td
+  OUTS
+    -gen-enum-decls HALEnums.h.inc
+    -gen-enum-defs HALEnums.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    HALOpInterfaceGen
+  SRCS
+    HALBase.td
+  OUTS
+    -gen-op-interface-decls HALOpInterface.h.inc
+    -gen-op-interface-defs HALOpInterface.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    HALOpsGen
+  SRCS
+    HALOps.td
+  OUTS
+    -gen-op-decls HALOps.h.inc
+    -gen-op-defs HALOps.cpp.inc
+)
diff --git a/iree/compiler/Dialect/HAL/Target/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt
new file mode 100644
index 0000000..c5e6206
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    ExecutableTarget
+  HDRS
+    "ExecutableTarget.h"
+    "LegacyUtil.h"
+  SRCS
+    "ExecutableTarget.cpp"
+    "LegacyUtil.cpp"
+  DEPS
+    iree::compiler::Dialect::Flow::IR
+    iree::compiler::Dialect::HAL::IR
+    iree::compiler::IR
+    iree::compiler::Utils
+    LLVMSupport
+    MLIRIR
+    MLIRStandardOps
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt
new file mode 100644
index 0000000..965d1f8
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    VulkanSPIRV
+  HDRS
+    "VulkanSPIRVTarget.h"
+  SRCS
+    "VulkanSPIRVTarget.cpp"
+  DEPS
+    iree::compiler::Dialect::Flow::IR
+    iree::compiler::Dialect::HAL:Target::ExecutableTarget
+    iree::compiler::IR
+    iree::compiler::Translation::SPIRV
+    iree::schemas
+    iree::schemas::spirv_executable_def_cc_fbs
+    flatbuffers
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRSPIRVDialect
+    MLIRSPIRVSerialization
+    MLIRSupport
+    tensorflow::mlir_xla
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt b/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt
new file mode 100644
index 0000000..d7dde57
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Transforms
+  HDRS
+    "Passes.h"
+  SRCS
+    "Passes.cpp"
+    "TranslateExecutables.cpp"
+  DEPS
+    iree::compiler::Dialect::Flow::IR
+    iree::compiler::Dialect::HAL::Conversion::FlowToHAL
+    iree::compiler::Dialect::HAL::IR
+    iree::compiler::Dialect::HAL::Target::ExecutableTarget
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt b/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt
new file mode 100644
index 0000000..28e65b4
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt
@@ -0,0 +1,29 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Utils
+  HDRS
+    "TypeUtils.h"
+  SRCS
+    "TypeUtils.cpp"
+  DEPS
+    iree::compiler::Dialect::HAL::IR
+    MLIRIR
+    MLIRStandardOps
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt b/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt
new file mode 100644
index 0000000..1c335db
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Analysis
+  HDRS
+    "RegisterAllocation.h"
+    "ValueLiveness.h"
+  SRCS
+    "RegisterAllocation.cpp"
+    "RegisterAllocationTest.cpp"
+    "ValueLiveness.cpp"
+    "ValueLivenessTest.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::VM::IR
+    LLVMSupport
+    MLIRIR
+    MLIRParser
+    MLIRSupport
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt
new file mode 100644
index 0000000..e81845a
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    ImportUtils
+  HDRS
+    "ImportUtils.h"
+  SRCS
+    "ImportUtils.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::VM:IR
+    MLIRIR
+    MLIRParser
+    MLIRSupport
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt
new file mode 100644
index 0000000..e8ae38d
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    StandardToVM
+  HDRS
+    "ConvertStandardToVM.h"
+  SRCS
+    "ConvertStandardToVM.cpp"
+    "ConvertStandardToVMPass.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::VM:IR
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransformUtils
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/IR/CMakeLists.txt b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
new file mode 100644
index 0000000..770825b
--- /dev/null
+++ b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
@@ -0,0 +1,90 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    IR
+  HDRS
+    "VMDialect.h"
+    "VMEnums.h.inc"
+    "VMFuncEncoder.h"
+    "VMOpInterface.h.inc"
+    "VMOps.h"
+    "VMOps.h.inc"
+    "VMTraits.h"
+    "VMTypes.h"
+  SRCS
+    "VMDialect.cpp"
+    "VMEnums.cpp.inc"
+    "VMOpEncoder.cpp.inc"
+    "VMOpFolders.cpp"
+    "VMOpInterface.cpp.inc"
+    "VMOps.cpp"
+    "VMOps.cpp.inc"
+    "VMTypes.cpp"
+  DEPS
+    VMEnumsGen
+    VMOpEncoderGen
+    VMOpInterfaceGen
+    VMOpsGen
+    iree::compiler::Dialect
+    LLVMSupport
+    MLIRIR
+    MLIRStandardOps
+    MLIRSupport
+    MLIRTransformUtils
+  ALWAYSLINK
+  PUBLIC
+)
+
+iree_tablegen_library(
+  NAME
+    VMEnumsGen
+  SRCS
+    VMBase.td
+  OUTS
+    -gen-enum-decls VMEnums.h.inc
+    -gen-enum-defs VMEnums.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    VMOpsGen
+  SRCS
+    VMOps.td
+  OUTS
+    -gen-op-decls VMOps.h.inc
+    -gen-op-defs VMOps.cpp.inc
+)
+
+iree_tablegen_library(
+  NAME
+    VMOpEncoderGen
+  SRCS
+    VMOps.td
+  OUTS
+    -gen-iree-vm-op-encoder-defs VMOpEncoder.cpp.inc
+  TBLGEN
+    IREE
+)
+
+iree_tablegen_library(
+  NAME
+    VMOpInterfaceGen
+  SRCS
+    VMBase.td
+  OUTS
+    -gen-op-interface-decls VMOpInterface.h.inc
+    -gen-op-interface-defs VMOpInterface.cpp.inc
+)
diff --git a/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt b/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt
new file mode 100644
index 0000000..138db13
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Bytecode
+  HDRS
+    "BytecodeModuleTarget.h"
+  SRCS
+    "BytecodeEncoder.cpp"
+    "BytecodeEncoder.h"
+    "BytecodeModuleTarget.cpp"
+    "ConstantEncoder.cpp"
+    "ConstantEncoder.h"
+    "TranslationRegistration.cpp"
+  DEPS
+    iree::compiler::Dialect
+    iree::compiler::Dialect::VM::Analysis
+    iree::compiler::Dialect::VM::IR
+    iree::compiler::Dialect::VM::Transforms
+    iree::schemas::bytecode_module_def_cc_fbs
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRSupport
+    MLIRTransforms
+    MLIRTranslation
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/Tools/CMakeLists.txt b/iree/compiler/Dialect/VM/Tools/CMakeLists.txt
new file mode 100644
index 0000000..a66a7bb
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Tools/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Tools
+  SRCS
+    "VMOpEncoderGen.cpp"
+    "VMOpTableGen.cpp"
+  DEPS
+    LLVMSupport
+    LLVMTableGen
+    MLIRSupport
+    LLVMMLIRTableGen
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt b/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt
new file mode 100644
index 0000000..1fd4a59
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Copyright 2019 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.
+
+iree_cc_library(
+  NAME
+    Transforms
+  HDRS
+    "Passes.h"
+  SRCS
+    "OrdinalAllocationPass.cpp"
+  DEPS
+    iree::compiler::Dialect::VM::IR
+    LLVMSupport
+    MLIRIR
+    MLIRPass
+    MLIRSupport
+    MLIRTransformUtils
+    MLIRTransforms
+  ALWAYSLINK
+  PUBLIC
+)
diff --git a/iree/schemas/CMakeLists.txt b/iree/schemas/CMakeLists.txt
index d9a8abc..edb0898 100644
--- a/iree/schemas/CMakeLists.txt
+++ b/iree/schemas/CMakeLists.txt
@@ -63,6 +63,14 @@
 
 flatbuffer_cc_library(
   NAME
+    bytecode_module_def_cc_fbs
+  SRC
+    "bytecode_module_def.fbs"
+  PUBLIC
+)
+
+flatbuffer_cc_library(
+  NAME
     debug_service_cc_fbs
   SRCS
     "debug_service.fbs"