[Hexagon] Adding expression MC emission and removing XFAIL from test that hits this...
[oota-llvm.git] / lib / Target / Hexagon / MCTargetDesc / HexagonMCCodeEmitter.h
1 //===-- HexagonMCCodeEmitter.h - Hexagon Target Descriptions ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Definition for classes that emit Hexagon machine code from MCInsts
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef HEXAGONMCCODEEMITTER_H
16 #define HEXAGONMCCODEEMITTER_H
17
18 #include "llvm/MC/MCCodeEmitter.h"
19 #include "llvm/MC/MCExpr.h"
20 #include "llvm/MC/MCInst.h"
21 #include "llvm/MC/MCInstrInfo.h"
22 #include "llvm/MC/MCRegisterInfo.h"
23 #include "llvm/MC/MCSubtargetInfo.h"
24 #include "llvm/Support/raw_ostream.h"
25
26 namespace llvm {
27
28 class HexagonMCCodeEmitter : public MCCodeEmitter {
29   MCContext &MCT;
30   MCInstrInfo const &MCII;
31   std::unique_ptr<unsigned> Addend;
32   std::unique_ptr<bool> Extended;
33
34   // helper routine for getMachineOpValue()
35   unsigned getExprOpValue(const MCInst &MI, const MCOperand &MO,
36                           const MCExpr *ME, SmallVectorImpl<MCFixup> &Fixups,
37                           const MCSubtargetInfo &STI) const;
38
39 public:
40   HexagonMCCodeEmitter(MCInstrInfo const &aMII, MCContext &aMCT);
41
42   MCSubtargetInfo const &getSubtargetInfo() const;
43
44   void EncodeInstruction(MCInst const &MI, raw_ostream &OS,
45                          SmallVectorImpl<MCFixup> &Fixups,
46                          MCSubtargetInfo const &STI) const override;
47
48   // \brief TableGen'erated function for getting the
49   // binary encoding for an instruction.
50   uint64_t getBinaryCodeForInstr(MCInst const &MI,
51                                  SmallVectorImpl<MCFixup> &Fixups,
52                                  MCSubtargetInfo const &STI) const;
53
54   /// \brief Return binary encoding of operand.
55   unsigned getMachineOpValue(MCInst const &MI, MCOperand const &MO,
56                              SmallVectorImpl<MCFixup> &Fixups,
57                              MCSubtargetInfo const &STI) const;
58
59 private:
60   HexagonMCCodeEmitter(HexagonMCCodeEmitter const &) = delete;
61   void operator=(HexagonMCCodeEmitter const &) = delete;
62 }; // class HexagonMCCodeEmitter
63
64 } // namespace llvm
65
66 #endif /* HEXAGONMCCODEEMITTER_H */