mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 07:34:06 +00:00
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:
parent
ca3aa26c20
commit
d27a258d2d
@ -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([getpagesize getrusage gettimeofday isatty mkdtemp mkstemp ])
|
||||||
AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])
|
AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])
|
||||||
AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
|
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_C_PRINTF_A
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_FUNC_RAND48
|
AC_FUNC_RAND48
|
||||||
|
@ -416,12 +416,6 @@
|
|||||||
/* Define to 1 if you have the <windows.h> header file. */
|
/* Define to 1 if you have the <windows.h> header file. */
|
||||||
#undef HAVE_WINDOWS_H
|
#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 */
|
/* Installation directory for binary executables */
|
||||||
#undef LLVM_BINDIR
|
#undef LLVM_BINDIR
|
||||||
|
|
||||||
|
@ -379,12 +379,18 @@ public:
|
|||||||
return allowUnalignedMemoryAccesses;
|
return allowUnalignedMemoryAccesses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// usesUnderscoreSetJmpLongJmp - Determine if we should use _setjmp or setjmp
|
/// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
|
||||||
/// to implement llvm.setjmp.
|
/// to implement llvm.setjmp.
|
||||||
bool usesUnderscoreSetJmpLongJmp() const {
|
bool usesUnderscoreSetJmp() const {
|
||||||
return UseUnderscoreSetJmpLongJmp;
|
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
|
/// getStackPointerRegisterToSaveRestore - If a physical register, this
|
||||||
/// specifies the register that llvm.savestack/llvm.restorestack should save
|
/// specifies the register that llvm.savestack/llvm.restorestack should save
|
||||||
/// and restore.
|
/// and restore.
|
||||||
@ -564,13 +570,20 @@ protected:
|
|||||||
ShiftAmtHandling = OORSA;
|
ShiftAmtHandling = OORSA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// setUseUnderscoreSetJmpLongJmp - Indicate whether this target prefers to
|
/// setUseUnderscoreSetJmp - Indicate whether this target prefers to
|
||||||
/// use _setjmp and _longjmp to or implement llvm.setjmp/llvm.longjmp or
|
/// use _setjmp to implement llvm.setjmp or the non _ version.
|
||||||
/// the non _ versions. Defaults to false.
|
/// Defaults to false.
|
||||||
void setUseUnderscoreSetJmpLongJmp(bool Val) {
|
void setUseUnderscoreSetJmp(bool Val) {
|
||||||
UseUnderscoreSetJmpLongJmp = 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
|
/// setStackPointerRegisterToSaveRestore - If set to a physical register, this
|
||||||
/// specifies the register that llvm.savestack/llvm.restorestack should save
|
/// specifies the register that llvm.savestack/llvm.restorestack should save
|
||||||
/// and restore.
|
/// and restore.
|
||||||
@ -883,10 +896,14 @@ private:
|
|||||||
/// total cycles or lowest register usage.
|
/// total cycles or lowest register usage.
|
||||||
SchedPreference SchedPreferenceInfo;
|
SchedPreference SchedPreferenceInfo;
|
||||||
|
|
||||||
/// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
|
/// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
|
||||||
/// _longjmp to implement llvm.setjmp/llvm.longjmp. Defaults to false.
|
/// llvm.setjmp. Defaults to false.
|
||||||
bool UseUnderscoreSetJmpLongJmp;
|
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
|
/// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
|
||||||
unsigned JumpBufSize;
|
unsigned JumpBufSize;
|
||||||
|
|
||||||
|
@ -1974,10 +1974,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
|
|||||||
case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
|
case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
|
||||||
case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return 0;
|
case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return 0;
|
||||||
case Intrinsic::setjmp:
|
case Intrinsic::setjmp:
|
||||||
return "_setjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
|
return "_setjmp"+!TLI.usesUnderscoreSetJmp();
|
||||||
break;
|
break;
|
||||||
case Intrinsic::longjmp:
|
case Intrinsic::longjmp:
|
||||||
return "_longjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
|
return "_longjmp"+!TLI.usesUnderscoreLongJmp();
|
||||||
break;
|
break;
|
||||||
case Intrinsic::memcpy_i32:
|
case Intrinsic::memcpy_i32:
|
||||||
case Intrinsic::memcpy_i64:
|
case Intrinsic::memcpy_i64:
|
||||||
|
@ -47,7 +47,8 @@ TargetLowering::TargetLowering(TargetMachine &tm)
|
|||||||
sizeof(TargetDAGCombineArray)/sizeof(TargetDAGCombineArray[0]));
|
sizeof(TargetDAGCombineArray)/sizeof(TargetDAGCombineArray[0]));
|
||||||
maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
|
maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
|
||||||
allowUnalignedMemoryAccesses = false;
|
allowUnalignedMemoryAccesses = false;
|
||||||
UseUnderscoreSetJmpLongJmp = false;
|
UseUnderscoreSetJmp = false;
|
||||||
|
UseUnderscoreLongJmp = false;
|
||||||
IntDivIsCheap = false;
|
IntDivIsCheap = false;
|
||||||
Pow2DivIsCheap = false;
|
Pow2DivIsCheap = false;
|
||||||
StackPointerRegisterToSaveRestore = 0;
|
StackPointerRegisterToSaveRestore = 0;
|
||||||
|
@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
|
|||||||
<< "#elif defined(__APPLE__)\n"
|
<< "#elif defined(__APPLE__)\n"
|
||||||
<< "extern void *__builtin_alloca(unsigned long);\n"
|
<< "extern void *__builtin_alloca(unsigned long);\n"
|
||||||
<< "#define alloca(x) __builtin_alloca(x)\n"
|
<< "#define alloca(x) __builtin_alloca(x)\n"
|
||||||
|
<< "#define longjmp _longjmp\n"
|
||||||
|
<< "#define setjmp _setjmp\n"
|
||||||
<< "#elif defined(__sun__)\n"
|
<< "#elif defined(__sun__)\n"
|
||||||
<< "#if defined(__sparcv9)\n"
|
<< "#if defined(__sparcv9)\n"
|
||||||
<< "extern void *__builtin_alloca(unsigned long);\n"
|
<< "extern void *__builtin_alloca(unsigned long);\n"
|
||||||
@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
|
|||||||
Out << ')';
|
Out << ')';
|
||||||
return;
|
return;
|
||||||
case Intrinsic::setjmp:
|
case Intrinsic::setjmp:
|
||||||
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
|
|
||||||
Out << "_"; // Use _setjmp on systems that support it!
|
|
||||||
#endif
|
|
||||||
Out << "setjmp(*(jmp_buf*)";
|
Out << "setjmp(*(jmp_buf*)";
|
||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ')';
|
Out << ')';
|
||||||
return;
|
return;
|
||||||
case Intrinsic::longjmp:
|
case Intrinsic::longjmp:
|
||||||
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
|
|
||||||
Out << "_"; // Use _longjmp on systems that support it!
|
|
||||||
#endif
|
|
||||||
Out << "longjmp(*(jmp_buf*)";
|
Out << "longjmp(*(jmp_buf*)";
|
||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
|
@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
|
|||||||
<< "#elif defined(__APPLE__)\n"
|
<< "#elif defined(__APPLE__)\n"
|
||||||
<< "extern void *__builtin_alloca(unsigned long);\n"
|
<< "extern void *__builtin_alloca(unsigned long);\n"
|
||||||
<< "#define alloca(x) __builtin_alloca(x)\n"
|
<< "#define alloca(x) __builtin_alloca(x)\n"
|
||||||
|
<< "#define longjmp _longjmp\n"
|
||||||
|
<< "#define setjmp _setjmp\n"
|
||||||
<< "#elif defined(__sun__)\n"
|
<< "#elif defined(__sun__)\n"
|
||||||
<< "#if defined(__sparcv9)\n"
|
<< "#if defined(__sparcv9)\n"
|
||||||
<< "extern void *__builtin_alloca(unsigned long);\n"
|
<< "extern void *__builtin_alloca(unsigned long);\n"
|
||||||
@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
|
|||||||
Out << ')';
|
Out << ')';
|
||||||
return;
|
return;
|
||||||
case Intrinsic::setjmp:
|
case Intrinsic::setjmp:
|
||||||
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
|
|
||||||
Out << "_"; // Use _setjmp on systems that support it!
|
|
||||||
#endif
|
|
||||||
Out << "setjmp(*(jmp_buf*)";
|
Out << "setjmp(*(jmp_buf*)";
|
||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ')';
|
Out << ')';
|
||||||
return;
|
return;
|
||||||
case Intrinsic::longjmp:
|
case Intrinsic::longjmp:
|
||||||
#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
|
|
||||||
Out << "_"; // Use _longjmp on systems that support it!
|
|
||||||
#endif
|
|
||||||
Out << "longjmp(*(jmp_buf*)";
|
Out << "longjmp(*(jmp_buf*)";
|
||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
|
@ -41,7 +41,8 @@ PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM)
|
|||||||
setPow2DivIsCheap();
|
setPow2DivIsCheap();
|
||||||
|
|
||||||
// Use _setjmp/_longjmp instead of setjmp/longjmp.
|
// Use _setjmp/_longjmp instead of setjmp/longjmp.
|
||||||
setUseUnderscoreSetJmpLongJmp(true);
|
setUseUnderscoreSetJmp(true);
|
||||||
|
setUseUnderscoreLongJmp(true);
|
||||||
|
|
||||||
// Set up the register classes.
|
// Set up the register classes.
|
||||||
addRegisterClass(MVT::i32, PPC::GPRCRegisterClass);
|
addRegisterClass(MVT::i32, PPC::GPRCRegisterClass);
|
||||||
|
@ -54,10 +54,19 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
|
|||||||
setShiftAmountFlavor(Mask); // shl X, 32 == shl X, 0
|
setShiftAmountFlavor(Mask); // shl X, 32 == shl X, 0
|
||||||
setStackPointerRegisterToSaveRestore(X86StackPtr);
|
setStackPointerRegisterToSaveRestore(X86StackPtr);
|
||||||
|
|
||||||
if (!Subtarget->isTargetDarwin())
|
if (Subtarget->isTargetDarwin()) {
|
||||||
// Darwin should use _setjmp/_longjmp instead of setjmp/longjmp.
|
// 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.
|
// Add legal addressing mode scale values.
|
||||||
addLegalAddressScale(8);
|
addLegalAddressScale(8);
|
||||||
addLegalAddressScale(4);
|
addLegalAddressScale(4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user