Debian Codegraph @

suite/synctools/tablegen/include/llvm/CodeGen/FaultMaps.h

raw symbols SCIP
1 //===- FaultMaps.h - The "FaultMaps" section --------------------*- 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 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_CODEGEN_FAULTMAPS_H
10 #define LLVM_CODEGEN_FAULTMAPS_H
11
12 #include "llvm/MC/MCSymbol.h"
13 #include "llvm/Support/Endian.h"
14 #include <map>
15 #include <vector>
16
17 namespace llvm {
18
19 class AsmPrinter;
20 class MCExpr;
21
22 class FaultMaps {
23 public:
24 enum FaultKind {
25 FaultingLoad = 1,
26 FaultingLoadStore,
27 FaultingStore,
28 FaultKindMax
29 };
30
31 explicit FaultMaps(AsmPrinter &AP);
32
33 static const char *faultTypeToString(FaultKind);
34
35 void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel,
36 const MCSymbol *HandlerLabel);
37 void serializeToFaultMapSection();
38 void reset() {
39 FunctionInfos.clear();
40 }
41
42 private:
43 static const char *WFMP;
44
45 struct FaultInfo {
46 FaultKind Kind = FaultKindMax;
47 const MCExpr *FaultingOffsetExpr = nullptr;
48 const MCExpr *HandlerOffsetExpr = nullptr;
49
50 FaultInfo() = default;
51
52 explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
53 const MCExpr *HandlerOffset)
54 : Kind(Kind), FaultingOffsetExpr(FaultingOffset),
55 HandlerOffsetExpr(HandlerOffset) {}
56 };
57
58 using FunctionFaultInfos = std::vector<FaultInfo>;
59
60 // We'd like to keep a stable iteration order for FunctionInfos to help
61 // FileCheck based testing.
62 struct MCSymbolComparator {
63 bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const {
64 return LHS->getName() < RHS->getName();
65 }
66 };
67
68 std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
69 FunctionInfos;
70 AsmPrinter &AP;
71
72 void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI);
73 };
74
75 } // end namespace llvm
76
77 #endif // LLVM_CODEGEN_FAULTMAPS_H