2016-04-08 11:14:23 +00:00
|
|
|
#
|
2024-02-26 15:43:47 +00:00
|
|
|
# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
2016-04-08 11:14:23 +00:00
|
|
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
#
|
|
|
|
# This code is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License version 2 only, as
|
|
|
|
# published by the Free Software Foundation. Oracle designates this
|
|
|
|
# particular file as subject to the "Classpath" exception as provided
|
|
|
|
# by Oracle in the LICENSE file that accompanied this code.
|
|
|
|
#
|
|
|
|
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
# accompanied this code).
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License version
|
|
|
|
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
# or visit www.oracle.com if you need additional information or have any
|
|
|
|
# questions.
|
|
|
|
#
|
|
|
|
|
2017-10-05 10:41:06 +00:00
|
|
|
$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcAdlc.gmk))
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
ifeq ($(call check-jvm-feature, compiler2), true)
|
|
|
|
|
|
|
|
ADLC_SUPPORT_DIR := $(JVM_SUPPORT_DIR)/adlc
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Build the ad compiler (the adlc build tool)
|
|
|
|
|
|
|
|
# Flags depending on the build platform/tool chain
|
|
|
|
# NOTE: No optimization or debug flags set here
|
2019-02-07 11:35:45 +00:00
|
|
|
ifeq ($(call isBuildOs, linux), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
ADLC_CFLAGS := -fno-exceptions -DLINUX
|
2019-02-07 11:35:45 +00:00
|
|
|
else ifeq ($(call isBuildOs, aix), true)
|
2023-05-11 07:40:38 +00:00
|
|
|
ifeq ($(TOOLCHAIN_TYPE), clang)
|
|
|
|
ADLC_LDFLAGS += -m64
|
2023-05-12 07:02:45 +00:00
|
|
|
ADLC_CFLAGS := -fno-rtti -fexceptions -ffunction-sections -m64 -DAIX -mcpu=pwr8
|
2023-05-11 07:40:38 +00:00
|
|
|
else
|
|
|
|
ADLC_LDFLAGS += -q64
|
|
|
|
ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX
|
|
|
|
endif
|
2019-02-07 11:35:45 +00:00
|
|
|
else ifeq ($(call isBuildOs, windows), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
ADLC_CFLAGS := -nologo -EHsc
|
|
|
|
ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS
|
|
|
|
endif
|
|
|
|
|
2020-07-22 04:13:53 +00:00
|
|
|
# Set the C++ standard
|
2024-02-06 06:56:48 +00:00
|
|
|
ADLC_CFLAGS += $(ADLC_LANGSTD_CXXFLAGS)
|
2018-02-28 20:16:11 +00:00
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
# NOTE: The old build didn't set -DASSERT for windows but it doesn't seem to
|
|
|
|
# hurt.
|
|
|
|
ADLC_CFLAGS += -DASSERT
|
|
|
|
|
|
|
|
ADLC_CFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)
|
|
|
|
|
2017-09-12 17:03:56 +00:00
|
|
|
ADLC_CFLAGS += -I$(TOPDIR)/src/hotspot/share
|
2016-04-08 11:14:23 +00:00
|
|
|
|
2022-04-06 19:11:49 +00:00
|
|
|
# Add file macro mappings
|
2023-09-20 12:48:19 +00:00
|
|
|
ADLC_CFLAGS += $(FILE_MACRO_CFLAGS) $(REPRODUCIBLE_CFLAGS)
|
2022-04-06 19:11:49 +00:00
|
|
|
|
2023-01-13 04:07:42 +00:00
|
|
|
ifeq ($(UBSAN_ENABLED), true)
|
|
|
|
ADLC_CFLAGS += $(UBSAN_CFLAGS)
|
|
|
|
ADLC_LDFLAGS += $(UBSAN_LDFLAGS)
|
|
|
|
endif
|
|
|
|
|
2024-04-05 08:37:41 +00:00
|
|
|
##############################################################################
|
|
|
|
## Build adlc
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
$(eval $(call SetupJdkExecutable, BUILD_ADLC, \
|
2018-02-28 20:16:11 +00:00
|
|
|
NAME := adlc, \
|
2024-02-27 11:14:11 +00:00
|
|
|
TARGET_TYPE := BUILD, \
|
|
|
|
LINK_TYPE := C++, \
|
2017-09-12 17:03:56 +00:00
|
|
|
SRC := $(TOPDIR)/src/hotspot/share/adlc, \
|
|
|
|
EXTRA_FILES := $(TOPDIR)/src/hotspot/share/opto/opcodes.cpp, \
|
2024-04-05 08:37:41 +00:00
|
|
|
DEFAULT_CFLAGS := false, \
|
2016-04-08 11:14:23 +00:00
|
|
|
CFLAGS := $(ADLC_CFLAGS) $(ADLC_CFLAGS_WARNINGS), \
|
2024-04-05 08:37:41 +00:00
|
|
|
DEFAULT_LDFLAGS := false, \
|
2016-04-08 11:14:23 +00:00
|
|
|
LDFLAGS := $(ADLC_LDFLAGS), \
|
|
|
|
LIBS := $(ADLC_LIBS), \
|
2024-04-05 08:37:41 +00:00
|
|
|
DEFAULT_VERSIONINFO_RESOURCE := false, \
|
2016-04-08 11:14:23 +00:00
|
|
|
OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc/objs, \
|
|
|
|
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
|
|
|
|
DEBUG_SYMBOLS := false, \
|
2017-07-05 23:50:26 +00:00
|
|
|
DISABLED_WARNINGS_clang := tautological-compare, \
|
2016-04-08 11:14:23 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
ADLC_TOOL := $(BUILD_ADLC_TARGET)
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Transform the ad source files into C++ source files using adlc
|
|
|
|
|
|
|
|
# Setup flags for the adlc build tool (ADLCFLAGS).
|
|
|
|
ADLCFLAGS += -q -T
|
|
|
|
|
|
|
|
# ADLC flags depending on target OS
|
2019-02-07 11:35:45 +00:00
|
|
|
ifeq ($(call isTargetOs, linux), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1
|
2019-02-07 11:35:45 +00:00
|
|
|
else ifeq ($(call isTargetOs, aix), true)
|
2016-04-13 09:13:14 +00:00
|
|
|
ADLCFLAGS += -DAIX=1
|
2019-02-07 11:35:45 +00:00
|
|
|
else ifeq ($(call isTargetOs, macosx), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1
|
2021-03-25 18:10:18 +00:00
|
|
|
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)
|
|
|
|
ADLCFLAGS += -DR18_RESERVED
|
|
|
|
endif
|
2020-10-05 03:21:39 +00:00
|
|
|
else ifeq ($(call isTargetOs, windows), true)
|
2024-11-13 09:41:57 +00:00
|
|
|
ADLCFLAGS += -D_WIN64=1
|
2020-10-05 03:21:39 +00:00
|
|
|
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)
|
|
|
|
ADLCFLAGS += -DR18_RESERVED
|
|
|
|
endif
|
2016-04-08 11:14:23 +00:00
|
|
|
endif
|
|
|
|
|
2019-02-07 11:35:45 +00:00
|
|
|
ifeq ($(call isTargetOs, windows), false)
|
2016-04-08 11:14:23 +00:00
|
|
|
# NOTE: Windows adlc flags was different in the old build. Is this really
|
|
|
|
# correct?
|
|
|
|
|
|
|
|
# -g makes #line directives in the generated C++ files.
|
|
|
|
ADLCFLAGS += -g
|
|
|
|
|
|
|
|
ADLCFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
# This generates checks in the generated C++ files that _LP64 is correctly
|
|
|
|
# (un)defined when compiling them.
|
2019-02-07 11:35:45 +00:00
|
|
|
ifeq ($(call isTargetCpuBits, 64), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
ADLCFLAGS += -D_LP64=1
|
|
|
|
else
|
|
|
|
ADLCFLAGS += -U_LP64
|
|
|
|
endif
|
|
|
|
|
2016-12-19 17:39:01 +00:00
|
|
|
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
|
|
|
|
ADLCFLAGS += -DARM=1
|
|
|
|
endif
|
|
|
|
|
2023-10-17 07:14:11 +00:00
|
|
|
# Set ASSERT, NDEBUG and PRODUCT flags just like in JvmFlags.gmk
|
|
|
|
ifeq ($(DEBUG_LEVEL), release)
|
|
|
|
# release builds disable uses of assert macro from <assert.h>.
|
|
|
|
ADLCFLAGS += -DNDEBUG
|
|
|
|
# For hotspot, release builds differ internally between "optimized" and "product"
|
|
|
|
# in that "optimize" does not define PRODUCT.
|
|
|
|
ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
|
|
|
|
ADLCFLAGS += -DPRODUCT
|
|
|
|
endif
|
|
|
|
else ifeq ($(DEBUG_LEVEL), fastdebug)
|
|
|
|
ADLCFLAGS += -DASSERT
|
|
|
|
else ifeq ($(DEBUG_LEVEL), slowdebug)
|
|
|
|
ADLCFLAGS += -DASSERT
|
|
|
|
endif
|
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
##############################################################################
|
|
|
|
# Concatenate all ad source files into a single file, which will be fed to
|
|
|
|
# adlc. Also include a #line directive at the start of every included file
|
|
|
|
# (after the initial header block), stating the original source file name.
|
|
|
|
#
|
|
|
|
# Normally, debugging is done directly on the ad_<arch>*.cpp files, but the
|
|
|
|
# #line directives in those files will be pointing back to <arch>.ad.
|
|
|
|
|
|
|
|
# AD_SRC_ROOTS might have been added to by a custom extension
|
2017-09-12 17:03:56 +00:00
|
|
|
AD_SRC_ROOTS += $(TOPDIR)/src/hotspot
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
AD_SRC_FILES := $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
2017-09-12 17:03:56 +00:00
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU).ad \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH).ad \
|
|
|
|
$d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH).ad \
|
2016-04-08 11:14:23 +00:00
|
|
|
)))
|
|
|
|
|
2020-09-02 01:45:44 +00:00
|
|
|
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)
|
|
|
|
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
2022-08-17 03:51:46 +00:00
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH)_vector.ad \
|
2020-09-02 01:45:44 +00:00
|
|
|
)))
|
|
|
|
endif
|
|
|
|
|
2022-03-24 09:22:46 +00:00
|
|
|
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), riscv)
|
|
|
|
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH)_v.ad \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH)_b.ad \
|
|
|
|
)))
|
|
|
|
endif
|
|
|
|
|
2018-12-10 14:47:44 +00:00
|
|
|
ifeq ($(call check-jvm-feature, shenandoahgc), true)
|
|
|
|
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/shenandoah/shenandoah_$(HOTSPOT_TARGET_CPU).ad \
|
2021-11-18 19:00:58 +00:00
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/shenandoah/shenandoah_$(HOTSPOT_TARGET_CPU_ARCH).ad \
|
2018-12-10 14:47:44 +00:00
|
|
|
)))
|
|
|
|
endif
|
|
|
|
|
2019-01-29 09:23:38 +00:00
|
|
|
ifeq ($(call check-jvm-feature, zgc), true)
|
|
|
|
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/z/z_$(HOTSPOT_TARGET_CPU).ad \
|
2021-10-13 07:36:52 +00:00
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/z/z_$(HOTSPOT_TARGET_CPU_ARCH).ad \
|
2019-01-29 09:23:38 +00:00
|
|
|
)))
|
|
|
|
endif
|
|
|
|
|
2024-10-03 08:36:33 +00:00
|
|
|
ifeq ($(call check-jvm-feature, g1gc), true)
|
|
|
|
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU).ad \
|
|
|
|
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU_ARCH).ad \
|
|
|
|
)))
|
|
|
|
endif
|
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
SINGLE_AD_SRCFILE := $(ADLC_SUPPORT_DIR)/all-ad-src.ad
|
|
|
|
|
|
|
|
INSERT_FILENAME_AWK_SCRIPT := \
|
|
|
|
'{ \
|
2024-08-30 08:58:18 +00:00
|
|
|
if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
|
|
|
|
if (need_lineno && $$0 !~ /\/\//) \
|
|
|
|
{ print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
|
|
|
|
print \
|
|
|
|
}'
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
$(SINGLE_AD_SRCFILE): $(AD_SRC_FILES)
|
|
|
|
$(call LogInfo, Preprocessing adlc files $(^F))
|
|
|
|
$(call MakeDir, $(@D))
|
2020-11-30 16:35:02 +00:00
|
|
|
$(AWK) $(INSERT_FILENAME_AWK_SCRIPT) $^ > $@
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Run the adlc tool on the single concatenated ad source file, and store the
|
|
|
|
# output in support/adlc for further processing.
|
2019-03-05 10:07:19 +00:00
|
|
|
$(eval $(call SetupExecute, adlc_run, \
|
|
|
|
INFO := Generating adlc files, \
|
|
|
|
DEPS := $(BUILD_ADLC) $(SINGLE_AD_SRCFILE), \
|
|
|
|
OUTPUT_DIR := $(ADLC_SUPPORT_DIR), \
|
|
|
|
COMMAND := $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
|
|
|
|
-c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
|
|
|
|
-h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
|
|
|
|
-a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
|
|
|
|
-v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp, \
|
|
|
|
))
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Finally copy the generated files from support/adlc into gensrc/adfiles,
|
|
|
|
# and postprocess them by fixing dummy #line directives.
|
|
|
|
|
|
|
|
ADLC_GENERATED_FILES := $(addprefix $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/, \
|
2016-07-13 10:23:05 +00:00
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_clone.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_expand.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_format.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_gen.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_misc.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_peephole.cpp \
|
|
|
|
ad_$(HOTSPOT_TARGET_CPU_ARCH)_pipeline.cpp \
|
|
|
|
adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
|
|
|
|
dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
|
2016-04-08 11:14:23 +00:00
|
|
|
)
|
|
|
|
|
2019-03-05 10:07:19 +00:00
|
|
|
$(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(adlc_run_TARGET)
|
2016-04-08 11:14:23 +00:00
|
|
|
$(call LogInfo, Postprocessing adlc file $*)
|
|
|
|
$(call MakeDir, $(@D))
|
2020-11-30 16:35:02 +00:00
|
|
|
$(AWK) \
|
2016-04-08 11:14:23 +00:00
|
|
|
'BEGIN { print "#line 1 \"$*\""; } \
|
|
|
|
/^#line 999999$$/ {print "#line " (NR+1) " \"$*\""; next} \
|
2019-12-13 16:27:51 +00:00
|
|
|
$(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), false), \
|
|
|
|
/^#line .*$$/ {sub("$(WORKSPACE_ROOT)/","")} \
|
|
|
|
) \
|
2016-04-08 11:14:23 +00:00
|
|
|
{print}' \
|
|
|
|
< $(ADLC_SUPPORT_DIR)/$* > $@
|
|
|
|
|
2019-03-05 12:41:36 +00:00
|
|
|
TARGETS += $(ADLC_GENERATED_FILES)
|
2016-04-08 11:14:23 +00:00
|
|
|
|
|
|
|
endif
|