Skip to content

Commit

Permalink
Merge pull request #42 from Zapeth/master
Browse files Browse the repository at this point in the history
Merge changes from upstream
  • Loading branch information
richard42 authored Aug 27, 2018
2 parents 6fa063c + 4acc1f8 commit 6224403
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 564 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*.asm
*.s
*.o

/obj
*.o
*.so
obj

*.obj
*.dll
Expand Down
39 changes: 39 additions & 0 deletions lto.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/******************************************************************************\
* Project: Primitive LTO Merger Substitute *
* Authors: Iconoclast *
* Release: 2018.03.17 *
* License: CC0 Public Domain Dedication *
* *
* To the extent possible under law, the author(s) have dedicated all copyright *
* and related and neighboring rights to this software to the public domain *
* worldwide. This software is distributed without any warranty. *
* *
* You should have received a copy of the CC0 Public Domain Dedication along *
* with this software. *
* If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. *
\******************************************************************************/

/*
* A single compile-and-link command will be sufficient with this method.
*
* A command exemplifying this on UNIX with all optimizations in tact may be:
* $ cc --shared -o rsp.so lto.c -O3 -msse2 -DARCH_MIN_SSE2 -s
*
* To control the link-time stage during build with a separate command:
* $ gcc -c -o rsp.o lto.c -O3 -msse2 -DARCH_MIN_SSE2
* $ ld --shared -o rsp.so -lc rsp.o --strip-all
*/

#include "module.c"
#include "su.c"

#include "vu/vu.c"

#include "vu/multiply.c"
#include "vu/add.c"
#include "vu/select.c"
#include "vu/logical.c"
#include "vu/divide.c"
#if 0
#include "vu/pack.c"
#endif
43 changes: 16 additions & 27 deletions make.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mkdir -p obj
mkdir -p obj/vu

# The below path configuration will only work if you have this `make.sh` script
# installed to the parent directory just outside the RSP source when you run it.
src="." # or an absolute path, like "/home/user/rsp"
obj="$src/obj"

Expand All @@ -16,18 +14,10 @@ OBJ_LIST="\
$obj/vu/logical.o \
$obj/vu/divide.o"

FLAGS_ANSI="\
-O3 \
-fPIC \
-DPLUGIN_API_VERSION=0x0101 \
-march=native \
-mstackrealign \
-Wall \
-pedanticz"
FLAGS_ANSI="-fPIC -DPLUGIN_API_VERSION=0x0101 -mstackrealign -Wall -pedantic"

if [ `uname -m` == 'x86_64' ]; then
FLAGS_x86="\
-O3 \
-masm=intel \
-fPIC \
-DPLUGIN_API_VERSION=0x0101 \
Expand All @@ -38,11 +28,10 @@ FLAGS_x86="\
-pedantic \
-Wall -Wshadow -Wredundant-decls -Wextra -Wcast-align -Wcast-qual \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op
-Wmissing-include-dirs -Wstrict-overflow=5 -Wundef -Wno-unused \
-Wmissing-include-dirs -Wstrict-overflow=1 -Wundef -Wno-unused \
-Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option"
else
FLAGS_x86="\
-O3 \
-masm=intel \
-DPLUGIN_API_VERSION=0x0101 \
-DARCH_MIN_SSE2 \
Expand All @@ -52,31 +41,31 @@ FLAGS_x86="\
-pedantic \
-Wall -Wshadow -Wredundant-decls -Wextra -Wcast-align -Wcast-qual \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op
-Wmissing-include-dirs -Wstrict-overflow=5 -Wundef -Wno-unused \
-Wmissing-include-dirs -Wstrict-overflow=1 -Wundef -Wno-unused \
-Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option"
fi
C_FLAGS=$FLAGS_x86 # default since Intel SIMD was the most tested

echo Compiling C source code...
cc -S $C_FLAGS -o $obj/module.s $src/module.c
cc -S $C_FLAGS -o $obj/su.s $src/su.c
cc -S $C_FLAGS -o $obj/vu/vu.s $src/vu/vu.c
cc -S $C_FLAGS -o $obj/vu/multiply.s $src/vu/multiply.c
cc -S $C_FLAGS -o $obj/vu/add.s $src/vu/add.c
cc -S $C_FLAGS -o $obj/vu/select.s $src/vu/select.c
cc -S $C_FLAGS -o $obj/vu/logical.s $src/vu/logical.c
cc -S $C_FLAGS -o $obj/vu/divide.s $src/vu/divide.c
cc -S -Os $C_FLAGS -o $obj/module.s $src/module.c
cc -S -O3 $C_FLAGS -o $obj/su.s $src/su.c
cc -S -O3 $C_FLAGS -o $obj/vu/vu.s $src/vu/vu.c
cc -S -O3 $C_FLAGS -o $obj/vu/multiply.s $src/vu/multiply.c
cc -S -O3 $C_FLAGS -o $obj/vu/add.s $src/vu/add.c
cc -S -O3 $C_FLAGS -o $obj/vu/select.s $src/vu/select.c
cc -S -O3 $C_FLAGS -o $obj/vu/logical.s $src/vu/logical.c
cc -S -O2 $C_FLAGS -o $obj/vu/divide.s $src/vu/divide.c

echo Assembling compiled sources...
as --statistics -o $obj/module.o $obj/module.s
as --statistics -o $obj/su.o $obj/su.s
as --statistics -o $obj/vu/vu.o $obj/vu/vu.s
as -o $obj/module.o $obj/module.s
as -o $obj/su.o $obj/su.s
as -o $obj/vu/vu.o $obj/vu/vu.s
as -o $obj/vu/multiply.o $obj/vu/multiply.s
as -o $obj/vu/add.o $obj/vu/add.s
as -o $obj/vu/select.o $obj/vu/select.s
as -o $obj/vu/logical.o $obj/vu/logical.s
as -o $obj/vu/divide.o $obj/vu/divide.s

echo Linking assembled object files...
ld --shared -o $obj/rspdebug.so $OBJ_LIST
strip -o $obj/rsp.so $obj/rspdebug.so
ld --shared -o $obj/rspdebug.so -lc $OBJ_LIST
strip -o $obj/rsp.so $obj/rspdebug.so --strip-all
63 changes: 36 additions & 27 deletions make_w32.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
@ECHO OFF
TITLE MinGW Compiler Suite Invocation

REM If you have MinGW on a different drive letter or installed at a custom path
REM (or just not yet installed at all), this build script may not work out of
REM the box for most Windows users. Alternatives include MinGW-w32 or trying
REM to execute the Unix shell script "make.sh" from Windows 10+ or Git Bash.

REM The following line is the only one you should ever need to change.
set MinGW=C:\MinGW

set lib=%MinGW%\lib
set bin=%MinGW%\bin
set inc=%MinGW%\include

REM set rsp=%USERPROFILE%\rsp
set rsp=%CD%
set obj=%rsp%\obj
Expand All @@ -16,52 +27,50 @@ set OBJ_LIST=^
%obj%\vu\logical.o ^
%obj%\vu\divide.o

set FLAGS_ANSI=-O3^
set FLAGS_ANSI=-Wall -pedantic^
-DPLUGIN_API_VERSION=0x0101^
-march=native^
-mstackrealign^
-Wall^
-pedantic
set FLAGS_x86=-O3^
-march=native
set FLAGS_x86=-Wall -pedantic^
-masm=intel^
-DPLUGIN_API_VERSION=0x0101^
-DARCH_MIN_SSE2^
-march=native^
-mstackrealign^
-Wall^
-pedantic
-march=native
set C_FLAGS=%FLAGS_x86%

if not exist obj (
mkdir obj
cd obj
mkdir vu
)
cd %MinGW%\bin
cd /D %bin%

ECHO Compiling C source code...
cc -S %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
cc -S %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
cc -S %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
cc -S %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
cc -S %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
cc -S %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
cc -S %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
cc -S %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
@ECHO ON
gcc -Os -S %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
gcc -O3 -S %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
gcc -O2 -S %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
@ECHO OFF
ECHO.

ECHO Assembling compiled sources...
as --statistics -o %obj%\module.o %obj%\module.asm
as --statistics -o %obj%\su.o %obj%\su.asm
as --statistics -o %obj%\vu\vu.o %obj%\vu\vu.asm
as -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
as -o %obj%\vu\add.o %obj%\vu\add.asm
as -o %obj%\vu\select.o %obj%\vu\select.asm
as -o %obj%\vu\logical.o %obj%\vu\logical.asm
as -o %obj%\vu\divide.o %obj%\vu\divide.asm
as -o %obj%\module.o %obj%\module.asm
as -o %obj%\su.o %obj%\su.asm
as -o %obj%\vu\vu.o %obj%\vu\vu.asm
as -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
as -o %obj%\vu\add.o %obj%\vu\add.asm
as -o %obj%\vu\select.o %obj%\vu\select.asm
as -o %obj%\vu\logical.o %obj%\vu\logical.asm
as -o %obj%\vu\divide.o %obj%\vu\divide.asm
ECHO.

ECHO Linking assembled object files...
ld --shared -e _DllMain@12 -o %obj%\rspdebug.dll %OBJ_LIST% %MinGW%\lib\libkernel32.a
strip -o %obj%/rsp.dll %obj%/rspdebug.dll
ld --shared -e _DllMain@12 -o %obj%\rspdebug.dll -L %lib% %OBJ_LIST% -lmsvcrt
strip -o %obj%\rsp.dll %obj%\rspdebug.dll --strip-all
PAUSE
73 changes: 43 additions & 30 deletions make_w64.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
@ECHO OFF
TITLE MinGW Compiler Suite Invocation

set version=x86_64-5.1.0-win32-seh-rt_v4-rev0
set MinGW="C:\Program Files\mingw-w64\%version%\mingw64"
REM If you have installed MinGW-w64 without using MSYS2 to obtain the package
REM (or just not yet installed at all), this build script may not work out of
REM the box for most Windows users. If you have Cygwin instead or whatever
REM else, be sure to adjust the path below, or execute "make.sh" in a Git shell.

REM The following line is the only one you should ever need to change.
set mingw64=C:\msys64\mingw64

REM The following two variables are irrelevant, unless you set a 32-bit target.
set mingw32=%mingw64%\..\mingw32
set lib=%mingw32%\i686-w64-mingw32\lib

set lib64=%mingw64%\x86_64-w64-mingw32\lib
set bin=%mingw64%\bin
set inc=%lib64%\..\include

REM set rsp=%USERPROFILE%\rsp
set rsp=%CD%
set obj=%rsp%\obj
Expand All @@ -15,53 +29,52 @@ set OBJ_LIST=^
%obj%\vu\add.o ^
%obj%\vu\select.o ^
%obj%\vu\logical.o ^
%obj%\vu\divide.o ^
%MinGW%\x86_64-w64-mingw32\lib\libkernel32.a
%obj%\vu\divide.o

set FLAGS_ANSI=-Wall^
set FLAGS_ANSI=-Wall -pedantic^
-DPLUGIN_API_VERSION=0x0101^
-march=native^
-mstackrealign^
-pedantic
set FLAGS_x86=-Wall^
-masm=intel^
-march=native
set FLAGS_x86=-Wall -pedantic^
-DPLUGIN_API_VERSION=0x0101^
-DARCH_MIN_SSE2^
-march=native^
-masm=intel^
-mstackrealign^
-pedantic
-march=native
set C_FLAGS=%FLAGS_x86%

if not exist obj (
mkdir obj
cd obj
mkdir vu
)
cd %MinGW%\bin
cd /D %bin%

ECHO Compiling C source code...
%MinGW%\bin\gcc.exe -S -Os %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
%MinGW%\bin\gcc.exe -S -O3 %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
@ECHO ON
gcc -S -Os %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
gcc -S -O3 %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
gcc -S -O2 %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
@ECHO OFF
ECHO.

ECHO Assembling compiled sources...
%MinGW%\bin\as.exe -o %obj%\module.o %obj%\module.asm
%MinGW%\bin\as.exe -o %obj%\su.o %obj%\su.asm
%MinGW%\bin\as.exe -o %obj%\vu\vu.o %obj%\vu\vu.asm
%MinGW%\bin\as.exe -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
%MinGW%\bin\as.exe -o %obj%\vu\add.o %obj%\vu\add.asm
%MinGW%\bin\as.exe -o %obj%\vu\select.o %obj%\vu\select.asm
%MinGW%\bin\as.exe -o %obj%\vu\logical.o %obj%\vu\logical.asm
%MinGW%\bin\as.exe -o %obj%\vu\divide.o %obj%\vu\divide.asm
as -o %obj%\module.o %obj%\module.asm
as -o %obj%\su.o %obj%\su.asm
as -o %obj%\vu\vu.o %obj%\vu\vu.asm
as -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
as -o %obj%\vu\add.o %obj%\vu\add.asm
as -o %obj%\vu\select.o %obj%\vu\select.asm
as -o %obj%\vu\logical.o %obj%\vu\logical.asm
as -o %obj%\vu\divide.o %obj%\vu\divide.asm
ECHO.

ECHO Linking assembled object files...
%MinGW%\bin\ld.exe --shared -e DllMain -o %obj%\rspdebug.dll %OBJ_LIST%
%MinGW%\bin\strip.exe -o %obj%/rsp.dll %obj%/rspdebug.dll
ld --shared -e DllMain -o %obj%\rspdebug.dll -L%lib64% %OBJ_LIST% -lmsvcrt
strip -o %obj%\rsp.dll %obj%\rspdebug.dll --strip-all
PAUSE
Loading

0 comments on commit 6224403

Please sign in to comment.