aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/TargetInfo.h8
-rw-r--r--lib/Basic/Targets.cpp12
-rw-r--r--lib/CodeGen/CGStmt.cpp9
-rw-r--r--lib/CodeGen/TargetInfo.cpp22
-rw-r--r--lib/CodeGen/TargetInfo.h9
5 files changed, 36 insertions, 24 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index 586680bbd0..b9087f2c47 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -26,8 +26,6 @@
namespace llvm {
struct fltSemantics;
class StringRef;
-class LLVMContext;
-class Type;
}
namespace clang {
@@ -532,12 +530,6 @@ public:
virtual const char *getStaticInitSectionSpecifier() const {
return 0;
}
-
- virtual const llvm::Type* adjustInlineAsmType(std::string& Constraint,
- const llvm::Type* Ty,
- llvm::LLVMContext& Context) const {
- return Ty;
- }
protected:
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
return PointerWidth;
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 35817a2453..45b08e11fc 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -1014,9 +1014,6 @@ public:
}
virtual bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const;
- virtual const llvm::Type* adjustInlineAsmType(std::string& Constraint,
- const llvm::Type* Ty,
- llvm::LLVMContext& Context) const;
virtual std::string convertConstraint(const char Constraint) const;
virtual const char *getClobbers() const {
return "~{dirflag},~{fpsr},~{flags}";
@@ -1341,15 +1338,6 @@ X86TargetInfo::validateAsmConstraint(const char *&Name,
return false;
}
-const llvm::Type*
-X86TargetInfo::adjustInlineAsmType(std::string& Constraint,
- const llvm::Type* Ty,
- llvm::LLVMContext &Context) const {
- if (Constraint=="y" && Ty->isVectorTy())
- return llvm::Type::getX86_MMXTy(Context);
- return Ty;
-}
-
std::string
X86TargetInfo::convertConstraint(const char Constraint) const {
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index f809c009ce..cd238112ed 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -14,6 +14,7 @@
#include "CGDebugInfo.h"
#include "CodeGenModule.h"
#include "CodeGenFunction.h"
+#include "TargetInfo.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/PrettyStackTrace.h"
#include "clang/Basic/TargetInfo.h"
@@ -1135,8 +1136,8 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
}
}
if (const llvm::Type* AdjTy =
- Target.adjustInlineAsmType(OutputConstraint, ResultRegTypes.back(),
- getLLVMContext()))
+ getTargetHooks().adjustInlineAsmType(*this, OutputConstraint,
+ ResultRegTypes.back()))
ResultRegTypes.back() = AdjTy;
} else {
ArgTypes.push_back(Dest.getAddress()->getType());
@@ -1207,8 +1208,8 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
}
}
if (const llvm::Type* AdjTy =
- Target.adjustInlineAsmType(InputConstraint, Arg->getType(),
- getLLVMContext()))
+ getTargetHooks().adjustInlineAsmType(*this, InputConstraint,
+ Arg->getType()))
Arg = Builder.CreateBitCast(Arg, AdjTy);
ArgTypes.push_back(Arg->getType());
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 881a7ee4d0..f95aab0744 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -355,6 +355,14 @@ bool UseX86_MMXType(const llvm::Type *IRType) {
IRType->getScalarSizeInBits() != 64;
}
+static const llvm::Type* X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
+ llvm::StringRef Constraint,
+ const llvm::Type* Ty) {
+ if (Constraint=="y" && UseX86_MMXType(Ty))
+ return llvm::Type::getX86_MMXTy(CGF.getLLVMContext());
+ return Ty;
+}
+
//===----------------------------------------------------------------------===//
// X86-32 ABI Implementation
//===----------------------------------------------------------------------===//
@@ -415,6 +423,13 @@ public:
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const;
+
+ const llvm::Type* adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
+ llvm::StringRef Constraint,
+ const llvm::Type* Ty) const {
+ return X86AdjustInlineAsmType(CGF, Constraint, Ty);
+ }
+
};
}
@@ -895,6 +910,13 @@ public:
return false;
}
+
+ const llvm::Type* adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
+ llvm::StringRef Constraint,
+ const llvm::Type* Ty) const {
+ return X86AdjustInlineAsmType(CGF, Constraint, Ty);
+ }
+
};
class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
diff --git a/lib/CodeGen/TargetInfo.h b/lib/CodeGen/TargetInfo.h
index 9d4cf16103..4f59eb619e 100644
--- a/lib/CodeGen/TargetInfo.h
+++ b/lib/CodeGen/TargetInfo.h
@@ -15,8 +15,11 @@
#ifndef CLANG_CODEGEN_TARGETINFO_H
#define CLANG_CODEGEN_TARGETINFO_H
+#include "llvm/ADT/StringRef.h"
+
namespace llvm {
class GlobalValue;
+ class Type;
class Value;
}
@@ -102,6 +105,12 @@ namespace clang {
llvm::Value *Address) const {
return Address;
}
+
+ virtual const llvm::Type* adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
+ llvm::StringRef Constraint,
+ const llvm::Type* Ty) const {
+ return Ty;
+ }
};
}