From adce558b1740b3f8ba99f498c7fc4aa0461472a1 Mon Sep 17 00:00:00 2001 From: Dirk Steinke Date: Tue, 17 Jun 2014 15:55:54 +0200 Subject: [PATCH] Preliminary support for 64bit. Untested. --- makefile | 107 ++++++++++++++++++++++++++++++++++-------------------------- src/cpu.cpp | 2 +- 2 files changed, 62 insertions(+), 47 deletions(-) rewrite makefile (64%) diff --git a/makefile b/makefile dissimilarity index 64% index 0d1c247..224b3dc 100644 --- a/makefile +++ b/makefile @@ -1,46 +1,61 @@ -CC = g++.bat -CFLAGS = -I ./include -CFLAGS_DBG = -CFLAGS_REL = -O3 -LUA = lua51x.bat -SRC_SRC = cpu.cpp -OBJDIR = _objs -LIBDIR = _lib -BINDIR = _bin -TEST_NAMES = $(patsubst %.cpp,%.o,$(SRC_SRC)) -LIBOBJ_NAMES = $(addprefix src_,$(patsubst %.cpp,%.o,$(SRC_SRC))) -LIBOBJS_DEBUG = $(addprefix $(OBJDIR)/dbg_,$(LIBOBJ_NAMES)) -LIBOBJS_RELEASE = $(addprefix $(OBJDIR)/rel_,$(LIBOBJ_NAMES)) - -all : debug release tests -debug : $(LIBDIR)/jitcs_debug.a - rem - $(SRC_SRC) - rem - $(TEST_NAMES) - rem - $(LIBOBJ_NAMES) - rem - $(LIBOBJS_DEBUG) -release : $(LIBDIR)/jitcs_release.a -tests : $(BINDIR)/test_cpuinfo.exe - -$(LIBDIR)/jitcs_debug.a : $(LIBOBJS_DEBUG) | $(LIBDIR) - ar r $@ $? -$(LIBDIR)/jitcs_release.a : $(LIBOBJS_RELEASE) | $(LIBDIR) - ar r $@ $? - -$(BINDIR)/test_cpuinfo.exe : tests/cpuinfo.cpp $(LIBDIR)/jitcs_release.a \ - include/jitcs_cpu.h \ - | $(BINDIR) - $(CC) -o $@ $(CFLAGS) $(CFLAGS_DBG) $< $(LIBDIR)/jitcs_release.a - -$(OBJDIR)/dbg_src_cpu.o : include/jitcs_base.h include/jitcs_cpu.h \ - include/jitcs_adt_bitstore.h -$(OBJDIR)/rel_src_cpu.o : include/jitcs_base.h include/jitcs_cpu.h \ - include/jitcs_adt_bitstore.h -$(OBJDIR)/dbg_src_%.o : src/%.cpp - $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_DBG) $< -$(OBJDIR)/rel_src_%.o : src/%.cpp - $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_REL) $< - -$(LIBOBJS_DEBUG) : | $(OBJDIR) -$(LIBOBJS_RELEASE) : | $(OBJDIR) -$(OBJDIR) $(LIBDIR) $(BINDIR) : - mkdir $@ +CC = g++.bat +CFLAGS = -I ./include +CFLAGS_DBG32 = +CFLAGS_REL32 = -O3 +CFLAGS_DBG64 = -m64 +CFLAGS_REL64 = -O3 -m64 +LUA = lua51x.bat +SRC_SRC = cpu.cpp +OBJDIR = _objs +LIBDIR = _lib +BINDIR = _bin +TEST_NAMES = $(patsubst %.cpp,%.o,$(SRC_SRC)) +LIBOBJ_NAMES = $(addprefix src_,$(patsubst %.cpp,%.o,$(SRC_SRC))) +LIBOBJS_DEBUG32 = $(addprefix $(OBJDIR)/dbg32_,$(LIBOBJ_NAMES)) +LIBOBJS_RELEASE32 = $(addprefix $(OBJDIR)/rel32_,$(LIBOBJ_NAMES)) +LIBOBJS_DEBUG64 = $(addprefix $(OBJDIR)/dbg64_,$(LIBOBJ_NAMES)) +LIBOBJS_RELEASE64 = $(addprefix $(OBJDIR)/rel64_,$(LIBOBJ_NAMES)) + +all : debug release tests +debug : $(LIBDIR)/jitcs_debug32.a $(LIBDIR)/jitcs_debug64.a + rem - $(SRC_SRC) + rem - $(TEST_NAMES) + rem - $(LIBOBJ_NAMES) + rem - $(LIBOBJS_DEBUG) +release : $(LIBDIR)/jitcs_release32.a $(LIBDIR)/jitcs_release64.a +tests : $(BINDIR)/test_cpuinfo32.exe $(BINDIR)/test_cpuinfo64.exe + +$(LIBDIR)/jitcs_debug32.a : $(LIBOBJS_DEBUG32) | $(LIBDIR) + ar r $@ $? +$(LIBDIR)/jitcs_release32.a : $(LIBOBJS_RELEASE32) | $(LIBDIR) + ar r $@ $? +$(LIBDIR)/jitcs_debug64.a : | $(LIBDIR) + rem -- +$(LIBDIR)/jitcs_release64.a : | $(LIBDIR) + rem -- + +$(BINDIR)/test_cpuinfo32.exe : tests/cpuinfo.cpp $(LIBDIR)/jitcs_release32.a \ + include/jitcs_cpu.h \ + | $(BINDIR) + $(CC) -o $@ $(CFLAGS) $(CFLAGS_REL32) $< $(LIBDIR)/jitcs_release32.a +$(BINDIR)/test_cpuinfo64.exe : | $(BINDIR) + rem -- + +$(OBJDIR)/dbg32_src_cpu.o $(OBJDIR)/rel32_src_cpu.o \ + $(OBJDIR)/dbg64_src_cpu.o $(OBJDIR)/rel64_src_cpu.o: \ + include/jitcs_base.h include/jitcs_cpu.h \ + include/jitcs_adt_bitstore.h + +$(OBJDIR)/dbg32_src_%.o : src/%.cpp + $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_DBG32) $< +$(OBJDIR)/rel32_src_%.o : src/%.cpp + $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_REL32) $< +$(OBJDIR)/dbg64_src_%.o : src/%.cpp + $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_DBG64) $< +$(OBJDIR)/rel64_src_%.o : src/%.cpp + $(CC) -o $@ -c $(CFLAGS) $(CFLAGS_REL64) $< + +$(LIBOBJS_DEBUG32) $(LIBOBJS_RELEASE32) \ + $(LIBOBJS_DEBUG64) $(LIBOBJS_RELEASE64) : | $(OBJDIR) +$(OBJDIR) $(LIBDIR) $(BINDIR) : + mkdir $@ diff --git a/src/cpu.cpp b/src/cpu.cpp index 5046903..b82d9c7 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -334,7 +334,7 @@ void jitcs::CPUInfo::_initializeFromHost() { _setFeat(F_X86CLFLUSH, _TestBit(_s_x86cpuinfo.features1, 19)); //_setFeat(F_MULTITHREADING, _TestBit(_s_x86cpuinfo.features1, 28)); //_setFeat(F_MONITOR, _TestBit(_s_x86cpuinfo.features2, 3)); - _setFeat(F_X86CMPXCHG16B, _TestBit(_s_x86cpuinfo.features2, 13)); + _setFeat(F_X86CMPXCHG16B, _TestBit(_s_x86cpuinfo.features2, 13) && sizeof(void*) == 8); _setFeat(F_X86POPCNT, _TestBit(_s_x86cpuinfo.features2, 23)); _setFeat(F_X86RDRAND, _TestBit(_s_x86cpuinfo.features2, 30)); // amd 9/2010: reserved _setFeat(F_X86BMI1, _TestBit(_s_x86cpuinfo.features3, 3)); -- 2.11.4.GIT