aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <nickdesaulniers@users.noreply.github.com>2023-09-11 09:27:37 -0700
committerGitHub <noreply@github.com>2023-09-11 09:27:37 -0700
commit93bd428742f985a4b909dd5efee462ea520c96c0 (patch)
tree6d1e1854a26ca06d9b0cc6d49111ad3c6d343cd0 /llvm/lib/CodeGen/MachineInstr.cpp
parente33f3f09b85935ab3540d7718c2098d4e6942916 (diff)
downloadllvm-93bd428742f985a4b909dd5efee462ea520c96c0.zip
llvm-93bd428742f985a4b909dd5efee462ea520c96c0.tar.gz
llvm-93bd428742f985a4b909dd5efee462ea520c96c0.tar.bz2
[InlineAsm] refactor InlineAsm class NFC (#65649)
I would like to steal one of these bits to denote whether a kind may be spilled by the register allocator or not, but I'm afraid to touch of any this code using bitwise operands. Make flags a first class type using bitfields, rather than launder data around via `unsigned`.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index fefae65..8cc3391 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -845,7 +845,8 @@ int MachineInstr::findInlineAsmFlagIdx(unsigned OpIdx,
// If we reach the implicit register operands, stop looking.
if (!FlagMO.isImm())
return -1;
- NumOps = 1 + InlineAsm::getNumOperandRegisters(FlagMO.getImm());
+ const InlineAsm::Flag F(FlagMO.getImm());
+ NumOps = 1 + F.getNumOperandRegisters();
if (i + NumOps > OpIdx) {
if (GroupNo)
*GroupNo = Group;
@@ -922,16 +923,14 @@ MachineInstr::getRegClassConstraint(unsigned OpIdx,
if (FlagIdx < 0)
return nullptr;
- unsigned Flag = getOperand(FlagIdx).getImm();
+ const InlineAsm::Flag F(getOperand(FlagIdx).getImm());
unsigned RCID;
- if ((InlineAsm::getKind(Flag) == InlineAsm::Kind::RegUse ||
- InlineAsm::getKind(Flag) == InlineAsm::Kind::RegDef ||
- InlineAsm::getKind(Flag) == InlineAsm::Kind::RegDefEarlyClobber) &&
- InlineAsm::hasRegClassConstraint(Flag, RCID))
+ if ((F.isRegUseKind() || F.isRegDefKind() || F.isRegDefEarlyClobberKind()) &&
+ F.hasRegClassConstraint(RCID))
return TRI->getRegClass(RCID);
// Assume that all registers in a memory operand are pointers.
- if (InlineAsm::getKind(Flag) == InlineAsm::Kind::Mem)
+ if (F.isMemKind())
return TRI->getPointerRegClass(MF);
return nullptr;
@@ -1196,12 +1195,13 @@ unsigned MachineInstr::findTiedOperandIdx(unsigned OpIdx) const {
assert(FlagMO.isImm() && "Invalid tied operand on inline asm");
unsigned CurGroup = GroupIdx.size();
GroupIdx.push_back(i);
- NumOps = 1 + InlineAsm::getNumOperandRegisters(FlagMO.getImm());
+ const InlineAsm::Flag F(FlagMO.getImm());
+ NumOps = 1 + F.getNumOperandRegisters();
// OpIdx belongs to this operand group.
if (OpIdx > i && OpIdx < i + NumOps)
OpIdxGroup = CurGroup;
unsigned TiedGroup;
- if (!InlineAsm::isUseOperandTiedToDef(FlagMO.getImm(), TiedGroup))
+ if (!F.isUseOperandTiedToDef(TiedGroup))
continue;
// Operands in this group are tied to operands in TiedGroup which must be
// earlier. Find the number of operands between the two groups.
@@ -1765,31 +1765,31 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST,
// Pretty print the inline asm operand descriptor.
OS << '$' << AsmOpCount++;
unsigned Flag = MO.getImm();
+ const InlineAsm::Flag F(Flag);
OS << ":[";
- OS << InlineAsm::getKindName(InlineAsm::getKind(Flag));
+ OS << F.getKindName();
- unsigned RCID = 0;
- if (!InlineAsm::isImmKind(Flag) && !InlineAsm::isMemKind(Flag) &&
- InlineAsm::hasRegClassConstraint(Flag, RCID)) {
+ unsigned RCID;
+ if (!F.isImmKind() && !F.isMemKind() && F.hasRegClassConstraint(RCID)) {
if (TRI) {
OS << ':' << TRI->getRegClassName(TRI->getRegClass(RCID));
} else
OS << ":RC" << RCID;
}
- if (InlineAsm::isMemKind(Flag)) {
- unsigned MCID = InlineAsm::getMemoryConstraintID(Flag);
+ if (F.isMemKind()) {
+ const unsigned MCID = F.getMemoryConstraintID();
OS << ":" << InlineAsm::getMemConstraintName(MCID);
}
- unsigned TiedTo = 0;
- if (InlineAsm::isUseOperandTiedToDef(Flag, TiedTo))
+ unsigned TiedTo;
+ if (F.isUseOperandTiedToDef(TiedTo))
OS << " tiedto:$" << TiedTo;
OS << ']';
// Compute the index of the next operand descriptor.
- AsmDescOp += 1 + InlineAsm::getNumOperandRegisters(Flag);
+ AsmDescOp += 1 + F.getNumOperandRegisters();
} else {
LLT TypeToPrint = MRI ? getTypeToPrint(i, PrintedTypes, *MRI) : LLT{};
unsigned TiedOperandIdx = getTiedOperandIdx(i);