LLVM  13.0.0git
FaultMaps.h
Go to the documentation of this file.
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 class raw_ostream;
22 
23 class FaultMaps {
24 public:
25  enum FaultKind {
30  };
31 
32  explicit FaultMaps(AsmPrinter &AP);
33 
34  static const char *faultTypeToString(FaultKind);
35 
36  void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel,
37  const MCSymbol *HandlerLabel);
39  void reset() {
40  FunctionInfos.clear();
41  }
42 
43 private:
44  static const char *WFMP;
45 
46  struct FaultInfo {
48  const MCExpr *FaultingOffsetExpr = nullptr;
49  const MCExpr *HandlerOffsetExpr = nullptr;
50 
51  FaultInfo() = default;
52 
53  explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
54  const MCExpr *HandlerOffset)
55  : Kind(Kind), FaultingOffsetExpr(FaultingOffset),
56  HandlerOffsetExpr(HandlerOffset) {}
57  };
58 
59  using FunctionFaultInfos = std::vector<FaultInfo>;
60 
61  // We'd like to keep a stable iteration order for FunctionInfos to help
62  // FileCheck based testing.
63  struct MCSymbolComparator {
64  bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const {
65  return LHS->getName() < RHS->getName();
66  }
67  };
68 
69  std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
70  FunctionInfos;
71  AsmPrinter &AP;
72 
73  void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI);
74 };
75 
76 } // end namespace llvm
77 
78 #endif // LLVM_CODEGEN_FAULTMAPS_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::FaultMaps
Definition: FaultMaps.h:23
llvm::FaultMaps::FaultingLoadStore
@ FaultingLoadStore
Definition: FaultMaps.h:27
llvm::FaultMaps::serializeToFaultMapSection
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:45
MCSymbol.h
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::FaultMaps::reset
void reset()
Definition: FaultMaps.h:39
llvm::FaultMaps::FaultingStore
@ FaultingStore
Definition: FaultMaps.h:28
llvm::FaultMaps::FaultKindMax
@ FaultKindMax
Definition: FaultMaps.h:29
llvm::FaultMaps::FaultingLoad
@ FaultingLoad
Definition: FaultMaps.h:26
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::FaultMaps::FaultKind
FaultKind
Definition: FaultMaps.h:25
llvm::FaultMaps::faultTypeToString
static const char * faultTypeToString(FaultKind)
Definition: FaultMaps.cpp:103
Endian.h
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::FaultMaps::FaultMaps
FaultMaps(AsmPrinter &AP)
Definition: FaultMaps.cpp:26
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:172
llvm::FaultMaps::recordFaultingOp
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel)
Definition: FaultMaps.cpp:28