sw:vec: Add scalar build support to build rv32im binaries
Add CMake option "BUILD_SIMPLIFIED_CORE" to use the macros defined in
https://spacebeaker-review.googlesource.com/c/shodan/sw/vec/+/18021
to build rv32im SW binaries.
Also remove the unused "riscv_vector.h" header file in the softrvv test
code. The header checks the vector extension in the compilation -march
flag and fails if v-ext is not used. Instead of guard it with the macro,
I remove the unused header.
Change-Id: I85c81cf2d63c232dac53ae15826753d3dd117aa8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac3e2a9..f1bb05e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required (VERSION 3.10)
+option(BUILD_SIMPLIFIED_CORE "Build the project with a simplified set of ISA support.")
set(CMAKE_C_ABI_COMPILED ON)
set(CMAKE_CXX_ABI_COMPILED ON)
@@ -11,6 +12,12 @@
project(springbok_project)
+if(${BUILD_SIMPLIFIED_CORE})
+ add_definitions(-DLIBSPRINGBOK_NO_VECTOR_SUPPORT)
+ add_definitions(-DLIBSPRINGBOK_NO_FLOAT_SUPPORT)
+ add_definitions(-DLIBSPRINGBOK_NO_EXCEPTION_SUPPORT)
+endif()
+
enable_language(ASM)
include($ENV{ROOTDIR}/sw/pigweed/pw_build/pigweed.cmake)
diff --git a/cmake/riscv_baremetal.cmake b/cmake/riscv_baremetal.cmake
index 29ed234..b10e7ca 100644
--- a/cmake/riscv_baremetal.cmake
+++ b/cmake/riscv_baremetal.cmake
@@ -23,8 +23,11 @@
)
if(${BUILD_WITH_CLANG})
- set(CMAKE_SYSTEM_PROCESSOR rv32imfv1p0)
-
+ if(${BUILD_SIMPLIFIED_CORE})
+ set(CMAKE_SYSTEM_PROCESSOR rv32im)
+ else()
+ set(CMAKE_SYSTEM_PROCESSOR rv32imfv1p0)
+ endif()
set(RISCV_TOOLCHAIN_ROOT "$ENV{CACHE}/toolchain_iree_rv32imf/bin/" CACHE PATH "RISC-V toolchain root path")
message (STATUS "RISC-V toolchain path is ${RISCV_TOOLCHAIN_ROOT}")
find_file(RISCV_COMPILER "clang" HINTS ${RISCV_TOOLCHAIN_ROOT} PATHS ENV INCLUDE)
diff --git a/pw_unit_test_demo/CMakeLists.txt b/pw_unit_test_demo/CMakeLists.txt
index 6116e7a..96a718e 100644
--- a/pw_unit_test_demo/CMakeLists.txt
+++ b/pw_unit_test_demo/CMakeLists.txt
@@ -1,4 +1,6 @@
-
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
vec_cc_test(
NAME
pw_unit_test_demo
diff --git a/softrvv/tests/CMakeLists.txt b/softrvv/tests/CMakeLists.txt
index aec740a..364304d 100644
--- a/softrvv/tests/CMakeLists.txt
+++ b/softrvv/tests/CMakeLists.txt
@@ -1,15 +1,3 @@
-
-vec_cc_test(
- NAME
- vec_disable_test
- SRCS
- vec_disable_test.cpp
- DEPS
- softrvv
- LINKOPTS
- -Xlinker --defsym=__itcm_length__=256K
-)
-
vec_cc_test(
NAME
softrvv_vwadd
@@ -100,24 +88,6 @@
softrvv_vec_cc_generated_test(
NAME
- vfadd
- TEMPLATE
- softrvv_vfadd_test.tpl.cpp
- LINKOPTS
- -Xlinker --defsym=__itcm_length__=128K
-)
-
-softrvv_vec_cc_generated_test(
- NAME
- vfsub
- TEMPLATE
- softrvv_vfsub_test.tpl.cpp
- LINKOPTS
- -Xlinker --defsym=__itcm_length__=128K
-)
-
-softrvv_vec_cc_generated_test(
- NAME
vadd
TEMPLATE
softrvv_vadd_test.tpl.cpp
@@ -353,3 +323,35 @@
-Xlinker --defsym=__itcm_length__=128K
)
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
+
+vec_cc_test(
+ NAME
+ vec_disable_test
+ SRCS
+ vec_disable_test.cpp
+ DEPS
+ softrvv
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=256K
+)
+
+softrvv_vec_cc_generated_test(
+ NAME
+ vfadd
+ TEMPLATE
+ softrvv_vfadd_test.tpl.cpp
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=128K
+)
+
+softrvv_vec_cc_generated_test(
+ NAME
+ vfsub
+ TEMPLATE
+ softrvv_vfsub_test.tpl.cpp
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=128K
+)
diff --git a/softrvv/tests/softrvv_vand_test.cpp b/softrvv/tests/softrvv_vand_test.cpp
index 2eb5f5f..f5db394 100644
--- a/softrvv/tests/softrvv_vand_test.cpp
+++ b/softrvv/tests/softrvv_vand_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vmacc_test.cpp b/softrvv/tests/softrvv_vmacc_test.cpp
index ed784d5..f0449f8 100644
--- a/softrvv/tests/softrvv_vmacc_test.cpp
+++ b/softrvv/tests/softrvv_vmacc_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vmadd_vnmsub_test.cpp b/softrvv/tests/softrvv_vmadd_vnmsub_test.cpp
index 8c1284f..57f1397 100644
--- a/softrvv/tests/softrvv_vmadd_vnmsub_test.cpp
+++ b/softrvv/tests/softrvv_vmadd_vnmsub_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vmax_test.cpp b/softrvv/tests/softrvv_vmax_test.cpp
index 8b1e179..4c15c71 100644
--- a/softrvv/tests/softrvv_vmax_test.cpp
+++ b/softrvv/tests/softrvv_vmax_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/softrvv/tests/softrvv_vmaxu_test.cpp b/softrvv/tests/softrvv_vmaxu_test.cpp
index cc7306b..747d3cd 100644
--- a/softrvv/tests/softrvv_vmaxu_test.cpp
+++ b/softrvv/tests/softrvv_vmaxu_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/softrvv/tests/softrvv_vmin_test.cpp b/softrvv/tests/softrvv_vmin_test.cpp
index c3852f7..82cbaea 100644
--- a/softrvv/tests/softrvv_vmin_test.cpp
+++ b/softrvv/tests/softrvv_vmin_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/softrvv/tests/softrvv_vmv_s_x_test.cpp b/softrvv/tests/softrvv_vmv_s_x_test.cpp
index fd10f46..55b74b2 100644
--- a/softrvv/tests/softrvv_vmv_s_x_test.cpp
+++ b/softrvv/tests/softrvv_vmv_s_x_test.cpp
@@ -1,5 +1,4 @@
#include <limits.h>
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
diff --git a/softrvv/tests/softrvv_vor_test.cpp b/softrvv/tests/softrvv_vor_test.cpp
index 9d01e5d..6879155 100644
--- a/softrvv/tests/softrvv_vor_test.cpp
+++ b/softrvv/tests/softrvv_vor_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vsext_test.cpp b/softrvv/tests/softrvv_vsext_test.cpp
index 27e3c81..adffb60 100644
--- a/softrvv/tests/softrvv_vsext_test.cpp
+++ b/softrvv/tests/softrvv_vsext_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vwadd_test.cpp b/softrvv/tests/softrvv_vwadd_test.cpp
index 6935a42..b955307 100644
--- a/softrvv/tests/softrvv_vwadd_test.cpp
+++ b/softrvv/tests/softrvv_vwadd_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vwaddu_test.cpp b/softrvv/tests/softrvv_vwaddu_test.cpp
index 871a62f..06d2e03 100644
--- a/softrvv/tests/softrvv_vwaddu_test.cpp
+++ b/softrvv/tests/softrvv_vwaddu_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vwsub_test.cpp b/softrvv/tests/softrvv_vwsub_test.cpp
index db44f4d..7111524 100644
--- a/softrvv/tests/softrvv_vwsub_test.cpp
+++ b/softrvv/tests/softrvv_vwsub_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vwsubu_test.cpp b/softrvv/tests/softrvv_vwsubu_test.cpp
index c23d6c2..0d10882 100644
--- a/softrvv/tests/softrvv_vwsubu_test.cpp
+++ b/softrvv/tests/softrvv_vwsubu_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/softrvv_vzext_test.cpp b/softrvv/tests/softrvv_vzext_test.cpp
index 896a764..7ef7e37 100644
--- a/softrvv/tests/softrvv_vzext_test.cpp
+++ b/softrvv/tests/softrvv_vzext_test.cpp
@@ -1,4 +1,3 @@
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/softrvv/tests/templates/base.tpl.cpp b/softrvv/tests/templates/base.tpl.cpp
index 586cfff..04aa997 100644
--- a/softrvv/tests/templates/base.tpl.cpp
+++ b/softrvv/tests/templates/base.tpl.cpp
@@ -12,7 +12,6 @@
return src1_data, src2_data, rs1
%>
/* File is auto-generated. */
-#include <riscv_vector.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/test_v_helpers/test_v_helpers.cpp b/test_v_helpers/test_v_helpers.cpp
index 133ad07..b539448 100644
--- a/test_v_helpers/test_v_helpers.cpp
+++ b/test_v_helpers/test_v_helpers.cpp
@@ -1,5 +1,5 @@
#include "test_v_helpers.h"
-
+#ifndef LIBSPRINGBOK_NO_VECTOR_SUPPORT
#include <riscv_vector.h>
namespace test_v_helpers {
@@ -530,3 +530,5 @@
}
} // namespace test_v_helpers
+
+#endif // #ifndef LIBSPRINGBOK_NO_VECTOR_SUPPORT
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index dbe8669..ba12983 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
+
vec_cc_generated_test(
NAME
vfadd
diff --git a/vector_executive/CMakeLists.txt b/vector_executive/CMakeLists.txt
index 9116c16..8128db2 100644
--- a/vector_executive/CMakeLists.txt
+++ b/vector_executive/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
vec_cc_binary(
NAME
diff --git a/vector_load_store_tests/CMakeLists.txt b/vector_load_store_tests/CMakeLists.txt
index d929aa7..fc5a350 100644
--- a/vector_load_store_tests/CMakeLists.txt
+++ b/vector_load_store_tests/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
vec_cc_binary(
NAME
diff --git a/vector_matmul4_asm_test/CMakeLists.txt b/vector_matmul4_asm_test/CMakeLists.txt
index 7b797a3..6c0c04b 100644
--- a/vector_matmul4_asm_test/CMakeLists.txt
+++ b/vector_matmul4_asm_test/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
+
vec_cc_binary(
NAME
vector_matmul4_asm_test
diff --git a/vector_tests/CMakeLists.txt b/vector_tests/CMakeLists.txt
index e939871..c943ad4 100644
--- a/vector_tests/CMakeLists.txt
+++ b/vector_tests/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
enable_language(ASM)
add_library(vector_tests
diff --git a/vector_vadd_vsub_tests/CMakeLists.txt b/vector_vadd_vsub_tests/CMakeLists.txt
index 2ce8ff3..72e39b2 100644
--- a/vector_vadd_vsub_tests/CMakeLists.txt
+++ b/vector_vadd_vsub_tests/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
set (OPERAND_TYPES VV VX VI)
diff --git a/vector_vset_tests/CMakeLists.txt b/vector_vset_tests/CMakeLists.txt
index 3388d71..6557b2f 100644
--- a/vector_vset_tests/CMakeLists.txt
+++ b/vector_vset_tests/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(${BUILD_SIMPLIFIED_CORE})
+ return()
+endif()
vec_cc_binary(
NAME