LLVM  14.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 
22 class FaultMaps {
23 public:
24  enum FaultKind {
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);
38  void reset() {
39  FunctionInfos.clear();
40  }
41 
42 private:
43  static const char *WFMP;
44 
45  struct FaultInfo {
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
llvm
This is an optimization pass for GlobalISel generic memory operations.
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:22
llvm::FaultMaps::FaultingLoadStore
@ FaultingLoadStore
Definition: FaultMaps.h:26
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::FaultMaps::serializeToFaultMapSection
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:45
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
MCSymbol.h
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::FaultMaps::reset
void reset()
Definition: FaultMaps.h:38
llvm::FaultMaps::FaultingStore
@ FaultingStore
Definition: FaultMaps.h:27
llvm::FaultMaps::FaultKindMax
@ FaultKindMax
Definition: FaultMaps.h:28
llvm::FaultMaps::FaultingLoad
@ FaultingLoad
Definition: FaultMaps.h:25
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:24
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