llvm.org GIT mirror llvm / d27a258
Cleaned setjmp/longjmp lowering interfaces. Now we're producing right code (both asm & cbe) for Mingw32 target. Removed autoconf checks for underscored versions of setjmp/longjmp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32415 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 12 years ago
9 changed file(s) with 56 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
669669 AC_CHECK_FUNCS([getpagesize getrusage gettimeofday isatty mkdtemp mkstemp ])
670670 AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])
671671 AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
672 AC_CHECK_FUNCS([_setjmp _longjmp setjmp longjmp sigsetjmp siglongjmp])
672 AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp])
673673 AC_C_PRINTF_A
674674 AC_FUNC_ALLOCA
675675 AC_FUNC_RAND48
414414
415415 /* Define to 1 if you have the header file. */
416416 #undef HAVE_WINDOWS_H
417
418 /* Define to 1 if you have the `_longjmp' function. */
419 #undef HAVE__LONGJMP
420
421 /* Define to 1 if you have the `_setjmp' function. */
422 #undef HAVE__SETJMP
423417
424418 /* Installation directory for binary executables */
425419 #undef LLVM_BINDIR
378378 return allowUnalignedMemoryAccesses;
379379 }
380380
381 /// usesUnderscoreSetJmpLongJmp - Determine if we should use _setjmp or setjmp
381 /// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
382382 /// to implement llvm.setjmp.
383 bool usesUnderscoreSetJmpLongJmp() const {
384 return UseUnderscoreSetJmpLongJmp;
385 }
386
383 bool usesUnderscoreSetJmp() const {
384 return UseUnderscoreSetJmp;
385 }
386
387 /// usesUnderscoreLongJmp - Determine if we should use _longjmp or longjmp
388 /// to implement llvm.longjmp.
389 bool usesUnderscoreLongJmp() const {
390 return UseUnderscoreLongJmp;
391 }
392
387393 /// getStackPointerRegisterToSaveRestore - If a physical register, this
388394 /// specifies the register that llvm.savestack/llvm.restorestack should save
389395 /// and restore.
563569 ShiftAmtHandling = OORSA;
564570 }
565571
566 /// setUseUnderscoreSetJmpLongJmp - Indicate whether this target prefers to
567 /// use _setjmp and _longjmp to or implement llvm.setjmp/llvm.longjmp or
568 /// the non _ versions. Defaults to false.
569 void setUseUnderscoreSetJmpLongJmp(bool Val) {
570 UseUnderscoreSetJmpLongJmp = Val;
571 }
572
572 /// setUseUnderscoreSetJmp - Indicate whether this target prefers to
573 /// use _setjmp to implement llvm.setjmp or the non _ version.
574 /// Defaults to false.
575 void setUseUnderscoreSetJmp(bool Val) {
576 UseUnderscoreSetJmp = Val;
577 }
578
579 /// setUseUnderscoreLongJmp - Indicate whether this target prefers to
580 /// use _longjmp to implement llvm.longjmp or the non _ version.
581 /// Defaults to false.
582 void setUseUnderscoreLongJmp(bool Val) {
583 UseUnderscoreLongJmp = Val;
584 }
585
573586 /// setStackPointerRegisterToSaveRestore - If set to a physical register, this
574587 /// specifies the register that llvm.savestack/llvm.restorestack should save
575588 /// and restore.
882895 /// total cycles or lowest register usage.
883896 SchedPreference SchedPreferenceInfo;
884897
885 /// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
886 /// _longjmp to implement llvm.setjmp/llvm.longjmp. Defaults to false.
887 bool UseUnderscoreSetJmpLongJmp;
888
898 /// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
899 /// llvm.setjmp. Defaults to false.
900 bool UseUnderscoreSetJmp;
901
902 /// UseUnderscoreLongJmp - This target prefers to use _longjmp to implement
903 /// llvm.longjmp. Defaults to false.
904 bool UseUnderscoreLongJmp;
905
889906 /// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
890907 unsigned JumpBufSize;
891908
19731973 case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
19741974 case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return 0;
19751975 case Intrinsic::setjmp:
1976 return "_setjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
1976 return "_setjmp"+!TLI.usesUnderscoreSetJmp();
19771977 break;
19781978 case Intrinsic::longjmp:
1979 return "_longjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
1979 return "_longjmp"+!TLI.usesUnderscoreLongJmp();
19801980 break;
19811981 case Intrinsic::memcpy_i32:
19821982 case Intrinsic::memcpy_i64:
4646 sizeof(TargetDAGCombineArray)/sizeof(TargetDAGCombineArray[0]));
4747 maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
4848 allowUnalignedMemoryAccesses = false;
49 UseUnderscoreSetJmpLongJmp = false;
49 UseUnderscoreSetJmp = false;
50 UseUnderscoreLongJmp = false;
5051 IntDivIsCheap = false;
5152 Pow2DivIsCheap = false;
5253 StackPointerRegisterToSaveRestore = 0;
11351135 << "#elif defined(__APPLE__)\n"
11361136 << "extern void *__builtin_alloca(unsigned long);\n"
11371137 << "#define alloca(x) __builtin_alloca(x)\n"
1138 << "#define longjmp _longjmp\n"
1139 << "#define setjmp _setjmp\n"
11381140 << "#elif defined(__sun__)\n"
11391141 << "#if defined(__sparcv9)\n"
11401142 << "extern void *__builtin_alloca(unsigned long);\n"
21402142 Out << ')';
21412143 return;
21422144 case Intrinsic::setjmp:
2143 #if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
2144 Out << "_"; // Use _setjmp on systems that support it!
2145 #endif
21462145 Out << "setjmp(*(jmp_buf*)";
21472146 writeOperand(I.getOperand(1));
21482147 Out << ')';
21492148 return;
21502149 case Intrinsic::longjmp:
2151 #if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
2152 Out << "_"; // Use _longjmp on systems that support it!
2153 #endif
21542150 Out << "longjmp(*(jmp_buf*)";
21552151 writeOperand(I.getOperand(1));
21562152 Out << ", ";
11351135 << "#elif defined(__APPLE__)\n"
11361136 << "extern void *__builtin_alloca(unsigned long);\n"
11371137 << "#define alloca(x) __builtin_alloca(x)\n"
1138 << "#define longjmp _longjmp\n"
1139 << "#define setjmp _setjmp\n"
11381140 << "#elif defined(__sun__)\n"
11391141 << "#if defined(__sparcv9)\n"
11401142 << "extern void *__builtin_alloca(unsigned long);\n"
21402142 Out << ')';
21412143 return;
21422144 case Intrinsic::setjmp:
2143 #if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
2144 Out << "_"; // Use _setjmp on systems that support it!
2145 #endif
21462145 Out << "setjmp(*(jmp_buf*)";
21472146 writeOperand(I.getOperand(1));
21482147 Out << ')';
21492148 return;
21502149 case Intrinsic::longjmp:
2151 #if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
2152 Out << "_"; // Use _longjmp on systems that support it!
2153 #endif
21542150 Out << "longjmp(*(jmp_buf*)";
21552151 writeOperand(I.getOperand(1));
21562152 Out << ", ";
4040 setPow2DivIsCheap();
4141
4242 // Use _setjmp/_longjmp instead of setjmp/longjmp.
43 setUseUnderscoreSetJmpLongJmp(true);
43 setUseUnderscoreSetJmp(true);
44 setUseUnderscoreLongJmp(true);
4445
4546 // Set up the register classes.
4647 addRegisterClass(MVT::i32, PPC::GPRCRegisterClass);
5353 setShiftAmountFlavor(Mask); // shl X, 32 == shl X, 0
5454 setStackPointerRegisterToSaveRestore(X86StackPtr);
5555
56 if (!Subtarget->isTargetDarwin())
56 if (Subtarget->isTargetDarwin()) {
5757 // Darwin should use _setjmp/_longjmp instead of setjmp/longjmp.
58 setUseUnderscoreSetJmpLongJmp(true);
59
58 setUseUnderscoreSetJmp(false);
59 setUseUnderscoreLongJmp(false);
60 } else if (Subtarget->isTargetCygwin()) {
61 // MS runtime is weird: it exports _setjmp, but longjmp!
62 setUseUnderscoreSetJmp(true);
63 setUseUnderscoreLongJmp(false);
64 } else {
65 setUseUnderscoreSetJmp(true);
66 setUseUnderscoreLongJmp(true);
67 }
68
6069 // Add legal addressing mode scale values.
6170 addLegalAddressScale(8);
6271 addLegalAddressScale(4);