From 142f36de332925dbe19d73d0612d9879b4f80e84 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 27 Nov 2007 07:22:09 +0000 Subject: [PATCH] Add builtin type signature support for vector types. Add correct type signatures for a bunch of MMX builtins. We now parse all the intrinsics in mmintrin.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44357 91177308-0d34-0410-b5e6-96231b3b80d8 --- AST/Builtins.cpp | 20 ++++-- Driver/X86Builtins.def | 123 +++++++++++++++++---------------- include/clang/AST/Builtins.def | 9 +-- 3 files changed, 84 insertions(+), 68 deletions(-) diff --git a/AST/Builtins.cpp b/AST/Builtins.cpp index 5a470ff950..137f4eaebb 100644 --- a/AST/Builtins.cpp +++ b/AST/Builtins.cpp @@ -112,10 +112,10 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context) { Type = Context.ShortTy; break; case 'i': - if (Long) - Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy; - else if (LongLong) + if (LongLong) Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy; + else if (Long) + Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy; else if (Unsigned) Type = Context.UnsignedIntTy; else @@ -137,10 +137,22 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context) { case 'F': Type = Context.getCFConstantStringType(); break; - case 'V': + case 'a': Type = Context.getBuiltinVaListType(); assert(!Type.isNull() && "builtin va list type not initialized!"); break; + case 'V': { + char *End; + + unsigned NumElements = strtoul(Str, &End, 10); + assert(End != Str && "Missing vector size"); + + Str = End; + + QualType ElementType = DecodeTypeFromStr(Str, Context); + Type = Context.getVectorType(ElementType, NumElements); + break; + } } Done = false; diff --git a/Driver/X86Builtins.def b/Driver/X86Builtins.def index c4e3033a55..ea4c7ea315 100644 --- a/Driver/X86Builtins.def +++ b/Driver/X86Builtins.def @@ -17,6 +17,9 @@ // The format of this database matches clang/AST/Builtins.def. +// FIXME: In GCC, these builtins are defined depending on whether support for +// MMX/SSE/etc is turned on. We should do this too. + BUILTIN(__builtin_ia32_emms , "v", "") // FIXME: These types are incorrect. @@ -88,47 +91,47 @@ BUILTIN(__builtin_ia32_movhlps, "v", "") BUILTIN(__builtin_ia32_movlhps, "v", "") BUILTIN(__builtin_ia32_unpckhps, "v", "") BUILTIN(__builtin_ia32_unpcklps, "v", "") -BUILTIN(__builtin_ia32_paddb, "v", "") -BUILTIN(__builtin_ia32_paddw, "v", "") -BUILTIN(__builtin_ia32_paddd, "v", "") -BUILTIN(__builtin_ia32_paddq, "v", "") -BUILTIN(__builtin_ia32_psubb, "v", "") -BUILTIN(__builtin_ia32_psubw, "v", "") -BUILTIN(__builtin_ia32_psubd, "v", "") -BUILTIN(__builtin_ia32_psubq, "v", "") -BUILTIN(__builtin_ia32_paddsb, "v", "") -BUILTIN(__builtin_ia32_paddsw, "v", "") -BUILTIN(__builtin_ia32_psubsb, "v", "") -BUILTIN(__builtin_ia32_psubsw, "v", "") -BUILTIN(__builtin_ia32_paddusb, "v", "") -BUILTIN(__builtin_ia32_paddusw, "v", "") -BUILTIN(__builtin_ia32_psubusb, "v", "") -BUILTIN(__builtin_ia32_psubusw, "v", "") -BUILTIN(__builtin_ia32_pmullw, "v", "") -BUILTIN(__builtin_ia32_pmulhw, "v", "") -BUILTIN(__builtin_ia32_pmulhuw, "v", "") -BUILTIN(__builtin_ia32_pand, "v", "") -BUILTIN(__builtin_ia32_pandn, "v", "") -BUILTIN(__builtin_ia32_por, "v", "") -BUILTIN(__builtin_ia32_pxor, "v", "") +BUILTIN(__builtin_ia32_paddb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_paddw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_paddd, "V2iV2iV2i", "") +BUILTIN(__builtin_ia32_paddq, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_psubb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_psubw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_psubd, "V2iV2iV2i", "") +BUILTIN(__builtin_ia32_psubq, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_paddsb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_paddsw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_psubsb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_psubsw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_paddusb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_paddusw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_psubusb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_psubusw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pmullw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pmulhw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pmulhuw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pand, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_pandn, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_por, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_pxor, "V1LLiV1LLiV1LLi", "") BUILTIN(__builtin_ia32_pavgb, "v", "") BUILTIN(__builtin_ia32_pavgw, "v", "") -BUILTIN(__builtin_ia32_pcmpeqb, "v", "") -BUILTIN(__builtin_ia32_pcmpeqw, "v", "") -BUILTIN(__builtin_ia32_pcmpeqd, "v", "") -BUILTIN(__builtin_ia32_pcmpgtb, "v", "") -BUILTIN(__builtin_ia32_pcmpgtw, "v", "") -BUILTIN(__builtin_ia32_pcmpgtd, "v", "") +BUILTIN(__builtin_ia32_pcmpeqb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_pcmpeqw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pcmpeqd, "V2iV2iV2i", "") +BUILTIN(__builtin_ia32_pcmpgtb, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_pcmpgtw, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_pcmpgtd, "V2iV2iV2i", "") BUILTIN(__builtin_ia32_pmaxub, "v", "") BUILTIN(__builtin_ia32_pmaxsw, "v", "") BUILTIN(__builtin_ia32_pminub, "v", "") BUILTIN(__builtin_ia32_pminsw, "v", "") -BUILTIN(__builtin_ia32_punpckhbw, "v", "") -BUILTIN(__builtin_ia32_punpckhwd, "v", "") -BUILTIN(__builtin_ia32_punpckhdq, "v", "") -BUILTIN(__builtin_ia32_punpcklbw, "v", "") -BUILTIN(__builtin_ia32_punpcklwd, "v", "") -BUILTIN(__builtin_ia32_punpckldq, "v", "") +BUILTIN(__builtin_ia32_punpckhbw, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_punpckhwd, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_punpckhdq, "V2iV2iV2i", "") +BUILTIN(__builtin_ia32_punpcklbw, "V8cV8cV8c", "") +BUILTIN(__builtin_ia32_punpcklwd, "V4sV4sV4s", "") +BUILTIN(__builtin_ia32_punpckldq, "V2iV2iV2i", "") BUILTIN(__builtin_ia32_addpd, "v", "") BUILTIN(__builtin_ia32_subpd, "v", "") BUILTIN(__builtin_ia32_mulpd, "v", "") @@ -250,19 +253,19 @@ BUILTIN(__builtin_ia32_pabsw128, "v", "") BUILTIN(__builtin_ia32_pabsw, "v", "") BUILTIN(__builtin_ia32_pabsd128, "v", "") BUILTIN(__builtin_ia32_pabsd, "v", "") -BUILTIN(__builtin_ia32_psllw, "v", "") -BUILTIN(__builtin_ia32_pslld, "v", "") -BUILTIN(__builtin_ia32_psllq, "v", "") -BUILTIN(__builtin_ia32_psrlw, "v", "") -BUILTIN(__builtin_ia32_psrld, "v", "") -BUILTIN(__builtin_ia32_psrlq, "v", "") -BUILTIN(__builtin_ia32_psraw, "v", "") -BUILTIN(__builtin_ia32_psrad, "v", "") +BUILTIN(__builtin_ia32_psllw, "V4sV4sV1LLi", "") +BUILTIN(__builtin_ia32_pslld, "V2iV2iV1LLi", "") +BUILTIN(__builtin_ia32_psllq, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_psrlw, "V4sV4sV1LLi", "") +BUILTIN(__builtin_ia32_psrld, "V2iV2iV1LLi", "") +BUILTIN(__builtin_ia32_psrlq, "V1LLiV1LLiV1LLi", "") +BUILTIN(__builtin_ia32_psraw, "V4sV4sV1LLi", "") +BUILTIN(__builtin_ia32_psrad, "V2iV2iV1LLi", "") BUILTIN(__builtin_ia32_pshufw, "v", "") -BUILTIN(__builtin_ia32_pmaddwd, "v", "") -BUILTIN(__builtin_ia32_packsswb, "v", "") -BUILTIN(__builtin_ia32_packssdw, "v", "") -BUILTIN(__builtin_ia32_packuswb, "v", "") +BUILTIN(__builtin_ia32_pmaddwd, "V2iV4sV4s", "") +BUILTIN(__builtin_ia32_packsswb, "V8cV4sV4s", "") +BUILTIN(__builtin_ia32_packssdw, "V4sV2iV2i", "") +BUILTIN(__builtin_ia32_packuswb, "V8cV4sV4s", "") BUILTIN(__builtin_ia32_ldmxcsr, "v", "") BUILTIN(__builtin_ia32_stmxcsr, "v", "") BUILTIN(__builtin_ia32_cvtpi2ps, "v", "") @@ -361,21 +364,21 @@ BUILTIN(__builtin_ia32_lfence, "v", "") BUILTIN(__builtin_ia32_mfence, "v", "") BUILTIN(__builtin_ia32_loaddqu, "v", "") BUILTIN(__builtin_ia32_storedqu, "v", "") -BUILTIN(__builtin_ia32_psllwi, "v", "") -BUILTIN(__builtin_ia32_pslldi, "v", "") -BUILTIN(__builtin_ia32_psllqi, "v", "") -BUILTIN(__builtin_ia32_psrawi, "v", "") -BUILTIN(__builtin_ia32_psradi, "v", "") -BUILTIN(__builtin_ia32_psrlwi, "v", "") -BUILTIN(__builtin_ia32_psrldi, "v", "") -BUILTIN(__builtin_ia32_psrlqi, "v", "") +BUILTIN(__builtin_ia32_psllwi, "V4sV4si", "") +BUILTIN(__builtin_ia32_pslldi, "V2iV2ii", "") +BUILTIN(__builtin_ia32_psllqi, "V1LLiV1LLii", "") +BUILTIN(__builtin_ia32_psrawi, "V4sV4si", "") +BUILTIN(__builtin_ia32_psradi, "V2iV2ii", "") +BUILTIN(__builtin_ia32_psrlwi, "V4sV4si", "") +BUILTIN(__builtin_ia32_psrldi, "V2iV2ii", "") +BUILTIN(__builtin_ia32_psrlqi, "V1LLiV1LLii", "") BUILTIN(__builtin_ia32_pmuludq, "v", "") BUILTIN(__builtin_ia32_pmuludq128, "v", "") BUILTIN(__builtin_ia32_psllw128, "v", "") BUILTIN(__builtin_ia32_pslld128, "v", "") BUILTIN(__builtin_ia32_psllq128, "v", "") BUILTIN(__builtin_ia32_psrlw128, "v", "") -BUILTIN(__builtin_ia32_psrld128, "v", "") +BUILTIN(__builtin_ia32_psrld128, "V2iV2iV1LLi", "") BUILTIN(__builtin_ia32_psrlq128, "v", "") BUILTIN(__builtin_ia32_psraw128, "v", "") BUILTIN(__builtin_ia32_psrad128, "v", "") @@ -397,16 +400,16 @@ BUILTIN(__builtin_ia32_movsldup, "v", "") BUILTIN(__builtin_ia32_lddqu, "v", "") BUILTIN(__builtin_ia32_palignr128, "v", "") BUILTIN(__builtin_ia32_palignr, "v", "") -BUILTIN(__builtin_ia32_vec_init_v2si, "v", "") -BUILTIN(__builtin_ia32_vec_init_v4hi, "v", "") -BUILTIN(__builtin_ia32_vec_init_v8qi, "v", "") +BUILTIN(__builtin_ia32_vec_init_v2si, "V2iii", "") +BUILTIN(__builtin_ia32_vec_init_v4hi, "V4sssss", "") +BUILTIN(__builtin_ia32_vec_init_v8qi, "V8ccccccccc", "") BUILTIN(__builtin_ia32_vec_ext_v2df, "v", "") BUILTIN(__builtin_ia32_vec_ext_v2di, "v", "") BUILTIN(__builtin_ia32_vec_ext_v4sf, "v", "") BUILTIN(__builtin_ia32_vec_ext_v4si, "v", "") BUILTIN(__builtin_ia32_vec_ext_v8hi, "v", "") BUILTIN(__builtin_ia32_vec_ext_v4hi, "v", "") -BUILTIN(__builtin_ia32_vec_ext_v2si, "v", "") +BUILTIN(__builtin_ia32_vec_ext_v2si, "iV2ii", "") BUILTIN(__builtin_ia32_vec_set_v8hi, "v", "") BUILTIN(__builtin_ia32_vec_set_v4hi, "v", "") diff --git a/include/clang/AST/Builtins.def b/include/clang/AST/Builtins.def index f0107e5859..7733a9b1b2 100644 --- a/include/clang/AST/Builtins.def +++ b/include/clang/AST/Builtins.def @@ -31,7 +31,8 @@ // d -> double // z -> size_t // F -> constant CFString -// V -> __builtin_va_list +// a -> __builtin_va_list +// V -> Vector, following num elements and a base type. // . -> "...". This may only occur at the end of the function list. // // Types maybe prefixed with the following modifiers: @@ -62,9 +63,9 @@ BUILTIN(__builtin_fabsl, "LdLd", "ncF") BUILTIN(__builtin_constant_p, "UsUs", "nc") BUILTIN(__builtin_classify_type, "i.", "nc") BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc") -BUILTIN(__builtin_va_start, "vV&.", "n") -BUILTIN(__builtin_va_end, "vV&", "n") -BUILTIN(__builtin_va_copy, "vV&V", "n") +BUILTIN(__builtin_va_start, "va&.", "n") +BUILTIN(__builtin_va_end, "va&", "n") +BUILTIN(__builtin_va_copy, "va&a", "n") BUILTIN(__builtin_memcpy, "v*v*vC*z", "n") #undef BUILTIN -- 2.40.0