adlc.make 8.6 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# 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.
#
# 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.
#
19 20 21
# 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.
D
duke 已提交
22 23 24 25 26 27 28
#  
#

# This makefile (adlc.make) is included from the adlc.make in the
# build directories.
# It knows how to compile, link, and run the adlc.

29
include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
30
include $(GAMMADIR)/make/altsrc.make
D
duke 已提交
31 32 33 34 35 36 37 38 39 40 41 42

# #########################################################################

# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
GENERATED = ../generated
OUTDIR  = $(GENERATED)/adfiles

ARCH = $(Platform_arch)
OS = $(Platform_os_family)

SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 

43 44
ifeq ("${Platform_arch_model}", "${Platform_arch}")
  SOURCES.AD = \
45 46
  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
47 48 49 50 51 52
else
  SOURCES.AD = \
  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) \
  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
endif
D
duke 已提交
53 54 55 56

EXEC	= $(OUTDIR)/adlc

# set VPATH so make knows where to look for source files
57 58
Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
VPATH += $(Src_Dirs_V:%=%:)
D
duke 已提交
59 60

# set INCLUDES for C preprocessor
61
Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
D
duke 已提交
62 63
INCLUDES += $(Src_Dirs_I:%=-I%)

64
# set flags for adlc compilation
65
CXXFLAGS = $(SYSDEFS) $(INCLUDES)
D
duke 已提交
66

67
# Force assertions on.
68
CXXFLAGS += -DASSERT
69

D
duke 已提交
70 71 72 73 74 75 76
ifndef USE_GCC
  # We need libCstd.so for adlc 
  CFLAGS += -library=Cstd -g
  LFLAGS += -library=Cstd -g
endif

# CFLAGS_WARN holds compiler options to suppress/enable warnings.
77
# Compiler warnings are treated as errors
78 79 80
ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
  CFLAGS_WARN = +w -errwarn
endif
D
duke 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
CFLAGS += $(CFLAGS_WARN)

ifeq ("${Platform_compiler}", "sparcWorks")
# Enable the following CFLAGS addition if you need to compare the
# built ELF objects.
#
# The -g option makes static data global and the "-Qoption ccfe
# -xglobalstatic" option tells the compiler to not globalize static
# data using a unique globalization prefix. Instead force the use
# of a static globalization prefix based on the source filepath so
# the objects from two identical compilations are the same.
#CFLAGS += -Qoption ccfe -xglobalstatic
endif # Platform_compiler == sparcWorks

OBJECTNAMES = \
	adlparse.o \
	archDesc.o \
	arena.o \
	dfa.o \
	dict2.o \
	filebuff.o \
	forms.o \
	formsopt.o \
	formssel.o \
	main.o \
	adlc-opcodes.o \
	output_c.o \
	output_h.o \

OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)

GENERATEDNAMES = \
        ad_$(Platform_arch_model).cpp \
        ad_$(Platform_arch_model).hpp \
        ad_$(Platform_arch_model)_clone.cpp \
        ad_$(Platform_arch_model)_expand.cpp \
        ad_$(Platform_arch_model)_format.cpp \
        ad_$(Platform_arch_model)_gen.cpp \
        ad_$(Platform_arch_model)_misc.cpp \
        ad_$(Platform_arch_model)_peephole.cpp \
        ad_$(Platform_arch_model)_pipeline.cpp \
        adGlobals_$(Platform_arch_model).hpp \
        dfa_$(Platform_arch_model).cpp \

GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)

# #########################################################################

all: $(EXEC)

$(EXEC) : $(OBJECTS)
	@echo Making adlc
133
	$(QUIETLY) $(LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
D
duke 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

# Random dependencies:
$(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

# The source files refer to ostream.h, which sparcworks calls iostream.h
$(OBJECTS): ostream.h

ostream.h :
	@echo >$@ '#include <iostream.h>'

dump:
	: OUTDIR=$(OUTDIR)
	: OBJECTS=$(OBJECTS)
	: products = $(GENERATEDFILES)

all: $(GENERATEDFILES)

$(GENERATEDFILES): refresh_adfiles

# Get a unique temporary directory name, so multiple makes can run in parallel.
# Note that product files are updated via "mv", which is atomic.
TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)

157 158 159
# Debuggable by default
CFLAGS += -g

160 161 162 163 164 165 166 167
# Pass -D flags into ADLC.
ADLCFLAGS += $(SYSDEFS)

# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
ADLCFLAGS += -q -T

# Normally, debugging is done directly on the ad_<arch>*.cpp files.
# But -g will put #line directives in those files pointing back to <arch>.ad.
168
ADLCFLAGS += -g
D
duke 已提交
169 170 171 172 173 174 175 176 177 178 179 180

ifdef LP64
ADLCFLAGS += -D_LP64
else
ADLCFLAGS += -U_LP64
endif

#
# adlc_updater is a simple sh script, under sccs control. It is
# used to selectively update generated adlc files. This should
# provide a nice compilation speed improvement.
#
181
ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
D
duke 已提交
182
ADLC_UPDATER = adlc_updater
183 184
$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
	$(QUIETLY) cp $< $@; chmod +x $@
D
duke 已提交
185 186 187 188 189 190 191 192 193

# This action refreshes all generated adlc files simultaneously.
# The way it works is this:
# 1) create a scratch directory to work in.
# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
# 5) If we actually updated any files, echo a notice.
#
194
refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
D
duke 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
 -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 \
	    || { rm -rf $(TEMPDIR); exit 1; }
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
		|| echo "Rescanned $(SOURCE.AD) but encountered no changes."
	$(QUIETLY) rm -rf $(TEMPDIR)


# #########################################################################

$(SOURCE.AD): $(SOURCES.AD)
218 219 220 221 222 223 224 225 226
	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)

#PROCESS_AD_FILES = cat
# Pass through #line directives, in case user enables -g option above:
PROCESS_AD_FILES = awk '{ \
    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 }'
D
duke 已提交
227 228 229 230

$(OUTDIR)/%.o: %.cpp
	@echo Compiling $<
	$(QUIETLY) $(REMOVE_TARGET)
231
	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
D
duke 已提交
232 233 234 235 236 237

# Some object files are given a prefix, to disambiguate
# them from objects of the same name built for the VM.
$(OUTDIR)/adlc-%.o: %.cpp
	@echo Compiling $<
	$(QUIETLY) $(REMOVE_TARGET)
238
	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
D
duke 已提交
239 240 241 242 243 244 245 246 247 248 249 250

# #########################################################################

clean	:
	rm $(OBJECTS)

cleanall :
	rm $(OBJECTS) $(EXEC)

# #########################################################################

.PHONY: all dump refresh_adfiles clean cleanall