Add build option to turn on/off RVV
Add build option to turn off/off RVV (default: ON).
Change-Id: Ic19ecad264b6ee3a5894f19105b0ad4fae2f03d7
diff --git a/cmake/springbok_bytecode_module.cmake b/cmake/springbok_bytecode_module.cmake
index 8e8e7f5..e9314de 100644
--- a/cmake/springbok_bytecode_module.cmake
+++ b/cmake/springbok_bytecode_module.cmake
@@ -9,6 +9,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.
+# RVV_OFF: Indicate RVV is OFF (default: ON)
#
# Examples:
# springbok_bytecode_module(
@@ -31,13 +32,14 @@
# "simple_float_mul_bytecode_module_dylib"
# FLAGS
# "-iree-input-type=mhlo"
+# RVV_OFF
# PUBLIC
# )
#
function(springbok_bytecode_module)
cmake_parse_arguments(
_RULE
- ""
+ "PUBLIC;RVV_OFF"
"NAME;SRC;C_IDENTIFIER"
"FLAGS"
${ARGN}
@@ -65,6 +67,11 @@
)
endif()
+ set(_CPU_FEATURES "+m,+f,+zvl512b,+zve32x")
+ if (${_RULE_RVV_OFF})
+ set(_CPU_FEATURES "+m,+f")
+ endif()
+
iree_bytecode_module(
NAME
"${_RULE_NAME}"
@@ -77,7 +84,7 @@
"-iree-hal-target-backends=dylib-llvm-aot"
"-iree-llvm-target-triple=riscv32-pc-linux-elf"
"-iree-llvm-target-cpu=generic-rv32"
- "-iree-llvm-target-cpu-features=+m,+f,+zvl512b,+zve32x"
+ "-iree-llvm-target-cpu-features=${_CPU_FEATURES}"
"-iree-llvm-target-abi=ilp32"
"-iree-llvm-link-embedded=true"
"-iree-llvm-debug-symbols=false"
diff --git a/cmake/springbok_c_module.cmake b/cmake/springbok_c_module.cmake
index 381c048..e9774bf 100644
--- a/cmake/springbok_c_module.cmake
+++ b/cmake/springbok_c_module.cmake
@@ -2,13 +2,14 @@
# springbok_c_module()
#
-# A wrapper for the iree_bytecode_module to apply common iree-translate flags
+# A wrapper for the iree c module to apply common iree-translate flags
# Parameters:
# NAME: Name of target.
# SRC: Source file to compile into an emitC module. Support relative path.
# 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.
+# RVV_OFF: Indicate RVV is OFF (default: ON)
#
# Examples:
# springbok_c_module(
@@ -27,13 +28,14 @@
# "simple_float_mul.mlir"
# FLAGS
# "-iree-input-type=mhlo"
+# RVV_OFF
# PUBLIC
# )
#
function(springbok_c_module)
cmake_parse_arguments(
_RULE
- "PUBLIC"
+ "PUBLIC;RVV_OFF"
"NAME;SRC"
"FLAGS"
${ARGN}
@@ -80,6 +82,11 @@
set(_EMITC_LIB_NAME "${_PACKAGE_NAME}_${_RULE_EMITC_NAME}")
set(_EMITC_FILE_NAME ${_RULE_EMITC_NAME}.h)
+ set(_CPU_FEATURES "+m,+f,+zvl512b,+zve32x")
+ if (${_RULE_RVV_OFF})
+ set(_CPU_FEATURES "+m,+f")
+ endif()
+
## Example with VM C module.
# Setup args for iree-translate.
set(_TRANSLATE_ARGS ${_RULE_FLAGS})
@@ -87,7 +94,7 @@
list(APPEND _TRANSLATE_ARGS "-iree-hal-target-backends=dylib-llvm-aot")
list(APPEND _TRANSLATE_ARGS "-iree-llvm-target-triple=riscv32-pc-linux-elf")
list(APPEND _TRANSLATE_ARGS "-iree-llvm-target-cpu=generic-rv32")
- list(APPEND _TRANSLATE_ARGS "-iree-llvm-target-cpu-features=+m,+f,+zvl512b,+zve32x")
+ list(APPEND _TRANSLATE_ARGS "-iree-llvm-target-cpu-features=${_CPU_FEATURES}")
list(APPEND _TRANSLATE_ARGS "-iree-llvm-target-abi=ilp32")
list(APPEND _TRANSLATE_ARGS "-iree-llvm-link-embedded=false")
list(APPEND _TRANSLATE_ARGS "-iree-llvm-link-static")
diff --git a/cmake/springbok_modules.cmake b/cmake/springbok_modules.cmake
index eee7e94..a410525 100644
--- a/cmake/springbok_modules.cmake
+++ b/cmake/springbok_modules.cmake
@@ -9,6 +9,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.
+# RVV_OFF: Indicate RVV is OFF (default: ON)
#
# Examples:
# springbok_modules(
@@ -31,6 +32,7 @@
# "simple_float_mul"
# FLAGS
# "-iree-input-type=mhlo"
+# RVV_OFF
# PUBLIC
# )
#
@@ -38,12 +40,16 @@
function(springbok_modules)
cmake_parse_arguments(
_RULE
- "PUBLIC"
+ "PUBLIC;RVV_OFF"
"NAME;SRC;C_IDENTIFIER"
"FLAGS"
${ARGN}
)
+ if (${_RULE_RVV_OFF})
+ set(_RVV_OFF_ARG "RVV_OFF")
+ endif()
+
springbok_bytecode_module(
NAME
"${_RULE_NAME}_bytecode_module_dylib"
@@ -53,6 +59,7 @@
"${_RULE_C_IDENTIFIER}_bytecode_module_dylib"
FLAGS
"${_RULE_FLAGS}"
+ "${_RVV_OFF_ARG}"
PUBLIC
)
@@ -63,6 +70,7 @@
"${_RULE_SRC}"
FLAGS
"${_RULE_FLAGS}"
+ "${_RVV_OFF_ARG}"
PUBLIC
)