aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-01 00:20:33 +0000
committerChris Lattner <sabre@nondot.org>2010-09-01 00:20:33 +0000
commit3db4dde12de84269c8f803f9dfca37a2d14f9898 (patch)
treeba1e507c4628cbbe9f0f48d4d4e148b5aeb4cfcf /lib/CodeGen/TargetInfo.cpp
parent8ea5b9d832455247a15925398fb663d299d33238 (diff)
refactor some code to cut down on redundancy, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112683 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r--lib/CodeGen/TargetInfo.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 0fb75fa31e..e9ce20d3db 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -1500,6 +1500,7 @@ classifyReturnType(QualType RetTy) const {
break;
}
+ const llvm::Type *HighPart = 0;
switch (Hi) {
// Memory was handled previously and X87 should
// never occur as a hi class.
@@ -1511,24 +1512,17 @@ classifyReturnType(QualType RetTy) const {
case NoClass:
break;
- case Integer: {
- const llvm::Type *HiType =
- GetINTEGERTypeAtOffset(CGT.ConvertTypeRecursive(RetTy), 8, RetTy, 8);
- if (Lo == NoClass) // Return HiType at offset 8 in memory.
- return ABIArgInfo::getDirect(HiType, 8);
-
- ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL);
+ case Integer:
+ HighPart = GetINTEGERTypeAtOffset(CGT.ConvertTypeRecursive(RetTy),
+ 8, RetTy, 8);
+ if (Lo == NoClass) // Return HighPart at offset 8 in memory.
+ return ABIArgInfo::getDirect(HighPart, 8);
break;
- }
- case SSE: {
- const llvm::Type *HiType =
- GetSSETypeAtOffset(CGT.ConvertTypeRecursive(RetTy), 8, RetTy, 8);
- if (Lo == NoClass) // Return HiType at offset 8 in memory.
- return ABIArgInfo::getDirect(HiType, 8);
-
- ResType = llvm::StructType::get(getVMContext(), ResType, HiType,NULL);
+ case SSE:
+ HighPart = GetSSETypeAtOffset(CGT.ConvertTypeRecursive(RetTy), 8, RetTy, 8);
+ if (Lo == NoClass) // Return HighPart at offset 8 in memory.
+ return ABIArgInfo::getDirect(HighPart, 8);
break;
- }
// AMD64-ABI 3.2.3p4: Rule 5. If the class is SSEUP, the eightbyte
// is passed in the upper half of the last used SSE register.
@@ -1547,15 +1541,18 @@ classifyReturnType(QualType RetTy) const {
// preceeded by X87. In such situations we follow gcc and pass the
// extra bits in an SSE reg.
if (Lo != X87) {
- const llvm::Type *HiType =
- GetSSETypeAtOffset(CGT.ConvertTypeRecursive(RetTy), 8, RetTy, 8);
- if (Lo == NoClass) // Return HiType at offset 8 in memory.
- return ABIArgInfo::getDirect(HiType, 8);
-
- ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL);
+ HighPart = GetSSETypeAtOffset(CGT.ConvertTypeRecursive(RetTy),
+ 8, RetTy, 8);
+ if (Lo == NoClass) // Return HighPart at offset 8 in memory.
+ return ABIArgInfo::getDirect(HighPart, 8);
}
break;
}
+
+ // If a high part was specified, merge it together with the low part. It is
+ // known to pass in the high eightbyte of the result.
+ if (HighPart)
+ ResType = llvm::StructType::get(getVMContext(), ResType, HighPart, NULL);
return ABIArgInfo::getDirect(ResType);
}