blob: 4cd07ab957320cd6499b76673b5632328c4e7403 [file] [log] [blame]
Colin LeMahieuaf304e52015-02-19 19:00:00 +00001//===- 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
18namespace llvm {
19MCInstrDesc 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.
25int 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}