/* Copyright (c) 2010-2016, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file main.cpp @brief main() entrypoint implementation for ispc */ #include "ispc.h" #include "module.h" #include "util.h" #include "type.h" #include #include #ifdef ISPC_IS_WINDOWS #include #else #include #endif // ISPC_IS_WINDOWS #include #include #include #ifdef ISPC_IS_WINDOWS #define strcasecmp stricmp #ifndef BUILD_DATE #define BUILD_DATE __DATE__ #endif #define BUILD_VERSION "" #if _MSC_VER >= 1900 #define ISPC_VS_VERSION "Visual Studio 2015 and later" #else #define ISPC_VS_VERSION "Visual Studio 2013 and earlier" #endif #endif // ISPC_IS_WINDOWS static void lPrintVersion() { #ifdef ISPC_IS_WINDOWS printf("Intel(r) SPMD Program Compiler (ispc), %s (build date %s, LLVM %s)\n" "Supported Visual Studio versions: %s.\n", ISPC_VERSION, BUILD_DATE, ISPC_LLVM_VERSION_STRING, ISPC_VS_VERSION ); #else printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n", ISPC_VERSION, BUILD_VERSION, BUILD_DATE, ISPC_LLVM_VERSION_STRING ); #endif } static void usage(int ret) { lPrintVersion(); printf("\nusage: ispc\n"); printf(" [--addressing={32,64}]\t\tSelect 32- or 64-bit addressing. (Note that 32-bit\n"); printf(" \t\taddressing calculations are done by default, even\n"); printf(" \t\ton 64-bit target architectures.)\n"); printf(" [--arch={%s}]\t\tSelect target architecture\n", Target::SupportedArchs()); printf(" [--c++-include-file=]\t\tSpecify name of file to emit in #include statement in generated C++ code.\n"); #ifndef ISPC_IS_WINDOWS printf(" [--colored-output]\t\tAlways use terminal colors in error/warning messages.\n"); #endif printf(" "); char cpuHelp[2048]; sprintf(cpuHelp, "[--cpu=]\t\t\tSelect target CPU type\n={%s}\n", Target::SupportedCPUs().c_str()); PrintWithWordBreaks(cpuHelp, 16, TerminalWidth(), stdout); printf(" [-D]\t\t\t\t#define given value when running preprocessor\n"); printf(" [--dev-stub ]\t\tEmit device-side offload stub functions to file\n"); #ifdef ISPC_IS_WINDOWS printf(" [--dllexport]\t\t\tMake non-static functions DLL exported. Windows only.\n"); #endif #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 printf(" [--dwarf-version={2,3,4}]\t\tGenerate source-level debug information with given DWARF version (triggers -g)\n"); #endif printf(" [--emit-asm]\t\t\tGenerate assembly language file as output\n"); printf(" [--emit-c++]\t\t\tEmit a C++ source file as output\n"); printf(" [--emit-llvm]\t\t\tEmit LLVM bitode file as output\n"); printf(" [--emit-obj]\t\t\tGenerate object file file as output (default)\n"); printf(" [--force-alignment=]\t\tForce alignment in memory allocations routine to be \n"); printf(" [-g]\t\t\t\tGenerate source-level debug information\n"); printf(" [--help]\t\t\t\tPrint help\n"); printf(" [--help-dev]\t\t\tPrint help for developer options\n"); printf(" [--host-stub ]\t\tEmit host-side offload stub functions to file\n"); printf(" [-h /--header-outfile=]\tOutput filename for header\n"); printf(" [-I ]\t\t\t\tAdd to #include file search path\n"); printf(" [--instrument]\t\t\tEmit instrumentation to gather performance data\n"); printf(" [--math-lib=