Add intel_ocl_bicc calling convention as a function attribute to clang. The calling convention is already implemented in LLVM.

llvm-svn: 171056
This commit is contained in:
Guy Benyei 2012-12-25 08:53:55 +00:00
parent ad24c58e16
commit f0a014bbb7
14 changed files with 43 additions and 4 deletions

View File

@ -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

View File

@ -3330,7 +3330,8 @@ public:
attr_stdcall,
attr_thiscall,
attr_pascal,
attr_pnaclcall
attr_pnaclcall,
attr_inteloclbicc
};
private:

View File

@ -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",

View File

@ -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

View File

@ -922,6 +922,7 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>,
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");
}
}

View File

@ -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.");

View File

@ -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 << "))";
}

View File

@ -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 {

View File

@ -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<PnaclCallAttr>())
return CC_PnaclCall;
if (D->hasAttr<IntelOclBiccAttr>())
return CC_IntelOclBicc;
return CC_C;
}

View File

@ -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:

View File

@ -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!");
}

View File

@ -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()

View File

@ -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) {}

View File

@ -480,6 +480,7 @@ CXCallingConv clang_getFunctionTypeCallingConv(CXType X) {
TCALLINGCONV(AAPCS);
TCALLINGCONV(AAPCS_VFP);
TCALLINGCONV(PnaclCall);
TCALLINGCONV(IntelOclBicc);
}
#undef TCALLINGCONV
}