LLVM  15.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 <map>
14 #include <vector>
15 
16 namespace llvm {
17 
18 class AsmPrinter;
19 class MCExpr;
20 
21 class FaultMaps {
22 public:
23  enum FaultKind {
28  };
29 
30  explicit FaultMaps(AsmPrinter &AP);
31 
32  static const char *faultTypeToString(FaultKind);
33 
34  void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel,
35  const MCSymbol *HandlerLabel);
37  void reset() {
38  FunctionInfos.clear();
39  }
40 
41 private:
42  static const char *WFMP;
43 
44  struct FaultInfo {
46  const MCExpr *FaultingOffsetExpr = nullptr;
47  const MCExpr *HandlerOffsetExpr = nullptr;
48 
49  FaultInfo() = default;
50 
51  explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
52  const MCExpr *HandlerOffset)
53  : Kind(Kind), FaultingOffsetExpr(FaultingOffset),
54  HandlerOffsetExpr(HandlerOffset) {}
55  };
56 
57  using FunctionFaultInfos = std::vector<FaultInfo>;
58 
59  // We'd like to keep a stable iteration order for FunctionInfos to help
60  // FileCheck based testing.
61  struct MCSymbolComparator {
62  bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const {
63  return LHS->getName() < RHS->getName();
64  }
65  };
66 
67  std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
68  FunctionInfos;
69  AsmPrinter &AP;
70 
71  void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI);
72 };
73 
74 } // end namespace llvm
75 
76 #endif // LLVM_CODEGEN_FAULTMAPS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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:21
llvm::FaultMaps::FaultingLoadStore
@ FaultingLoadStore
Definition: FaultMaps.h:25
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::FaultMaps::serializeToFaultMapSection
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:45
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
MCSymbol.h
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::FaultMaps::reset
void reset()
Definition: FaultMaps.h:37
llvm::FaultMaps::FaultingStore
@ FaultingStore
Definition: FaultMaps.h:26
llvm::FaultMaps::FaultKindMax
@ FaultKindMax
Definition: FaultMaps.h:27
llvm::FaultMaps::FaultingLoad
@ FaultingLoad
Definition: FaultMaps.h:24
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:81
llvm::FaultMaps::FaultKind
FaultKind
Definition: FaultMaps.h:23
llvm::FaultMaps::faultTypeToString
static const char * faultTypeToString(FaultKind)
Definition: FaultMaps.cpp:103
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