aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/MC/MCDwarf.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/MC/MCDwarf.h')
-rw-r--r--llvm/include/llvm/MC/MCDwarf.h83
1 files changed, 57 insertions, 26 deletions
diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h
index d0e45ab59a92..2fa7d73e1fa2 100644
--- a/llvm/include/llvm/MC/MCDwarf.h
+++ b/llvm/include/llvm/MC/MCDwarf.h
@@ -194,11 +194,23 @@ private:
public:
// Constructor to create an MCDwarfLineEntry given a symbol and the dwarf loc.
- MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
- : MCDwarfLoc(loc), Label(label) {}
+ MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc,
+ MCSymbol *lineStreamLabel = nullptr,
+ SMLoc streamLabelDefLoc = {})
+ : MCDwarfLoc(loc), Label(label), LineStreamLabel(lineStreamLabel),
+ StreamLabelDefLoc(streamLabelDefLoc) {}
MCSymbol *getLabel() const { return Label; }
+ // This is the label that is to be emitted into the line stream. If this is
+ // non-null and we need to emit a label, also make sure to restart the current
+ // line sequence.
+ MCSymbol *LineStreamLabel;
+
+ // Location where LineStreamLabel was defined. If there is an error emitting
+ // LineStreamLabel, we can use the SMLoc to report an error.
+ SMLoc StreamLabelDefLoc;
+
// This indicates the line entry is synthesized for an end entry.
bool IsEndEntry = false;
@@ -365,6 +377,9 @@ public:
emitOne(MCStreamer *MCOS, MCSection *Section,
const MCLineSection::MCDwarfLineEntryCollection &LineEntries);
+ void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc,
+ StringRef Name);
+
Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
@@ -500,8 +515,10 @@ public:
OpRegister,
OpWindowSave,
OpNegateRAState,
+ OpNegateRAStateWithPC,
OpGnuArgsSize,
OpLabel,
+ OpValOffset,
};
private:
@@ -509,11 +526,11 @@ private:
union {
struct {
unsigned Register;
- int Offset;
+ int64_t Offset;
} RI;
struct {
unsigned Register;
- int Offset;
+ int64_t Offset;
unsigned AddressSpace;
} RIA;
struct {
@@ -527,7 +544,7 @@ private:
std::vector<char> Values;
std::string Comment;
- MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, SMLoc Loc,
+ MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int64_t O, SMLoc Loc,
StringRef V = "", StringRef Comment = "")
: Label(L), Operation(Op), Loc(Loc), Values(V.begin(), V.end()),
Comment(Comment) {
@@ -539,7 +556,7 @@ private:
assert(Op == OpRegister);
U.RR = {R1, R2};
}
- MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS,
+ MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int64_t O, unsigned AS,
SMLoc Loc)
: Label(L), Operation(Op), Loc(Loc) {
assert(Op == OpLLVMDefAspaceCfa);
@@ -555,8 +572,8 @@ private:
public:
/// .cfi_def_cfa defines a rule for computing CFA as: take address from
/// Register and add Offset to it.
- static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset,
- SMLoc Loc = {}) {
+ static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register,
+ int64_t Offset, SMLoc Loc = {}) {
return MCCFIInstruction(OpDefCfa, L, Register, Offset, Loc);
}
@@ -564,13 +581,13 @@ public:
/// on Register will be used instead of the old one. Offset remains the same.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register,
SMLoc Loc = {}) {
- return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, Loc);
+ return MCCFIInstruction(OpDefCfaRegister, L, Register, INT64_C(0), Loc);
}
/// .cfi_def_cfa_offset modifies a rule for computing CFA. Register
/// remains the same, but offset is new. Note that it is the absolute offset
/// that will be added to a defined register to the compute CFA address.
- static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset,
+ static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset,
SMLoc Loc = {}) {
return MCCFIInstruction(OpDefCfaOffset, L, 0, Offset, Loc);
}
@@ -578,7 +595,7 @@ public:
/// .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but
/// Offset is a relative value that is added/subtracted from the previous
/// offset.
- static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment,
+ static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment,
SMLoc Loc = {}) {
return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, Loc);
}
@@ -588,7 +605,7 @@ public:
/// be the result of evaluating the DWARF operation expression
/// `DW_OP_constu AS; DW_OP_aspace_bregx R, B` as a location description.
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register,
- int Offset,
+ int64_t Offset,
unsigned AddressSpace,
SMLoc Loc) {
return MCCFIInstruction(OpLLVMDefAspaceCfa, L, Register, Offset,
@@ -598,7 +615,7 @@ public:
/// .cfi_offset Previous value of Register is saved at offset Offset
/// from CFA.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register,
- int Offset, SMLoc Loc = {}) {
+ int64_t Offset, SMLoc Loc = {}) {
return MCCFIInstruction(OpOffset, L, Register, Offset, Loc);
}
@@ -606,7 +623,7 @@ public:
/// Offset from the current CFA register. This is transformed to .cfi_offset
/// using the known displacement of the CFA register from the CFA.
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register,
- int Offset, SMLoc Loc = {}) {
+ int64_t Offset, SMLoc Loc = {}) {
return MCCFIInstruction(OpRelOffset, L, Register, Offset, Loc);
}
@@ -619,12 +636,18 @@ public:
/// .cfi_window_save SPARC register window is saved.
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc = {}) {
- return MCCFIInstruction(OpWindowSave, L, 0, 0, Loc);
+ return MCCFIInstruction(OpWindowSave, L, 0, INT64_C(0), Loc);
}
/// .cfi_negate_ra_state AArch64 negate RA state.
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc = {}) {
- return MCCFIInstruction(OpNegateRAState, L, 0, 0, Loc);
+ return MCCFIInstruction(OpNegateRAState, L, 0, INT64_C(0), Loc);
+ }
+
+ /// .cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
+ static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L,
+ SMLoc Loc = {}) {
+ return MCCFIInstruction(OpNegateRAStateWithPC, L, 0, INT64_C(0), Loc);
}
/// .cfi_restore says that the rule for Register is now the same as it
@@ -632,31 +655,31 @@ public:
/// by .cfi_startproc were executed.
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register,
SMLoc Loc = {}) {
- return MCCFIInstruction(OpRestore, L, Register, 0, Loc);
+ return MCCFIInstruction(OpRestore, L, Register, INT64_C(0), Loc);
}
/// .cfi_undefined From now on the previous value of Register can't be
/// restored anymore.
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register,
SMLoc Loc = {}) {
- return MCCFIInstruction(OpUndefined, L, Register, 0, Loc);
+ return MCCFIInstruction(OpUndefined, L, Register, INT64_C(0), Loc);
}
/// .cfi_same_value Current value of Register is the same as in the
/// previous frame. I.e., no restoration is needed.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register,
SMLoc Loc = {}) {
- return MCCFIInstruction(OpSameValue, L, Register, 0, Loc);
+ return MCCFIInstruction(OpSameValue, L, Register, INT64_C(0), Loc);
}
/// .cfi_remember_state Save all current rules for all registers.
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc = {}) {
- return MCCFIInstruction(OpRememberState, L, 0, 0, Loc);
+ return MCCFIInstruction(OpRememberState, L, 0, INT64_C(0), Loc);
}
/// .cfi_restore_state Restore the previously saved state.
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc = {}) {
- return MCCFIInstruction(OpRestoreState, L, 0, 0, Loc);
+ return MCCFIInstruction(OpRestoreState, L, 0, INT64_C(0), Loc);
}
/// .cfi_escape Allows the user to add arbitrary bytes to the unwind
@@ -667,7 +690,7 @@ public:
}
/// A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE
- static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size,
+ static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size,
SMLoc Loc = {}) {
return MCCFIInstruction(OpGnuArgsSize, L, 0, Size, Loc);
}
@@ -677,6 +700,13 @@ public:
return MCCFIInstruction(OpLabel, L, CfiLabel, Loc);
}
+ /// .cfi_val_offset Previous value of Register is offset Offset from the
+ /// current CFA register.
+ static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register,
+ int64_t Offset, SMLoc Loc = {}) {
+ return MCCFIInstruction(OpValOffset, L, Register, Offset, Loc);
+ }
+
OpType getOperation() const { return Operation; }
MCSymbol *getLabel() const { return Label; }
@@ -688,7 +718,7 @@ public:
assert(Operation == OpDefCfa || Operation == OpOffset ||
Operation == OpRestore || Operation == OpUndefined ||
Operation == OpSameValue || Operation == OpDefCfaRegister ||
- Operation == OpRelOffset);
+ Operation == OpRelOffset || Operation == OpValOffset);
return U.RI.Register;
}
@@ -702,12 +732,13 @@ public:
return U.RIA.AddressSpace;
}
- int getOffset() const {
+ int64_t getOffset() const {
if (Operation == OpLLVMDefAspaceCfa)
return U.RIA.Offset;
assert(Operation == OpDefCfa || Operation == OpOffset ||
Operation == OpRelOffset || Operation == OpDefCfaOffset ||
- Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
+ Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize ||
+ Operation == OpValOffset);
return U.RI.Offset;
}
@@ -736,7 +767,7 @@ struct MCDwarfFrameInfo {
unsigned CurrentCfaRegister = 0;
unsigned PersonalityEncoding = 0;
unsigned LsdaEncoding = 0;
- uint32_t CompactUnwindEncoding = 0;
+ uint64_t CompactUnwindEncoding = 0;
bool IsSignalFrame = false;
bool IsSimple = false;
unsigned RAReg = static_cast<unsigned>(INT_MAX);