[PATCH] D11437: Correct x86_64 fp128 calling convention

Chih-Hung Hsieh chh at google.com
Thu Jul 23 16:22:25 PDT 2015


chh marked an inline comment as done.
chh added a comment.

I tried to make X86_64ABIInfo::classify to return (Lo=SSE, Hi=NoClass) for fp128 long double type, or (Lo=SSE, Hi=SSEUp). That is not enough, although making fp128 Complex type to "Memory" worked.

X86_64ABIInfo::classifyArgumentType and classifyReturnType
will classify fp128 type as "double" through the help of GetSSETypeAtOffset.
These two or three functions still need more changes to handle fp128.
So I used the special cases for fp128, which seemed simpler with lower risk.

The mapping to register classes is quite complicated to decide converted parameter or return types. Although AMD64 spec has lengthy rules written this way, the rules are quite difficult to understand the mapping of fp128 type.

Is there other way to simplify these classification functions?


================
Comment at: lib/CodeGen/TargetInfo.cpp:1973-1987
@@ -1973,9 +1972,17 @@
+    } else if (ET == getContext().FloatTy) {
       Current = SSE;
-    else if (ET == getContext().DoubleTy ||
-             (ET == getContext().LongDoubleTy &&
-              getTarget().getTriple().isOSNaCl()))
+    } else if (ET == getContext().DoubleTy) {
       Lo = Hi = SSE;
-    else if (ET == getContext().LongDoubleTy)
-      Current = ComplexX87;
+    } else if (ET == getContext().LongDoubleTy) {
+      const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();
+      if (LDF == &llvm::APFloat::IEEEquad)
+        Current = Memory;
+      else if (LDF == &llvm::APFloat::x87DoubleExtended)
+        Current = ComplexX87;
+      else if (LDF == &llvm::APFloat::IEEEdouble)
+        Lo = Hi = SSE;
+      else
+        llvm_unreachable("unexpected long double representation!");
+    }
 
     // If this complex type crosses an eightbyte boundary then it
----------------
Done.



http://reviews.llvm.org/D11437







More information about the cfe-commits mailing list