1 # 2 # Copyright (c) 1997, 2013, 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. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 # 24 25 # This makefile (adlc.make) is included from the adlc.make in the 26 # build directories. 27 # It knows how to compile, link, and run the adlc. 28 29 include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make 30 include $(GAMMADIR)/make/altsrc.make 31 32 # ######################################################################### 33 34 # OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: 35 GENERATED = ../generated 36 OUTDIR = $(GENERATED)/adfiles 37 38 ARCH = $(Platform_arch) 39 OS = $(Platform_os_family) 40 41 SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 42 43 ifeq ("${Platform_arch_model}", "${Platform_arch}") 44 SOURCES.AD = \ 45 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 46 else 47 SOURCES.AD = \ 48 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ 49 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 50 endif 51 52 EXEC = $(OUTDIR)/adlc 53 54 # set VPATH so make knows where to look for source files 55 Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc 56 VPATH += $(Src_Dirs_V:%=%:) 57 58 # set INCLUDES for C preprocessor 59 Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) 60 INCLUDES += $(Src_Dirs_I:%=-I%) 61 62 # set flags for adlc compilation 63 CXXFLAGS = $(SYSDEFS) $(INCLUDES) 64 65 # Force assertions on. 66 CXXFLAGS += -DASSERT 67 68 ifndef USE_GCC 69 # We need libCstd.so for adlc 70 CFLAGS += -library=Cstd -g 71 LFLAGS += -library=Cstd -g 72 endif 73 74 # CFLAGS_WARN holds compiler options to suppress/enable warnings. 75 # Compiler warnings are treated as errors 76 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) 77 CFLAGS_WARN = +w -errwarn 78 endif 79 # When using compiler version 5.13 (Solaris Studio 12.4), calls to explicitly 80 # instantiated template functions trigger this warning when +w is active. 81 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 513), 1) 82 CFLAGS_WARN += -erroff=notemsource 83 endif 84 CFLAGS += $(CFLAGS_WARN) 85 86 ifeq ("${Platform_compiler}", "sparcWorks") 87 # Enable the following CFLAGS addition if you need to compare the 88 # built ELF objects. 89 # 90 # The -g option makes static data global and the "-Qoption ccfe 91 # -xglobalstatic" option tells the compiler to not globalize static 92 # data using a unique globalization prefix. Instead force the use 93 # of a static globalization prefix based on the source filepath so 94 # the objects from two identical compilations are the same. 95 #CFLAGS += -Qoption ccfe -xglobalstatic 96 endif # Platform_compiler == sparcWorks 97 98 OBJECTNAMES = \ 99 adlparse.o \ 100 archDesc.o \ 101 arena.o \ 102 dfa.o \ 103 dict2.o \ 104 filebuff.o \ 105 forms.o \ 106 formsopt.o \ 107 formssel.o \ 108 main.o \ 109 adlc-opcodes.o \ 110 output_c.o \ 111 output_h.o \ 112 113 OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) 114 115 GENERATEDNAMES = \ 116 ad_$(Platform_arch_model).cpp \ 117 ad_$(Platform_arch_model).hpp \ 118 ad_$(Platform_arch_model)_clone.cpp \ 119 ad_$(Platform_arch_model)_expand.cpp \ 120 ad_$(Platform_arch_model)_format.cpp \ 121 ad_$(Platform_arch_model)_gen.cpp \ 122 ad_$(Platform_arch_model)_misc.cpp \ 123 ad_$(Platform_arch_model)_peephole.cpp \ 124 ad_$(Platform_arch_model)_pipeline.cpp \ 125 adGlobals_$(Platform_arch_model).hpp \ 126 dfa_$(Platform_arch_model).cpp \ 127 128 GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) 129 130 # ######################################################################### 131 132 all: $(EXEC) 133 134 $(EXEC) : $(OBJECTS) 135 @echo $(LOG_INFO) Making adlc 136 $(QUIETLY) $(LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS) 137 138 # Random dependencies: 139 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp 140 141 # The source files refer to ostream.h, which sparcworks calls iostream.h 142 $(OBJECTS): ostream.h 143 144 ostream.h : 145 @echo >$@ '#include <iostream.h>' 146 147 dump: 148 : OUTDIR=$(OUTDIR) 149 : OBJECTS=$(OBJECTS) 150 : products = $(GENERATEDFILES) 151 152 all: $(GENERATEDFILES) 153 154 $(GENERATEDFILES): refresh_adfiles 155 156 # Get a unique temporary directory name, so multiple makes can run in parallel. 157 # Note that product files are updated via "mv", which is atomic. 158 TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) 159 160 # Debuggable by default 161 CFLAGS += -g 162 163 # Pass -D flags into ADLC. 164 ADLCFLAGS += $(SYSDEFS) 165 166 # Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. 167 ADLCFLAGS += -q -T 168 169 # Normally, debugging is done directly on the ad_<arch>*.cpp files. 170 # But -g will put #line directives in those files pointing back to <arch>.ad. 171 ADLCFLAGS += -g 172 173 ifdef LP64 174 ADLCFLAGS += -D_LP64 175 else 176 ADLCFLAGS += -U_LP64 177 endif 178 179 # 180 # adlc_updater is a simple sh script, under sccs control. It is 181 # used to selectively update generated adlc files. This should 182 # provide a nice compilation speed improvement. 183 # 184 ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) 185 ADLC_UPDATER = adlc_updater 186 $(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) 187 $(QUIETLY) cp $< $@; chmod +x $@ 188 189 # This action refreshes all generated adlc files simultaneously. 190 # The way it works is this: 191 # 1) create a scratch directory to work in. 192 # 2) if the current working directory does not have $(ADLC_UPDATER), copy it. 193 # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. 194 # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. 195 # 5) If we actually updated any files, echo a notice. 196 # 197 refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) 198 @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) 199 $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ 200 -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ 201 || { rm -rf $(TEMPDIR); exit 1; } 202 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) 203 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) 204 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) 205 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) 206 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) 207 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) 208 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) 209 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) 210 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) 211 $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) 212 $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) 213 $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ 214 || echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes." 215 $(QUIETLY) rm -rf $(TEMPDIR) 216 217 218 # ######################################################################### 219 220 $(SOURCE.AD): $(SOURCES.AD) 221 $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) 222 223 #PROCESS_AD_FILES = cat 224 # Pass through #line directives, in case user enables -g option above: 225 PROCESS_AD_FILES = awk '{ \ 226 if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ 227 if (need_lineno && $$0 !~ /\/\//) \ 228 { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ 229 print }' 230 231 $(OUTDIR)/%.o: %.cpp 232 @echo $(LOG_INFO) Compiling $< 233 $(QUIETLY) $(REMOVE_TARGET) 234 $(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE) 235 236 # Some object files are given a prefix, to disambiguate 237 # them from objects of the same name built for the VM. 238 $(OUTDIR)/adlc-%.o: %.cpp 239 @echo $(LOG_INFO) Compiling $< 240 $(QUIETLY) $(REMOVE_TARGET) 241 $(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE) 242 243 # ######################################################################### 244 245 clean : 246 rm $(OBJECTS) 247 248 cleanall : 249 rm $(OBJECTS) $(EXEC) 250 251 # ######################################################################### 252 253 .PHONY: all dump refresh_adfiles clean cleanall