Skip to content

Commit 2863894

Browse files
committed
[AArch64] Add getSwappedCondition
This implementation has been taken from PR #121412.
1 parent dc3ba8c commit 2863894

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,36 @@ inline static CondCode getInvertedCondCode(CondCode Code) {
306306
return static_cast<CondCode>(static_cast<unsigned>(Code) ^ 0x1);
307307
}
308308

309+
/// getSwappedCondition - assume the flags are set by MI(a,b), return
310+
/// the condition code if we modify the instructions such that flags are
311+
/// set by MI(b,a).
312+
inline static CondCode getSwappedCondition(CondCode CC) {
313+
switch (CC) {
314+
default:
315+
return AL;
316+
case EQ:
317+
return EQ;
318+
case NE:
319+
return NE;
320+
case HS:
321+
return LS;
322+
case LO:
323+
return HI;
324+
case HI:
325+
return LO;
326+
case LS:
327+
return HS;
328+
case GE:
329+
return LE;
330+
case LT:
331+
return GT;
332+
case GT:
333+
return LT;
334+
case LE:
335+
return GE;
336+
}
337+
}
338+
309339
/// Given a condition code, return NZCV flags that would satisfy that condition.
310340
/// The flag bits are in the format expected by the ccmp instructions.
311341
/// Note that many different flag settings can satisfy a given condition code,

0 commit comments

Comments
 (0)