summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2015-07-02 03:40:19 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2015-07-02 03:40:19 +0000
commit00396513046275f17c0e321bd8a5cc27080a3fa2 (patch)
tree886e885438bf58b01a29223292f21c349571ae76 /clang/lib/CodeGen
parent85225b0a367a488df4920caf3d11c6b04754891b (diff)
downloadbcm5719-llvm-00396513046275f17c0e321bd8a5cc27080a3fa2.tar.gz
bcm5719-llvm-00396513046275f17c0e321bd8a5cc27080a3fa2.zip
[OPENMP] Introduced type trait "__builtin_omp_required_simd_align" for default simd alignment.
Adds type trait "__builtin_omp_required_simd_align" after discussions here http://reviews.llvm.org/D9894 Differential Revision: http://reviews.llvm.org/D10597 llvm-svn: 241237
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp8
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp6
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp36
-rw-r--r--clang/lib/CodeGen/TargetInfo.h7
4 files changed, 15 insertions, 42 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 330a0dffb24..c73f1189314 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -16,6 +16,7 @@
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CodeGenModule.h"
+#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/RecordLayout.h"
@@ -2037,6 +2038,13 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
return size;
}
+ } else if (E->getKind() == UETT_OpenMPRequiredSimdAlign) {
+ auto Alignment =
+ CGF.getContext()
+ .toCharUnitsFromBits(CGF.getContext().getOpenMPDefaultSimdAlign(
+ E->getTypeOfArgument()->getPointeeType()))
+ .getQuantity();
+ return llvm::ConstantInt::get(CGF.SizeTy, Alignment);
}
// If this isn't sizeof(vla), the result must be constant; use the constant
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 8b4902fac05..8666b464984 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -649,8 +649,10 @@ static void emitAlignedClause(CodeGenFunction &CGF,
// If no optional parameter is specified, implementation-defined default
// alignments for SIMD instructions on the target platforms are assumed.
Alignment =
- CGF.CGM.getTargetCodeGenInfo().getOpenMPSimdDefaultAlignment(
- E->getType());
+ CGF.getContext()
+ .toCharUnitsFromBits(CGF.getContext().getOpenMPDefaultSimdAlign(
+ E->getType()->getPointeeType()))
+ .getQuantity();
}
assert((Alignment == 0 || llvm::isPowerOf2_32(Alignment)) &&
"alignment is not power of 2");
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index d7a6349047b..e5ba200e1c5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1577,11 +1577,9 @@ public:
};
class X86_64TargetCodeGenInfo : public TargetCodeGenInfo {
- X86AVXABILevel AVXLevel;
public:
X86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, X86AVXABILevel AVXLevel)
- : TargetCodeGenInfo(new X86_64ABIInfo(CGT, AVXLevel)),
- AVXLevel(AVXLevel) {}
+ : TargetCodeGenInfo(new X86_64ABIInfo(CGT, AVXLevel)) {}
const X86_64ABIInfo &getABIInfo() const {
return static_cast<const X86_64ABIInfo&>(TargetCodeGenInfo::getABIInfo());
@@ -1647,10 +1645,6 @@ public:
('T' << 24);
return llvm::ConstantInt::get(CGM.Int32Ty, Sig);
}
-
- unsigned getOpenMPSimdDefaultAlignment(QualType) const override {
- return getNativeVectorSizeForAVXABI(AVXLevel) / 8;
- }
};
class PS4TargetCodeGenInfo : public X86_64TargetCodeGenInfo {
@@ -1722,11 +1716,10 @@ void WinX86_32TargetCodeGenInfo::setTargetAttributes(const Decl *D,
}
class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
- X86AVXABILevel AVXLevel;
public:
WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
X86AVXABILevel AVXLevel)
- : TargetCodeGenInfo(new WinX86_64ABIInfo(CGT)), AVXLevel(AVXLevel) {}
+ : TargetCodeGenInfo(new WinX86_64ABIInfo(CGT)) {}
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override;
@@ -1756,10 +1749,6 @@ public:
llvm::SmallString<32> &Opt) const override {
Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
}
-
- unsigned getOpenMPSimdDefaultAlignment(QualType) const override {
- return getNativeVectorSizeForAVXABI(AVXLevel) / 8;
- }
};
void WinX86_64TargetCodeGenInfo::setTargetAttributes(const Decl *D,
@@ -3171,10 +3160,6 @@ public:
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
-
- unsigned getOpenMPSimdDefaultAlignment(QualType) const override {
- return 16; // Natural alignment for Altivec vectors.
- }
};
}
@@ -3414,13 +3399,11 @@ public:
};
class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
- bool HasQPX;
public:
PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes &CGT,
PPC64_SVR4_ABIInfo::ABIKind Kind, bool HasQPX)
- : TargetCodeGenInfo(new PPC64_SVR4_ABIInfo(CGT, Kind, HasQPX)),
- HasQPX(HasQPX) {}
+ : TargetCodeGenInfo(new PPC64_SVR4_ABIInfo(CGT, Kind, HasQPX)) {}
int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
// This is recovered from gcc output.
@@ -3429,15 +3412,6 @@ public:
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
-
- unsigned getOpenMPSimdDefaultAlignment(QualType QT) const override {
- if (HasQPX)
- if (const PointerType *PT = QT->getAs<PointerType>())
- if (PT->getPointeeType()->isSpecificBuiltinType(BuiltinType::Double))
- return 32; // Natural alignment for QPX doubles.
-
- return 16; // Natural alignment for Altivec and VSX vectors.
- }
};
class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
@@ -3451,10 +3425,6 @@ public:
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
-
- unsigned getOpenMPSimdDefaultAlignment(QualType) const override {
- return 16; // Natural alignment for Altivec vectors.
- }
};
}
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index bf63265f028..95275d5d42e 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -218,13 +218,6 @@ public:
virtual void getDetectMismatchOption(llvm::StringRef Name,
llvm::StringRef Value,
llvm::SmallString<32> &Opt) const {}
-
- /// Gets the target-specific default alignment used when an 'aligned' clause
- /// is used with a 'simd' OpenMP directive without specifying a specific
- /// alignment.
- virtual unsigned getOpenMPSimdDefaultAlignment(QualType Type) const {
- return 0;
- }
};
}
OpenPOWER on IntegriCloud