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
This commit is contained in:
Anton Korobeynikov 2006-12-10 23:12:42 +00:00
parent ca3aa26c20
commit d27a258d2d
9 changed files with 54 additions and 40 deletions

View File

@ -670,7 +670,7 @@ AC_CHECK_FUNCS([backtrace ceilf floorf roundf rintf nearbyintf getcwd ])
AC_CHECK_FUNCS([getpagesize getrusage gettimeofday isatty mkdtemp mkstemp ])
AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])
AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
AC_CHECK_FUNCS([_setjmp _longjmp setjmp longjmp sigsetjmp siglongjmp])
AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp])
AC_C_PRINTF_A
AC_FUNC_ALLOCA
AC_FUNC_RAND48

View File

@ -416,12 +416,6 @@
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if you have the `_longjmp' function. */
#undef HAVE__LONGJMP
/* Define to 1 if you have the `_setjmp' function. */
#undef HAVE__SETJMP
/* Installation directory for binary executables */
#undef LLVM_BINDIR

View File

@ -379,12 +379,18 @@ public:
return allowUnalignedMemoryAccesses;
}
/// usesUnderscoreSetJmpLongJmp - Determine if we should use _setjmp or setjmp
/// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
/// to implement llvm.setjmp.
bool usesUnderscoreSetJmpLongJmp() const {
return UseUnderscoreSetJmpLongJmp;
bool usesUnderscoreSetJmp() const {
return UseUnderscoreSetJmp;
}
/// usesUnderscoreLongJmp - Determine if we should use _longjmp or longjmp
/// to implement llvm.longjmp.
bool usesUnderscoreLongJmp() const {
return UseUnderscoreLongJmp;
}
/// getStackPointerRegisterToSaveRestore - If a physical register, this
/// specifies the register that llvm.savestack/llvm.restorestack should save
/// and restore.
@ -564,13 +570,20 @@ protected:
ShiftAmtHandling = OORSA;
}
/// setUseUnderscoreSetJmpLongJmp - Indicate whether this target prefers to
/// use _setjmp and _longjmp to or implement llvm.setjmp/llvm.longjmp or
/// the non _ versions. Defaults to false.
void setUseUnderscoreSetJmpLongJmp(bool Val) {
UseUnderscoreSetJmpLongJmp = Val;
/// setUseUnderscoreSetJmp - Indicate whether this target prefers to
/// use _setjmp to implement llvm.setjmp or the non _ version.
/// Defaults to false.
void setUseUnderscoreSetJmp(bool Val) {
UseUnderscoreSetJmp = Val;
}
/// setUseUnderscoreLongJmp - Indicate whether this target prefers to
/// use _longjmp to implement llvm.longjmp or the non _ version.
/// Defaults to false.
void setUseUnderscoreLongJmp(bool Val) {
UseUnderscoreLongJmp = Val;
}
/// setStackPointerRegisterToSaveRestore - If set to a physical register, this
/// specifies the register that llvm.savestack/llvm.restorestack should save
/// and restore.
@ -883,10 +896,14 @@ private:
/// total cycles or lowest register usage.
SchedPreference SchedPreferenceInfo;
/// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
/// _longjmp to implement llvm.setjmp/llvm.longjmp. Defaults to false.
bool UseUnderscoreSetJmpLongJmp;
/// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
/// llvm.setjmp. Defaults to false.
bool UseUnderscoreSetJmp;
/// UseUnderscoreLongJmp - This target prefers to use _longjmp to implement
/// llvm.longjmp. Defaults to false.
bool UseUnderscoreLongJmp;
/// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
unsigned JumpBufSize;

View File

@ -1974,10 +1974,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return 0;
case Intrinsic::setjmp:
return "_setjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
return "_setjmp"+!TLI.usesUnderscoreSetJmp();
break;
case Intrinsic::longjmp:
return "_longjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
return "_longjmp"+!TLI.usesUnderscoreLongJmp();
break;
case Intrinsic::memcpy_i32:
case Intrinsic::memcpy_i64:

View File

@ -47,7 +47,8 @@ TargetLowering::TargetLowering(TargetMachine &tm)
sizeof(TargetDAGCombineArray)/sizeof(TargetDAGCombineArray[0]));
maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
allowUnalignedMemoryAccesses = false;
UseUnderscoreSetJmpLongJmp = false;
UseUnderscoreSetJmp = false;
UseUnderscoreLongJmp = false;
IntDivIsCheap = false;
Pow2DivIsCheap = false;
StackPointerRegisterToSaveRestore = 0;

View File

@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#elif defined(__APPLE__)\n"
<< "extern void *__builtin_alloca(unsigned long);\n"
<< "#define alloca(x) __builtin_alloca(x)\n"
<< "#define longjmp _longjmp\n"
<< "#define setjmp _setjmp\n"
<< "#elif defined(__sun__)\n"
<< "#if defined(__sparcv9)\n"
<< "extern void *__builtin_alloca(unsigned long);\n"
@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
Out << ')';
return;
case Intrinsic::setjmp:
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
Out << "_"; // Use _setjmp on systems that support it!
#endif
Out << "setjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ')';
return;
case Intrinsic::longjmp:
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
Out << "_"; // Use _longjmp on systems that support it!
#endif
Out << "longjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ", ";

View File

@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#elif defined(__APPLE__)\n"
<< "extern void *__builtin_alloca(unsigned long);\n"
<< "#define alloca(x) __builtin_alloca(x)\n"
<< "#define longjmp _longjmp\n"
<< "#define setjmp _setjmp\n"
<< "#elif defined(__sun__)\n"
<< "#if defined(__sparcv9)\n"
<< "extern void *__builtin_alloca(unsigned long);\n"
@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
Out << ')';
return;
case Intrinsic::setjmp:
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
Out << "_"; // Use _setjmp on systems that support it!
#endif
Out << "setjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ')';
return;
case Intrinsic::longjmp:
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
Out << "_"; // Use _longjmp on systems that support it!
#endif
Out << "longjmp(*(jmp_buf*)";
writeOperand(I.getOperand(1));
Out << ", ";

View File

@ -41,7 +41,8 @@ PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM)
setPow2DivIsCheap();
// Use _setjmp/_longjmp instead of setjmp/longjmp.
setUseUnderscoreSetJmpLongJmp(true);
setUseUnderscoreSetJmp(true);
setUseUnderscoreLongJmp(true);
// Set up the register classes.
addRegisterClass(MVT::i32, PPC::GPRCRegisterClass);

View File

@ -54,10 +54,19 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
setShiftAmountFlavor(Mask); // shl X, 32 == shl X, 0
setStackPointerRegisterToSaveRestore(X86StackPtr);
if (!Subtarget->isTargetDarwin())
if (Subtarget->isTargetDarwin()) {
// Darwin should use _setjmp/_longjmp instead of setjmp/longjmp.
setUseUnderscoreSetJmpLongJmp(true);
setUseUnderscoreSetJmp(false);
setUseUnderscoreLongJmp(false);
} else if (Subtarget->isTargetCygwin()) {
// MS runtime is weird: it exports _setjmp, but longjmp!
setUseUnderscoreSetJmp(true);
setUseUnderscoreLongJmp(false);
} else {
setUseUnderscoreSetJmp(true);
setUseUnderscoreLongJmp(true);
}
// Add legal addressing mode scale values.
addLegalAddressScale(8);
addLegalAddressScale(4);