From a25c5f4a967e5f38aca8a15aff9f1ef189e1f7ff Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 24 Jan 2025 22:40:38 +0200 Subject: [PATCH] userspace: add SIMD test application Signed-off-by: EnderIce2 --- Userspace/apps/test/simd_test/.gitignore | 1 + Userspace/apps/test/simd_test/Makefile | 36 ++++++++++++++++++++++++ Userspace/apps/test/simd_test/simd.c | 11 ++++++++ 3 files changed, 48 insertions(+) create mode 100644 Userspace/apps/test/simd_test/.gitignore create mode 100644 Userspace/apps/test/simd_test/Makefile create mode 100644 Userspace/apps/test/simd_test/simd.c diff --git a/Userspace/apps/test/simd_test/.gitignore b/Userspace/apps/test/simd_test/.gitignore new file mode 100644 index 00000000..c9949562 --- /dev/null +++ b/Userspace/apps/test/simd_test/.gitignore @@ -0,0 +1 @@ +simd_test diff --git a/Userspace/apps/test/simd_test/Makefile b/Userspace/apps/test/simd_test/Makefile new file mode 100644 index 00000000..8d35570e --- /dev/null +++ b/Userspace/apps/test/simd_test/Makefile @@ -0,0 +1,36 @@ +default: + $(error Do not run this Makefile directly!) + +S_SOURCES = $(shell find ./ -type f -name '*.S') +C_SOURCES = $(shell find ./ -type f -name '*.c') +CXX_SOURCES = $(shell find ./ -type f -name '*.cpp') + +OBJ = $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) + +FILENAME = $(notdir $(shell pwd)) +WARNCFLAG = -Wall -Wextra + +build: $(FILENAME) + cp $(FILENAME) $(WORKSPACE_DIR)/out/bin/$(FILENAME) + +# Use static linking +LDFLAGS += -static -fno-pic -fno-pie -Wl,-static + +$(FILENAME): $(OBJ) + $(info Linking $@) + $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@ + +%.o: %.c $(HEADERS) + $(info Compiling $<) + $(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@ + +%.o: %.cpp $(HEADERS) + $(info Compiling $<) + $(CXX) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti + +%.o: %.S + $(info Compiling $<) + $(AS) -o $@ $< + +clean: + rm -f $(OBJ) $(FILENAME) diff --git a/Userspace/apps/test/simd_test/simd.c b/Userspace/apps/test/simd_test/simd.c new file mode 100644 index 00000000..3e526c0b --- /dev/null +++ b/Userspace/apps/test/simd_test/simd.c @@ -0,0 +1,11 @@ +int main(int, char *argv[], char *[]) +{ +#if defined(__amd64__) || defined(__i386__) + __asm__ __volatile__("movaps (%0), %%xmm0\n" + "movaps %%xmm0, (%0)\n" + : : "r"(argv) : "memory"); +#else +#warning "Unimplemented" +#endif + return 0; +}