[Hexagon] Moving more functions off of HexagonMCInst and in to HexagonMCInstrInfo.
[oota-llvm.git] / lib / Target / Hexagon / MCTargetDesc / HexagonMCInst.cpp
1 //===- HexagonMCInst.cpp - Hexagon sub-class of MCInst --------------------===//
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 // This class extends MCInst to allow some Hexagon VLIW annotations.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MCTargetDesc/HexagonBaseInfo.h"
15 #include "MCTargetDesc/HexagonMCInst.h"
16 #include "MCTargetDesc/HexagonMCInstrInfo.h"
17 #include "MCTargetDesc/HexagonMCTargetDesc.h"
18
19 using namespace llvm;
20
21 HexagonMCInst::HexagonMCInst() : MCII (createHexagonMCInstrInfo ()) {}
22 HexagonMCInst::HexagonMCInst(MCInstrDesc const &mcid) :
23   MCII (createHexagonMCInstrInfo ()){}
24
25 void HexagonMCInst::AppendImplicitOperands(MCInst &MCI) {
26   MCI.addOperand(MCOperand::CreateImm(0));
27   MCI.addOperand(MCOperand::CreateInst(nullptr));
28 }
29
30 std::bitset<16> HexagonMCInst::GetImplicitBits(MCInst const &MCI) {
31   SanityCheckImplicitOperands(MCI);
32   std::bitset<16> Bits(MCI.getOperand(MCI.getNumOperands() - 2).getImm());
33   return Bits;
34 }
35
36 void HexagonMCInst::SetImplicitBits(MCInst &MCI, std::bitset<16> Bits) {
37   SanityCheckImplicitOperands(MCI);
38   MCI.getOperand(MCI.getNumOperands() - 2).setImm(Bits.to_ulong());
39 }
40
41 void HexagonMCInst::setPacketBegin(bool f) {
42   std::bitset<16> Bits(GetImplicitBits(*this));
43   Bits.set(packetBeginIndex, f);
44   SetImplicitBits(*this, Bits);
45 }
46
47 bool HexagonMCInst::isPacketBegin() const {
48   std::bitset<16> Bits(GetImplicitBits(*this));
49   return Bits.test(packetBeginIndex);
50 }
51
52 void HexagonMCInst::setPacketEnd(bool f) {
53   std::bitset<16> Bits(GetImplicitBits(*this));
54   Bits.set(packetEndIndex, f);
55   SetImplicitBits(*this, Bits);
56 }
57
58 bool HexagonMCInst::isPacketEnd() const {
59   std::bitset<16> Bits(GetImplicitBits(*this));
60   return Bits.test(packetEndIndex);
61 }
62
63 void HexagonMCInst::resetPacket() {
64   setPacketBegin(false);
65   setPacketEnd(false);
66 }