aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineInstrBuilder.h
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2013-07-09 20:28:37 +0000
committerAdrian Prantl <aprantl@apple.com>2013-07-09 20:28:37 +0000
commit3517640443f0b5224e2a6414c246ac60016ee9d4 (patch)
tree011ad059026ee96743b0327cd32e41679c4f4021 /include/llvm/CodeGen/MachineInstrBuilder.h
parent7d185e4e5b1da7e07e1c3b9539e2c9bc8e983e62 (diff)
downloadexternal_llvm-3517640443f0b5224e2a6414c246ac60016ee9d4.zip
external_llvm-3517640443f0b5224e2a6414c246ac60016ee9d4.tar.gz
external_llvm-3517640443f0b5224e2a6414c246ac60016ee9d4.tar.bz2
Reapply an improved version of r180816/180817.
Change the informal convention of DBG_VALUE machine instructions so that we can express a register-indirect address with an offset of 0. The old convention was that a DBG_VALUE is a register-indirect value if the offset (operand 1) is nonzero. The new convention is that a DBG_VALUE is register-indirect if the first operand is a register and the second operand is an immediate. For plain register values the combination reg, reg is used. MachineInstrBuilder::BuildMI knows how to build the new DBG_VALUES. rdar://problem/13658587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineInstrBuilder.h')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 92c8da9..df01371 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -335,6 +335,51 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
return BuildMI(*BB, BB->end(), DL, MCID, DestReg);
}
+/// BuildMI - This version of the builder builds a DBG_VALUE intrinsic
+/// for either a value in a register or a register-indirect+offset
+/// address. The convention is that a DBG_VALUE is indirect iff the
+/// second operand is an immediate.
+///
+inline MachineInstrBuilder BuildMI(MachineFunction &MF,
+ DebugLoc DL,
+ const MCInstrDesc &MCID,
+ bool IsIndirect,
+ unsigned Reg,
+ unsigned Offset,
+ const MDNode *MD) {
+ if (IsIndirect)
+ return BuildMI(MF, DL, MCID)
+ .addReg(Reg, RegState::Debug)
+ .addImm(Offset)
+ .addMetadata(MD);
+ else {
+ assert(Offset == 0 && "A direct address cannot have an offset.");
+ return BuildMI(MF, DL, MCID)
+ .addReg(Reg, RegState::Debug)
+ .addReg(0U, RegState::Debug)
+ .addMetadata(MD);
+ }
+}
+
+/// BuildMI - This version of the builder builds a DBG_VALUE intrinsic
+/// for either a value in a register or a register-indirect+offset
+/// address and inserts it at position I.
+///
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
+ MachineBasicBlock::iterator I,
+ DebugLoc DL,
+ const MCInstrDesc &MCID,
+ bool IsIndirect,
+ unsigned Reg,
+ unsigned Offset,
+ const MDNode *MD) {
+ MachineFunction &MF = *BB.getParent();
+ MachineInstr *MI = BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, MD);
+ BB.insert(I, MI);
+ return MachineInstrBuilder(MF, MI);
+}
+
+
inline unsigned getDefRegState(bool B) {
return B ? RegState::Define : 0;
}