[cfe-commits] r62069 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/asm.c
Anders Carlsson
andersca at mac.com
Sun Jan 11 18:22:13 PST 2009
Author: andersca
Date: Sun Jan 11 20:22:13 2009
New Revision: 62069
URL: http://llvm.org/viewvc/llvm-project?rev=62069&view=rev
Log:
Handle multi-value inputs
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=62069&r1=62068&r2=62069&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sun Jan 11 20:22:13 2009
@@ -19,6 +19,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/InlineAsm.h"
#include "llvm/Intrinsics.h"
+#include "llvm/Target/TargetData.h"
using namespace clang;
using namespace CodeGen;
@@ -867,12 +868,24 @@
{
llvm::Value *Arg;
if ((Info & TargetInfo::CI_AllowsRegister) ||
- !(Info & TargetInfo::CI_AllowsMemory)) {
- if (ConvertType(InputExpr->getType())->isSingleValueType()) {
+ !(Info & TargetInfo::CI_AllowsMemory)) {
+ const llvm::Type *Ty = ConvertType(InputExpr->getType());
+
+ if (Ty->isSingleValueType()) {
Arg = EmitScalarExpr(InputExpr);
} else {
- ErrorUnsupported(&S,
- "asm statement passing multiple-value types as inputs");
+ LValue Dest = EmitLValue(InputExpr);
+
+ uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty);
+ if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
+ Ty = llvm::IntegerType::get(Size);
+ Ty = llvm::PointerType::getUnqual(Ty);
+
+ Arg = Builder.CreateLoad(Builder.CreateBitCast(Dest.getAddress(), Ty));
+ } else {
+ Arg = Dest.getAddress();
+ ConstraintStr += '*';
+ }
}
} else {
LValue Dest = EmitLValue(InputExpr);
@@ -964,7 +977,7 @@
TargetInfo::ConstraintInfo Info;
bool result = Target.validateInputConstraint(InputConstraint.c_str(),
- NumConstraints, Info);
+ NumConstraints, Info);
assert(result && "Failed to parse input constraint"); result=result;
if (i != 0 || S.getNumOutputs() > 0)
Modified: cfe/trunk/test/CodeGen/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm.c?rev=62069&r1=62068&r2=62069&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm.c (original)
+++ cfe/trunk/test/CodeGen/asm.c Sun Jan 11 20:22:13 2009
@@ -14,6 +14,13 @@
__asm__ volatile("" : "+m"(temp), "+r"(src));
}
+void t4()
+{
+ unsigned long long a;
+ struct reg { unsigned long long a, b; } b;
+
+ __asm__ volatile ("":: "m"(a), "m"(b));
+}
More information about the cfe-commits
mailing list