bmahjour added a comment.

Thanks for this patch @ZarkoCA.

We have six of these functions in altivec: `vec_ctd, vec_ctf, vec_cts, 
vec_ctsl, vec_ctu, vec_ctul`. They are all defined as macros in altivec.h and 
not all of them map to the builtins checked in this patch (eg `vec_ctul`). I 
realize this is an improvement over what we have, but just wondering if you've 
considered diagnosing cases like `vec_ctul` or the following:

  vector double a; 
  vector unsigned int res = vec_ctu(a, 32);

One solution I can think of is to introduce a noop pass-through builtin whose 
only purpose would be to allow semantic checking in places like 
`Sema::CheckPPCBuiltinFunctionCall`. For example say the builtin is called 
`_builtin_pass_through_with_rcheck_1_32` then we can change `vec_ctul` in 
altivec.h to the following:

  #define vec_ctul(__a, __b)                                                    
 \
    _Generic((__a), vector float                                                
 \
             : __extension__({                                                  
 \
                 vector float __ret =                                           
 \
                     (vector float)(__a) *                                      
 \
                     (vector float)(vector unsigned)((0x7f + 
(__builtin_pass_through_with_rcheck_1_32(__b))) << 23);      \
                 __builtin_vsx_xvcvspuxds(                                      
 \
                     __builtin_vsx_xxsldwi(__ret, __ret, 1));                   
 \
               }),                                                              
 \

and the sema check would look something like:

  case PPC::BI__builtin_pass_through_with_rcheck_1_32:
      return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31);

Any thoughts @nemanjai ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106409/new/

https://reviews.llvm.org/D106409

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to