This is an archive of the discontinued LLVM Phabricator instance.

Experimental: inline assembly operands
Needs ReviewPublic

Authored by jonpa on May 18 2021, 10:43 AM.

Details

Reviewers
uweigand
Summary

This was an attempt to let getRegForInlineAsmConstraint() return the regclass for an inline aseembly operand and then remember it and not recompute it.

The register class with this patch is encoded in all register operand Flags (also for physical regs), which causes some problems in target code that relies on the assumption that phys-regs do not have the reg-class encoded. All of those cases except one (X86FloatingPoint.cpp) seemed trivial to handle. Not sure if the X86 could be fixed without other changes (see patch comment in that file).

The motivation for this would be to simplify the handling of regclasses that are currently looked up again at a later point: The regclass is first carefully found in the default implementation of getRegForInlineAsmConstraint() but then later found again with TLI.getRegClassFor(MVT). This is confusing: which regclass computation is really correct? There could be a computation based on the type, or on the actual physreg. There are different regclasses possible for a phys-reg... Why not use the regclass that the target hook already returns...

Basically, it seemed right to let target override defaults for inline assembly operands in one place. This could also include NumParts. Given the problems with the targets, I am not sure if it is worthwhile... For the i128 operands on SystemZ, https://reviews.llvm.org/D100788 is a smaller and simpler patch even though it does not include the refactoring of this one.

Diff Detail

Event Timeline

jonpa created this revision.May 18 2021, 10:43 AM
jonpa requested review of this revision.May 18 2021, 10:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2021, 10:43 AM
pengfei added inline comments.May 18 2021, 7:53 PM
llvm/lib/Target/X86/X86FloatingPoint.cpp
1549–1551

Is this an existing bug for this pass, or affected by this patch? In which way, if it is affected?

1555

So this can be removed?

jonpa marked 2 inline comments as done.May 19 2021, 11:16 AM
jonpa added inline comments.
llvm/lib/Target/X86/X86FloatingPoint.cpp
1549–1551

No, it's not a current bug. This (and some other files) relies on the fact that currently the RegClass is only encoded for virtual registers... This patch is experimental in encoding the returned RegClass (from getRegForInlineAsmConstraint) always (also for physregs), and that's why some problems show up.

Thanks for taking a look... Have anybody else thought about this or would desire this?