]> granicus.if.org Git - clang/commitdiff
Various builtins a require an integer constant. Not providing
authorChris Lattner <sabre@nondot.org>
Fri, 1 Oct 2010 07:13:18 +0000 (07:13 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 1 Oct 2010 07:13:18 +0000 (07:13 +0000)
one results in an obscure error from the backend that doesn't make
sense.  Capture this information in the .def files for builtins with
a new "I" modifier letter indicating the an argument needs to be an ICE.

Nothing uses this yet, but sema will eventually enforce this (eliminating
some special cases from semachecking.cpp) and codegen will use this to
force an ICE value, preventing backend error messages.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115302 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Builtins.def
include/clang/Basic/BuiltinsX86.def
lib/AST/ASTContext.cpp

index d0459101c084893230c7afe33c2a361e5359fa89..ca710423d912bc38fa1180aca43a93e6486443e7 100644 (file)
 //  SJ -> sigjmp_buf
 //  . -> "...".  This may only occur at the end of the function list.
 //
-// Types maybe prefixed with the following modifiers:
+// Types may be prefixed with the following modifiers:
 //  L   -> long (e.g. Li for 'long int')
 //  LL  -> long long
 //  LLL -> __int128_t (e.g. LLLi)
 //  S   -> signed
 //  U   -> unsigned
+//  I   -> Required to constant fold to an integer constant expression.
 //
 // Types may be postfixed with the following modifiers:
 // * -> pointer (optionally followed by an address space number)
@@ -367,7 +368,7 @@ BUILTIN(__builtin___vfprintf_chk, "iP*icC*a", "FP:2:")
 BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
 
 BUILTIN(__builtin_expect, "LiLiLi"   , "nc")
-BUILTIN(__builtin_prefetch, "vvC*.", "nc")
+BUILTIN(__builtin_prefetch, "vvC*.", "nIc")
 BUILTIN(__builtin_trap, "v", "nr")
 BUILTIN(__builtin_unreachable, "v", "nr")
 BUILTIN(__builtin_shufflevector, "v."   , "nc")
index 025e7b60c23c13836c4d04664ea86fad2de8ee02..8a730a836b6ff4c6cb958325d850fc584de0cbfb 100644 (file)
@@ -97,7 +97,7 @@ BUILTIN(__builtin_ia32_pcmpgtd, "V2iV2iV2i", "")
 BUILTIN(__builtin_ia32_maskmovq, "vV8cV8cc*", "")
 BUILTIN(__builtin_ia32_pmovmskb, "iV8c", "")
 BUILTIN(__builtin_ia32_movntq, "vV1LLi*V1LLi", "")
-BUILTIN(__builtin_ia32_palignr, "V8cV8cV8cc", "")
+BUILTIN(__builtin_ia32_palignr, "V8cV8cV8cIc", "")
 BUILTIN(__builtin_ia32_vec_init_v2si, "V2iii", "")
 BUILTIN(__builtin_ia32_vec_init_v4hi, "V4sssss", "")
 BUILTIN(__builtin_ia32_vec_init_v8qi, "V8ccccccccc", "")
@@ -255,8 +255,8 @@ BUILTIN(__builtin_ia32_psraw128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "")
 BUILTIN(__builtin_ia32_psrlw128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_psrld128, "V4iV4iV4i", "")
-BUILTIN(__builtin_ia32_pslldqi128, "V2LLiV2LLii", "")
-BUILTIN(__builtin_ia32_psrldqi128, "V2LLiV2LLii", "")
+BUILTIN(__builtin_ia32_pslldqi128, "V2LLiV2LLiIi", "")
+BUILTIN(__builtin_ia32_psrldqi128, "V2LLiV2LLiIi", "")
 BUILTIN(__builtin_ia32_psrlq128, "V2LLiV2LLiV2LLi", "")
 BUILTIN(__builtin_ia32_psllw128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_pslld128, "V4iV4iV4i", "")
@@ -273,7 +273,7 @@ BUILTIN(__builtin_ia32_pmaddwd128, "V8sV8sV8s", "")
 BUILTIN(__builtin_ia32_monitor, "vv*UiUi", "")
 BUILTIN(__builtin_ia32_mwait, "vUiUi", "")
 BUILTIN(__builtin_ia32_lddqu, "V16ccC*", "")
-BUILTIN(__builtin_ia32_palignr128, "V16cV16cV16cc", "") // FIXME: Correct type?
+BUILTIN(__builtin_ia32_palignr128, "V16cV16cV16cIc", "") // FIXME: Correct type?
 BUILTIN(__builtin_ia32_insertps128, "V4fV4fV4fi", "")
 
 BUILTIN(__builtin_ia32_storelv4si, "vV2i*V2LLi", "")
index 57780ef981cd742a9088e4d4380567c9b8da44a6..ce76fcd9ba462fd1b31867214766645727188f48 100644 (file)
@@ -5187,12 +5187,16 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
   // Modifiers.
   int HowLong = 0;
   bool Signed = false, Unsigned = false;
-
+  bool RequiresIntegerConstant = false;
+  
   // Read the modifiers first.
   bool Done = false;
   while (!Done) {
     switch (*Str++) {
     default: Done = true; --Str; break;
+    case 'I':
+      RequiresIntegerConstant = true;
+      break;
     case 'S':
       assert(!Unsigned && "Can't use both 'S' and 'U' modifiers!");
       assert(!Signed && "Can't use 'S' modifier multiple times!");
@@ -5362,6 +5366,9 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
         break;
     }
   }
+  
+  assert((!RequiresIntegerConstant || Type->isIntegralOrEnumerationType()) &&
+         "Integer constant 'I' type must be an integer"); 
 
   return Type;
 }