Skip to content

Commit

Permalink
Add ability to get CPU features
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Jul 4, 2023
1 parent 1986920 commit 7e02bf4
Show file tree
Hide file tree
Showing 25 changed files with 865 additions and 7 deletions.
29 changes: 26 additions & 3 deletions gcc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ tm_p_file_list=@tm_p_file_list@
tm_p_include_list=@tm_p_include_list@
tm_d_file_list=@tm_d_file_list@
tm_d_include_list=@tm_d_include_list@
tm_jit_file_list=@tm_jit_file_list@
tm_jit_include_list=@tm_jit_include_list@
build_xm_file_list=@build_xm_file_list@
build_xm_include_list=@build_xm_include_list@
build_xm_defines=@build_xm_defines@
Expand Down Expand Up @@ -868,6 +870,7 @@ CONFIG_H = config.h $(host_xm_file_list)
TCONFIG_H = tconfig.h $(xm_file_list)
TM_P_H = tm_p.h $(tm_p_file_list)
TM_D_H = tm_d.h $(tm_d_file_list)
TM_JIT_H = tm_jit.h $(tm_jit_file_list)
GTM_H = tm.h $(tm_file_list) insn-constants.h
TM_H = $(GTM_H) insn-flags.h $(OPTIONS_H)

Expand Down Expand Up @@ -926,10 +929,12 @@ TARGET_DEF = target.def target-hooks-macros.h target-insns.def
C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
D_TARGET_DEF = d/d-target.def target-hooks-macros.h
JIT_TARGET_DEF = jit/jit-target.def target-hooks-macros.h
TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
COMMON_TARGET_H = common/common-target.h $(INPUT_H) $(COMMON_TARGET_DEF)
D_TARGET_H = d/d-target.h $(D_TARGET_DEF)
JIT_TARGET_H = jit/jit-target.h $(JIT_TARGET_DEF)
MACHMODE_H = machmode.h mode-classes.def
HOOKS_H = hooks.h
HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
Expand Down Expand Up @@ -1230,6 +1235,9 @@ CXX_TARGET_OBJS=@cxx_target_objs@
# Target specific, D specific object file
D_TARGET_OBJS=@d_target_objs@

# Target specific, JIT specific object file
JIT_TARGET_OBJS=@jit_target_objs@

# Target specific, Fortran specific object file
FORTRAN_TARGET_OBJS=@fortran_target_objs@

Expand Down Expand Up @@ -1947,6 +1955,7 @@ tconfig.h: cs-tconfig.h ; @true
tm.h: cs-tm.h ; @true
tm_p.h: cs-tm_p.h ; @true
tm_d.h: cs-tm_d.h ; @true
tm_jit.h: cs-tm_jit.h ; @true

cs-config.h: Makefile
TARGET_CPU_DEFAULT="" \
Expand Down Expand Up @@ -1978,6 +1987,11 @@ cs-tm_d.h: Makefile
HEADERS="$(tm_d_include_list)" DEFINES="" \
$(SHELL) $(srcdir)/mkconfig.sh tm_d.h

cs-tm_jit.h: Makefile
TARGET_CPU_DEFAULT="" \
HEADERS="$(tm_jit_include_list)" DEFINES="" \
$(SHELL) $(srcdir)/mkconfig.sh tm_jit.h

# Don't automatically run autoconf, since configure.ac might be accidentally
# newer than configure. Also, this writes into the source directory which
# might be on a read-only file system. If configured for maintainer mode
Expand Down Expand Up @@ -2619,6 +2633,15 @@ s-d-target-hooks-def-h: build/genhooks$(build_exeext)
d/d-target-hooks-def.h
$(STAMP) s-d-target-hooks-def-h

jit/jit-target-hooks-def.h: s-jit-target-hooks-def-h; @true

s-jit-target-hooks-def-h: build/genhooks$(build_exeext)
$(RUN_GEN) build/genhooks$(build_exeext) "JIT Target Hook" \
> tmp-jit-target-hooks-def.h
$(SHELL) $(srcdir)/../move-if-change tmp-jit-target-hooks-def.h \
jit/jit-target-hooks-def.h
$(STAMP) s-jit-target-hooks-def-h

# check if someone mistakenly only changed tm.texi.
# We use a different pathname here to avoid a circular dependency.
s-tm-texi: $(srcdir)/doc/../doc/tm.texi
Expand Down Expand Up @@ -2794,7 +2817,7 @@ s-gtype: $(EXTRA_GTYPE_DEPS) build/gengtype$(build_exeext) \
-r gtype.state
$(STAMP) s-gtype

generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_JIT_H) $(TM_H) multilib.h \
$(simple_generated_h) specs.h \
tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \
tm-preds.h tm-constrs.h \
Expand All @@ -2803,7 +2826,7 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
common/common-target-hooks-def.h pass-instances.def \
gimple-match.cc generic-match.cc \
c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
case-cfn-macros.h \
jit/jit-target-hooks-def.h case-cfn-macros.h \
cfn-operators.pd omp-device-properties.h

#
Expand Down Expand Up @@ -2937,7 +2960,7 @@ build/genrecog.o : genrecog.cc $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) \
$(HASH_TABLE_H) inchash.h
build/genhooks.o : genhooks.cc $(TARGET_DEF) $(C_TARGET_DEF) \
$(COMMON_TARGET_DEF) $(D_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
$(COMMON_TARGET_DEF) $(D_TARGET_DEF) $(JIT_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
build/genmddump.o : genmddump.cc $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
build/genmatch.o : genmatch.cc $(BCONFIG_H) $(SYSTEM_H) \
Expand Down
56 changes: 56 additions & 0 deletions gcc/config.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
# d_target_objs List of extra target-dependent objects that be
# linked into the D compiler only.
#
# jit_target_objs List of extra target-dependent objects that be
# linked into the jit compiler only.
#
# fortran_target_objs List of extra target-dependent objects that be
# linked into the fortran compiler only.
#
Expand Down Expand Up @@ -201,6 +204,9 @@
#
# target_has_targetdm Set to yes or no depending on whether the target
# has its own definition of targetdm.
#
# target_has_targetjitm Set to yes or no depending on whether the target
# has its own definition of targetdm.

out_file=
common_out_file=
Expand All @@ -217,10 +223,12 @@ extra_options=
c_target_objs=
cxx_target_objs=
d_target_objs=
jit_target_objs=
fortran_target_objs=
target_has_targetcm=no
target_has_targetm_common=yes
target_has_targetdm=no
target_has_targetjitm=no
tm_defines=
xm_defines=
# Set this to force installation and use of collect2.
Expand Down Expand Up @@ -338,6 +346,7 @@ aarch64*-*-*)
c_target_objs="aarch64-c.o"
cxx_target_objs="aarch64-c.o"
d_target_objs="aarch64-d.o"
#jit_target_objs="aarch64-jit.o"
extra_objs="aarch64-builtins.o aarch-common.o aarch64-sve-builtins.o aarch64-sve-builtins-shapes.o aarch64-sve-builtins-base.o aarch64-sve-builtins-sve2.o cortex-a57-fma-steering.o aarch64-speculation.o falkor-tag-collision-avoidance.o aarch64-bti-insert.o aarch64-cc-fusion.o"
target_gtfiles="\$(srcdir)/config/aarch64/aarch64-builtins.cc \$(srcdir)/config/aarch64/aarch64-sve-builtins.h \$(srcdir)/config/aarch64/aarch64-sve-builtins.cc"
target_has_targetm_common=yes
Expand Down Expand Up @@ -368,6 +377,7 @@ arm*-*-*)
c_target_objs="arm-c.o"
cxx_target_objs="arm-c.o"
d_target_objs="arm-d.o"
#jit_target_objs="arm-jit.o"
extra_options="${extra_options} arm/arm-tables.opt"
target_gtfiles="\$(srcdir)/config/arm/arm-builtins.cc \$(srcdir)/config/arm/arm-mve-builtins.h \$(srcdir)/config/arm/arm-mve-builtins.cc"
;;
Expand Down Expand Up @@ -401,6 +411,7 @@ i[34567]86-*-* | x86_64-*-*)
c_target_objs="i386-c.o"
cxx_target_objs="i386-c.o"
d_target_objs="i386-d.o"
jit_target_objs="i386-jit.o"
extra_objs="x86-tune-sched.o x86-tune-sched-bd.o x86-tune-sched-atom.o x86-tune-sched-core.o i386-options.o i386-builtins.o i386-expand.o i386-features.o"
target_gtfiles="\$(srcdir)/config/i386/i386-builtins.cc \$(srcdir)/config/i386/i386-expand.cc \$(srcdir)/config/i386/i386-options.cc"
extra_options="${extra_options} fused-madd.opt"
Expand Down Expand Up @@ -462,6 +473,7 @@ microblaze*-*-*)
mips*-*-*)
cpu_type=mips
d_target_objs="mips-d.o"
#jit_target_objs="mips-jit.o"
extra_headers="loongson.h loongson-mmiintrin.h msa.h"
extra_objs="frame-header-opt.o"
extra_options="${extra_options} g.opt fused-madd.opt mips/mips-tables.opt"
Expand Down Expand Up @@ -532,6 +544,7 @@ riscv*)
extra_objs="riscv-builtins.o riscv-c.o riscv-sr.o riscv-shorten-memrefs.o riscv-selftests.o riscv-v.o riscv-vsetvl.o"
extra_objs="${extra_objs} riscv-vector-builtins.o riscv-vector-builtins-shapes.o riscv-vector-builtins-bases.o"
d_target_objs="riscv-d.o"
#jit_target_objs="riscv-jit.o"
extra_headers="riscv_vector.h"
target_gtfiles="$target_gtfiles \$(srcdir)/config/riscv/riscv-vector-builtins.cc"
target_gtfiles="$target_gtfiles \$(srcdir)/config/riscv/riscv-vector-builtins.h"
Expand All @@ -548,11 +561,13 @@ sparc*-*-*)
c_target_objs="sparc-c.o"
cxx_target_objs="sparc-c.o"
d_target_objs="sparc-d.o"
#jit_target_objs="sparc-jit.o"
extra_headers="visintrin.h"
;;
s390*-*-*)
cpu_type=s390
d_target_objs="s390-d.o"
#jit_target_objs="s390-jit.o"
extra_options="${extra_options} fused-madd.opt"
extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
;;
Expand Down Expand Up @@ -588,6 +603,12 @@ then
tm_d_file="${tm_d_file} ${cpu_type}/${cpu_type}-d.h"
fi

tm_jit_file=
if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-jit.h
then
tm_jit_file="${tm_jit_file} ${cpu_type}/${cpu_type}-jit.h"
fi

extra_modes=
if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-modes.def
then
Expand Down Expand Up @@ -754,9 +775,11 @@ case ${target} in
c_target_objs="${c_target_objs} darwin-c.o"
cxx_target_objs="${cxx_target_objs} darwin-c.o"
d_target_objs="${d_target_objs} darwin-d.o"
#jit_target_objs="${jit_target_objs} darwin-jit.o"
fortran_target_objs="darwin-f.o"
target_has_targetcm=yes
target_has_targetdm=yes
#target_has_targetjitm=yes
extra_objs="${extra_objs} darwin.o"
extra_gcc_objs="darwin-driver.o"
default_use_cxa_atexit=yes
Expand Down Expand Up @@ -785,8 +808,10 @@ case ${target} in
default_use_cxa_atexit=yes
use_gcc_stdint=wrap
d_target_objs="${d_target_objs} dragonfly-d.o"
#jit_target_objs="${jit_target_objs} dragonfly-jit.o"
tmake_file="${tmake_file} t-dragonfly"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
Expand Down Expand Up @@ -836,8 +861,10 @@ case ${target} in
esac
use_gcc_stdint=wrap
d_target_objs="${d_target_objs} freebsd-d.o"
#jit_target_objs="${jit_target_objs} freebsd-jit.o"
tmake_file="${tmake_file} t-freebsd"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-fuchsia*)
native_system_header_dir=/include
Expand Down Expand Up @@ -910,19 +937,27 @@ case ${target} in
case $target in
*-*-*linux*)
d_target_objs="${d_target_objs} linux-d.o"
jit_target_objs="${jit_target_objs} linux-jit.o"
target_has_targetdm=yes
target_has_targetjitm=yes
;;
*-*-kfreebsd*-gnu)
d_target_objs="${d_target_objs} kfreebsd-d.o"
#jit_target_objs="${jit_target_objs} kfreebsd-jit.o"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-kopensolaris*-gnu)
d_target_objs="${d_target_objs} kopensolaris-d.o"
#jit_target_objs="${jit_target_objs} kopensolaris-jit.o"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-gnu*)
d_target_objs="${d_target_objs} gnu-d.o"
#jit_target_objs="${jit_target_objs} gnu-jit.o"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
esac
;;
Expand All @@ -931,6 +966,7 @@ case ${target} in
tmake_file="t-netbsd t-slibgcc"
extra_objs="${extra_objs} netbsd.o"
d_target_objs="${d_target_objs} netbsd-d.o"
#jit_target_objs="${jit_target_objs} netbsd-jit.o"
gas=yes
gnu_ld=yes
use_gcc_stdint=wrap
Expand All @@ -940,6 +976,7 @@ case ${target} in
nbsd_tm_file="netbsd.h netbsd-stdint.h netbsd-elf.h"
default_use_cxa_atexit=yes
target_has_targetdm=yes
#target_has_targetjitm=yes
case ${target} in
arm*-* | i[34567]86-* | powerpc*-* | sparc*-* | x86_64-*)
default_gnu_indirect_function=yes
Expand All @@ -959,7 +996,9 @@ case ${target} in
;;
esac
d_target_objs="${d_target_objs} openbsd-d.o"
#jit_target_objs="${jit_target_objs} openbsd-jit.o"
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-phoenix*)
gas=yes
Expand Down Expand Up @@ -1016,6 +1055,7 @@ case ${target} in
c_target_objs="${c_target_objs} sol2-c.o"
cxx_target_objs="${cxx_target_objs} sol2-c.o sol2-cxx.o"
d_target_objs="${d_target_objs} sol2-d.o"
#jit_target_objs="${jit_target_objs} sol2-jit.o"
extra_objs="${extra_objs} sol2.o sol2-stubs.o"
extra_options="${extra_options} sol2.opt"
case ${enable_threads}:${have_pthread_h}:${have_thread_h} in
Expand All @@ -1024,6 +1064,7 @@ case ${target} in
;;
esac
target_has_targetdm=yes
#target_has_targetjitm=yes
;;
*-*-*vms*)
extra_options="${extra_options} vms/vms.opt"
Expand Down Expand Up @@ -1760,6 +1801,7 @@ hppa*64*-*-linux*)
pa/pa64-linux.h"
tmake_file="${tmake_file} pa/t-pa pa/t-linux"
d_target_objs="${d_target_objs} pa-d.o"
#jit_target_objs="${jit_target_objs} pa-jit.o"
gas=yes gnu_ld=yes
;;
hppa*-*-linux*)
Expand All @@ -1768,6 +1810,7 @@ hppa*-*-linux*)
pa/pa32-regs.h pa/pa32-linux.h"
tmake_file="${tmake_file} pa/t-pa pa/t-linux"
d_target_objs="${d_target_objs} pa-d.o"
#jit_target_objs="${jit_target_objs} pa-jit.o"
;;
hppa*-*-openbsd*)
target_cpu_default="MASK_PA_11"
Expand All @@ -1776,6 +1819,7 @@ hppa*-*-openbsd*)
extra_options="${extra_options} openbsd.opt"
tmake_file="pa/t-pa"
d_target_objs="${d_target_objs} pa-d.o"
#jit_target_objs="${jit_target_objs} pa-jit.o"
gas=yes
gnu_ld=yes
;;
Expand Down Expand Up @@ -1813,6 +1857,7 @@ hppa*64*-*-hpux11*)
pa/pa-hpux1010.opt pa/pa64-hpux.opt hpux11.opt"
tmake_file="pa/t-pa t-slibgcc"
d_target_objs="${d_target_objs} pa-d.o"
#jit_target_objs="${jit_target_objs} pa-jit.o"
case x${enable_threads} in
x | xyes | xposix )
thread_file=posix
Expand Down Expand Up @@ -2086,7 +2131,9 @@ i[34567]86-*-cygwin*)
c_target_objs="${c_target_objs} msformat-c.o"
cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
d_target_objs="${d_target_objs} cygwin-d.o"
#jit_target_objs="${jit_target_objs} cygwin-jit.o"
target_has_targetdm="yes"
#target_has_targetjitm=yes
if test x$enable_threads = xyes; then
thread_file='posix'
fi
Expand All @@ -2104,7 +2151,9 @@ x86_64-*-cygwin*)
c_target_objs="${c_target_objs} msformat-c.o"
cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
d_target_objs="${d_target_objs} cygwin-d.o"
#jit_target_objs="${jit_target_objs} cygwin-jit.o"
target_has_targetdm="yes"
#target_has_targetjitm=yes
if test x$enable_threads = xyes; then
thread_file='posix'
fi
Expand All @@ -2118,8 +2167,10 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
c_target_objs="${c_target_objs} winnt-c.o"
cxx_target_objs="${cxx_target_objs} winnt-c.o"
d_target_objs="${d_target_objs} winnt-d.o"
#jit_target_objs="${jit_target_objs} winnt-jit.o"
target_has_targetcm="yes"
target_has_targetdm="yes"
#target_has_targetjitm=yes
case ${target} in
x86_64-*-* | *-w64-*)
need_64bit_isa=yes
Expand Down Expand Up @@ -3582,6 +3633,10 @@ if [ "$target_has_targetdm" = "no" ]; then
d_target_objs="$d_target_objs default-d.o"
fi

if [ "$target_has_targetjitm" = "no" ]; then
jit_target_objs="$jit_target_objs default-jit.o"
fi

# Support for --with-cpu and related options (and a few unrelated options,
# too).
case ${with_cpu} in
Expand Down Expand Up @@ -5752,6 +5807,7 @@ case ${target} in
c_target_objs="${c_target_objs} ${cpu_type}-c.o"
cxx_target_objs="${cxx_target_objs} ${cpu_type}-c.o"
d_target_objs="${d_target_objs} ${cpu_type}-d.o"
jit_target_objs="${jit_target_objs} ${cpu_type}-jit.o"
tmake_file="${cpu_type}/t-${cpu_type} ${tmake_file}"
;;

Expand Down
Loading

0 comments on commit 7e02bf4

Please sign in to comment.