API for message dispatch of methods returning floats

to match gcc's closely.

llvm-svn: 70493
This commit is contained in:
Fariborz Jahanian 2009-04-30 16:31:11 +00:00
parent 62e0cb0a22
commit 18c435a17d
2 changed files with 43 additions and 5 deletions

View File

@ -5002,12 +5002,19 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
Name += "objc_msgSend_stret_fixup";
}
}
else if (ResultType->isFloatingType() &&
// Selection of frret API only happens in 32bit nonfragile ABI.
CGM.getTargetData().getTypePaddedSize(ObjCTypes.LongTy) == 4) {
else if (!IsSuper && ResultType->isFloatingType()) {
if (const BuiltinType *BT = ResultType->getAsBuiltinType()) {
BuiltinType::Kind k = BT->getKind();
if (k == BuiltinType::LongDouble) {
Fn = ObjCTypes.getMessageSendFpretFixupFn();
Name += "objc_msgSend_fpret_fixup";
}
else {
Fn = ObjCTypes.getMessageSendFixupFn();
Name += "objc_msgSend_fixup";
}
}
}
else {
#if 0
// unlike what is documented. gcc never generates this API!!

View File

@ -34,6 +34,8 @@
// RUN: grep '@"\\01l_objc_msgSend_fixup_alloc" = weak hidden global .* section "__DATA, __objc_msgrefs, coalesced", align 16' %t &&
// RUN: grep '@_objc_empty_cache = external global' %t &&
// RUN: grep '@_objc_empty_vtable = external global' %t &&
// RUN: grep '@objc_msgSend_fixup(' %t &&
// RUN: grep '@objc_msgSend_fpret_fixup(' %t &&
// RUN: true
@ -94,7 +96,36 @@ llvm-gcc -m64 -emit-llvm -S -o - metadata-symbols-64.m | \
}
@end
// Test for FP dispatch method APIs
@interface Example
@end
float FLOAT;
double DOUBLE;
long double LONGDOUBLE;
id ID;
@implementation Example
- (double) RET_DOUBLE
{
return DOUBLE;
}
- (float) RET_FLOAT
{
return FLOAT;
}
- (long double) RET_LONGDOUBLE
{
return LONGDOUBLE;
}
@end
void *f0(id x) {
Example* pe;
double dd = [pe RET_DOUBLE];
dd = [pe RET_FLOAT];
dd = [pe RET_LONGDOUBLE];
[B im0];
[C im1];
[D alloc];