...
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
17PERL_FIXUP_ROTATE=perl -i -pe 's/(ro[rl]\s+\w{2,3})$$/\1, 1/'
18# since we're passing an int16, swap the MOVQ for the argument to a MOVW as per
19# the message given by go vet since it's a 2-byte value.
20PERL_FIXUP_MOVQ_MOVW=perl -i -pe 's/MOVQ rhs\+16\(FP\)/MOVW rhs+16(FP)/'
21C2GOASM=c2goasm -a -f
22CC=clang
23C_FLAGS=-masm=intel -mno-red-zone -mstackrealign -mllvm -inline-threshold=1000 \
24 -fno-asynchronous-unwind-tables -fno-exceptions -fno-rtti -O3 -fno-builtin -ffast-math -fno-jump-tables -I_lib
25ASM_FLAGS_AVX2=-mavx2 -mfma
26ASM_FLAGS_BMI2=-mbmi2
27ASM_FLAGS_POPCNT=-mpopcnt
28
29GO_SOURCES := $(shell find . -path ./_lib -prune -o -name '*.go' -not -name '*_test.go')
30ALL_SOURCES := $(shell find . -path ./_lib -prune -o -name '*.go' -name '*.s' -not -name '*_test.go')
31
32INTEL_SOURCES := \
33 bitmap_bmi2.s
34
35.PHONEY: assembly
36
37assembly: $(INTEL_SOURCES)
38
39_lib/bitmap_bmi2.s: _lib/bitmap_bmi2.c
40 $(CC) -S $(ASM_FLAGS_AVX2) $(ASM_FLAGS_BMI2) $(ASM_FLAGS_POPCNT) $(C_FLAGS) $^ -o $@ ; $(PERL_FIXUP_ROTATE) $@
41
42bitmap_bmi2.s: _lib/bitmap_bmi2.s
43 $(C2GOASM) $^ $@ ; $(PERL_FIXUP_MOVQ_MOVW) $@
44
45clean:
46 rm -f $(INTEL_SOURCES)
47 rm -f _lib/$(INTEL_SOURCES)
View as plain text