[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / lib / ExecutionEngine / JITLink / EHFrameSupportImpl.h
blob6f9f68ad8382c50708d1239fc34fdef24acbaec6
1 //===------- EHFrameSupportImpl.h - JITLink eh-frame utils ------*- 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 // EHFrame registration support for JITLink.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
14 #define LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
16 #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
18 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
19 #include "llvm/Support/BinaryStreamReader.h"
21 namespace llvm {
22 namespace jitlink {
24 /// A generic binary parser for eh-frame sections.
25 ///
26 /// Adds blocks and symbols representing CIE and FDE entries to a JITLink graph.
27 ///
28 /// This parser assumes that the user has already verified that the EH-frame's
29 /// address range does not overlap any other section/symbol, so that generated
30 /// CIE/FDE records do not overlap other sections/symbols.
31 class EHFrameBinaryParser {
32 public:
33 EHFrameBinaryParser(JITTargetAddress EHFrameAddress, StringRef EHFrameContent,
34 unsigned PointerSize, support::endianness Endianness);
35 virtual ~EHFrameBinaryParser() {}
37 Error addToGraph();
39 private:
40 virtual void anchor();
41 virtual Symbol *getSymbolAtAddress(JITTargetAddress Addr) = 0;
42 virtual Symbol &createCIERecord(JITTargetAddress RecordAddr,
43 StringRef RecordContent) = 0;
44 virtual Expected<Symbol &>
45 createFDERecord(JITTargetAddress RecordAddr, StringRef RecordContent,
46 Symbol &CIE, size_t CIEOffset, Symbol &Func,
47 size_t FuncOffset, Symbol *LSDA, size_t LSDAOffset) = 0;
49 struct AugmentationInfo {
50 bool AugmentationDataPresent = false;
51 bool EHDataFieldPresent = false;
52 uint8_t Fields[4] = {0x0, 0x0, 0x0, 0x0};
55 Expected<AugmentationInfo> parseAugmentationString();
56 Expected<JITTargetAddress> readAbsolutePointer();
57 Error processCIE(size_t RecordOffset, size_t RecordLength);
58 Error processFDE(size_t RecordOffset, size_t RecordLength,
59 JITTargetAddress CIEPointerOffset, uint32_t CIEPointer);
61 struct CIEInformation {
62 CIEInformation() = default;
63 CIEInformation(Symbol &CIESymbol) : CIESymbol(&CIESymbol) {}
64 Symbol *CIESymbol = nullptr;
65 bool FDEsHaveLSDAField = false;
68 JITTargetAddress EHFrameAddress;
69 StringRef EHFrameContent;
70 unsigned PointerSize;
71 BinaryStreamReader EHFrameReader;
72 DenseMap<JITTargetAddress, CIEInformation> CIEInfos;
75 } // end namespace jitlink
76 } // end namespace llvm
78 #endif // LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H