-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
93 lines (76 loc) · 1.98 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
ifndef CC
override CC = gcc
endif
ifndef CXX
override CXX = g++
endif
ifndef ENABLE_TEST_ALL
DEFINED_FLAGS =
else
DEFINED_FLAGS = -DENABLE_TEST_ALL
endif
ifndef CROSS_COMPILE
processor := $(shell uname -m)
ARCH_CFLAGS = -march=armv8.4-a+simd+i8mm+dotprod+sha3
else # CROSS_COMPILE was set
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
CXXFLAGS += -static
LDFLAGS += -static
check_riscv := $(shell echo | $(CROSS_COMPILE)cpp -dM - | grep " __riscv_xlen " | cut -c22-)
uname_result := $(shell uname -m)
ifeq ($(check_riscv),64)
processor = rv64
else ifeq ($(uname_result),rv64imafdc)
processor = rv64
else ifeq ($(check_riscv),32)
processor = rv32
else ifeq ($(uname_result),rv32i)
processor = rv32
else
$(error Unsupported cross-compiler)
endif
ARCH_CFLAGS = -march=$(processor)gcv_zba
ifeq ($(SIMULATOR_TYPE), qemu)
SIMULATOR += qemu-riscv64
SIMULATOR_FLAGS = -cpu $(processor),v=true,zba=true,vlen=128
else
SIMULATOR = spike
SIMULATOR_FLAGS = --isa=$(processor)gcv_zba
PROXY_KERNEL = pk
endif
endif
CXXFLAGS += -Wall -Wcast-qual -I. $(ARCH_CFLAGS)
LDFLAGS += -lm
OBJS = \
tests/binding.o \
tests/common.o \
tests/debug_tools.o \
tests/impl.o \
tests/main.o
deps := $(OBJS:%.o=%.o.d)
.SUFFIXES: .o .cpp
.cpp.o:
$(CXX) -o $@ $(CXXFLAGS) $(DEFINED_FLAGS) -c -MMD -MF $@.d $<
EXEC = tests/main
$(EXEC): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^
test: tests/main
ifeq ($(processor),$(filter $(processor),rv32 rv64))
$(CC) $(ARCH_CFLAGS) -c neon2rvv.h
endif
$(SIMULATOR) $(SIMULATOR_FLAGS) $(PROXY_KERNEL) $^
build-test: tests/main
ifeq ($(processor),$(filter $(processor),rv32 rv64))
$(CC) $(ARCH_CFLAGS) -c neon2rvv.h
endif
format:
@echo "Formatting files with clang-format.."
@if ! hash clang-format; then echo "clang-format is required to indent"; fi
clang-format -i neon2rvv.h tests/*.cpp tests/*.h
.PHONY: clean check format
clean:
$(RM) $(OBJS) $(EXEC) $(deps) neon2rvv.h.gch
clean-all: clean
$(RM) *.log
-include $(deps)