cvw/tests/fp/vectors/riscv/Makefile

75 lines
2.5 KiB
Makefile
Executable File

.DELETE_ON_ERROR:
.SECONDEXPANSION:
.ONESHELL:
# MAKEFLAGS += --no-print-directory
SHELL := /bin/bash
VECTOR_TYPE := riscv
TESTFLOAT_DIR := ${WALLY}/tests/fp/testfloat
TESTFLOAT_GEN := ${TESTFLOAT_DIR}/${VECTOR_TYPE}/testfloat_gen
# List of testvectors to generate. Each rounding mode will be generated for each test.
cvtint := ui32_to_f16 ui32_to_f32 ui32_to_f64 ui32_to_f128 \
ui64_to_f16 ui64_to_f32 ui64_to_f64 ui64_to_f128 \
i32_to_f16 i32_to_f32 i32_to_f64 i32_to_f128 \
i64_to_f16 i64_to_f32 i64_to_f64 i64_to_f128 \
f16_to_ui32 f32_to_ui32 f64_to_ui32 f128_to_ui32 \
f16_to_ui64 f32_to_ui64 f64_to_ui64 f128_to_ui64
cvtfp := f16_to_i32 f32_to_i32 f64_to_i32 f128_to_i32 \
f16_to_i64 f32_to_i64 f64_to_i64 f128_to_i64 \
f16_to_f32 f16_to_f64 f16_to_f128 \
f32_to_f16 f32_to_f64 f32_to_f128 \
f64_to_f16 f64_to_f32 f64_to_f128 \
f128_to_f16 f128_to_f32 f128_to_f64
add := f16_add f32_add f64_add f128_add
sub := f16_sub f32_sub f64_sub f128_sub
mul := f16_mul f32_mul f64_mul f128_mul
div := f16_div f32_div f64_div f128_div
sqrt := f16_sqrt f32_sqrt f64_sqrt f128_sqrt
eq := f16_eq f32_eq f64_eq f128_eq
le := f16_le f32_le f64_le f128_le
lt := f16_lt f32_lt f64_lt f128_lt
mulAdd := f16_mulAdd f32_mulAdd f64_mulAdd f128_mulAdd
tests := $(cvtfp) $(cvtint) $(add) $(sub) $(mul) $(div) $(sqrt) $(eq) $(le) $(lt) $(mulAdd)
# Set rounding modes and extensions
rne: ROUND_MODE := rnear_even
rne: ROUND_EXT := rne
rz: ROUND_MODE := rminMag
rz: ROUND_EXT := rz
ru: ROUND_MODE := rmax
ru: ROUND_EXT := ru
rd: ROUND_MODE := rmin
rd: ROUND_EXT := rd
rnm: ROUND_MODE := rnear_maxMag
rnm: ROUND_EXT := rnm
.PHONY: all rne rz ru rd rnm clean
all: rne rz ru rd rnm
# Generate test vectors for each rounding mode
rne: $(addsuffix _rne.tv, $(tests))
rz: $(addsuffix _rz.tv, $(tests))
ru: $(addsuffix _ru.tv, $(tests))
rd: $(addsuffix _rd.tv, $(tests))
rnm: $(addsuffix _rnm.tv, $(tests))
# Rule to generate individual test vectors
%.tv: ${TESTFLOAT_GEN}
@echo "Creating $(VECTOR_TYPE) $@ vectors"
@if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi
@if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi
${TESTFLOAT_GEN} -tininessafter -level $$level $$exact -$(ROUND_MODE) $(patsubst %_$(ROUND_EXT).tv, %, $@) > $@
@sed -i 's/ /_/g' $@
# Appropriate testfloat_gen must exist
${TESTFLOAT_GEN}:
$(MAKE) -C ${TESTFLOAT_DIR} ${VECTOR_TYPE}
clean:
rm -f *.tv
rm -f sed*