From: Guy Benyei Date: Tue, 25 Dec 2012 08:53:55 +0000 (+0000) Subject: Add intel_ocl_bicc calling convention as a function attribute to clang. The calling... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38980086c0f791e8c23cc882574f18e5b4a87db6;p=clang Add intel_ocl_bicc calling convention as a function attribute to clang. The calling convention is already implemented in LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171056 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index ea84de6d79..94c896ec6e 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -2626,6 +2626,7 @@ enum CXCallingConv { CXCallingConv_AAPCS = 6, CXCallingConv_AAPCS_VFP = 7, CXCallingConv_PnaclCall = 8, + CXCallingConv_IntelOclBicc = 9, CXCallingConv_Invalid = 100, CXCallingConv_Unexposed = 200 diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 7277f0fc68..70f61cb041 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -3330,7 +3330,8 @@ public: attr_stdcall, attr_thiscall, attr_pascal, - attr_pnaclcall + attr_pnaclcall, + attr_inteloclbicc }; private: diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 7b7dc48a38..858df3ae21 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -565,6 +565,10 @@ def PnaclCall : InheritableAttr { let Spellings = [GNU<"pnaclcall">]; } +def IntelOclBicc : InheritableAttr { + let Spellings = [GNU<"intel_ocl_bicc">]; +} + def Pcs : InheritableAttr { let Spellings = [GNU<"pcs">]; let Args = [EnumArgument<"PCS", "PCSType", diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index fedb321464..321048f985 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -192,7 +192,8 @@ namespace clang { CC_X86Pascal, // __attribute__((pascal)) CC_AAPCS, // __attribute__((pcs("aapcs"))) CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp"))) - CC_PnaclCall // __attribute__((pnaclcall)) + CC_PnaclCall, // __attribute__((pnaclcall)) + CC_IntelOclBicc // __attribute__((intel_ocl_bicc)) }; } // end namespace clang diff --git a/lib/AST/DumpXML.cpp b/lib/AST/DumpXML.cpp index f2483f4296..ce4e21f90b 100644 --- a/lib/AST/DumpXML.cpp +++ b/lib/AST/DumpXML.cpp @@ -922,6 +922,7 @@ struct XMLDumper : public XMLDeclVisitor, case CC_AAPCS: return set("cc", "aapcs"); case CC_AAPCS_VFP: return set("cc", "aapcs_vfp"); case CC_PnaclCall: return set("cc", "pnaclcall"); + case CC_IntelOclBicc: return set("cc", "intel_ocl_bicc"); } } diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 673528ada0..2f91cd8551 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1552,6 +1552,7 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) { case CC_AAPCS: return "aapcs"; case CC_AAPCS_VFP: return "aapcs-vfp"; case CC_PnaclCall: return "pnaclcall"; + case CC_IntelOclBicc: return "intel_ocl_bicc"; } llvm_unreachable("Invalid calling convention."); diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 83ffec4cda..9feaf5721e 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -647,6 +647,9 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T, case CC_PnaclCall: OS << " __attribute__((pnaclcall))"; break; + case CC_IntelOclBicc: + OS << " __attribute__((intel_ocl_bicc))"; + break; } if (Info.getNoReturn()) OS << " __attribute__((noreturn))"; @@ -1168,6 +1171,7 @@ void TypePrinter::printAttributedAfter(const AttributedType *T, break; } case AttributedType::attr_pnaclcall: OS << "pnaclcall"; break; + case AttributedType::attr_inteloclbicc: OS << "inteloclbicc"; break; } OS << "))"; } diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 5f7f75d440..ea19b15848 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1803,7 +1803,8 @@ public: CC == CC_X86FastCall || CC == CC_X86StdCall || CC == CC_C || - CC == CC_X86Pascal) ? CCCR_OK : CCCR_Warning; + CC == CC_X86Pascal || + CC == CC_IntelOclBicc) ? CCCR_OK : CCCR_Warning; } virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const { diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 31cff910a2..cdac2fc762 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -41,6 +41,7 @@ static unsigned ClangCallConvToLLVMCallConv(CallingConv CC) { case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall; case CC_AAPCS: return llvm::CallingConv::ARM_AAPCS; case CC_AAPCS_VFP: return llvm::CallingConv::ARM_AAPCS_VFP; + case CC_IntelOclBicc: return llvm::CallingConv::Intel_OCL_BI; // TODO: add support for CC_X86Pascal to llvm } } @@ -151,6 +152,9 @@ static CallingConv getCallingConventionForDecl(const Decl *D) { if (D->hasAttr()) return CC_PnaclCall; + if (D->hasAttr()) + return CC_IntelOclBicc; + return CC_C; } diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 437e2a826b..cf3335316e 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3613,6 +3613,9 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) { case AttributeList::AT_PnaclCall: D->addAttr(::new (S.Context) PnaclCallAttr(Attr.getRange(), S.Context)); return; + case AttributeList::AT_IntelOclBicc: + D->addAttr(::new (S.Context) IntelOclBiccAttr(Attr.getRange(), S.Context)); + return; default: llvm_unreachable("unexpected attribute kind"); @@ -3668,6 +3671,7 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, return true; } case AttributeList::AT_PnaclCall: CC = CC_PnaclCall; break; + case AttributeList::AT_IntelOclBicc: CC = CC_IntelOclBicc; break; default: llvm_unreachable("unexpected attribute kind"); } @@ -4440,6 +4444,7 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, case AttributeList::AT_Pascal: case AttributeList::AT_Pcs: case AttributeList::AT_PnaclCall: + case AttributeList::AT_IntelOclBicc: handleCallConvAttr(S, D, Attr); break; case AttributeList::AT_OpenCLKernel: diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 1afc8c7f25..bbd8a7e935 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -106,7 +106,8 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, case AttributeList::AT_Pascal: \ case AttributeList::AT_Regparm: \ case AttributeList::AT_Pcs: \ - case AttributeList::AT_PnaclCall \ + case AttributeList::AT_PnaclCall: \ + case AttributeList::AT_IntelOclBicc \ namespace { /// An object which stores processing state for the entire @@ -3032,6 +3033,8 @@ static AttributeList::Kind getAttrListKind(AttributedType::Kind kind) { return AttributeList::AT_Pcs; case AttributedType::attr_pnaclcall: return AttributeList::AT_PnaclCall; + case AttributedType::attr_inteloclbicc: + return AttributeList::AT_IntelOclBicc; } llvm_unreachable("unexpected attribute kind!"); } diff --git a/test/CodeGen/intel_ocl_bicc.c b/test/CodeGen/intel_ocl_bicc.c new file mode 100644 index 0000000000..2f5c58cfc3 --- /dev/null +++ b/test/CodeGen/intel_ocl_bicc.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +void __attribute__((intel_ocl_bicc)) f1(void); + +void f2(void) { + f1(); +// CHECK: call intel_ocl_bicc void @f1() +} + +// CHECK: declare intel_ocl_bicc void @f1() diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c index 266242d4a3..4c0d4b1bb1 100644 --- a/test/Sema/callingconv.c +++ b/test/Sema/callingconv.c @@ -54,3 +54,5 @@ typedef __attribute__((stdcall)) void (*PROC)(); PROC __attribute__((cdecl)) ctest4(const char *x) {} void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}} + +void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index e2fbc0be82..25ea2853d3 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -480,6 +480,7 @@ CXCallingConv clang_getFunctionTypeCallingConv(CXType X) { TCALLINGCONV(AAPCS); TCALLINGCONV(AAPCS_VFP); TCALLINGCONV(PnaclCall); + TCALLINGCONV(IntelOclBicc); } #undef TCALLINGCONV }