Colin LeMahieu | af304e5 | 2015-02-19 19:00:00 +0000 | [diff] [blame] | 1 | //===- HexagonMCInstrInfo.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 MCInstrInfo to allow Hexagon specific MCInstr queries |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 14 | #include "HexagonMCInstrInfo.h" |
| 15 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 16 | #include "Hexagon.h" |
Colin LeMahieu | af304e5 | 2015-02-19 19:00:00 +0000 | [diff] [blame] | 17 | #include "HexagonBaseInfo.h" |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 18 | #include "HexagonMCChecker.h" |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 19 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCContext.h" |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCExpr.h" |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCInstrInfo.h" |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCSubtargetInfo.h" |
Colin LeMahieu | af304e5 | 2015-02-19 19:00:00 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 26 | void HexagonMCInstrInfo::addConstant(MCInst &MI, uint64_t Value, |
| 27 | MCContext &Context) { |
| 28 | MI.addOperand(MCOperand::createExpr(MCConstantExpr::create(Value, Context))); |
| 29 | } |
| 30 | |
Benjamin Kramer | 7c576d8 | 2015-11-12 19:30:40 +0000 | [diff] [blame] | 31 | void HexagonMCInstrInfo::addConstExtender(MCContext &Context, |
| 32 | MCInstrInfo const &MCII, MCInst &MCB, |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 33 | MCInst const &MCI) { |
| 34 | assert(HexagonMCInstrInfo::isBundle(MCB)); |
| 35 | MCOperand const &exOp = |
| 36 | MCI.getOperand(HexagonMCInstrInfo::getExtendableOp(MCII, MCI)); |
| 37 | |
| 38 | // Create the extender. |
| 39 | MCInst *XMCI = |
Benjamin Kramer | 7c576d8 | 2015-11-12 19:30:40 +0000 | [diff] [blame] | 40 | new (Context) MCInst(HexagonMCInstrInfo::deriveExtender(MCII, MCI, exOp)); |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 41 | |
| 42 | MCB.addOperand(MCOperand::createInst(XMCI)); |
| 43 | } |
| 44 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 45 | iterator_range<MCInst::const_iterator> |
| 46 | HexagonMCInstrInfo::bundleInstructions(MCInst const &MCI) { |
| 47 | assert(isBundle(MCI)); |
Craig Topper | 15576e1 | 2015-12-06 05:08:07 +0000 | [diff] [blame] | 48 | return make_range(MCI.begin() + bundleInstructionsOffset, MCI.end()); |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | size_t HexagonMCInstrInfo::bundleSize(MCInst const &MCI) { |
| 52 | if (HexagonMCInstrInfo::isBundle(MCI)) |
| 53 | return (MCI.size() - bundleInstructionsOffset); |
| 54 | else |
| 55 | return (1); |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 58 | bool HexagonMCInstrInfo::canonicalizePacket(MCInstrInfo const &MCII, |
| 59 | MCSubtargetInfo const &STI, |
| 60 | MCContext &Context, MCInst &MCB, |
| 61 | HexagonMCChecker *Check) { |
| 62 | // Examine the packet and convert pairs of instructions to compound |
| 63 | // instructions when possible. |
| 64 | if (!HexagonDisableCompound) |
| 65 | HexagonMCInstrInfo::tryCompound(MCII, Context, MCB); |
| 66 | // Check the bundle for errors. |
| 67 | bool CheckOk = Check ? Check->check() : true; |
| 68 | if (!CheckOk) |
| 69 | return false; |
| 70 | HexagonMCShuffle(MCII, STI, MCB); |
| 71 | // Examine the packet and convert pairs of instructions to duplex |
| 72 | // instructions when possible. |
| 73 | MCInst InstBundlePreDuplex = MCInst(MCB); |
| 74 | if (!HexagonDisableDuplex) { |
| 75 | SmallVector<DuplexCandidate, 8> possibleDuplexes; |
| 76 | possibleDuplexes = HexagonMCInstrInfo::getDuplexPossibilties(MCII, MCB); |
| 77 | HexagonMCShuffle(MCII, STI, Context, MCB, possibleDuplexes); |
| 78 | } |
| 79 | // Examines packet and pad the packet, if needed, when an |
| 80 | // end-loop is in the bundle. |
Colin LeMahieu | b3c9727 | 2015-11-13 07:58:06 +0000 | [diff] [blame] | 81 | HexagonMCInstrInfo::padEndloop(Context, MCB); |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 82 | // If compounding and duplexing didn't reduce the size below |
| 83 | // 4 or less we have a packet that is too big. |
| 84 | if (HexagonMCInstrInfo::bundleSize(MCB) > HEXAGON_PACKET_SIZE) |
| 85 | return false; |
| 86 | HexagonMCShuffle(MCII, STI, MCB); |
| 87 | return true; |
| 88 | } |
| 89 | |
Colin LeMahieu | 8ab7e8e | 2015-11-10 00:02:27 +0000 | [diff] [blame] | 90 | void HexagonMCInstrInfo::clampExtended(MCInstrInfo const &MCII, |
| 91 | MCContext &Context, MCInst &MCI) { |
Colin LeMahieu | be99a02 | 2015-06-17 03:06:16 +0000 | [diff] [blame] | 92 | assert(HexagonMCInstrInfo::isExtendable(MCII, MCI) || |
| 93 | HexagonMCInstrInfo::isExtended(MCII, MCI)); |
| 94 | MCOperand &exOp = |
| 95 | MCI.getOperand(HexagonMCInstrInfo::getExtendableOp(MCII, MCI)); |
| 96 | // If the extended value is a constant, then use it for the extended and |
| 97 | // for the extender instructions, masking off the lower 6 bits and |
| 98 | // including the assumed bits. |
Colin LeMahieu | 8ab7e8e | 2015-11-10 00:02:27 +0000 | [diff] [blame] | 99 | int64_t Value; |
| 100 | if (exOp.getExpr()->evaluateAsAbsolute(Value)) { |
Colin LeMahieu | be99a02 | 2015-06-17 03:06:16 +0000 | [diff] [blame] | 101 | unsigned Shift = HexagonMCInstrInfo::getExtentAlignment(MCII, MCI); |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame^] | 102 | exOp.setExpr(HexagonMCExpr::create( |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 103 | MCConstantExpr::create((Value & 0x3f) << Shift, Context), Context)); |
Colin LeMahieu | be99a02 | 2015-06-17 03:06:16 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
Colin LeMahieu | f0af6e5 | 2015-11-13 17:42:46 +0000 | [diff] [blame] | 107 | MCInst HexagonMCInstrInfo::createBundle() { |
| 108 | MCInst Result; |
| 109 | Result.setOpcode(Hexagon::BUNDLE); |
| 110 | Result.addOperand(MCOperand::createImm(0)); |
| 111 | return Result; |
| 112 | } |
| 113 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 114 | MCInst *HexagonMCInstrInfo::deriveDuplex(MCContext &Context, unsigned iClass, |
| 115 | MCInst const &inst0, |
| 116 | MCInst const &inst1) { |
| 117 | assert((iClass <= 0xf) && "iClass must have range of 0 to 0xf"); |
| 118 | MCInst *duplexInst = new (Context) MCInst; |
| 119 | duplexInst->setOpcode(Hexagon::DuplexIClass0 + iClass); |
| 120 | |
| 121 | MCInst *SubInst0 = new (Context) MCInst(deriveSubInst(inst0)); |
| 122 | MCInst *SubInst1 = new (Context) MCInst(deriveSubInst(inst1)); |
| 123 | duplexInst->addOperand(MCOperand::createInst(SubInst0)); |
| 124 | duplexInst->addOperand(MCOperand::createInst(SubInst1)); |
| 125 | return duplexInst; |
| 126 | } |
| 127 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 128 | MCInst HexagonMCInstrInfo::deriveExtender(MCInstrInfo const &MCII, |
| 129 | MCInst const &Inst, |
| 130 | MCOperand const &MO) { |
| 131 | assert(HexagonMCInstrInfo::isExtendable(MCII, Inst) || |
| 132 | HexagonMCInstrInfo::isExtended(MCII, Inst)); |
| 133 | |
| 134 | MCInstrDesc const &Desc = HexagonMCInstrInfo::getDesc(MCII, Inst); |
| 135 | MCInst XMI; |
| 136 | XMI.setOpcode((Desc.isBranch() || Desc.isCall() || |
| 137 | HexagonMCInstrInfo::getType(MCII, Inst) == HexagonII::TypeCR) |
| 138 | ? Hexagon::A4_ext_b |
| 139 | : Hexagon::A4_ext); |
| 140 | if (MO.isImm()) |
| 141 | XMI.addOperand(MCOperand::createImm(MO.getImm() & (~0x3f))); |
| 142 | else if (MO.isExpr()) |
| 143 | XMI.addOperand(MCOperand::createExpr(MO.getExpr())); |
| 144 | else |
| 145 | llvm_unreachable("invalid extendable operand"); |
| 146 | return XMI; |
| 147 | } |
| 148 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 149 | MCInst const *HexagonMCInstrInfo::extenderForIndex(MCInst const &MCB, |
| 150 | size_t Index) { |
| 151 | assert(Index <= bundleSize(MCB)); |
| 152 | if (Index == 0) |
| 153 | return nullptr; |
| 154 | MCInst const *Inst = |
| 155 | MCB.getOperand(Index + bundleInstructionsOffset - 1).getInst(); |
| 156 | if (isImmext(*Inst)) |
| 157 | return Inst; |
| 158 | return nullptr; |
| 159 | } |
| 160 | |
Benjamin Kramer | 7c576d8 | 2015-11-12 19:30:40 +0000 | [diff] [blame] | 161 | void HexagonMCInstrInfo::extendIfNeeded(MCContext &Context, |
| 162 | MCInstrInfo const &MCII, MCInst &MCB, |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 163 | MCInst const &MCI, bool MustExtend) { |
| 164 | if (isConstExtended(MCII, MCI) || MustExtend) |
Benjamin Kramer | 7c576d8 | 2015-11-12 19:30:40 +0000 | [diff] [blame] | 165 | addConstExtender(Context, MCII, MCB, MCI); |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Colin LeMahieu | b662565 | 2015-05-01 21:14:21 +0000 | [diff] [blame] | 168 | HexagonII::MemAccessSize |
| 169 | HexagonMCInstrInfo::getAccessSize(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 170 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 171 | |
| 172 | return (HexagonII::MemAccessSize((F >> HexagonII::MemAccessSizePos) & |
| 173 | HexagonII::MemAccesSizeMask)); |
| 174 | } |
| 175 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 176 | unsigned HexagonMCInstrInfo::getBitCount(MCInstrInfo const &MCII, |
| 177 | MCInst const &MCI) { |
| 178 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 179 | return ((F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask); |
| 180 | } |
| 181 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 182 | // Return constant extended operand number. |
| 183 | unsigned short HexagonMCInstrInfo::getCExtOpNum(MCInstrInfo const &MCII, |
| 184 | MCInst const &MCI) { |
| 185 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 186 | return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask); |
| 187 | } |
| 188 | |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 189 | MCInstrDesc const &HexagonMCInstrInfo::getDesc(MCInstrInfo const &MCII, |
| 190 | MCInst const &MCI) { |
| 191 | return (MCII.get(MCI.getOpcode())); |
| 192 | } |
| 193 | |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 194 | MCExpr const &HexagonMCInstrInfo::getExpr(MCExpr const &Expr) { |
| 195 | HexagonMCExpr const &HExpr = *llvm::cast<HexagonMCExpr>(&Expr); |
| 196 | return *HExpr.getExpr(); |
| 197 | } |
| 198 | |
Colin LeMahieu | 86f218e | 2015-05-30 18:55:47 +0000 | [diff] [blame] | 199 | unsigned short HexagonMCInstrInfo::getExtendableOp(MCInstrInfo const &MCII, |
| 200 | MCInst const &MCI) { |
| 201 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 202 | return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask); |
| 203 | } |
| 204 | |
| 205 | MCOperand const & |
| 206 | HexagonMCInstrInfo::getExtendableOperand(MCInstrInfo const &MCII, |
| 207 | MCInst const &MCI) { |
| 208 | unsigned O = HexagonMCInstrInfo::getExtendableOp(MCII, MCI); |
| 209 | MCOperand const &MO = MCI.getOperand(O); |
| 210 | |
| 211 | assert((HexagonMCInstrInfo::isExtendable(MCII, MCI) || |
| 212 | HexagonMCInstrInfo::isExtended(MCII, MCI)) && |
| 213 | (MO.isImm() || MO.isExpr())); |
| 214 | return (MO); |
| 215 | } |
| 216 | |
Colin LeMahieu | b662565 | 2015-05-01 21:14:21 +0000 | [diff] [blame] | 217 | unsigned HexagonMCInstrInfo::getExtentAlignment(MCInstrInfo const &MCII, |
| 218 | MCInst const &MCI) { |
| 219 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 220 | return ((F >> HexagonII::ExtentAlignPos) & HexagonII::ExtentAlignMask); |
| 221 | } |
| 222 | |
| 223 | unsigned HexagonMCInstrInfo::getExtentBits(MCInstrInfo const &MCII, |
| 224 | MCInst const &MCI) { |
| 225 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 226 | return ((F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask); |
| 227 | } |
| 228 | |
Colin LeMahieu | af304e5 | 2015-02-19 19:00:00 +0000 | [diff] [blame] | 229 | // Return the max value that a constant extendable operand can have |
| 230 | // without being extended. |
| 231 | int HexagonMCInstrInfo::getMaxValue(MCInstrInfo const &MCII, |
| 232 | MCInst const &MCI) { |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 233 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
Colin LeMahieu | af304e5 | 2015-02-19 19:00:00 +0000 | [diff] [blame] | 234 | unsigned isSigned = |
| 235 | (F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; |
| 236 | unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; |
| 237 | |
| 238 | if (isSigned) // if value is signed |
| 239 | return ~(-1U << (bits - 1)); |
| 240 | else |
| 241 | return ~(-1U << bits); |
| 242 | } |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 243 | |
| 244 | // Return the min value that a constant extendable operand can have |
| 245 | // without being extended. |
| 246 | int HexagonMCInstrInfo::getMinValue(MCInstrInfo const &MCII, |
| 247 | MCInst const &MCI) { |
| 248 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 249 | unsigned isSigned = |
| 250 | (F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; |
| 251 | unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; |
| 252 | |
| 253 | if (isSigned) // if value is signed |
| 254 | return -1U << (bits - 1); |
| 255 | else |
| 256 | return 0; |
| 257 | } |
| 258 | |
Colin LeMahieu | b662565 | 2015-05-01 21:14:21 +0000 | [diff] [blame] | 259 | char const *HexagonMCInstrInfo::getName(MCInstrInfo const &MCII, |
| 260 | MCInst const &MCI) { |
| 261 | return MCII.getName(MCI.getOpcode()); |
| 262 | } |
| 263 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 264 | unsigned short HexagonMCInstrInfo::getNewValueOp(MCInstrInfo const &MCII, |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 265 | MCInst const &MCI) { |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 266 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 267 | return ((F >> HexagonII::NewValueOpPos) & HexagonII::NewValueOpMask); |
| 268 | } |
| 269 | |
| 270 | MCOperand const &HexagonMCInstrInfo::getNewValueOperand(MCInstrInfo const &MCII, |
| 271 | MCInst const &MCI) { |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 272 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 273 | unsigned const O = |
| 274 | (F >> HexagonII::NewValueOpPos) & HexagonII::NewValueOpMask; |
| 275 | MCOperand const &MCO = MCI.getOperand(O); |
| 276 | |
| 277 | assert((HexagonMCInstrInfo::isNewValue(MCII, MCI) || |
| 278 | HexagonMCInstrInfo::hasNewValue(MCII, MCI)) && |
| 279 | MCO.isReg()); |
| 280 | return (MCO); |
| 281 | } |
| 282 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 283 | /// Return the new value or the newly produced value. |
| 284 | unsigned short HexagonMCInstrInfo::getNewValueOp2(MCInstrInfo const &MCII, |
| 285 | MCInst const &MCI) { |
| 286 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 287 | return ((F >> HexagonII::NewValueOpPos2) & HexagonII::NewValueOpMask2); |
| 288 | } |
| 289 | |
| 290 | MCOperand const & |
| 291 | HexagonMCInstrInfo::getNewValueOperand2(MCInstrInfo const &MCII, |
| 292 | MCInst const &MCI) { |
| 293 | unsigned O = HexagonMCInstrInfo::getNewValueOp2(MCII, MCI); |
| 294 | MCOperand const &MCO = MCI.getOperand(O); |
| 295 | |
| 296 | assert((HexagonMCInstrInfo::isNewValue(MCII, MCI) || |
| 297 | HexagonMCInstrInfo::hasNewValue2(MCII, MCI)) && |
| 298 | MCO.isReg()); |
| 299 | return (MCO); |
| 300 | } |
| 301 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 302 | int HexagonMCInstrInfo::getSubTarget(MCInstrInfo const &MCII, |
| 303 | MCInst const &MCI) { |
| 304 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 305 | |
| 306 | HexagonII::SubTarget Target = static_cast<HexagonII::SubTarget>( |
| 307 | (F >> HexagonII::validSubTargetPos) & HexagonII::validSubTargetMask); |
| 308 | |
| 309 | switch (Target) { |
| 310 | default: |
| 311 | return Hexagon::ArchV4; |
| 312 | case HexagonII::HasV5SubT: |
| 313 | return Hexagon::ArchV5; |
| 314 | } |
| 315 | } |
| 316 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 317 | // Return the Hexagon ISA class for the insn. |
| 318 | unsigned HexagonMCInstrInfo::getType(MCInstrInfo const &MCII, |
| 319 | MCInst const &MCI) { |
| 320 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 321 | |
| 322 | return ((F >> HexagonII::TypePos) & HexagonII::TypeMask); |
| 323 | } |
| 324 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 325 | unsigned HexagonMCInstrInfo::getUnits(MCInstrInfo const &MCII, |
| 326 | MCSubtargetInfo const &STI, |
| 327 | MCInst const &MCI) { |
| 328 | |
| 329 | const InstrItinerary *II = STI.getSchedModel().InstrItineraries; |
| 330 | int SchedClass = HexagonMCInstrInfo::getDesc(MCII, MCI).getSchedClass(); |
| 331 | return ((II[SchedClass].FirstStage + HexagonStages)->getUnits()); |
| 332 | } |
| 333 | |
| 334 | bool HexagonMCInstrInfo::hasImmExt(MCInst const &MCI) { |
| 335 | if (!HexagonMCInstrInfo::isBundle(MCI)) |
| 336 | return false; |
| 337 | |
| 338 | for (const auto &I : HexagonMCInstrInfo::bundleInstructions(MCI)) { |
| 339 | auto MI = I.getInst(); |
| 340 | if (isImmext(*MI)) |
| 341 | return true; |
| 342 | } |
| 343 | |
| 344 | return false; |
| 345 | } |
| 346 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 347 | bool HexagonMCInstrInfo::hasExtenderForIndex(MCInst const &MCB, size_t Index) { |
| 348 | return extenderForIndex(MCB, Index) != nullptr; |
| 349 | } |
| 350 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 351 | // Return whether the instruction is a legal new-value producer. |
| 352 | bool HexagonMCInstrInfo::hasNewValue(MCInstrInfo const &MCII, |
| 353 | MCInst const &MCI) { |
| 354 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 355 | return ((F >> HexagonII::hasNewValuePos) & HexagonII::hasNewValueMask); |
| 356 | } |
| 357 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 358 | /// Return whether the insn produces a second value. |
| 359 | bool HexagonMCInstrInfo::hasNewValue2(MCInstrInfo const &MCII, |
| 360 | MCInst const &MCI) { |
| 361 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 362 | return ((F >> HexagonII::hasNewValuePos2) & HexagonII::hasNewValueMask2); |
| 363 | } |
| 364 | |
Colin LeMahieu | 86f218e | 2015-05-30 18:55:47 +0000 | [diff] [blame] | 365 | MCInst const &HexagonMCInstrInfo::instruction(MCInst const &MCB, size_t Index) { |
| 366 | assert(isBundle(MCB)); |
| 367 | assert(Index < HEXAGON_PACKET_SIZE); |
| 368 | return *MCB.getOperand(bundleInstructionsOffset + Index).getInst(); |
| 369 | } |
| 370 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 371 | bool HexagonMCInstrInfo::isBundle(MCInst const &MCI) { |
| 372 | auto Result = Hexagon::BUNDLE == MCI.getOpcode(); |
| 373 | assert(!Result || (MCI.size() > 0 && MCI.getOperand(0).isImm())); |
| 374 | return Result; |
| 375 | } |
| 376 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 377 | // Return whether the insn is an actual insn. |
| 378 | bool HexagonMCInstrInfo::isCanon(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 379 | return (!HexagonMCInstrInfo::getDesc(MCII, MCI).isPseudo() && |
| 380 | !HexagonMCInstrInfo::isPrefix(MCII, MCI) && |
| 381 | HexagonMCInstrInfo::getType(MCII, MCI) != HexagonII::TypeENDLOOP); |
| 382 | } |
| 383 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 384 | bool HexagonMCInstrInfo::isCompound(MCInstrInfo const &MCII, |
| 385 | MCInst const &MCI) { |
| 386 | return (getType(MCII, MCI) == HexagonII::TypeCOMPOUND); |
| 387 | } |
| 388 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 389 | bool HexagonMCInstrInfo::isDblRegForSubInst(unsigned Reg) { |
| 390 | return ((Reg >= Hexagon::D0 && Reg <= Hexagon::D3) || |
| 391 | (Reg >= Hexagon::D8 && Reg <= Hexagon::D11)); |
| 392 | } |
| 393 | |
| 394 | bool HexagonMCInstrInfo::isDuplex(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 395 | return HexagonII::TypeDUPLEX == HexagonMCInstrInfo::getType(MCII, MCI); |
| 396 | } |
| 397 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 398 | // Return whether the instruction needs to be constant extended. |
| 399 | // 1) Always return true if the instruction has 'isExtended' flag set. |
| 400 | // |
| 401 | // isExtendable: |
| 402 | // 2) For immediate extended operands, return true only if the value is |
| 403 | // out-of-range. |
| 404 | // 3) For global address, always return true. |
| 405 | |
| 406 | bool HexagonMCInstrInfo::isConstExtended(MCInstrInfo const &MCII, |
| 407 | MCInst const &MCI) { |
| 408 | if (HexagonMCInstrInfo::isExtended(MCII, MCI)) |
| 409 | return true; |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 410 | // Branch insns are handled as necessary by relaxation. |
| 411 | if ((HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypeJ) || |
| 412 | (HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypeCOMPOUND && |
| 413 | HexagonMCInstrInfo::getDesc(MCII, MCI).isBranch()) || |
| 414 | (HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypeNV && |
| 415 | HexagonMCInstrInfo::getDesc(MCII, MCI).isBranch())) |
| 416 | return false; |
| 417 | // Otherwise loop instructions and other CR insts are handled by relaxation |
| 418 | else if ((HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypeCR) && |
| 419 | (MCI.getOpcode() != Hexagon::C4_addipc)) |
| 420 | return false; |
| 421 | else if (!HexagonMCInstrInfo::isExtendable(MCII, MCI)) |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 422 | return false; |
| 423 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 424 | MCOperand const &MO = HexagonMCInstrInfo::getExtendableOperand(MCII, MCI); |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 425 | |
| 426 | // We could be using an instruction with an extendable immediate and shoehorn |
| 427 | // a global address into it. If it is a global address it will be constant |
| 428 | // extended. We do this for COMBINE. |
| 429 | // We currently only handle isGlobal() because it is the only kind of |
| 430 | // object we are going to end up with here for now. |
| 431 | // In the future we probably should add isSymbol(), etc. |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 432 | assert(!MO.isImm()); |
| 433 | int64_t Value; |
| 434 | if (!MO.getExpr()->evaluateAsAbsolute(Value)) |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 435 | return true; |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 436 | int MinValue = HexagonMCInstrInfo::getMinValue(MCII, MCI); |
| 437 | int MaxValue = HexagonMCInstrInfo::getMaxValue(MCII, MCI); |
| 438 | return (MinValue > Value || Value > MaxValue); |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 439 | } |
| 440 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 441 | bool HexagonMCInstrInfo::isExtendable(MCInstrInfo const &MCII, |
| 442 | MCInst const &MCI) { |
| 443 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 444 | return (F >> HexagonII::ExtendablePos) & HexagonII::ExtendableMask; |
| 445 | } |
| 446 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 447 | bool HexagonMCInstrInfo::isExtended(MCInstrInfo const &MCII, |
| 448 | MCInst const &MCI) { |
| 449 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 450 | return (F >> HexagonII::ExtendedPos) & HexagonII::ExtendedMask; |
| 451 | } |
| 452 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 453 | bool HexagonMCInstrInfo::isFloat(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 454 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 455 | return ((F >> HexagonII::FPPos) & HexagonII::FPMask); |
| 456 | } |
| 457 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 458 | bool HexagonMCInstrInfo::isImmext(MCInst const &MCI) { |
| 459 | auto Op = MCI.getOpcode(); |
| 460 | return (Op == Hexagon::A4_ext_b || Op == Hexagon::A4_ext_c || |
| 461 | Op == Hexagon::A4_ext_g || Op == Hexagon::A4_ext); |
| 462 | } |
| 463 | |
| 464 | bool HexagonMCInstrInfo::isInnerLoop(MCInst const &MCI) { |
| 465 | assert(isBundle(MCI)); |
| 466 | int64_t Flags = MCI.getOperand(0).getImm(); |
| 467 | return (Flags & innerLoopMask) != 0; |
| 468 | } |
| 469 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 470 | bool HexagonMCInstrInfo::isIntReg(unsigned Reg) { |
| 471 | return (Reg >= Hexagon::R0 && Reg <= Hexagon::R31); |
| 472 | } |
| 473 | |
| 474 | bool HexagonMCInstrInfo::isIntRegForSubInst(unsigned Reg) { |
| 475 | return ((Reg >= Hexagon::R0 && Reg <= Hexagon::R7) || |
| 476 | (Reg >= Hexagon::R16 && Reg <= Hexagon::R23)); |
| 477 | } |
| 478 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 479 | // Return whether the insn is a new-value consumer. |
| 480 | bool HexagonMCInstrInfo::isNewValue(MCInstrInfo const &MCII, |
| 481 | MCInst const &MCI) { |
| 482 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 483 | return ((F >> HexagonII::NewValuePos) & HexagonII::NewValueMask); |
| 484 | } |
| 485 | |
| 486 | // Return whether the operand can be constant extended. |
| 487 | bool HexagonMCInstrInfo::isOperandExtended(MCInstrInfo const &MCII, |
| 488 | MCInst const &MCI, |
| 489 | unsigned short OperandNum) { |
| 490 | uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 491 | return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask) == |
| 492 | OperandNum; |
| 493 | } |
| 494 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 495 | bool HexagonMCInstrInfo::isOuterLoop(MCInst const &MCI) { |
| 496 | assert(isBundle(MCI)); |
| 497 | int64_t Flags = MCI.getOperand(0).getImm(); |
| 498 | return (Flags & outerLoopMask) != 0; |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 499 | } |
| 500 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 501 | bool HexagonMCInstrInfo::isPredicated(MCInstrInfo const &MCII, |
| 502 | MCInst const &MCI) { |
| 503 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 504 | return ((F >> HexagonII::PredicatedPos) & HexagonII::PredicatedMask); |
| 505 | } |
| 506 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 507 | bool HexagonMCInstrInfo::isPredicateLate(MCInstrInfo const &MCII, |
| 508 | MCInst const &MCI) { |
| 509 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 510 | return (F >> HexagonII::PredicateLatePos & HexagonII::PredicateLateMask); |
| 511 | } |
| 512 | |
| 513 | /// Return whether the insn is newly predicated. |
| 514 | bool HexagonMCInstrInfo::isPredicatedNew(MCInstrInfo const &MCII, |
| 515 | MCInst const &MCI) { |
| 516 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 517 | return ((F >> HexagonII::PredicatedNewPos) & HexagonII::PredicatedNewMask); |
| 518 | } |
| 519 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 520 | bool HexagonMCInstrInfo::isPredicatedTrue(MCInstrInfo const &MCII, |
| 521 | MCInst const &MCI) { |
| 522 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 523 | return ( |
| 524 | !((F >> HexagonII::PredicatedFalsePos) & HexagonII::PredicatedFalseMask)); |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 527 | bool HexagonMCInstrInfo::isPredReg(unsigned Reg) { |
| 528 | return (Reg >= Hexagon::P0 && Reg <= Hexagon::P3_0); |
| 529 | } |
| 530 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 531 | bool HexagonMCInstrInfo::isPrefix(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 532 | return (HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypePREFIX); |
| 533 | } |
| 534 | |
Colin LeMahieu | 745c471 | 2015-02-19 19:49:27 +0000 | [diff] [blame] | 535 | bool HexagonMCInstrInfo::isSolo(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 536 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 537 | return ((F >> HexagonII::SoloPos) & HexagonII::SoloMask); |
| 538 | } |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 539 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 540 | bool HexagonMCInstrInfo::isMemReorderDisabled(MCInst const &MCI) { |
| 541 | assert(isBundle(MCI)); |
| 542 | auto Flags = MCI.getOperand(0).getImm(); |
| 543 | return (Flags & memReorderDisabledMask) != 0; |
| 544 | } |
| 545 | |
| 546 | bool HexagonMCInstrInfo::isMemStoreReorderEnabled(MCInst const &MCI) { |
| 547 | assert(isBundle(MCI)); |
| 548 | auto Flags = MCI.getOperand(0).getImm(); |
| 549 | return (Flags & memStoreReorderEnabledMask) != 0; |
| 550 | } |
| 551 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 552 | bool HexagonMCInstrInfo::isSoloAX(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 553 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 554 | return ((F >> HexagonII::SoloAXPos) & HexagonII::SoloAXMask); |
| 555 | } |
| 556 | |
| 557 | bool HexagonMCInstrInfo::isSoloAin1(MCInstrInfo const &MCII, |
| 558 | MCInst const &MCI) { |
| 559 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 560 | return ((F >> HexagonII::SoloAin1Pos) & HexagonII::SoloAin1Mask); |
| 561 | } |
| 562 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 563 | bool HexagonMCInstrInfo::isVector(MCInstrInfo const &MCII, MCInst const &MCI) { |
| 564 | if ((getType(MCII, MCI) <= HexagonII::TypeCVI_LAST) && |
| 565 | (getType(MCII, MCI) >= HexagonII::TypeCVI_FIRST)) |
| 566 | return true; |
| 567 | return false; |
| 568 | } |
| 569 | |
| 570 | int64_t HexagonMCInstrInfo::minConstant(MCInst const &MCI, size_t Index) { |
| 571 | auto Sentinal = static_cast<int64_t>(std::numeric_limits<uint32_t>::max()) |
| 572 | << 8; |
| 573 | if (MCI.size() <= Index) |
| 574 | return Sentinal; |
| 575 | MCOperand const &MCO = MCI.getOperand(Index); |
| 576 | if (!MCO.isExpr()) |
| 577 | return Sentinal; |
| 578 | int64_t Value; |
| 579 | if (!MCO.getExpr()->evaluateAsAbsolute(Value)) |
| 580 | return Sentinal; |
| 581 | return Value; |
| 582 | } |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 583 | |
| 584 | void HexagonMCInstrInfo::setMustExtend(MCExpr &Expr, bool Val) { |
| 585 | HexagonMCExpr &HExpr = *llvm::cast<HexagonMCExpr>(&Expr); |
| 586 | HExpr.setMustExtend(Val); |
| 587 | } |
| 588 | |
| 589 | bool HexagonMCInstrInfo::mustExtend(MCExpr const &Expr) { |
| 590 | HexagonMCExpr const &HExpr = *llvm::cast<HexagonMCExpr>(&Expr); |
| 591 | return HExpr.mustExtend(); |
| 592 | } |
| 593 | void HexagonMCInstrInfo::setMustNotExtend(MCExpr const &Expr, bool Val) { |
| 594 | HexagonMCExpr &HExpr = |
| 595 | const_cast<HexagonMCExpr &>(*llvm::cast<HexagonMCExpr>(&Expr)); |
| 596 | HExpr.setMustNotExtend(Val); |
| 597 | } |
| 598 | bool HexagonMCInstrInfo::mustNotExtend(MCExpr const &Expr) { |
| 599 | HexagonMCExpr const &HExpr = *llvm::cast<HexagonMCExpr>(&Expr); |
| 600 | return HExpr.mustNotExtend(); |
| 601 | } |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 602 | |
Colin LeMahieu | b3c9727 | 2015-11-13 07:58:06 +0000 | [diff] [blame] | 603 | void HexagonMCInstrInfo::padEndloop(MCContext &Context, MCInst &MCB) { |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 604 | MCInst Nop; |
| 605 | Nop.setOpcode(Hexagon::A2_nop); |
| 606 | assert(isBundle(MCB)); |
| 607 | while ((HexagonMCInstrInfo::isInnerLoop(MCB) && |
| 608 | (HexagonMCInstrInfo::bundleSize(MCB) < HEXAGON_PACKET_INNER_SIZE)) || |
| 609 | ((HexagonMCInstrInfo::isOuterLoop(MCB) && |
| 610 | (HexagonMCInstrInfo::bundleSize(MCB) < HEXAGON_PACKET_OUTER_SIZE)))) |
Colin LeMahieu | b3c9727 | 2015-11-13 07:58:06 +0000 | [diff] [blame] | 611 | MCB.addOperand(MCOperand::createInst(new (Context) MCInst(Nop))); |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 612 | } |
| 613 | |
Colin LeMahieu | b23c47b | 2015-05-31 21:57:09 +0000 | [diff] [blame] | 614 | bool HexagonMCInstrInfo::prefersSlot3(MCInstrInfo const &MCII, |
| 615 | MCInst const &MCI) { |
| 616 | if (HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypeCR) |
| 617 | return false; |
| 618 | |
| 619 | unsigned SchedClass = HexagonMCInstrInfo::getDesc(MCII, MCI).getSchedClass(); |
| 620 | switch (SchedClass) { |
| 621 | case Hexagon::Sched::ALU32_3op_tc_2_SLOT0123: |
| 622 | case Hexagon::Sched::ALU64_tc_2_SLOT23: |
| 623 | case Hexagon::Sched::ALU64_tc_3x_SLOT23: |
| 624 | case Hexagon::Sched::M_tc_2_SLOT23: |
| 625 | case Hexagon::Sched::M_tc_3x_SLOT23: |
| 626 | case Hexagon::Sched::S_2op_tc_2_SLOT23: |
| 627 | case Hexagon::Sched::S_3op_tc_2_SLOT23: |
| 628 | case Hexagon::Sched::S_3op_tc_3x_SLOT23: |
| 629 | return true; |
| 630 | } |
| 631 | return false; |
| 632 | } |
| 633 | |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 634 | void HexagonMCInstrInfo::replaceDuplex(MCContext &Context, MCInst &MCB, |
| 635 | DuplexCandidate Candidate) { |
| 636 | assert(Candidate.packetIndexI < MCB.size()); |
| 637 | assert(Candidate.packetIndexJ < MCB.size()); |
| 638 | assert(isBundle(MCB)); |
| 639 | MCInst *Duplex = |
| 640 | deriveDuplex(Context, Candidate.iClass, |
| 641 | *MCB.getOperand(Candidate.packetIndexJ).getInst(), |
| 642 | *MCB.getOperand(Candidate.packetIndexI).getInst()); |
| 643 | assert(Duplex != nullptr); |
| 644 | MCB.getOperand(Candidate.packetIndexI).setInst(Duplex); |
| 645 | MCB.erase(MCB.begin() + Candidate.packetIndexJ); |
| 646 | } |
| 647 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 648 | void HexagonMCInstrInfo::setInnerLoop(MCInst &MCI) { |
| 649 | assert(isBundle(MCI)); |
| 650 | MCOperand &Operand = MCI.getOperand(0); |
| 651 | Operand.setImm(Operand.getImm() | innerLoopMask); |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 652 | } |
| 653 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 654 | void HexagonMCInstrInfo::setMemReorderDisabled(MCInst &MCI) { |
| 655 | assert(isBundle(MCI)); |
| 656 | MCOperand &Operand = MCI.getOperand(0); |
| 657 | Operand.setImm(Operand.getImm() | memReorderDisabledMask); |
| 658 | assert(isMemReorderDisabled(MCI)); |
| 659 | } |
| 660 | |
| 661 | void HexagonMCInstrInfo::setMemStoreReorderEnabled(MCInst &MCI) { |
| 662 | assert(isBundle(MCI)); |
| 663 | MCOperand &Operand = MCI.getOperand(0); |
| 664 | Operand.setImm(Operand.getImm() | memStoreReorderEnabledMask); |
| 665 | assert(isMemStoreReorderEnabled(MCI)); |
| 666 | } |
| 667 | |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 668 | void HexagonMCInstrInfo::setOuterLoop(MCInst &MCI) { |
| 669 | assert(isBundle(MCI)); |
| 670 | MCOperand &Operand = MCI.getOperand(0); |
| 671 | Operand.setImm(Operand.getImm() | outerLoopMask); |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 672 | } |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 673 | } |