Skip to content

Commit

Permalink
Export jl_test_cpu_feature and generate Julia list of CPU features
Browse files Browse the repository at this point in the history
Co-authored-by: Elliot Saba <[email protected]>
  • Loading branch information
giordano and staticfloat committed Sep 16, 2020
1 parent 608592c commit f40dbbd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions base/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/features_h.jl
/pcre_h.jl
/errno_h.jl
/build_h.jl
Expand Down
15 changes: 14 additions & 1 deletion base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
CPP_STDOUT := $(CPP) -E
endif

all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony file_constants.jl uv_constants.jl version_git.jl.phony)
all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony)

PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\)
ifeq ($(USE_SYSTEM_PCRE), 1)
Expand All @@ -21,6 +21,18 @@ else
PCRE_INCL_PATH := $(build_includedir)/pcre2.h
endif

define parse_features
@echo "# $(2) features" >> $@
@$(call PRINT_PERL, cat ../src/features_$(1).h | perl -lne 'print "const JL_$(2)_$$1 = UInt32($$2)" if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@)
@echo >> $@
endef

$(BUILDDIR)/features_h.jl: ../src/features_x86.h ../src/features_aarch32.h ../src/features_aarch64.h
@-rm -f $@
@$(call parse_features,x86,X86)
@$(call parse_features,aarch32,AArch32)
@$(call parse_features,aarch64,AArch64)

$(BUILDDIR)/pcre_h.jl: $(PCRE_INCL_PATH)
@$(call PRINT_PERL, $(CPP) -D PCRE2_CODE_UNIT_WIDTH=8 -dM $< | perl -nle '/^\s*#define\s+PCRE2_(\w*)\s*\(?($(PCRE_CONST))\)?u?\s*$$/ and print index($$1, "ERROR_") == 0 ? "const $$1 = Cint($$2)" : "const $$1 = UInt32($$2)"' | LC_ALL=C sort > $@)

Expand Down Expand Up @@ -236,6 +248,7 @@ clean:
-rm -f $(BUILDDIR)/errno_h.jl
-rm -f $(BUILDDIR)/build_h.jl
-rm -f $(BUILDDIR)/build_h.jl.phony
-rm -f $(BUILDDIR)/features_h.jl
-rm -f $(BUILDDIR)/uv_constants.jl
-rm -f $(BUILDDIR)/file_constants.jl
-rm -f $(BUILDDIR)/version_git.jl
Expand Down
2 changes: 1 addition & 1 deletion src/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef enum {
} jl_cpu_feature_t;
#undef JL_FEATURE_DEF_NAME

int jl_test_cpu_feature(jl_cpu_feature_t feature);
JL_DLLEXPORT int jl_test_cpu_feature(jl_cpu_feature_t feature);

static const uint32_t jl_sysimg_tag_mask = 0x80000000u;
static const uint32_t jl_sysimg_val_mask = ~((uint32_t)0x80000000u);
Expand Down

0 comments on commit f40dbbd

Please sign in to comment.