[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'
Jolanta Jensen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 6 03:30:50 PDT 2022
jolanta.jensen added inline comments.
================
Comment at: clang/include/clang/Basic/TargetInfo.h:60
+ Ibm128,
+ Half
};
----------------
tahonermann wrote:
> The existing enumerators were ordered according to precision. Consider moving `Half` to before `Float` if doing so doesn't cause any problems (I would hope there is no dependence on the assigned enumerator values anywhere; if there is, then it would be helpful to add a comment about that here).
In clang/test/CodeGenObjC/fpret.m, IR for i386-apple-darwin9 and x86_64-apple-darwin10 differ for long double after the move of Half to before Float:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Half added last to the FloatModeKind enum (test PASS) generates:
; Function Attrs: noinline nounwind optnone
define void @t0() #0 {
entry:
%0 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_, align 4
%call = call float bitcast (double (i8*, i8*, ...)* @objc_msgSend_fpret to float (i8*, i8*)*)(i8* noundef null, i8* noundef %0)
%1 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.2, align 4
%call1 = call double bitcast (double (i8*, i8*, ...)* @objc_msgSend_fpret to double (i8*, i8*)*)(i8* noundef null, i8* noundef %1)
%2 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.4, align 4
%call2 = call x86_fp80 bitcast (double (i8*, i8*, ...)* @objc_msgSend_fpret to x86_fp80 (i8*, i8*)*)(i8* noundef null, i8* noundef %2)
ret void
}
declare double @objc_msgSend_fpret(i8*, i8*, ...)
attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
While Half added before Float to the FloatModeKind enum (test FAIL) generates:
; Function Attrs: noinline nounwind optnone
define void @t0() #0 {
entry:
%0 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_, align 4
%call = call float bitcast (double (i8*, i8*, ...)* @objc_msgSend_fpret to float (i8*, i8*)*)(i8* noundef null, i8* noundef %0)
%1 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.2, align 4
%call1 = call double bitcast (double (i8*, i8*, ...)* @objc_msgSend_fpret to double (i8*, i8*)*)(i8* noundef null, i8* noundef %1)
%2 = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.4, align 4
%call2 = call x86_fp80 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to x86_fp80 (i8*, i8*)*)(i8* noundef null, i8* noundef %2)
ret void
}
declare double @objc_msgSend_fpret(i8*, i8*, ...)
; Function Attrs: nonlazybind
declare i8* @objc_msgSend(i8*, i8*, ...) #1
attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
attributes #1 = { nonlazybind }
There is a similar failure in CodeGenObjC/metadata-symbols-64.m for x86_64-apple-darwin10 where @objc_msgSend_fpret is replaced by @objc_msgSend.
It looks like there are dependencies on the FloatModeKind enum values in clang/lib/Basic/Targets/X86.h and in clang/include/clang/Basic/TargetInfo.h
If I shift the initial value of RealTypeUsesObjCFPRet one bit to the left the tests above will PASS, i.e this together seems to work:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 57bf4278251a..32e163b9cf38 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -52,12 +52,12 @@ namespace Builtin { struct Info; }
enum class FloatModeKind {
NoFloat = 255,
- Float = 0,
+ Half = 0,
+ Float,
Double,
LongDouble,
Float128,
- Ibm128,
- Half
+ Ibm128
};
/// Fields controlling how types are laid out in memory; these may need to
@@ -219,7 +219,7 @@ protected:
mutable VersionTuple PlatformMinVersion;
unsigned HasAlignMac68kSupport : 1;
- unsigned RealTypeUsesObjCFPRet : 3;
+ unsigned RealTypeUsesObjCFPRet : 6;
unsigned ComplexLongDoubleUsesFP2Ret : 1;
unsigned HasBuiltinMSVaList : 1;
Is the solution, i.e. shifting the initial value of the RealTypeUsesObjCFPRet to 6, acceptable or is it too hacky?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126479/new/
https://reviews.llvm.org/D126479
More information about the cfe-commits
mailing list