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 | |
| 14 | #include "HexagonMCInstrInfo.h" |
| 15 | #include "HexagonBaseInfo.h" |
| 16 | #include "llvm/MC/MCInstrInfo.h" |
| 17 | |
| 18 | namespace llvm { |
| 19 | MCInstrDesc const &HexagonMCInstrInfo::getDesc(MCInstrInfo const &MCII, |
| 20 | MCInst const &MCI) { |
| 21 | return (MCII.get(MCI.getOpcode())); |
| 22 | } |
| 23 | // Return the max value that a constant extendable operand can have |
| 24 | // without being extended. |
| 25 | int HexagonMCInstrInfo::getMaxValue(MCInstrInfo const &MCII, |
| 26 | MCInst const &MCI) { |
| 27 | const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags; |
| 28 | unsigned isSigned = |
| 29 | (F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; |
| 30 | unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; |
| 31 | |
| 32 | if (isSigned) // if value is signed |
| 33 | return ~(-1U << (bits - 1)); |
| 34 | else |
| 35 | return ~(-1U << bits); |
| 36 | } |
| 37 | } |