[cfe-commits] r70675 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/asm.c
Chris Lattner
sabre at nondot.org
Sun May 3 00:53:26 PDT 2009
Author: lattner
Date: Sun May 3 02:53:25 2009
New Revision: 70675
URL: http://llvm.org/viewvc/llvm-project?rev=70675&view=rev
Log:
implement support for asm outputs targetting non-simple lvalue destinations
like bitfields. incidentally llvm-gcc crashes on this sort of thing also. :)
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/CodeGen/asm.c
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=70675&r1=70674&r2=70675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sun May 3 02:53:25 2009
@@ -803,7 +803,9 @@
std::string Constraints;
- std::vector<llvm::Value *> ResultAddrs;
+ std::vector<LValue> ResultRegDests;
+ std::vector<QualType> ResultRegQualTys;
+
std::vector<const llvm::Type *> ResultTypes;
std::vector<const llvm::Type*> ArgTypes;
@@ -827,15 +829,13 @@
OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
LValue Dest = EmitLValue(OutExpr);
- const llvm::Type *DestValueType =
- cast<llvm::PointerType>(Dest.getAddress()->getType())->getElementType();
-
- if (i != 0)
+ if (!Constraints.empty())
Constraints += ',';
- if (!Info.allowsMemory() && DestValueType->isSingleValueType()) {
- ResultAddrs.push_back(Dest.getAddress());
- ResultTypes.push_back(DestValueType);
+ if (!Info.allowsMemory() && !hasAggregateLLVMType(OutExpr->getType())) {
+ ResultRegQualTys.push_back(OutExpr->getType());
+ ResultRegDests.push_back(Dest);
+ ResultTypes.push_back(ConvertTypeForMem(OutExpr->getType()));
Constraints += "=" + OutputConstraint;
} else {
ArgTypes.push_back(Dest.getAddress()->getType());
@@ -867,7 +867,7 @@
TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
- if (i != 0 || S.getNumOutputs() > 0)
+ if (!Constraints.empty())
Constraints += ',';
// Simplify the input constraint.
@@ -952,11 +952,13 @@
Result->addAttribute(~0, llvm::Attribute::NoUnwind);
if (ResultTypes.size() == 1) {
- Builder.CreateStore(Result, ResultAddrs[0]);
+ EmitStoreThroughLValue(RValue::get(Result), ResultRegDests[0],
+ ResultRegQualTys[0]);
} else {
for (unsigned i = 0, e = ResultTypes.size(); i != e; ++i) {
llvm::Value *Tmp = Builder.CreateExtractValue(Result, i, "asmresult");
- Builder.CreateStore(Tmp, ResultAddrs[i]);
+ EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i],
+ ResultRegQualTys[i]);
}
}
}
Modified: cfe/trunk/test/CodeGen/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm.c?rev=70675&r1=70674&r2=70675&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm.c (original)
+++ cfe/trunk/test/CodeGen/asm.c Sun May 3 02:53:25 2009
@@ -59,3 +59,14 @@
: "0" (input));
return output;
}
+
+
+
+
+struct S {
+ int a : 4;
+};
+
+void test13(struct S *P) {
+ __asm__("abc %0" : "=r"(P->a) );
+}
More information about the cfe-commits
mailing list