LLVM: include/llvm/MC/MCDecoder.h Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10#ifndef LLVM_MC_MCDECODER_H
11#define LLVM_MC_MCDECODER_H
12
15#include
16#include
17
19
20
21
22
23
29
30
31
32template
33#if defined(_MSC_VER) && !defined(__clang__)
34__declspec(noinline)
35#endif
36inline std::enable_if_t<std::is_integral_v, IntType>
38 assert(StartBit + NumBits <= 64 && "Cannot support >64-bit extractions!");
39 assert(StartBit + NumBits <= (sizeof(IntType) * 8) &&
41 const IntType Mask = maskTrailingOnes(NumBits);
42 return (Insn >> StartBit) & Mask;
43}
44
45template
46inline std::enable_if_t<!std::is_integral_v, uint64_t>
47fieldFromInstruction(const InsnType &Insn, unsigned StartBit,
48 unsigned NumBits) {
49 return Insn.extractBitsAsZExtValue(NumBits, StartBit);
50}
51
52template <size_t N>
53uint64_t fieldFromInstruction(const std::bitset &Insn, unsigned StartBit,
54 unsigned NumBits) {
55 assert(StartBit + NumBits <= N && "Instruction field out of bounds!");
56 assert(NumBits <= 64 && "Cannot support >64-bit extractions!");
57 const std::bitset Mask(maskTrailingOnes<uint64_t>(NumBits));
58 return ((Insn >> StartBit) & Mask).to_ullong();
59}
60
61} // namespace llvm::MCD
62
63#endif // LLVM_MC_MCDECODER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
DecodeStatus
Ternary decode status.
Definition MCDecoder.h:18
bool Check(MCDisassembler::DecodeStatus &Out, MCDisassembler::DecodeStatus In)
Definition MCDecoder.h:24
std::enable_if_t< std::is_integral_v< IntType >, IntType > fieldFromInstruction(const IntType &Insn, unsigned StartBit, unsigned NumBits)
Definition MCDecoder.h:37