< prev index next >

make/hotspot/gensrc/GensrcAdlc.gmk

Print this page


   1 #
   2 # Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 $(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcAdlc.gmk))
  27 
  28 ifeq ($(call check-jvm-feature, compiler2), true)
  29 
  30   ADLC_SUPPORT_DIR := $(JVM_SUPPORT_DIR)/adlc
  31 
  32   ##############################################################################
  33   # Build the ad compiler (the adlc build tool)
  34 
  35   # Flags depending on the build platform/tool chain
  36   # NOTE: No optimization or debug flags set here
  37   ifeq ($(call isBuildOs, linux), true)
  38     ADLC_CFLAGS := -fno-exceptions -DLINUX
  39   else ifeq ($(call isBuildOs, solaris), true)
  40     ADLC_LDFLAGS := -m64
  41     ADLC_CFLAGS := -m64
  42     ADLC_CFLAGS_WARNINGS := +w
  43   else ifeq ($(call isBuildOs, aix), true)
  44     ADLC_LDFLAGS := -q64
  45     ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX
  46   else ifeq ($(call isBuildOs, windows), true)
  47     ADLC_LDFLAGS := -nologo
  48     ADLC_CFLAGS := -nologo -EHsc
  49     # NOTE: The old build also have -D_CRT_SECURE_NO_DEPRECATE but it doesn't
  50     # seem needed any more.
  51     ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS
  52   endif
  53 
  54   # Set the C++ standard if supported
  55   ADLC_CFLAGS += $(ADLC_CXXFLAG)
  56 
  57   # NOTE: The old build didn't set -DASSERT for windows but it doesn't seem to
  58   # hurt.
  59   ADLC_CFLAGS += -DASSERT
  60 
  61   ADLC_CFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)
  62 
  63   ADLC_CFLAGS += -I$(TOPDIR)/src/hotspot/share
  64 
  65   $(eval $(call SetupNativeCompilation, BUILD_ADLC, \
  66       NAME := adlc, \
  67       TYPE := EXECUTABLE, \
  68       TOOLCHAIN := TOOLCHAIN_BUILD_LINK_CXX, \
  69       SRC := $(TOPDIR)/src/hotspot/share/adlc, \
  70       EXTRA_FILES := $(TOPDIR)/src/hotspot/share/opto/opcodes.cpp, \
  71       CFLAGS := $(ADLC_CFLAGS) $(ADLC_CFLAGS_WARNINGS), \
  72       LDFLAGS := $(ADLC_LDFLAGS), \
  73       LIBS := $(ADLC_LIBS), \
  74       OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc/objs, \
  75       OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
  76       DEBUG_SYMBOLS := false, \
  77       DISABLED_WARNINGS_clang := tautological-compare, \
  78       DISABLED_WARNINGS_solstudio := notemsource, \
  79       DEFINE_THIS_FILE := false, \
  80   ))
  81 
  82   ADLC_TOOL := $(BUILD_ADLC_TARGET)
  83 
  84   ##############################################################################
  85   # Transform the ad source files into C++ source files using adlc
  86 
  87   # Setup flags for the adlc build tool (ADLCFLAGS).
  88   ADLCFLAGS += -q -T
  89 
  90   # ADLC flags depending on target OS
  91   ifeq ($(call isTargetOs, linux), true)
  92     ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1
  93   else ifeq ($(call isTargetOs, solaris), true)
  94     ADLCFLAGS += -DSOLARIS=1 -DSPARC_WORKS=1
  95   else ifeq ($(call isTargetOs, aix), true)
  96     ADLCFLAGS += -DAIX=1
  97   else ifeq ($(call isTargetOs, macosx), true)
  98     ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1
  99   endif
 100 
 101   ifeq ($(call isTargetOs, windows), false)
 102     # NOTE: Windows adlc flags was different in the old build. Is this really
 103     # correct?
 104 
 105     # -g makes #line directives in the generated C++ files.
 106     ADLCFLAGS += -g
 107 
 108     ADLCFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)=1
 109   endif
 110 
 111   # This generates checks in the generated C++ files that _LP64 is correctly
 112   # (un)defined when compiling them.
 113   ifeq ($(call isTargetCpuBits, 64), true)
 114     ADLCFLAGS += -D_LP64=1
 115   else
 116     ADLCFLAGS += -U_LP64
 117   endif
 118 
 119   ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
 120     ADLCFLAGS += -DARM=1
 121   endif
 122 
 123   ##############################################################################
 124   # Concatenate all ad source files into a single file, which will be fed to
 125   # adlc. Also include a #line directive at the start of every included file
 126   # (after the initial header block), stating the original source file name.
 127   #
 128   # Normally, debugging is done directly on the ad_<arch>*.cpp files, but the
 129   # #line directives in those files will be pointing back to <arch>.ad.
 130 
 131   # AD_SRC_ROOTS might have been added to by a custom extension
 132   AD_SRC_ROOTS += $(TOPDIR)/src/hotspot
 133 
 134   AD_SRC_FILES := $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
 135       $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU).ad \
 136       $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH).ad \
 137       $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH).ad \
 138     )))
 139 
 140   ifeq ($(call check-jvm-feature, shenandoahgc), true)
 141     AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
 142         $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/shenandoah/shenandoah_$(HOTSPOT_TARGET_CPU).ad \
 143       )))
 144   endif
 145 
 146   ifeq ($(call check-jvm-feature, zgc), true)
 147     AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
 148         $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/z/z_$(HOTSPOT_TARGET_CPU).ad \
 149       )))
 150   endif
 151 
 152   SINGLE_AD_SRCFILE := $(ADLC_SUPPORT_DIR)/all-ad-src.ad
 153 
 154   INSERT_FILENAME_AWK_SCRIPT := \
 155       '{ \
 156          if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
 157          if (need_lineno && $$0 !~ /\/\//) \
 158            { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
 159          print \
 160        }'
 161 
 162   $(SINGLE_AD_SRCFILE): $(AD_SRC_FILES)
 163         $(call LogInfo, Preprocessing adlc files $(^F))
 164         $(call MakeDir, $(@D))
 165         $(NAWK) $(INSERT_FILENAME_AWK_SCRIPT) $^ > $@
 166 
 167   ##############################################################################
 168   # Run the adlc tool on the single concatenated ad source file, and store the
 169   # output in support/adlc for further processing.
 170   $(eval $(call SetupExecute, adlc_run, \
 171       INFO := Generating adlc files, \
 172       DEPS := $(BUILD_ADLC) $(SINGLE_AD_SRCFILE), \
 173       OUTPUT_DIR := $(ADLC_SUPPORT_DIR), \
 174       COMMAND := $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
 175           -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 176           -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 177           -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 178           -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp, \
 179   ))


 180 
 181   ##############################################################################
 182   # Finally copy the generated files from support/adlc into gensrc/adfiles,
 183   # and postprocess them by fixing dummy #line directives.
 184 
 185   ADLC_GENERATED_FILES := $(addprefix $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/, \
 186       ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 187       ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 188       ad_$(HOTSPOT_TARGET_CPU_ARCH)_clone.cpp \
 189       ad_$(HOTSPOT_TARGET_CPU_ARCH)_expand.cpp \
 190       ad_$(HOTSPOT_TARGET_CPU_ARCH)_format.cpp \
 191       ad_$(HOTSPOT_TARGET_CPU_ARCH)_gen.cpp \
 192       ad_$(HOTSPOT_TARGET_CPU_ARCH)_misc.cpp \
 193       ad_$(HOTSPOT_TARGET_CPU_ARCH)_peephole.cpp \
 194       ad_$(HOTSPOT_TARGET_CPU_ARCH)_pipeline.cpp \
 195       adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 196       dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 197   )
 198 
 199   $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(adlc_run_TARGET)
 200         $(call LogInfo, Postprocessing adlc file $*)
 201         $(call MakeDir, $(@D))
 202         $(NAWK) \
 203             'BEGIN { print "#line 1 \"$*\""; } \
 204              /^#line 999999$$/ {print "#line " (NR+1) " \"$*\""; next} \
 205              {print}' \
 206             < $(ADLC_SUPPORT_DIR)/$* > $@
 207 
 208   TARGETS += $(ADLC_GENERATED_FILES)
 209 
 210 endif
   1 #
   2 # Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 $(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcAdlc.gmk))
  27 
  28 ifeq ($(call check-jvm-feature, compiler2), true)
  29 
  30   ADLC_SUPPORT_DIR := $(JVM_SUPPORT_DIR)/adlc
  31 
  32   ##############################################################################
  33   # Build the ad compiler (the adlc build tool)
  34 
  35   # Flags depending on the build platform/tool chain
  36   # NOTE: No optimization or debug flags set here
  37   ifeq ($(OPENJDK_BUILD_OS), linux)
  38     ADLC_CFLAGS := -fno-exceptions -DLINUX
  39   else ifeq ($(OPENJDK_BUILD_OS), solaris)
  40     ADLC_LDFLAGS := -m64
  41     ADLC_CFLAGS := -m64
  42     ADLC_CFLAGS_WARNINGS := +w
  43   else ifeq ($(OPENJDK_BUILD_OS), aix)
  44     ADLC_LDFLAGS := -q64
  45     ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX
  46   else ifeq ($(OPENJDK_BUILD_OS), windows)
  47     ADLC_LDFLAGS := -nologo
  48     ADLC_CFLAGS := -nologo -EHsc
  49     # NOTE: The old build also have -D_CRT_SECURE_NO_DEPRECATE but it doesn't
  50     # seem needed any more.
  51     ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS
  52   endif
  53 
  54   # Set the C++ standard if supported
  55   ADLC_CFLAGS += $(ADLC_CXXFLAG)
  56 
  57   # NOTE: The old build didn't set -DASSERT for windows but it doesn't seem to
  58   # hurt.
  59   ADLC_CFLAGS += -DASSERT
  60 
  61   ADLC_CFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)
  62 
  63   ADLC_CFLAGS += -I$(TOPDIR)/src/hotspot/share
  64 
  65   $(eval $(call SetupNativeCompilation, BUILD_ADLC, \
  66       NAME := adlc, \
  67       TYPE := EXECUTABLE, \
  68       TOOLCHAIN := TOOLCHAIN_BUILD_LINK_CXX, \
  69       SRC := $(TOPDIR)/src/hotspot/share/adlc, \
  70       EXTRA_FILES := $(TOPDIR)/src/hotspot/share/opto/opcodes.cpp, \
  71       CFLAGS := $(ADLC_CFLAGS) $(ADLC_CFLAGS_WARNINGS), \
  72       LDFLAGS := $(ADLC_LDFLAGS), \
  73       LIBS := $(ADLC_LIBS), \
  74       OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc/objs, \
  75       OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
  76       DEBUG_SYMBOLS := false, \
  77       DISABLED_WARNINGS_clang := tautological-compare, \
  78       DISABLED_WARNINGS_solstudio := notemsource, \

  79   ))
  80 
  81   ADLC_TOOL := $(BUILD_ADLC_TARGET)
  82 
  83   ##############################################################################
  84   # Transform the ad source files into C++ source files using adlc
  85 
  86   # Setup flags for the adlc build tool (ADLCFLAGS).
  87   ADLCFLAGS += -q -T
  88 
  89   # ADLC flags depending on target OS
  90   ifeq ($(OPENJDK_TARGET_OS), linux)
  91     ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1
  92   else ifeq ($(OPENJDK_TARGET_OS), solaris)
  93     ADLCFLAGS += -DSOLARIS=1 -DSPARC_WORKS=1
  94   else ifeq ($(OPENJDK_TARGET_OS), aix)
  95     ADLCFLAGS += -DAIX=1
  96   else ifeq ($(OPENJDK_TARGET_OS), macosx)
  97     ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1
  98   endif
  99 
 100   ifneq ($(OPENJDK_TARGET_OS), windows)
 101     # NOTE: Windows adlc flags was different in the old build. Is this really
 102     # correct?
 103 
 104     # -g makes #line directives in the generated C++ files.
 105     ADLCFLAGS += -g
 106 
 107     ADLCFLAGS += -D$(HOTSPOT_TARGET_CPU_DEFINE)=1
 108   endif
 109 
 110   # This generates checks in the generated C++ files that _LP64 is correctly
 111   # (un)defined when compiling them.
 112   ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 113     ADLCFLAGS += -D_LP64=1
 114   else
 115     ADLCFLAGS += -U_LP64
 116   endif
 117 
 118   ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
 119     ADLCFLAGS += -DARM=1
 120   endif
 121 
 122   ##############################################################################
 123   # Concatenate all ad source files into a single file, which will be fed to
 124   # adlc. Also include a #line directive at the start of every included file
 125   # (after the initial header block), stating the original source file name.
 126   #
 127   # Normally, debugging is done directly on the ad_<arch>*.cpp files, but the
 128   # #line directives in those files will be pointing back to <arch>.ad.
 129 
 130   # AD_SRC_ROOTS might have been added to by a custom extension
 131   AD_SRC_ROOTS += $(TOPDIR)/src/hotspot
 132 
 133   AD_SRC_FILES := $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
 134       $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU).ad \
 135       $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH).ad \
 136       $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH).ad \
 137     )))
 138 












 139   SINGLE_AD_SRCFILE := $(ADLC_SUPPORT_DIR)/all-ad-src.ad
 140 
 141   INSERT_FILENAME_AWK_SCRIPT := \
 142       '{ \
 143          if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
 144          if (need_lineno && $$0 !~ /\/\//) \
 145            { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
 146          print \
 147        }'
 148 
 149   $(SINGLE_AD_SRCFILE): $(AD_SRC_FILES)
 150         $(call LogInfo, Preprocessing adlc files $(^F))
 151         $(call MakeDir, $(@D))
 152         $(NAWK) $(INSERT_FILENAME_AWK_SCRIPT) $^ > $@
 153 
 154   ##############################################################################
 155   # Run the adlc tool on the single concatenated ad source file, and store the
 156   # output in support/adlc for further processing.
 157   ADLC_RUN_MARKER := $(ADLC_SUPPORT_DIR)/_adlc_run.marker
 158 
 159   $(ADLC_RUN_MARKER): $(BUILD_ADLC) $(SINGLE_AD_SRCFILE)
 160         $(call LogInfo, Generating adlc files)
 161         $(call MakeDir, $(@D))
 162         $(call ExecuteWithLog, $(ADLC_SUPPORT_DIR)/adlc_run, \
 163             $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
 164                 -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 165                 -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 166                 -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 167                 -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp)
 168         $(TOUCH) $@
 169 
 170   ##############################################################################
 171   # Finally copy the generated files from support/adlc into gensrc/adfiles,
 172   # and postprocess them by fixing dummy #line directives.
 173 
 174   ADLC_GENERATED_FILES := $(addprefix $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/, \
 175       ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 176       ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 177       ad_$(HOTSPOT_TARGET_CPU_ARCH)_clone.cpp \
 178       ad_$(HOTSPOT_TARGET_CPU_ARCH)_expand.cpp \
 179       ad_$(HOTSPOT_TARGET_CPU_ARCH)_format.cpp \
 180       ad_$(HOTSPOT_TARGET_CPU_ARCH)_gen.cpp \
 181       ad_$(HOTSPOT_TARGET_CPU_ARCH)_misc.cpp \
 182       ad_$(HOTSPOT_TARGET_CPU_ARCH)_peephole.cpp \
 183       ad_$(HOTSPOT_TARGET_CPU_ARCH)_pipeline.cpp \
 184       adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
 185       dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 186   )
 187 
 188   $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(ADLC_RUN_MARKER)
 189         $(call LogInfo, Postprocessing adlc file $*)
 190         $(call MakeDir, $(@D))
 191         $(NAWK) \
 192             'BEGIN { print "#line 1 \"$*\""; } \
 193              /^#line 999999$$/ {print "#line " (NR+1) " \"$*\""; next} \
 194              {print}' \
 195             < $(ADLC_SUPPORT_DIR)/$* > $@
 196 
 197   TARGETS := $(ADLC_GENERATED_FILES)
 198 
 199 endif
< prev index next >