Add support for emitting ~generic vectorized C++ code.

The compiler now supports an --emit-c++ option, which generates generic
vector C++ code.  To actually compile this code, the user must provide
C++ code that implements a variety of types and operations (e.g. adding
two floating-point vector values together, comparing them, etc).

There are two examples of this required code in examples/intrinsics:
generic-16.h is a "generic" 16-wide implementation that does all required
with scalar math; it's useful for demonstrating the requirements of the
implementation.  Then, sse4.h shows a simple implementation of a SSE4
target that maps the emitted function calls to SSE intrinsics.

When using these example implementations with the ispc test suite,
all but one or two tests pass with gcc and clang on Linux and OSX.
There are currently ~10 failures with icc on Linux, and ~50 failures with
MSVC 2010.  (To be fixed in coming days.)

Performance varies: when running the examples through the sse4.h
target, some have the same performance as when compiled with --target=sse4
from ispc directly (options), while noise is 12% slower, rt is 26%
slower, and aobench is 2.2x slower.  The details of this haven't yet been
carefully investigated, but will be in coming days as well.

Issue #92.
This commit is contained in:
Matt Pharr
2012-01-04 12:37:26 -08:00
parent 4151778f5e
commit 8938e14442
11 changed files with 9594 additions and 27 deletions

View File

@@ -80,6 +80,9 @@ public:
enum OutputType { Asm, /** Generate text assembly language output */
Bitcode, /** Generate LLVM IR bitcode output */
Object, /** Generate a native object file */
#ifndef LLVM_2_9
CXX, /** Generate a C++ file */
#endif // !LLVM_2_9
Header /** Generate a C/C++ header file with
declarations of 'export'ed functions, global
variables, and the types used by them. */
@@ -108,6 +111,10 @@ public:
inclusion from C/C++ code with declarations of
types and functions exported from the given ispc
source file.
@param includeFileName If non-NULL, gives the filename for the C++
backend to emit in an #include statement to
get definitions of the builtins for the generic
target.
@return Number of errors encountered when compiling
srcFile.
*/
@@ -115,7 +122,8 @@ public:
const char *cpu, const char *targets,
bool generatePIC, OutputType outputType,
const char *outFileName,
const char *headerFileName);
const char *headerFileName,
const char *includeFileName);
/** Total number of errors encountered during compilation. */
int errorCount;
@@ -138,7 +146,8 @@ private:
true on success, false if there has been an error. The given
filename may be NULL, indicating that output should go to standard
output. */
bool writeOutput(OutputType ot, const char *filename);
bool writeOutput(OutputType ot, const char *filename,
const char *includeFileName = NULL);
bool writeHeader(const char *filename);
bool writeObjectFileOrAssembly(OutputType outputType, const char *filename);
static bool writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,