1 //===- HexagonMCInst.cpp - Hexagon sub-class of MCInst --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class extends MCInst to allow some Hexagon VLIW annotations.
12 //===----------------------------------------------------------------------===//
14 #include "MCTargetDesc/HexagonBaseInfo.h"
15 #include "MCTargetDesc/HexagonMCInst.h"
16 #include "MCTargetDesc/HexagonMCInstrInfo.h"
17 #include "MCTargetDesc/HexagonMCTargetDesc.h"
21 HexagonMCInst::HexagonMCInst() : MCII (createHexagonMCInstrInfo ()) {}
22 HexagonMCInst::HexagonMCInst(MCInstrDesc const &mcid) :
23 MCII (createHexagonMCInstrInfo ()){}
25 void HexagonMCInst::AppendImplicitOperands(MCInst &MCI) {
26 MCI.addOperand(MCOperand::CreateImm(0));
27 MCI.addOperand(MCOperand::CreateInst(nullptr));
30 std::bitset<16> HexagonMCInst::GetImplicitBits(MCInst const &MCI) {
31 SanityCheckImplicitOperands(MCI);
32 std::bitset<16> Bits(MCI.getOperand(MCI.getNumOperands() - 2).getImm());
36 void HexagonMCInst::SetImplicitBits(MCInst &MCI, std::bitset<16> Bits) {
37 SanityCheckImplicitOperands(MCI);
38 MCI.getOperand(MCI.getNumOperands() - 2).setImm(Bits.to_ulong());
41 void HexagonMCInst::setPacketBegin(bool f) {
42 std::bitset<16> Bits(GetImplicitBits(*this));
43 Bits.set(packetBeginIndex, f);
44 SetImplicitBits(*this, Bits);
47 bool HexagonMCInst::isPacketBegin() const {
48 std::bitset<16> Bits(GetImplicitBits(*this));
49 return Bits.test(packetBeginIndex);
52 void HexagonMCInst::setPacketEnd(bool f) {
53 std::bitset<16> Bits(GetImplicitBits(*this));
54 Bits.set(packetEndIndex, f);
55 SetImplicitBits(*this, Bits);
58 bool HexagonMCInst::isPacketEnd() const {
59 std::bitset<16> Bits(GetImplicitBits(*this));
60 return Bits.test(packetEndIndex);
63 void HexagonMCInst::resetPacket() {
64 setPacketBegin(false);