| 1 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 2 |
# or more contributor license agreements. See the NOTICE file |
| 3 |
# distributed with this work for additional information |
| 4 |
# regarding copyright ownership. The ASF licenses this file |
| 5 |
# to you under the Apache License, Version 2.0 (the |
| 6 |
# "License"); you may not use this file except in compliance |
| 7 |
# with the License. You may obtain a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, software |
| 12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
# See the License for the specific language governing permissions and |
| 15 |
# limitations under the License. |
| 16 |
|
| 17 |
GO_BUILD=go build |
| 18 |
GO_GEN=go generate |
| 19 |
GO_TEST=go test |
| 20 |
GOPATH=$(realpath ../../../../../..) |
| 21 |
|
| 22 |
# this converts rotate instructions from "ro[lr] <reg>" -> "ro[lr] <reg>, 1" for yasm compatibility |
| 23 |
PERL_FIXUP_ROTATE=perl -i -pe 's/(ro[rl]\s+\w{2,3})$$/\1, 1/' |
| 24 |
|
| 25 |
C2GOASM=c2goasm -a -f |
| 26 |
CC=clang |
| 27 |
C_FLAGS=-target x86_64-unknown-none -masm=intel -mno-red-zone -mstackrealign -mllvm -inline-threshold=1000 -fno-asynchronous-unwind-tables \ |
| 28 |
-fno-exceptions -fno-rtti -O3 -fno-builtin -ffast-math -fno-jump-tables -I_lib |
| 29 |
ASM_FLAGS_AVX2=-mavx2 -mfma -mllvm -force-vector-width=32 |
| 30 |
ASM_FLAGS_SSE4=-msse4 |
| 31 |
|
| 32 |
C_FLAGS_NEON=-O3 -fvectorize -mllvm -force-vector-width=16 -fno-asynchronous-unwind-tables -mno-red-zone -mstackrealign -fno-exceptions \ |
| 33 |
-fno-rtti -fno-builtin -ffast-math -fno-jump-tables -I_lib |
| 34 |
|
| 35 |
GO_SOURCES := $(shell find . -path ./_lib -prune -o -name '*.go' -not -name '*_test.go') |
| 36 |
ALL_SOURCES := $(shell find . -path ./_lib -prune -o -name '*.go' -name '*.s' -not -name '*_test.go') |
| 37 |
|
| 38 |
INTEL_SOURCES := \ |
| 39 |
float64_avx2_amd64.s float64_sse4_amd64.s \ |
| 40 |
int64_avx2_amd64.s int64_sse4_amd64.s \ |
| 41 |
uint64_avx2_amd64.s uint64_sse4_amd64.s |
| 42 |
|
| 43 |
.PHONEY: assembly |
| 44 |
|
| 45 |
# |
| 46 |
# ARROW-15172: DO NOT add the assembly target for Arm64 (ARM_SOURCES) until c2goasm added the Arm64 support. |
| 47 |
# The related Arm64 assembly (uint64_neon_arm64.s, int64_neon_arm64.s, float64_neon_arm64.s) were generated by asm2plan9s. |
| 48 |
# And manually formatted them as the Arm64 Plan9. |
| 49 |
# |
| 50 |
assembly: $(INTEL_SOURCES) |
| 51 |
|
| 52 |
generate: ../bin/tmpl |
| 53 |
../bin/tmpl -i -data=float64.tmpldata type.go.tmpl=float64.go type_amd64.go.tmpl=float64_amd64.go type_arm64.go.tmpl=float64_arm64.go type_ppc64le.go.tmpl=float64_ppc64le.go type_s390x.go.tmpl=float64_s390x.go type_noasm.go.tmpl=float64_noasm.go type_test.go.tmpl=float64_test.go |
| 54 |
../bin/tmpl -i -data=float64.tmpldata -d arch=avx2 type_simd_amd64.go.tmpl=float64_avx2_amd64.go |
| 55 |
../bin/tmpl -i -data=float64.tmpldata -d arch=sse4 type_simd_amd64.go.tmpl=float64_sse4_amd64.go |
| 56 |
../bin/tmpl -i -data=float64.tmpldata -d arch=neon type_simd_arm64.go.tmpl=float64_neon_arm64.go |
| 57 |
../bin/tmpl -i -data=int64.tmpldata type.go.tmpl=int64.go type_amd64.go.tmpl=int64_amd64.go type_arm64.go.tmpl=int64_arm64.go type_ppc64le.go.tmpl=int64_ppc64le.go type_s390x.go.tmpl=int64_s390x.go type_noasm.go.tmpl=int64_noasm.go type_test.go.tmpl=int64_test.go |
| 58 |
../bin/tmpl -i -data=int64.tmpldata -d arch=avx2 type_simd_amd64.go.tmpl=int64_avx2_amd64.go |
| 59 |
../bin/tmpl -i -data=int64.tmpldata -d arch=sse4 type_simd_amd64.go.tmpl=int64_sse4_amd64.go |
| 60 |
../bin/tmpl -i -data=int64.tmpldata -d arch=neon type_simd_arm64.go.tmpl=int64_neon_arm64.go |
| 61 |
../bin/tmpl -i -data=uint64.tmpldata type.go.tmpl=uint64.go type_amd64.go.tmpl=uint64_amd64.go type_arm64.go.tmpl=uint64_arm64.go type_ppc64le.go.tmpl=uint64_ppc64le.go type_s390x.go.tmpl=uint64_s390x.go type_noasm.go.tmpl=uint64_noasm.go type_test.go.tmpl=uint64_test.go |
| 62 |
../bin/tmpl -i -data=uint64.tmpldata -d arch=avx2 type_simd_amd64.go.tmpl=uint64_avx2_amd64.go |
| 63 |
../bin/tmpl -i -data=uint64.tmpldata -d arch=sse4 type_simd_amd64.go.tmpl=uint64_sse4_amd64.go |
| 64 |
../bin/tmpl -i -data=uint64.tmpldata -d arch=neon type_simd_arm64.go.tmpl=uint64_neon_arm64.go |
| 65 |
|
| 66 |
_lib/float64_avx2.s: _lib/float64.c |
| 67 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_AVX2) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 68 |
|
| 69 |
_lib/float64_sse4.s: _lib/float64.c |
| 70 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_SSE4) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 71 |
|
| 72 |
_lib/float64_neon.s: _lib/float64.c |
| 73 |
$(CC) -S $(C_FLAGS_NEON) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 74 |
|
| 75 |
float64_avx2_amd64.s: _lib/float64_avx2.s |
| 76 |
$(C2GOASM) -a -f $^ $@ |
| 77 |
|
| 78 |
float64_sse4_amd64.s: _lib/float64_sse4.s |
| 79 |
$(C2GOASM) -a -f $^ $@ |
| 80 |
|
| 81 |
_lib/int64_avx2.s: _lib/int64.c |
| 82 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_AVX2) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 83 |
|
| 84 |
_lib/int64_sse4.s: _lib/int64.c |
| 85 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_SSE4) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 86 |
|
| 87 |
_lib/int64_neon.s: _lib/int64.c |
| 88 |
$(CC) -S $(C_FLAGS_NEON) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 89 |
|
| 90 |
int64_avx2_amd64.s: _lib/int64_avx2.s |
| 91 |
$(C2GOASM) -a -f $^ $@ |
| 92 |
|
| 93 |
int64_sse4_amd64.s: _lib/int64_sse4.s |
| 94 |
$(C2GOASM) -a -f $^ $@ |
| 95 |
|
| 96 |
_lib/uint64_avx2.s: _lib/uint64.c |
| 97 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_AVX2) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 98 |
|
| 99 |
_lib/uint64_sse4.s: _lib/uint64.c |
| 100 |
$(CC) -S $(C_FLAGS) $(ASM_FLAGS_SSE4) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 101 |
|
| 102 |
_lib/uint64_neon.s: _lib/uint64.c |
| 103 |
$(CC) -S $(C_FLAGS_NEON) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@ |
| 104 |
|
| 105 |
uint64_avx2_amd64.s: _lib/uint64_avx2.s |
| 106 |
$(C2GOASM) -a -f $^ $@ |
| 107 |
|
| 108 |
uint64_sse4_amd64.s: _lib/uint64_sse4.s |
| 109 |
$(C2GOASM) -a -f $^ $@ |
| 110 |
|