[PATCH] D61321: [globalisel] Allow SrcOp to convert an APInt and render it as an immediate operand (MO.isImm() == true)

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 12:09:58 PDT 2019


aditya_nandakumar added a comment.

In D61321#1546809 <https://reviews.llvm.org/D61321#1546809>, @bogner wrote:

> In D61321#1546724 <https://reviews.llvm.org/D61321#1546724>, @aditya_nandakumar wrote:
>
> > In D61321#1546581 <https://reviews.llvm.org/D61321#1546581>, @arsenm wrote:
> >
> > > How terrible would it be to use APInt as the interface type, but then store it as int64_t?
> >
> >
> > That seems like a good compromise to me.
>
>
> I don't think I agree. APInt as an interface type won't really save any typing, so what advantage would this compromise have? It's about the same to write `SrcOp(APInt(x))` vs `SrcOp(int64_t(x))`, but the APInt version is more expensive and if we're not actually handling arbitrary precision it's quite a bit more confusing.


I think it'd be nice to not worry about picking the wrong overloads. For eg, if you have an unsigned constant and you forget to explicitly cast to int64_t it will still compile (and pick the register version even though we wanted the immediate) - where as if the only way to get immediate is APInt and we forget to cast, it will not compile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61321





More information about the llvm-commits mailing list