[llvm-dev] Force casting a Value*

Nikodemus Siivola via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 11 11:32:58 PDT 2017


On Sun, Jun 11, 2017 at 7:49 PM, Dipanjan Das via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

>
>
> On 11 June 2017 at 07:53, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Sounds like you're looking for reinterpret_cast: http://en.cp
>> preference.com/w/cpp/language/reinterpret_cast
>>
>
> I tried cast<ConstInt>(vo), but that failed at run-time.
>

That is not the same as reinterpret_cast<int64>(some_value_star).

Or better yet, reinterpret_cast<intptr_t>(some_value_star)

http://www.cplusplus.com/reference/cstdint/

Cheers,

  -- nikodemus


>
>
>>
>> On Sun, Jun 11, 2017 at 3:06 AM Dipanjan Das via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>>>
>>> I am trying to cast a Value* irrespective of  its underlying subclass to
>>> uint64 and pass it on to a method as an argument.
>>>
>>> if (StoreInst *store_inst = dyn_cast<StoreInst>(&I)) {
>>>                     Value* vo = store_inst->getValueOperand();
>>>                      uint64 value = /* cast vo to unsigned int 64 bit */
>>>                      func(value);
>>>                 }
>>>
>>> How can I force cast 'vo' to unsigned int?
>>>
>>> --
>>>
>>> Thanks & Regards,
>>> Dipanjan
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>
>>
>
>
> --
>
> Thanks & Regards,
> Dipanjan
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170611/eea1c4dc/attachment.html>


More information about the llvm-dev mailing list