summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp4
-rw-r--r--clang/lib/AST/Type.cpp2
-rw-r--r--clang/lib/AST/TypePrinter.cpp4
-rw-r--r--clang/lib/Basic/Targets.cpp9
-rw-r--r--clang/lib/CodeGen/CGCall.cpp2
-rw-r--r--clang/lib/Sema/SemaType.cpp20
6 files changed, 38 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7f17fe8b8cc..c1bbc5f085f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8043,7 +8043,9 @@ CallingConv ASTContext::getDefaultCallingConvention(bool IsVariadic,
if (IsCXXMethod)
return ABI->getDefaultMethodCallConv(IsVariadic);
- return (LangOpts.MRTD && !IsVariadic) ? CC_X86StdCall : CC_C;
+ if (LangOpts.MRTD && !IsVariadic) return CC_X86StdCall;
+
+ return Target->getDefaultCallingConv(TargetInfo::CCMT_Unknown);
}
bool ASTContext::isNearlyEmpty(const CXXRecordDecl *RD) const {
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e4f364d04f8..5a39ca0c6b4 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -1588,6 +1588,8 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
case CC_AAPCS_VFP: return "aapcs-vfp";
case CC_PnaclCall: return "pnaclcall";
case CC_IntelOclBicc: return "intel_ocl_bicc";
+ case CC_SpirFunction: return "spir_function";
+ case CC_SpirKernel: return "spir_kernel";
}
llvm_unreachable("Invalid calling convention.");
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index e36fc175c44..b874dd0b4c2 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -697,6 +697,10 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
case CC_X86_64SysV:
OS << " __attribute__((sysv_abi))";
break;
+ case CC_SpirFunction:
+ case CC_SpirKernel:
+ // Do nothing. These CCs are not available as attributes.
+ break;
}
}
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 9aac3b78643..476217146ed 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -6346,6 +6346,15 @@ namespace {
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
+
+ CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+ return (CC == CC_SpirFunction ||
+ CC == CC_SpirKernel) ? CCCR_OK : CCCR_Warning;
+ }
+
+ CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
+ return CC_SpirFunction;
+ }
};
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index f9b26b62103..cb035d39c58 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -51,6 +51,8 @@ static unsigned ClangCallConvToLLVMCallConv(CallingConv CC) {
case CC_X86Pascal: return llvm::CallingConv::C;
// TODO: Add support for __vectorcall to LLVM.
case CC_X86VectorCall: return llvm::CallingConv::X86_VectorCall;
+ case CC_SpirFunction: return llvm::CallingConv::SPIR_FUNC;
+ case CC_SpirKernel: return llvm::CallingConv::SPIR_KERNEL;
}
}
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 7116973cf8d..5624f709c9a 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2476,8 +2476,24 @@ getCCForDeclaratorChunk(Sema &S, Declarator &D,
}
}
- return S.Context.getDefaultCallingConvention(FTI.isVariadic,
- IsCXXInstanceMethod);
+ CallingConv CC = S.Context.getDefaultCallingConvention(FTI.isVariadic,
+ IsCXXInstanceMethod);
+
+ // Attribute AT_OpenCLKernel affects the calling convention only on
+ // the SPIR target, hence it cannot be treated as a calling
+ // convention attribute. This is the simplest place to infer
+ // "spir_kernel" for OpenCL kernels on SPIR.
+ if (CC == CC_SpirFunction) {
+ for (const AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
+ Attr; Attr = Attr->getNext()) {
+ if (Attr->getKind() == AttributeList::AT_OpenCLKernel) {
+ CC = CC_SpirKernel;
+ break;
+ }
+ }
+ }
+
+ return CC;
}
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
OpenPOWER on IntegriCloud