[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:39:04 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:
https://github.com/llvm/llvm-project/pull/67057/commits/a542e81ffc8a7d178f4a661c40c6155e04388e63
https://github.com/llvm/llvm-project/pull/67057
More information about the llvm-commits
mailing list