[InstCombine] Signed saturation patterns
[llvm-core.git] / include / llvm / DebugInfo / CodeView / Line.h
blobeb2aa154df1bd9b96207a498475a3fe4623c42b3
1 //===- Line.h ---------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_LINE_H
10 #define LLVM_DEBUGINFO_CODEVIEW_LINE_H
12 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
13 #include "llvm/Support/Endian.h"
14 #include <cinttypes>
16 namespace llvm {
17 namespace codeview {
19 using llvm::support::ulittle32_t;
21 class LineInfo {
22 public:
23 enum : uint32_t {
24 AlwaysStepIntoLineNumber = 0xfeefee,
25 NeverStepIntoLineNumber = 0xf00f00
28 enum : int { EndLineDeltaShift = 24 };
30 enum : uint32_t {
31 StartLineMask = 0x00ffffff,
32 EndLineDeltaMask = 0x7f000000,
33 StatementFlag = 0x80000000u
36 LineInfo(uint32_t StartLine, uint32_t EndLine, bool IsStatement);
37 LineInfo(uint32_t LineData) : LineData(LineData) {}
39 uint32_t getStartLine() const { return LineData & StartLineMask; }
41 uint32_t getLineDelta() const {
42 return (LineData & EndLineDeltaMask) >> EndLineDeltaShift;
45 uint32_t getEndLine() const { return getStartLine() + getLineDelta(); }
47 bool isStatement() const { return (LineData & StatementFlag) != 0; }
49 uint32_t getRawData() const { return LineData; }
51 bool isAlwaysStepInto() const {
52 return getStartLine() == AlwaysStepIntoLineNumber;
55 bool isNeverStepInto() const {
56 return getStartLine() == NeverStepIntoLineNumber;
59 private:
60 uint32_t LineData;
63 class ColumnInfo {
64 private:
65 static const uint32_t StartColumnMask = 0x0000ffffu;
66 static const uint32_t EndColumnMask = 0xffff0000u;
67 static const int EndColumnShift = 16;
69 public:
70 ColumnInfo(uint16_t StartColumn, uint16_t EndColumn) {
71 ColumnData =
72 (static_cast<uint32_t>(StartColumn) & StartColumnMask) |
73 ((static_cast<uint32_t>(EndColumn) << EndColumnShift) & EndColumnMask);
76 uint16_t getStartColumn() const {
77 return static_cast<uint16_t>(ColumnData & StartColumnMask);
80 uint16_t getEndColumn() const {
81 return static_cast<uint16_t>((ColumnData & EndColumnMask) >>
82 EndColumnShift);
85 uint32_t getRawData() const { return ColumnData; }
87 private:
88 uint32_t ColumnData;
91 class Line {
92 private:
93 int32_t CodeOffset;
94 LineInfo LineInf;
95 ColumnInfo ColumnInf;
97 public:
98 Line(int32_t CodeOffset, uint32_t StartLine, uint32_t EndLine,
99 uint16_t StartColumn, uint16_t EndColumn, bool IsStatement)
100 : CodeOffset(CodeOffset), LineInf(StartLine, EndLine, IsStatement),
101 ColumnInf(StartColumn, EndColumn) {}
103 Line(int32_t CodeOffset, LineInfo LineInf, ColumnInfo ColumnInf)
104 : CodeOffset(CodeOffset), LineInf(LineInf), ColumnInf(ColumnInf) {}
106 LineInfo getLineInfo() const { return LineInf; }
108 ColumnInfo getColumnInfo() const { return ColumnInf; }
110 int32_t getCodeOffset() const { return CodeOffset; }
112 uint32_t getStartLine() const { return LineInf.getStartLine(); }
114 uint32_t getLineDelta() const { return LineInf.getLineDelta(); }
116 uint32_t getEndLine() const { return LineInf.getEndLine(); }
118 uint16_t getStartColumn() const { return ColumnInf.getStartColumn(); }
120 uint16_t getEndColumn() const { return ColumnInf.getEndColumn(); }
122 bool isStatement() const { return LineInf.isStatement(); }
124 bool isAlwaysStepInto() const { return LineInf.isAlwaysStepInto(); }
126 bool isNeverStepInto() const { return LineInf.isNeverStepInto(); }
129 } // namespace codeview
130 } // namespace llvm
132 #endif