diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
commit | 3a0822f094b578157263e04114075ad7df81db41 (patch) | |
tree | bc48361fe2cd1ca5f93ac01b38b183774468fc79 /include/llvm/CodeGen/FaultMaps.h | |
parent | 85d8b2bbe386bcfe669575d05b61482d7be07e5d (diff) |
Diffstat (limited to 'include/llvm/CodeGen/FaultMaps.h')
-rw-r--r-- | include/llvm/CodeGen/FaultMaps.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/FaultMaps.h b/include/llvm/CodeGen/FaultMaps.h new file mode 100644 index 000000000000..d5c2feefaa67 --- /dev/null +++ b/include/llvm/CodeGen/FaultMaps.h @@ -0,0 +1,73 @@ +//===------------------- FaultMaps.h - StackMaps ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_FAULTMAPS_H +#define LLVM_CODEGEN_FAULTMAPS_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/MC/MCSymbol.h" + +#include <vector> +#include <map> + +namespace llvm { + +class AsmPrinter; +class MCExpr; +class MCSymbol; +class MCStreamer; + +class FaultMaps { +public: + enum FaultKind { FaultingLoad = 1, FaultKindMax }; + + static const char *faultTypeToString(FaultKind); + + explicit FaultMaps(AsmPrinter &AP); + + void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel); + void serializeToFaultMapSection(); + +private: + static const char *WFMP; + + struct FaultInfo { + FaultKind Kind; + const MCExpr *FaultingOffsetExpr; + const MCExpr *HandlerOffsetExpr; + + FaultInfo() + : Kind(FaultKindMax), FaultingOffsetExpr(nullptr), + HandlerOffsetExpr(nullptr) {} + + explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset, + const MCExpr *HandlerOffset) + : Kind(Kind), FaultingOffsetExpr(FaultingOffset), + HandlerOffsetExpr(HandlerOffset) {} + }; + + typedef std::vector<FaultInfo> FunctionFaultInfos; + + // We'd like to keep a stable iteration order for FunctionInfos to help + // FileCheck based testing. + struct MCSymbolComparator { + bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const { + return LHS->getName() < RHS->getName(); + } + }; + + std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator> + FunctionInfos; + AsmPrinter &AP; + + void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI); +}; +} // namespace llvm + +#endif |