aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOperand.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-19 21:46:55 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-19 21:46:55 +0000
commit8122660226be6e5cf7782f4d5ad1d632787a942a (patch)
tree1b0be3c4e3c18a12e3e90ec8728eefab3b6070ac /llvm/lib/CodeGen/MachineOperand.cpp
parent0be8825146e5c4bcf663d3300a98b97323924c37 (diff)
downloadllvm-8122660226be6e5cf7782f4d5ad1d632787a942a.zip
llvm-8122660226be6e5cf7782f4d5ad1d632787a942a.tar.gz
llvm-8122660226be6e5cf7782f4d5ad1d632787a942a.tar.bz2
[CodeGen] Refactor printOffset from MO and MIRPrinter
llvm-svn: 321109
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOperand.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp
index 50f7017..3b916fa 100644
--- a/llvm/lib/CodeGen/MachineOperand.cpp
+++ b/llvm/lib/CodeGen/MachineOperand.cpp
@@ -380,16 +380,6 @@ static void tryToGetTargetInfo(const MachineOperand &MO,
}
}
-static void printOffset(raw_ostream &OS, int64_t Offset) {
- if (Offset == 0)
- return;
- if (Offset < 0) {
- OS << " - " << -Offset;
- return;
- }
- OS << " + " << Offset;
-}
-
static const char *getTargetIndexName(const MachineFunction &MF, int Index) {
const auto *TII = MF.getSubtarget().getInstrInfo();
assert(TII && "expected instruction info");
@@ -505,6 +495,16 @@ void MachineOperand::printStackObjectReference(raw_ostream &OS,
OS << '.' << Name;
}
+void MachineOperand::printOperandOffset(raw_ostream &OS, int64_t Offset) {
+ if (Offset == 0)
+ return;
+ if (Offset < 0) {
+ OS << " - " << -Offset;
+ return;
+ }
+ OS << " + " << Offset;
+}
+
static void printCFI(raw_ostream &OS, const MCCFIInstruction &CFI,
const TargetRegisterInfo *TRI) {
switch (CFI.getOperation()) {
@@ -723,7 +723,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
}
case MachineOperand::MO_ConstantPoolIndex:
OS << "%const." << getIndex();
- printOffset(OS, getOffset());
+ printOperandOffset(OS, getOffset());
break;
case MachineOperand::MO_TargetIndex: {
OS << "target-index(";
@@ -732,7 +732,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
if (const auto *TargetIndexName = getTargetIndexName(*MF, getIndex()))
Name = TargetIndexName;
OS << Name << ')';
- printOffset(OS, getOffset());
+ printOperandOffset(OS, getOffset());
break;
}
case MachineOperand::MO_JumpTableIndex:
@@ -740,7 +740,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
break;
case MachineOperand::MO_GlobalAddress:
getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST);
- printOffset(OS, getOffset());
+ printOperandOffset(OS, getOffset());
break;
case MachineOperand::MO_ExternalSymbol: {
StringRef Name = getSymbolName();
@@ -750,7 +750,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
} else {
printLLVMNameWithoutPrefix(OS, Name);
}
- printOffset(OS, getOffset());
+ printOperandOffset(OS, getOffset());
break;
}
case MachineOperand::MO_BlockAddress: