1 | //===-- llvm/MC/MCXCOFFObjectWriter.h - XCOFF Object Writer ---------------===// |
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_MC_MCXCOFFOBJECTWRITER_H |
10 | #define LLVM_MC_MCXCOFFOBJECTWRITER_H |
11 | |
12 | #include "llvm/MC/MCObjectWriter.h" |
13 | |
14 | namespace llvm { |
15 | |
16 | class raw_pwrite_stream; |
17 | |
18 | class MCXCOFFObjectTargetWriter : public MCObjectTargetWriter { |
19 | protected: |
20 | MCXCOFFObjectTargetWriter(bool Is64Bit); |
21 | |
22 | public: |
23 | ~MCXCOFFObjectTargetWriter() override; |
24 | |
25 | Triple::ObjectFormatType getFormat() const override { return Triple::XCOFF; } |
26 | static bool classof(const MCObjectTargetWriter *W) { |
27 | return W->getFormat() == Triple::XCOFF; |
28 | } |
29 | bool is64Bit() const { return Is64Bit; } |
30 | |
31 | // Returns relocation info such as type, sign and size. |
32 | // First element of the pair contains type, |
33 | // second element contains sign and size. |
34 | virtual std::pair<uint8_t, uint8_t> |
35 | getRelocTypeAndSignSize(const MCValue &Target, const MCFixup &Fixup, |
36 | bool IsPCRel) const = 0; |
37 | |
38 | private: |
39 | bool Is64Bit; |
40 | }; |
41 | |
42 | class XCOFFObjectWriter : public MCObjectWriter { |
43 | // AIX specific CPU type. |
44 | std::string CPUType; |
45 | |
46 | public: |
47 | virtual void addExceptionEntry(const MCSymbol *Symbol, const MCSymbol *Trap, |
48 | unsigned LanguageCode, unsigned ReasonCode, |
49 | unsigned FunctionSize, bool hasDebug) = 0; |
50 | virtual void addCInfoSymEntry(StringRef Name, StringRef Metadata) = 0; |
51 | StringRef getCPUType() const { return CPUType; } |
52 | void setCPU(StringRef TargetCPU) { CPUType = TargetCPU; } |
53 | }; |
54 | |
55 | std::unique_ptr<MCObjectWriter> |
56 | createXCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW, |
57 | raw_pwrite_stream &OS); |
58 | |
59 | } // end namespace llvm |
60 | |
61 | #endif // LLVM_MC_MCXCOFFOBJECTWRITER_H |
62 | |