================
@@ -5393,6 +5405,38 @@ class LLVM_ABI TargetLowering : public
TargetLoweringBase {
/// Given a constraint, return the type of constraint it is for this target.
virtual ConstraintType getConstraintType(StringRef Constraint) const;
+ /// Returns true if this target can fold a register operand of an inline
+ /// asm instruction back to a memory operand (see
+ /// TargetInstrInfo::getFrameIndexOperands(), which a target must override
+ /// with its own addressing-mode encoding for this to work -- the base
+ /// TargetInstrInfo implementation is unreachable()). ParseConstraints()
+ /// only sets MayFoldRegister -- and so only ever prefers 'r' over 'm' for
+ /// an exact "rm"/"+rm" constraint -- when this returns true, so that
+ /// register-pressure fallback (RegAllocFast's inline asm folding, or
+ /// InlineSpiller for the greedy allocator) has an actual implementation to
+ /// fall back to instead of crashing. Defaults to false: without this,
+ /// preferring 'r' for "rm" and then genuinely running out of registers
+ /// would attempt to fold to memory and hit that unreachable() instead of
+ /// RegAllocFast's or InlineSpiller's normal "ran out of registers"
+ /// diagnostic.
+ virtual bool supportsRegMemInlineAsmFolding() const { return false; }
+
+ /// The diagnostic to report when a direct (non-indirect) inline asm
+ /// operand needed a memory constraint but has nowhere to spill to -- see
+ /// supportsRegMemInlineAsmFolding() above for when this can happen.
+ /// Shared between the SelectionDAG (SelectionDAGBuilder.cpp's
+ /// computeConstraintToUse()) and GlobalISel (InlineAsmLowering.cpp's
+ /// lowerInlineAsm()) constraint-selection paths, which are otherwise
+ /// entirely independent implementations, so the two can't drift apart by
+ /// having their own hand-written copies of the same message text.
+ static std::string
+ getRegMemInlineAsmUnsupportedDiag(StringRef ConstraintCode) {
+ return ("unsupported inline asm: constraint '" + ConstraintCode +
+ "' cannot be satisfied in a register and has no memory to fall "
+ "back to")
+ .str();
----------------
isanbard wrote:
*From Claude:*
Worth adding to your reply: this isn't a new pattern this PR introduced — it
reuses the exact `Info.ErrorMsg <</emitInlineAsmError` idiom the surrounding
function already used before this change (e.g. the pre-existing "cannot handle
tied indirect register inputs" message a few lines above it). Plain-string, no
diagnostic ID, no localization — yes, that's genuinely how `SelectionDAG`-level
inline-asm errors have always been reported here. A move to structured
diagnostics for this subsystem would be a legitimate but much larger, separate
project, not something in scope for this change.
**[editor: I'd be in favor of moving LLVM error reporting into something akin
to Clang's with ID's and stuff, but that's another project]**
https://github.com/llvm/llvm-project/pull/214061
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits