10#ifndef LLVM_MC_MCDECODER_H
11#define LLVM_MC_MCDECODER_H
32template <
typename IntType>
33#if defined(_MSC_VER) && !defined(__clang__)
36inline std::enable_if_t<std::is_integral_v<IntType>, IntType>
38 assert(StartBit + NumBits <= 64 && "Cannot support >64-bit extractions!
");
39 assert(StartBit + NumBits <= (sizeof(IntType) * 8) &&
41 const IntType Mask = maskTrailingOnes<IntType>(NumBits);
42 return (Insn >> StartBit) & Mask;
45template <typename InsnType>
46inline std::enable_if_t<!std::is_integral_v<InsnType>, uint64_t>
47fieldFromInstruction(const InsnType &Insn, unsigned StartBit,
49 return Insn.extractBitsAsZExtValue(NumBits, StartBit);
53uint64_t fieldFromInstruction(const std::bitset<N> &Insn, unsigned StartBit,
55 assert(StartBit + NumBits <= N && "Instruction field out of bounds!
");
56 assert(NumBits <= 64 && "Cannot
support >64-bit extractions!
");
57 const std::bitset<N> Mask(maskTrailingOnes<uint64_t>(NumBits));
58 return ((Insn >> StartBit) & Mask).to_ullong();
61} // namespace llvm::MCD
63#endif // LLVM_MC_MCDECODER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
DecodeStatus
Ternary decode status.
bool Check(MCDisassembler::DecodeStatus &Out, MCDisassembler::DecodeStatus In)
std::enable_if_t< std::is_integral_v< IntType >, IntType > fieldFromInstruction(const IntType &Insn, unsigned StartBit, unsigned NumBits)