aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-01-11 19:32:54 +0000
committerAnders Carlsson <andersca@mac.com>2009-01-11 19:32:54 +0000
commit634717238844cf3f51039411be1b27fe1fac622e (patch)
tree17fd3e50d1c0b9de30a924bad4288a14d55e53b9 /lib/CodeGen/CGStmt.cpp
parent02fbb2578538e93f901f75fdc7d278c4c0e935de (diff)
Use a common function for emitting asm inputs and remove a FIXME
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp57
1 files changed, 26 insertions, 31 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 794d7cb272..8d80a498b4 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -860,6 +860,29 @@ static std::string SimplifyConstraint(const char* Constraint,
return Result;
}
+llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
+ TargetInfo::ConstraintInfo Info,
+ const Expr *InputExpr,
+ std::string &ConstraintStr)
+{
+ llvm::Value *Arg;
+ if ((Info & TargetInfo::CI_AllowsRegister) ||
+ !(Info & TargetInfo::CI_AllowsMemory)) {
+ if (ConvertType(InputExpr->getType())->isSingleValueType()) {
+ Arg = EmitScalarExpr(InputExpr);
+ } else {
+ ErrorUnsupported(&S,
+ "asm statement passing multiple-value types as inputs");
+ }
+ } else {
+ LValue Dest = EmitLValue(InputExpr);
+ Arg = Dest.getAddress();
+ ConstraintStr += '*';
+ }
+
+ return Arg;
+}
+
void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
bool Failed;
std::string AsmString =
@@ -916,24 +939,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
}
if (Info & TargetInfo::CI_ReadWrite) {
- // FIXME: This code should be shared with the code that handles inputs.
InOutConstraints += ',';
-
+
const Expr *InputExpr = S.getOutputExpr(i);
- llvm::Value *Arg;
- if ((Info & TargetInfo::CI_AllowsRegister) ||
- !(Info & TargetInfo::CI_AllowsMemory)) {
- if (ConvertType(InputExpr->getType())->isSingleValueType()) {
- Arg = EmitScalarExpr(InputExpr);
- } else {
- ErrorUnsupported(&S,
- "asm statement passing multiple-value types as inputs");
- }
- } else {
- LValue Dest = EmitLValue(InputExpr);
- Arg = Dest.getAddress();
- InOutConstraints += '*';
- }
+ llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, InOutConstraints);
InOutArgTypes.push_back(Arg->getType());
InOutArgs.push_back(Arg);
@@ -960,21 +969,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
// Simplify the input constraint.
InputConstraint = SimplifyConstraint(InputConstraint.c_str(), Target);
- llvm::Value *Arg;
-
- if ((Info & TargetInfo::CI_AllowsRegister) ||
- !(Info & TargetInfo::CI_AllowsMemory)) {
- if (ConvertType(InputExpr->getType())->isSingleValueType()) {
- Arg = EmitScalarExpr(InputExpr);
- } else {
- ErrorUnsupported(&S,
- "asm statement passing multiple-value types as inputs");
- }
- } else {
- LValue Dest = EmitLValue(InputExpr);
- Arg = Dest.getAddress();
- Constraints += '*';
- }
+ llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, Constraints);
ArgTypes.push_back(Arg->getType());
Args.push_back(Arg);