9#ifndef LLVM_DEBUGINFO_DWARF_LOWLEVEL_DWARFCFIPROGRAM_H
10#define LLVM_DEBUGINFO_DWARF_LOWLEVEL_DWARFCFIPROGRAM_H
66 unsigned size()
const {
return (
unsigned)Instructions.size(); }
67 bool empty()
const {
return Instructions.empty(); }
69 int64_t
dataAlign()
const {
return DataAlignmentFactor; }
74 : CodeAlignmentFactor(CodeAlignmentFactor),
75 DataAlignmentFactor(DataAlignmentFactor), Arch(Arch) {}
85 const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
86 const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;
89 while (
C &&
C.tell() < EndOffset) {
95 if (
uint8_t Primary = Opcode & DWARF_CFI_PRIMARY_OPCODE_MASK) {
98 uint64_t Op1 = Opcode & DWARF_CFI_PRIMARY_OPERAND_MASK;
100 case DW_CFA_advance_loc:
117 "invalid extended CFI opcode 0x%" PRIx8,
120 case DW_CFA_remember_state:
121 case DW_CFA_restore_state:
122 case DW_CFA_GNU_window_save:
123 case DW_CFA_AARCH64_negate_ra_state_with_pc:
131 case DW_CFA_advance_loc1:
135 case DW_CFA_advance_loc2:
139 case DW_CFA_advance_loc4:
143 case DW_CFA_restore_extended:
144 case DW_CFA_undefined:
145 case DW_CFA_same_value:
146 case DW_CFA_def_cfa_register:
147 case DW_CFA_def_cfa_offset:
148 case DW_CFA_GNU_args_size:
152 case DW_CFA_def_cfa_offset_sf:
156 case DW_CFA_LLVM_def_aspace_cfa:
157 case DW_CFA_LLVM_def_aspace_cfa_sf: {
158 auto RegNum =
Data.getULEB128(
C);
159 auto CfaOffset = Opcode == DW_CFA_LLVM_def_aspace_cfa
161 :
Data.getSLEB128(
C);
166 case DW_CFA_offset_extended:
167 case DW_CFA_register:
169 case DW_CFA_val_offset: {
179 case DW_CFA_offset_extended_sf:
180 case DW_CFA_def_cfa_sf:
181 case DW_CFA_val_offset_sf: {
189 case DW_CFA_def_cfa_expression: {
195 Data.getAddressSize());
199 Instructions.back().Expression =
203 case DW_CFA_expression:
204 case DW_CFA_val_expression: {
211 Data.getAddressSize());
215 Instructions.back().Expression =
223 return C.takeError();
265 Instructions.back().Ops.push_back(Operand1);
271 Instructions.back().Ops.push_back(Operand1);
272 Instructions.back().Ops.push_back(Operand2);
279 Instructions.back().Ops.push_back(Operand1);
280 Instructions.back().Ops.push_back(Operand2);
281 Instructions.back().Ops.push_back(Operand3);
285 std::vector<Instruction> Instructions;
287 const int64_t DataAlignmentFactor;
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Class representing an expression and its matching format.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Represent a sequence of Call Frame Information instructions that, when read in order,...
std::vector< Instruction > InstrList
const_iterator end() const
void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2)
Add a new instruction that has two operands.
InstrList::const_iterator const_iterator
Triple::ArchType triple() const
InstrList::iterator iterator
OperandType
Types of operands to CFI instructions In DWARF, this type is implicitly tied to a CFI instruction opc...
@ OT_SignedFactDataOffset
@ OT_UnsignedFactDataOffset
void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2, uint64_t Operand3)
Add a new instruction that has three operands.
uint64_t codeAlign() const
static constexpr size_t MaxOperands
Error parse(DWARFDataExtractorBase< T > &Data, uint64_t *Offset, uint64_t EndOffset)
Parse and store a sequence of CFI instructions from Data, starting at *Offset and ending at EndOffset...
static LLVM_ABI ArrayRef< OperandType[MaxOperands]> getOperandTypes()
Retrieve the array describing the types of operands according to the enum above.
SmallVector< uint64_t, MaxOperands > Operands
const_iterator begin() const
void addInstruction(const Instruction &I)
CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, Triple::ArchType Arch)
int64_t dataAlign() const
static LLVM_ABI const char * operandTypeString(OperandType OT)
Get the OperandType as a "const char *".
LLVM_ABI StringRef callFrameString(unsigned Opcode) const
Get a DWARF CFI call frame string for the given DW_CFA opcode.
void addInstruction(uint8_t Opcode, uint64_t Operand1)
Add a new single-operand instruction.
void addInstruction(uint8_t Opcode)
Convenience method to add a new instruction with the given opcode.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
An instruction consists of a DWARF CFI opcode and an optional sequence of operands.
std::optional< DWARFExpression > Expression
LLVM_ABI Expected< uint64_t > getOperandAsUnsigned(const CFIProgram &CFIP, uint32_t OperandIdx) const
Instruction(uint8_t Opcode)
LLVM_ABI Expected< int64_t > getOperandAsSigned(const CFIProgram &CFIP, uint32_t OperandIdx) const