LLVM 20.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
16namespace llvm {
17
18class AsmPrinter;
19class MCExpr;
20
21class FaultMaps {
22public:
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
41private:
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
Value * RHS
Value * LHS
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:86
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel)
Definition: FaultMaps.cpp:28
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:45
static const char * faultTypeToString(FaultKind)
Definition: FaultMaps.cpp:103
void reset()
Definition: FaultMaps.h:37
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18