[LLVMdev] Inverse of ConstantFP::get and similar functions?
Stephen Lin
swlin at post.harvard.edu
Tue Jul 23 10:10:14 PDT 2013
> On 22/07/13 19:19, Stephen Lin wrote:
>>
>> Hi,
>>
>> I noticed that ConstantFP::get automatically returns the appropriately
>> types Constant depending on the LLVM type passed in (i.e. if called
>> with a vector, it returns a splat vector with the given constant).
>>
>> Is there any simple way to do the inverse of this function? i.e.,
>> given a llvm::Value, check whether it is either a scalar of the given
>> constant value or a splat vector with the given constant value? I
>> can't seem to find any, and it doesn't look like the pattern matching
>> interface provides something similar to this either.
>
>
> yes, getUniqueInteger.
>
> Ciao, Duncan.
>
Well, Eli already pointed me in the direction of m_SpecificFP, so no
big deal now, but getUniqueInteger isn't what I needed because:
1. It's only for integers
2. It asserts when the vector does not contain all of the same
integer, rather than returning some kind of failure code.
Anyway, it's not a big deal now, but it does seem kind of odd to me
that the Constant hierarchy of classes contain so many functions that
allow easy abstraction of scalar and vector types in one direction
(when creating constants), but not in the other direction (when
detecting constants). Using the pattern matches work okay, though.
Stephen
More information about the llvm-dev
mailing list