Handle multi-value inputs

llvm-svn: 62069
This commit is contained in:
Anders Carlsson 2009-01-12 02:22:13 +00:00
parent 30c235d182
commit 00057e4e09
2 changed files with 25 additions and 5 deletions

View File

@ -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;
@ -868,11 +869,23 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
llvm::Value *Arg;
if ((Info & TargetInfo::CI_AllowsRegister) ||
!(Info & TargetInfo::CI_AllowsMemory)) {
if (ConvertType(InputExpr->getType())->isSingleValueType()) {
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);

View File

@ -14,6 +14,13 @@ void t3(unsigned char *src, unsigned long long temp)
__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));
}