[llvm] [TargetLowering] Deduplicate choosing InlineAsm constraint between ISels (PR #67057)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 14:33:31 PDT 2023
================
@@ -5701,13 +5702,19 @@ TargetLowering::ParseConstraints(const DataLayout &DL,
return ConstraintOperands;
}
-/// Return an integer indicating how general CT is.
-static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
+/// Return a number indicating our preference for chosing a type of constraint
+/// over another, for the purpose of sorting them. Immediates are almost always
+/// preferrable (when they can be emitted).
+/// FIXME: We should prefer registers over memory but doing so may lead to
+/// unrecoverable register exhaustion later.
+/// https://github.com/llvm/llvm-project/issues/20571
+static unsigned getConstraintPiority(TargetLowering::ConstraintType CT) {
switch (CT) {
- case TargetLowering::C_Immediate:
- case TargetLowering::C_Other:
case TargetLowering::C_Unknown:
return 0;
+ case TargetLowering::C_Immediate:
+ case TargetLowering::C_Other:
+ return 4;
----------------
nickdesaulniers wrote:
Higher is preferable; I'll add that info the method comment. Immediate is preferrable to register. Other is an oddball, we use that for the flag constraints.
https://github.com/llvm/llvm-project/pull/67057
More information about the llvm-commits
mailing list