46 #ifdef ISPC_HOST_IS_WINDOWS 50 #endif // ISPC_HOST_IS_WINDOWS 51 #include <llvm/Support/CommandLine.h> 52 #include <llvm/Support/Debug.h> 53 #include <llvm/Support/Signals.h> 54 #include <llvm/Support/TargetRegistry.h> 55 #include <llvm/Support/TargetSelect.h> 57 #ifdef ISPC_HOST_IS_WINDOWS 58 #define strcasecmp stricmp 60 #define BUILD_DATE __DATE__ 62 #define BUILD_VERSION "" 64 #define ISPC_VS_VERSION "Visual Studio 2015 and later" 66 #define ISPC_VS_VERSION "Visual Studio 2013 and earlier" 68 #endif // ISPC_HOST_IS_WINDOWS 71 #ifdef ISPC_HOST_IS_WINDOWS 72 printf(
"Intel(r) Implicit SPMD Program Compiler (Intel(r) ISPC), %s (build date %s, LLVM %s)\n" 73 "Supported Visual Studio versions: %s.\n",
76 printf(
"Intel(r) Implicit SPMD Program Compiler (Intel(r) ISPC), %s (build %s @ %s, LLVM %s)\n",
ISPC_VERSION,
84 printf(
"This version is likely linked against non-recommended LLVM binaries.\n" 85 "For best stability and performance please use official binary distribution from " 86 "http://ispc.github.io/downloads.html");
90 [[noreturn]]
static void usage(
int ret) {
92 printf(
"\nusage: ispc\n");
93 printf(
" [--addressing={32,64}]\t\tSelect 32- or 64-bit addressing. (Note that 32-bit\n");
94 printf(
" \t\taddressing calculations are done by default, even\n");
95 printf(
" \t\ton 64-bit target architectures.)\n");
97 printf(
" [--c++-include-file=<name>]\t\tSpecify name of file to emit in #include statement in generated C++ " 99 #ifndef ISPC_HOST_IS_WINDOWS 100 printf(
" [--colored-output]\t\tAlways use terminal colors in error/warning messages\n");
104 snprintf(cpuHelp,
sizeof(cpuHelp),
"[--cpu=<cpu>]\t\t\tSelect target CPU type\n<cpu>={%s}\n",
107 printf(
" [-D<foo>]\t\t\t\t#define given value when running preprocessor\n");
108 printf(
" [--dev-stub <filename>]\t\tEmit device-side offload stub functions to file\n");
109 printf(
" [--dllexport]\t\t\tMake non-static functions DLL exported. Windows target only\n");
110 printf(
" [--dwarf-version={2,3,4}]\t\tGenerate source-level debug information with given DWARF version " 111 "(triggers -g). Ignored for Windows target\n");
112 printf(
" [--emit-asm]\t\t\tGenerate assembly language file as output\n");
113 printf(
" [--x86-asm-syntax=<option>]\t\tSelect style of code if generating assembly\n");
114 printf(
" intel\t\t\t\tEmit Intel-style assembly\n");
115 printf(
" att\t\t\t\tEmit AT&T-style assembly\n");
116 printf(
" [--emit-c++]\t\t\tEmit a C++ source file as output\n");
117 printf(
" [--emit-llvm]\t\t\tEmit LLVM bitcode file as output\n");
118 printf(
" [--emit-llvm-text]\t\t\tEmit LLVM bitcode file as output in textual form\n");
119 printf(
" [--emit-obj]\t\t\tGenerate object file file as output (default)\n");
120 printf(
" [--force-alignment=<value>]\t\tForce alignment in memory allocations routine to be <value>\n");
121 printf(
" [--error-limit=<value>]\t\tLimit maximum number of errors emitting by ISPC to <value>\n");
122 printf(
" [-g]\t\t\t\tGenerate source-level debug information\n");
123 printf(
" [--help]\t\t\t\tPrint help\n");
124 printf(
" [--help-dev]\t\t\tPrint help for developer options\n");
125 printf(
" [--host-stub <filename>]\t\tEmit host-side offload stub functions to file\n");
126 printf(
" [-h <name>/--header-outfile=<name>]\tOutput filename for header\n");
127 printf(
" [-I <path>]\t\t\t\tAdd <path> to #include file search path\n");
128 printf(
" [--instrument]\t\t\tEmit instrumentation to gather performance data\n");
129 printf(
" [--math-lib=<option>]\t\tSelect math library\n");
130 printf(
" default\t\t\t\tUse ispc's built-in math functions\n");
131 printf(
" fast\t\t\t\tUse high-performance but lower-accuracy math functions\n");
132 printf(
" svml\t\t\t\tUse the Intel(r) SVML math libraries\n");
133 printf(
" system\t\t\t\tUse the system's math library (*may be quite slow*)\n");
134 printf(
" [-MMM <filename>]\t\t\tWrite #include dependencies to given file.\n");
135 printf(
" [-M]\t\t\t\tOutput a rule suitable for `make' describing the dependencies of the main source file to " 137 printf(
" [-MF <filename>]\t\t\tWhen used with `-M', specifies a file to write the dependencies to.\n");
138 printf(
" [-MT <filename>]\t\t\tWhen used with `-M', changes the target of the rule emitted by dependency " 140 printf(
" [--no-omit-frame-pointer]\t\tDisable frame pointer omission. It may be useful for profiling\n");
141 printf(
" [--nostdlib]\t\t\tDon't make the ispc standard library available\n");
142 printf(
" [--no-pragma-once]\t\t\tDon't use #pragma once in created headers\n");
143 printf(
" [--nocpp]\t\t\t\tDon't run the C preprocessor\n");
144 printf(
" [-o <name>/--outfile=<name>]\tOutput filename (may be \"-\" for standard output)\n");
145 printf(
" [-O0/-O(1/2/3)]\t\t\tSet optimization level. Default behavior is to optimize for speed.\n");
146 printf(
" -O0\t\t\t\tOptimizations disabled.\n");
147 printf(
" -O1\t\t\t\tOptimization for size.\n");
148 printf(
" -O2/O3\t\t\t\tOptimization for speed.\n");
149 printf(
" [--opt=<option>]\t\t\tSet optimization option\n");
150 printf(
" disable-assertions\t\tRemove assertion statements from final code.\n");
151 printf(
" disable-fma\t\t\tDisable 'fused multiply-add' instructions (on targets that support them)\n");
152 printf(
" disable-loop-unroll\t\tDisable loop unrolling.\n");
153 #if ISPC_LLVM_VERSION >= ISPC_LLVM_8_0 154 printf(
" disable-zmm\t\tDisable using zmm registers for avx512 targets in favour of ymm. This also affects " 157 printf(
" fast-masked-vload\t\tFaster masked vector loads on SSE (may go past end of array)\n");
158 printf(
" fast-math\t\t\tPerform non-IEEE-compliant optimizations of numeric expressions\n");
159 printf(
" force-aligned-memory\t\tAlways issue \"aligned\" vector load and store instructions\n");
160 printf(
" [--pic]\t\t\t\tGenerate position-independent code. Ignored for Windows target\n");
161 printf(
" [--quiet]\t\t\t\tSuppress all output\n");
162 printf(
" [--support-matrix]\t\t\tPrint full matrix of supported targets, architectures and OSes\n");
164 char targetHelp[2048];
165 snprintf(targetHelp,
sizeof(targetHelp),
166 "[--target=<t>]\t\t\tSelect target ISA and width.\n" 171 snprintf(targetHelp,
sizeof(targetHelp),
"[--target-os=<os>]\t\t\tSelect target OS. <os>={%s}",
174 printf(
" [--version]\t\t\t\tPrint ispc version\n");
175 printf(
" [--werror]\t\t\t\tTreat warnings as errors\n");
176 printf(
" [--woff]\t\t\t\tDisable warnings\n");
177 printf(
" [--wno-perf]\t\t\tDon't issue warnings related to performance-related issues\n");
178 printf(
" [@<filename>]\t\t\tRead additional arguments from the given file\n");
179 printf(
" <file to compile or \"-\" for stdin>\n");
185 printf(
"\nusage (developer options): ispc\n");
186 printf(
" [--debug]\t\t\t\tPrint information useful for debugging ispc\n");
187 printf(
" [--debug-llvm]\t\t\tEnable LLVM debugging information (dumps to stderr)\n");
188 printf(
" [--print-target]\t\t\tPrint target's information\n");
189 printf(
" [--fuzz-test]\t\t\tRandomly perturb program input to test error conditions\n");
190 printf(
" [--fuzz-seed=<value>]\t\tSeed value for RNG for fuzz testing\n");
191 printf(
" [--opt=<option>]\t\t\tSet optimization option\n");
192 printf(
" disable-all-on-optimizations\t\tDisable optimizations that take advantage of \"all on\" mask\n");
193 printf(
" disable-blended-masked-stores\t\tScalarize masked stores on SSE (vs. using vblendps)\n");
194 printf(
" disable-blending-removal\t\tDisable eliminating blend at same scope\n");
195 printf(
" disable-coalescing\t\t\tDisable gather coalescing\n");
196 printf(
" disable-coherent-control-flow\t\tDisable coherent control flow optimizations\n");
197 printf(
" disable-gather-scatter-flattening\tDisable flattening when all lanes are on\n");
198 printf(
" disable-gather-scatter-optimizations\tDisable improvements to gather/scatter\n");
199 printf(
" disable-handle-pseudo-memory-ops\tLeave __pseudo_* calls for gather/scatter/etc. in final IR\n");
200 printf(
" disable-uniform-control-flow\t\tDisable uniform control flow optimizations\n");
201 printf(
" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n");
202 printf(
" [--yydebug]\t\t\t\tPrint debugging information during parsing\n");
203 #ifndef ISPC_NO_DUMPS 204 printf(
" [--debug-phase=<value>]\t\tSet optimization phases to dump. " 205 "--debug-phase=first,210:220,300,305,310:last\n");
206 printf(
" [--dump-file]\t\t\tDump module IR to file(s) in current directory\n");
208 printf(
" [--off-phase=<value>]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n");
218 int len =
string.length();
219 char *ptr =
new char[len + 1];
220 strncpy(ptr,
string.c_str(), len);
233 bool insideDQ =
false;
234 bool insideSQ =
false;
247 while (c !=
'\0' && !(isspace(c) && !insideDQ && !insideSQ)) {
248 if (c ==
'\"' && !insideSQ) {
250 insideDQ = !insideDQ;
253 if (c ==
'\'' && !insideDQ) {
255 insideSQ = !insideSQ;
272 int c = fgetc(InputFile);
290 char c = *InputString;
303 static void lAddSingleArg(
char *arg, std::vector<char *> &argv);
335 char *filename = &arg[1];
336 FILE *file = fopen(filename,
"r");
353 static void lGetAllArgs(
int Argc,
char *Argv[], std::vector<char *> &argv) {
355 for (
int i = 0; i < Argc; ++i)
359 const char *env = getenv(
"ISPC_ARGS");
364 static void lSignal(
void *) {
FATAL(
"Unhandled signal sent to process; terminating."); }
375 if (vasprintf(&messageBuf, format, args) == -1) {
376 fprintf(stderr,
"vasprintf() unable to allocate memory!\n");
380 m_messages.push_back(std::make_pair(msg_type, messageBuf));
389 va_start(args, format);
390 AddMessage(MsgType::error, format, args);
395 va_start(args, format);
396 AddMessage(MsgType::warning, format, args);
401 for (
auto &message : m_messages) {
416 if (strncmp(stage,
"first", 5) == 0) {
418 }
else if (strncmp(stage,
"last", 4) == 0) {
423 errorHandler.
AddError(
"Phases must be from 0 to %d. %s is incorrect.", LAST_OPT_NUMBER, stage);
432 constexpr
int parsing_limit = 100;
433 std::set<int> phases;
434 auto len = strnlen(stages, parsing_limit);
436 errorHandler.
AddError(
"Empty phase list.");
439 if (len == parsing_limit && stages[parsing_limit] !=
'\0') {
440 errorHandler.
AddError(
"Phase list is too long.");
446 for (
unsigned i = 0; i < strlen(stages); i++) {
447 if ((stages[i] ==
',') || (i == strlen(stages) - 1)) {
448 for (
int j = begin; j < end + 1; j++) {
453 }
else if (stages[i] ==
':') {
461 #ifdef ISPC_HOST_IS_WINDOWS 466 size_t pos = 0, pos_end;
467 std::string str_path(path);
469 pos_end = str_path.find(delim, pos);
470 size_t len = (pos_end == std::string::npos) ?
476 std::string s = str_path.substr(pos, len);
479 }
while (pos_end != std::string::npos);
482 int main(
int Argc,
char *Argv[]) {
483 std::vector<char *> argv;
485 int argc = argv.size();
487 llvm::sys::AddSignalHandler(
lSignal, NULL);
495 LLVMInitializeX86TargetInfo();
496 LLVMInitializeX86Target();
497 LLVMInitializeX86AsmPrinter();
498 LLVMInitializeX86AsmParser();
499 LLVMInitializeX86Disassembler();
500 LLVMInitializeX86TargetMC();
503 #ifdef ISPC_ARM_ENABLED 505 LLVMInitializeARMTargetInfo();
506 LLVMInitializeARMTarget();
507 LLVMInitializeARMAsmPrinter();
508 LLVMInitializeARMAsmParser();
509 LLVMInitializeARMDisassembler();
510 LLVMInitializeARMTargetMC();
512 LLVMInitializeAArch64TargetInfo();
513 LLVMInitializeAArch64Target();
514 LLVMInitializeAArch64AsmPrinter();
515 LLVMInitializeAArch64AsmParser();
516 LLVMInitializeAArch64Disassembler();
517 LLVMInitializeAArch64TargetMC();
520 #ifdef ISPC_WASM_ENABLED 521 LLVMInitializeWebAssemblyAsmParser();
522 LLVMInitializeWebAssemblyAsmPrinter();
523 LLVMInitializeWebAssemblyDisassembler();
524 LLVMInitializeWebAssemblyTarget();
525 LLVMInitializeWebAssemblyTargetInfo();
526 LLVMInitializeWebAssemblyTargetMC();
530 const char *headerFileName = NULL;
531 const char *outFileName = NULL;
532 const char *includeFileName = NULL;
533 const char *depsFileName = NULL;
534 const char *depsTargetName = NULL;
535 const char *hostStubFileName = NULL;
536 const char *devStubFileName = NULL;
544 std::vector<ISPCTarget> targets;
545 const char *cpu = NULL, *intelAsmSyntax = NULL;
549 for (
int i = 1; i < argc; ++i) {
550 if (!strcmp(argv[i],
"--help")) {
552 }
else if (!strcmp(argv[i],
"--help-dev")) {
554 }
else if (!strcmp(argv[i],
"--support-matrix")) {
557 }
else if (!strncmp(argv[i],
"-D", 2)) {
559 }
else if (!strncmp(argv[i],
"--addressing=", 13)) {
560 if (atoi(argv[i] + 13) == 64)
563 else if (atoi(argv[i] + 13) == 32)
566 errorHandler.
AddError(
"Addressing width \"%s\" invalid -- only 32 and " 570 }
else if (!strncmp(argv[i],
"--arch=", 7)) {
571 Arch prev_arch = arch;
575 errorHandler.
AddError(
"Unsupported value for --arch, supported values are: %s",
579 if (prev_arch !=
Arch::none && prev_arch != arch) {
582 errorHandler.
AddWarning(
"Overwriting --arch=%s with --arch=%s", prev_arch_str.c_str(),
585 }
else if (!strncmp(argv[i],
"--x86-asm-syntax=", 17)) {
586 intelAsmSyntax = argv[i] + 17;
587 if (!((std::string(intelAsmSyntax) ==
"intel") || (std::string(intelAsmSyntax) ==
"att"))) {
588 intelAsmSyntax = NULL;
589 errorHandler.
AddError(
"Invalid value for --x86-asm-syntax: \"%s\" -- " 590 "only intel and att are allowed.",
593 }
else if (!strncmp(argv[i],
"--cpu=", 6)) {
595 }
else if (!strcmp(argv[i],
"--fast-math")) {
596 errorHandler.
AddError(
"--fast-math option has been renamed to --opt=fast-math!");
597 }
else if (!strcmp(argv[i],
"--fast-masked-vload")) {
598 errorHandler.
AddError(
"--fast-masked-vload option has been renamed to " 599 "--opt=fast-masked-vload!");
600 }
else if (!strcmp(argv[i],
"--debug"))
602 else if (!strcmp(argv[i],
"--debug-llvm"))
603 llvm::DebugFlag =
true;
604 else if (!strcmp(argv[i],
"--dllexport"))
606 else if (!strncmp(argv[i],
"--dwarf-version=", 16)) {
607 int val = atoi(argv[i] + 16);
608 if (2 <= val && val <= 4) {
612 errorHandler.
AddError(
"Invalid value for DWARF version: \"%s\" -- " 613 "only 2, 3 and 4 are allowed.",
616 }
else if (!strcmp(argv[i],
"--print-target"))
618 else if (!strcmp(argv[i],
"--no-omit-frame-pointer"))
620 else if (!strcmp(argv[i],
"--instrument"))
622 else if (!strcmp(argv[i],
"--no-pragma-once"))
624 else if (!strcmp(argv[i],
"-g")) {
626 }
else if (!strcmp(argv[i],
"--emit-asm"))
628 else if (!strcmp(argv[i],
"--emit-c++"))
630 else if (!strcmp(argv[i],
"--emit-llvm"))
632 else if (!strcmp(argv[i],
"--emit-llvm-text"))
634 else if (!strcmp(argv[i],
"--emit-obj"))
636 else if (!strcmp(argv[i],
"-I")) {
640 errorHandler.
AddError(
"No path specified after -I option.");
642 }
else if (!strncmp(argv[i],
"-I", 2))
644 else if (!strcmp(argv[i],
"--fuzz-test"))
646 else if (!strncmp(argv[i],
"--fuzz-seed=", 12))
648 else if (!strcmp(argv[i],
"--target")) {
652 targets = result.first;
653 if (!result.second.empty()) {
654 errorHandler.
AddError(
"Incorrect targets: %s. Choices are: %s.", result.second.c_str(),
658 errorHandler.
AddError(
"No target specified after --target option.");
660 }
else if (!strncmp(argv[i],
"--target=", 9)) {
662 targets = result.first;
663 if (!result.second.empty()) {
664 errorHandler.
AddError(
"Incorrect targets: %s. Choices are: %s.", result.second.c_str(),
667 }
else if (!strncmp(argv[i],
"--target-os=", 12)) {
670 errorHandler.
AddError(
"Unsupported value for --target-os, supported values are: %s",
673 }
else if (!strncmp(argv[i],
"--math-lib=", 11)) {
674 const char *lib = argv[i] + 11;
675 if (!strcmp(lib,
"default"))
677 else if (!strcmp(lib,
"fast"))
679 else if (!strcmp(lib,
"svml"))
681 else if (!strcmp(lib,
"system"))
684 errorHandler.
AddError(
"Unknown --math-lib= option \"%s\".", lib);
686 }
else if (!strncmp(argv[i],
"--opt=", 6)) {
687 const char *opt = argv[i] + 6;
688 if (!strcmp(opt,
"fast-math"))
690 else if (!strcmp(opt,
"fast-masked-vload"))
692 else if (!strcmp(opt,
"disable-assertions"))
694 else if (!strcmp(opt,
"disable-loop-unroll"))
696 else if (!strcmp(opt,
"disable-fma"))
698 #if ISPC_LLVM_VERSION >= ISPC_LLVM_8_0 699 else if (!strcmp(opt,
"disable-zmm"))
702 else if (!strcmp(opt,
"force-aligned-memory"))
707 else if (!strcmp(opt,
"disable-all-on-optimizations"))
709 else if (!strcmp(opt,
"disable-coalescing"))
711 else if (!strcmp(opt,
"disable-handle-pseudo-memory-ops"))
713 else if (!strcmp(opt,
"disable-blended-masked-stores"))
715 else if (!strcmp(opt,
"disable-coherent-control-flow"))
717 else if (!strcmp(opt,
"disable-uniform-control-flow"))
719 else if (!strcmp(opt,
"disable-gather-scatter-optimizations"))
721 else if (!strcmp(opt,
"disable-blending-removal"))
723 else if (!strcmp(opt,
"disable-gather-scatter-flattening"))
725 else if (!strcmp(opt,
"disable-uniform-memory-optimizations"))
728 errorHandler.
AddError(
"Unknown --opt= option \"%s\".", opt);
730 }
else if (!strncmp(argv[i],
"--force-alignment=", 18)) {
732 }
else if (!strcmp(argv[i],
"--woff") || !strcmp(argv[i],
"-woff")) {
735 }
else if (!strcmp(argv[i],
"--werror"))
737 else if (!strncmp(argv[i],
"--error-limit=", 14)) {
738 int errLimit = atoi(argv[i] + 14);
742 errorHandler.
AddError(
"Invalid value for --error-limit: \"%d\" -- " 743 "value cannot be a negative number.",
745 }
else if (!strcmp(argv[i],
"--nowrap"))
747 else if (!strcmp(argv[i],
"--wno-perf") || !strcmp(argv[i],
"-wno-perf"))
749 else if (!strcmp(argv[i],
"-o")) {
751 outFileName = argv[i];
753 errorHandler.
AddError(
"No output file specified after -o option.");
755 }
else if (!strncmp(argv[i],
"--outfile=", 10))
756 outFileName = argv[i] + strlen(
"--outfile=");
757 else if (!strcmp(argv[i],
"-h")) {
759 headerFileName = argv[i];
761 errorHandler.
AddError(
"No header file name specified after -h option.");
763 }
else if (!strncmp(argv[i],
"--header-outfile=", 17)) {
764 headerFileName = argv[i] + strlen(
"--header-outfile=");
765 }
else if (!strncmp(argv[i],
"--c++-include-file=", 19)) {
766 includeFileName = argv[i] + strlen(
"--c++-include-file=");
767 }
else if (!strcmp(argv[i],
"-O0")) {
770 }
else if (!strcmp(argv[i],
"-O") || !strcmp(argv[i],
"-O1") || !strcmp(argv[i],
"-O2") ||
771 !strcmp(argv[i],
"-O3")) {
774 if (!strcmp(argv[i],
"-O1"))
776 }
else if (!strcmp(argv[i],
"-")) {
778 }
else if (!strcmp(argv[i],
"--nostdlib"))
780 else if (!strcmp(argv[i],
"--nocpp"))
782 else if (!strcmp(argv[i],
"--pic"))
784 #ifndef ISPC_IS_HOST_WINDOWS 785 else if (!strcmp(argv[i],
"--colored-output"))
787 #endif // !ISPC_IS_HOST_WINDOWS 788 else if (!strcmp(argv[i],
"--quiet"))
790 else if (!strcmp(argv[i],
"--yydebug")) {
793 }
else if (!strcmp(argv[i],
"-MMM")) {
795 depsFileName = argv[i];
798 errorHandler.
AddError(
"No output file name specified after -MMM option.");
800 }
else if (!strcmp(argv[i],
"-M")) {
802 }
else if (!strcmp(argv[i],
"-MF")) {
803 depsFileName =
nullptr;
805 depsFileName = argv[i];
807 errorHandler.
AddError(
"No output file name specified after -MF option.");
809 }
else if (!strcmp(argv[i],
"-MT")) {
810 depsTargetName =
nullptr;
812 depsTargetName = argv[i];
814 errorHandler.
AddError(
"No target name specified after -MT option.");
816 }
else if (!strcmp(argv[i],
"--dev-stub")) {
818 devStubFileName = argv[i];
820 errorHandler.
AddError(
"No output file name specified after --dev-stub option.");
822 }
else if (!strcmp(argv[i],
"--host-stub")) {
824 hostStubFileName = argv[i];
826 errorHandler.
AddError(
"No output file name specified after --host-stub option.");
829 #ifndef ISPC_NO_DUMPS 830 else if (strncmp(argv[i],
"--debug-phase=", 14) == 0) {
831 errorHandler.
AddWarning(
"Adding debug phases may change the way PassManager" 832 "handles the phases and it may possibly make some bugs go" 833 "away or introduce the new ones.");
835 }
else if (strncmp(argv[i],
"--dump-file", 11) == 0)
839 else if (strncmp(argv[i],
"--off-phase=", 12) == 0) {
841 }
else if (!strcmp(argv[i],
"-v") || !strcmp(argv[i],
"--version")) {
844 }
else if (argv[i][0] ==
'-') {
845 errorHandler.
AddError(
"Unknown option \"%s\".", argv[i]);
848 errorHandler.
AddError(
"Multiple input files specified on command " 849 "line: \"%s\" and \"%s\".",
862 Error(
SourcePos(),
"No input file were specified. To read text from stdin use \"-\" as file name.");
879 Warning(
SourcePos(),
"--arch switch is ignored for PS4 target OS. x86-64 arch is used.");
890 if (targets.empty()) {
894 "No --target specified on command-line." 896 target_string.c_str());
902 #ifdef ISPC_HOST_IS_WINDOWS 903 int seed = (unsigned)time(NULL);
910 #ifdef ISPC_HOST_IS_WINDOWS 917 if (depsFileName != NULL)
918 flags &= ~
Module::OutputDepsToStdout;
922 "mode specified; did you forget to specify -M or -MMM? " 923 "No dependency output will be generated.");
930 "-MMM takes precedence.");
934 if (outFileName == NULL && headerFileName == NULL &&
936 devStubFileName == NULL) {
938 "Program will be compiled and warnings/errors will " 939 "be issued, but no output will be generated.");
947 Warning(
SourcePos(),
"--dllexport switch will be ignored, as the target OS is not Windows.");
950 if (targets.size() > 1)
953 if ((ot ==
Module::Asm) && (intelAsmSyntax != NULL)) {
954 std::vector<const char *> Args(3);
955 Args[0] =
"ispc (LLVM option parsing)";
957 if (std::string(intelAsmSyntax) ==
"intel")
958 Args[1] =
"--x86-asm-syntax=intel";
960 Args[1] =
"--x86-asm-syntax=att";
961 llvm::cl::ParseCommandLineOptions(2, Args.data());
964 for (
auto target : targets) {
966 Assert(targets.size() == 1 &&
"wasm32 supports only one target: i32x4");
973 depsFileName, depsTargetName, hostStubFileName, devStubFileName);
std::string ArchToString(Arch arch)
bool isMultiTargetCompilation
std::vector< std::pair< MsgType, std::string > > m_messages
void AddMessage(MsgType msg_type, const char *format, va_list args)
TargetLibRegistry * target_registry
This structure collects together a number of global variables.
static int ParsingPhaseName(char *stage, ArgErrors &errorHandler)
bool disableBlendedMaskedStores
static void lSignal(void *)
Registry to handle bitcode libraries.
virtual char GetNextChar()=0
std::vector< std::string > includePath
void AddWarning(const char *format,...) PRINTF_FUNC
std::string getSupportedTargets()
static void lAddSingleArg(char *arg, std::vector< char *> &argv)
char * AllocateString(std::string string)
static void devUsage(int ret)
virtual char GetNextChar()
std::set< int > debug_stages
bool disableMaskAllOnOptimizations
static std::string SupportedCPUs()
bool disableGatherScatterOptimizations
bool disableCoherentControlFlow
std::string getSupportedOSes()
static void lPrintVersion()
static void lAddArgsFromFactory(ArgFactory &Args, std::vector< char *> &argv)
#define ISPC_LLVM_VERSION_STRING
Arch ParseArch(std::string arch)
CodegenOptLevel codegenOptLevel
void printSupportMatrix() const
Representation of a range of positions in a source file.
std::string ISPCTargetToString(ISPCTarget target)
bool disableUniformMemoryOptimizations
bool generateDebuggingSymbols
static void lAddArgsFromFile(FILE *file, std::vector< char *> &argv)
static void lParseInclude(const char *path)
bool disableHandlePseudoMemoryOps
bool force32BitAddressing
static std::set< int > ParsingPhases(char *stages, ArgErrors &errorHandler)
void Error(SourcePos p, const char *fmt,...)
int main(int Argc, char *Argv[])
StringArgFactory(const char *string)
TargetOS ParseOS(std::string os)
bool disableUniformControlFlow
bool disableMaskedStoreToStore
static void lAddArgsFromString(const char *string, std::vector< char *> &argv)
void AddError(const char *format,...) PRINTF_FUNC
void PrintWithWordBreaks(const char *buf, int indent, int columnWidth, FILE *out)
std::set< int > off_stages
static int CompileAndOutput(const char *srcFile, Arch arch, const char *cpu, std::vector< ISPCTarget > targets, OutputFlags outputFlags, OutputType outputType, const char *outFileName, const char *headerFileName, const char *includeFileName, const char *depsFileName, const char *depsTargetName, const char *hostStubFileName, const char *devStubFileName)
std::vector< std::string > cppArgs
virtual char GetNextChar()
Declaration of the Module class, which is the ispc-side representation of the results of compiling a ...
static void lGetAllArgs(int Argc, char *Argv[], std::vector< char *> &argv)
Main ispc.header file. Defines Target, Globals and Opt classes.
static void usage(int ret)
void Warning(SourcePos p, const char *fmt,...)
std::pair< std::vector< ISPCTarget >, std::string > ParseISPCTargets(const char *target)
File with declarations for classes related to type representation.
bool disableGatherScatterFlattening
FileArgFactory(FILE *file)
std::string getSupportedArchs()