Merge "sw/vec_iree: Add build option for intermediate output"
diff --git a/cmake/sparrow_modules.cmake b/cmake/sparrow_modules.cmake
index 971564e..195246c 100644
--- a/cmake/sparrow_modules.cmake
+++ b/cmake/sparrow_modules.cmake
@@ -7,6 +7,7 @@
 # FLAGS: Flags to pass to the translation tool (list of strings).
 # C_IDENTIFIER: Identifier to use for generate c embed code.
 #     If omitted then no C embed code will be generated.
+# TFLITE_OUTPUT: TFLite output array name
 # RVV_OFF: Indicate RVV is OFF (default: ON)
 # VMVX: Compile VMVX backend
 # INLINE_HAL: Use inline HAL.
@@ -41,7 +42,7 @@
   cmake_parse_arguments(
     _RULE
     "PUBLIC;RVV_OFF;VMVX;INLINE_HAL"
-    "NAME;SRC;C_IDENTIFIER"
+    "NAME;SRC;C_IDENTIFIER;TFLITE_OUTPUT"
     "FLAGS"
     ${ARGN}
   )
@@ -61,6 +62,8 @@
       "${_RULE_SRC}"
     C_IDENTIFIER
       "${_RULE_C_IDENTIFIER}_bytecode_module_static"
+    TFLITE_OUTPUT
+      "${_RULE_TFLITE_OUTPUT}"
     FLAGS
       "${_RULE_FLAGS}"
     "${_RVV_OFF_ARG}"
@@ -72,6 +75,8 @@
       "${_RULE_NAME}_c_module_static"
     SRC
       "${_RULE_SRC}"
+    TFLITE_OUTPUT
+      "${_RULE_TFLITE_OUTPUT}"
     FLAGS
       "${_RULE_FLAGS}"
     "${_RVV_OFF_ARG}"
@@ -87,6 +92,8 @@
         "${_RULE_SRC}"
       C_IDENTIFIER
         "${_RULE_C_IDENTIFIER}_bytecode_module_vmvx"
+      TFLITE_OUTPUT
+        "${_RULE_TFLITE_OUTPUT}"
       FLAGS
         "${_RULE_FLAGS}"
       "${_INLINE_HAL_ARG}"
@@ -97,6 +104,8 @@
         "${_RULE_NAME}_c_module_vmvx"
       SRC
         "${_RULE_SRC}"
+      TFLITE_OUTPUT
+        "${_RULE_TFLITE_OUTPUT}"
       FLAGS
         "${_RULE_FLAGS}"
       "${_INLINE_HAL_ARG}"
diff --git a/cmake/sparrow_static_module.cmake b/cmake/sparrow_static_module.cmake
index a42e3c6..0aa6928 100644
--- a/cmake/sparrow_static_module.cmake
+++ b/cmake/sparrow_static_module.cmake
@@ -5,6 +5,7 @@
 # NAME: Name of target.
 # SRC: Source file to compile into a bytecode module. Support relative path.
 # C_IDENTIFIER: Identifier to use for generate c embed code.
+# OUTPUT: TFLite output array name
 # FLAGS: Flags to pass to the translation tool (list of strings).
 # RVV_OFF: Indicate RVV is OFF (default: ON)
 # EMITC: Uses EmitC to output C code instead of VM bytecode.
@@ -39,7 +40,7 @@
   cmake_parse_arguments(
     _RULE
     "RVV_OFF;EMITC;INLINE_HAL"
-    "NAME;SRC;C_IDENTIFIER"
+    "NAME;SRC;C_IDENTIFIER;TFLITE_OUTPUT"
     "FLAGS"
     ${ARGN}
   )
@@ -53,6 +54,7 @@
     set(_MLIR_SRC "${CMAKE_CURRENT_BINARY_DIR}/${_RULE_NAME}.mlir")
     get_filename_component(_SRC_PATH "${_RULE_SRC}" REALPATH)
     set(_ARGS "${_SRC_PATH}")
+    list(APPEND _ARGS "${_RULE_TFLITE_OUTPUT}")
     list(APPEND _ARGS "-o")
     list(APPEND _ARGS "${_RULE_NAME}.mlir")
     # Only add the custom_command here. The output is passed to
diff --git a/cmake/sparrow_vmvx_module.cmake b/cmake/sparrow_vmvx_module.cmake
index 60ee602..6a3f997 100644
--- a/cmake/sparrow_vmvx_module.cmake
+++ b/cmake/sparrow_vmvx_module.cmake
@@ -4,6 +4,8 @@
 # Parameters:
 # NAME: Name of target.
 # SRC: Source file to compile into a bytecode module. Support relative path.
+# C_IDENTIFIER: Identifier to use for generate c embed code.
+# TFLITE_OUTPUT: TFLite output array name
 # FLAGS: Flags to pass to the translation tool (list of strings).
 # EMITC: Uses EmitC to output C code instead of VM bytecode.
 # INLINE_HAL: Use inline HAL.
@@ -36,7 +38,7 @@
   cmake_parse_arguments(
     _RULE
     "EMITC;INLINE_HAL"
-    "NAME;SRC;C_IDENTIFIER"
+    "NAME;SRC;C_IDENTIFIER;TFLITE_OUTPUT"
     "FLAGS"
     ${ARGN}
   )
@@ -50,6 +52,7 @@
     set(_MLIR_SRC "${CMAKE_CURRENT_BINARY_DIR}/${_RULE_NAME}.mlir")
     get_filename_component(_SRC_PATH "${_RULE_SRC}" REALPATH)
     set(_ARGS "${_SRC_PATH}")
+    list(APPEND _ARGS "${_RULE_TFLITE_OUTPUT}")
     list(APPEND _ARGS "-o")
     list(APPEND _ARGS "${_RULE_NAME}.mlir")
     # Only add the custom_command here. The output is passed to