diff options
author | Anders Carlsson <andersca@mac.com> | 2009-01-12 02:22:13 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-01-12 02:22:13 +0000 |
commit | ebaae2a3103b443d50444d335ab5ab0ff7680da2 (patch) | |
tree | b4aebacf975e220ab465af96b52dc0bb907b165d /lib/CodeGen/CGStmt.cpp | |
parent | 0e936db474731964e72c11a4b24dd75460457f8d (diff) |
Handle multi-value inputs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62069 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index fd01905698..edccbe41bf 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -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* CodeGenFunction::EmitAsmInput(const AsmStmt &S, { 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 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { 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) |