aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRParser/MIParser.cpp
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2022-09-15 11:26:57 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2023-01-06 18:03:48 +0000
commite10e936315410abd222eb58911b1e20fbfa80baf (patch)
treea30eec4a4b1e7413b842c0323a461e3a1b791ba4 /llvm/lib/CodeGen/MIRParser/MIParser.cpp
parentbdf7da280f624c53e6184d0410041220a9b405a7 (diff)
downloadllvm-e10e936315410abd222eb58911b1e20fbfa80baf.zip
llvm-e10e936315410abd222eb58911b1e20fbfa80baf.tar.gz
llvm-e10e936315410abd222eb58911b1e20fbfa80baf.tar.bz2
[DebugInfo][NFC] Add new MachineOperand type and change DBG_INSTR_REF syntax
This patch makes two notable changes to the MIR debug info representation, which result in different MIR output but identical final DWARF output (NFC w.r.t. the full compilation). The two changes are: * The introduction of a new MachineOperand type, MO_DbgInstrRef, which consists of two unsigned numbers that are used to index an instruction and an output operand within that instruction, having a meaning identical to first two operands of the current DBG_INSTR_REF instruction. This operand is only used in DBG_INSTR_REF (see below). * A change in syntax for the DBG_INSTR_REF instruction, shuffling the operands to make it resemble DBG_VALUE_LIST instead of DBG_VALUE, and replacing the first two operands with a single MO_DbgInstrRef-type operand. This patch is the first of a set that will allow DBG_INSTR_REF instructions to refer to multiple machine locations in the same manner as DBG_VALUE_LIST. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D129372
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIParser.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 8b27ede..f87d262 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -485,6 +485,7 @@ public:
bool parsePredicateOperand(MachineOperand &Dest);
bool parseShuffleMaskOperand(MachineOperand &Dest);
bool parseTargetIndexOperand(MachineOperand &Dest);
+ bool parseDbgInstrRefOperand(MachineOperand &Dest);
bool parseCustomRegisterMaskOperand(MachineOperand &Dest);
bool parseLiveoutRegisterMaskOperand(MachineOperand &Dest);
bool parseMachineOperand(const unsigned OpCode, const unsigned OpIdx,
@@ -2715,6 +2716,37 @@ bool MIParser::parseShuffleMaskOperand(MachineOperand &Dest) {
return false;
}
+bool MIParser::parseDbgInstrRefOperand(MachineOperand &Dest) {
+ assert(Token.is(MIToken::kw_dbg_instr_ref));
+
+ lex();
+ if (expectAndConsume(MIToken::lparen))
+ return error("expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
+
+ if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isNegative())
+ return error("expected unsigned integer for instruction index");
+ uint64_t InstrIdx = Token.integerValue().getZExtValue();
+ assert(InstrIdx <= std::numeric_limits<unsigned>::max() &&
+ "Instruction reference's instruction index is too large");
+ lex();
+
+ if (expectAndConsume(MIToken::comma))
+ return error("expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
+
+ if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isNegative())
+ return error("expected unsigned integer for operand index");
+ uint64_t OpIdx = Token.integerValue().getZExtValue();
+ assert(OpIdx <= std::numeric_limits<unsigned>::max() &&
+ "Instruction reference's operand index is too large");
+ lex();
+
+ if (expectAndConsume(MIToken::rparen))
+ return error("expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
+
+ Dest = MachineOperand::CreateDbgInstrRef(InstrIdx, OpIdx);
+ return false;
+}
+
bool MIParser::parseTargetIndexOperand(MachineOperand &Dest) {
assert(Token.is(MIToken::kw_target_index));
lex();
@@ -2866,6 +2898,8 @@ bool MIParser::parseMachineOperand(const unsigned OpCode, const unsigned OpIdx,
return parsePredicateOperand(Dest);
case MIToken::kw_shufflemask:
return parseShuffleMaskOperand(Dest);
+ case MIToken::kw_dbg_instr_ref:
+ return parseDbgInstrRefOperand(Dest);
case MIToken::Error:
return true;
case MIToken::Identifier: