[llvm-dev] RFC: token arguments and operand bundles

Joseph Tremoulet via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 15 13:06:59 PST 2019


As I recall, tokens were added largely as a mechanism to constrain particular users to particular single-entry regions of the CFG, and to do so in a way that guaranteed that later phases would be able to determine to which region any given use was tied.  That sounds pretty different to me than the use here of wanting something that's less string-y than metadata but prints as something less obtuse than an integer constant.  I think it would functionally work to do what you're proposing, but it strikes me as mixing unrelated concepts (one of which is already fairly esoteric) in a way that I for one would caution against.  Your issue here strikes me as similar to what 'immArg' addresses, and I'd imagine that having a way to constrain particular 'immArg' arguments to particular known enumerations of values in a way that prints legibly is something that could have other uses as well and involve less conceptual gymnastics.  I'll also note that with the CFG-centric view of tokens, it makes sense that the only constant token is 'None' - you only need one way to indicate "not tied to any region".


Bundles strike me as a better fit.  What strikes me as a bit odd there is that bundles tend (or at least originally tended) to be used to communicate things orthogonal to the semantics of the call itself (or the operation represented by the call) - the ambient state of the virtual machine, the GC values that happen to be live across the call, the EH region that happens to contain the call.  In this new case, the bundle is communicating something relevant to the semantics of the operation that the call represents... but it's also true that, like the other examples, it's communicating something about the context or ambient state at the point of the call, and that it (IIUC) would be applied consistently across the different fp operations... so that one passes my sniff test, for whatever that's worth.


I'm also wondering if "named metadata" could help with the readability issue.


-Joseph


From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Kaylor, Andrew via llvm-dev
Sent: Thursday, November 14, 2019 2:40 PM
To: LLVM Developers Mailing List <llvm-dev at lists.llvm.org>
Subject: [llvm-dev] RFC: token arguments and operand bundles

Hello everyone,

I've just uploaded a patch (https://reviews.llvm.org/D70261<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70261&data=02%7C01%7Cjotrem%40microsoft.com%7C681ef688e2804e28dbf308d7693a70f6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637093572046751978&sdata=BB2AZOZrm2BhlMQg20f88CYkXLTMdwxwP1I9NO3lLZw%3D&reserved=0>) to introduce a could of new token types to be used with constrained floating point intrinsics and, optionally, vector predicated intrinsics. These intrinsics may not be of interest to many of you, but I have a more general question.

I would like some general feedback on the way I am proposing to use token arguments and operand bundles. I have an incomplete understanding of how these are intended to be used, and I want to make sure what I have in mind is consistent with the philosophy behind them.

Currently, the constrained floating point intrinsics require string metadata arguments to describe the rounding mode and exception semantics. These "arguments" are really providing information to the optimizer about what it can and cannot assume when acting on these intrinsics. The rounding mode argument potentially overrides the default optimizer assumption that the "to nearest" rounding mode is in use, and the exception behavior argument overrides the default optimizer assumption that floating point operations have no side effects. I've never liked the use of strings here, and the fact that these arguments are not actually inputs to the operation represented by the intrinsic seems vaguely wrong.

A typical call to a current intrinsic looks like this:

%sum = call double @llvm.experimental.constrained.fadd(double %x,
                                                       double %y,
                                                       Metadata "fpround.dynamic",
                                                       Metadata "fpexcept.strict")

The idea I am pursuing in my patch is to replace these metadata arguments with optional operand bundles, "fpround" and "fpexcept". If the operand bundles are present, they would mean what the arguments currently mean. If not, the default assumption is allowed. A typical call to a constrained intrinsic would look like this:

%sum = call double @llvm.experimental2.constrained.fadd(double %x,
                                                        double %y) [ "fpround"(token rmDynamic),
                                                                     "fpexcept"(token ebStrict) ]

Does that seem like a valid use of tokens and operand bundles? Does it seem better than the current approach?

Thanks,
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191115/64eda889/attachment-0001.html>


More information about the llvm-dev mailing list