LLVM  10.0.0svn
Classes | Functions
llvm::AArch64_IMM Namespace Reference

Classes

struct  ImmInsnModel
 

Functions

static uint64_t getChunk (uint64_t Imm, unsigned ChunkIdx)
 Helper function which extracts the specified 16-bit chunk from a 64-bit value. More...
 
static bool canUseOrr (uint64_t Chunk, uint64_t &Encoding)
 Check whether the given 16-bit chunk replicated to full 64-bit width can be materialized with an ORR instruction. More...
 
static bool tryToreplicateChunks (uint64_t UImm, SmallVectorImpl< ImmInsnModel > &Insn)
 Check for identical 16-bit chunks within the constant and if so materialize them with a single ORR instruction. More...
 
static bool isStartChunk (uint64_t Chunk)
 Check whether this chunk matches the pattern '1...0...'. More...
 
static bool isEndChunk (uint64_t Chunk)
 Check whether this chunk matches the pattern '0...1...' This pattern ends a contiguous sequence of ones if we look at the bits from the LSB towards the MSB. More...
 
static uint64_t updateImm (uint64_t Imm, unsigned Idx, bool Clear)
 Clear or set all bits in the chunk at the given index. More...
 
static bool trySequenceOfOnes (uint64_t UImm, SmallVectorImpl< ImmInsnModel > &Insn)
 Check whether the constant contains a sequence of contiguous ones, which might be interrupted by one or two chunks. More...
 
static void expandMOVImmSimple (uint64_t Imm, unsigned BitSize, unsigned OneChunks, unsigned ZeroChunks, SmallVectorImpl< ImmInsnModel > &Insn)
 Expand a MOVi32imm or MOVi64imm pseudo instruction to a MOVZ or MOVN of width BitSize followed by up to 3 MOVK instructions. More...
 
void expandMOVImm (uint64_t Imm, unsigned BitSize, SmallVectorImpl< ImmInsnModel > &Insn)
 Expand a MOVi32imm or MOVi64imm pseudo instruction to one or more real move-immediate instructions to synthesize the immediate. More...
 

Function Documentation

◆ canUseOrr()

static bool llvm::AArch64_IMM::canUseOrr ( uint64_t  Chunk,
uint64_t &  Encoding 
)
static

Check whether the given 16-bit chunk replicated to full 64-bit width can be materialized with an ORR instruction.

Definition at line 31 of file AArch64ExpandImm.cpp.

References llvm::AArch64_AM::processLogicalImmediate().

◆ expandMOVImm()

void llvm::AArch64_IMM::expandMOVImm ( uint64_t  Imm,
unsigned  BitSize,
SmallVectorImpl< ImmInsnModel > &  Insn 
)

◆ expandMOVImmSimple()

static void llvm::AArch64_IMM::expandMOVImmSimple ( uint64_t  Imm,
unsigned  BitSize,
unsigned  OneChunks,
unsigned  ZeroChunks,
SmallVectorImpl< ImmInsnModel > &  Insn 
)
inlinestatic

Expand a MOVi32imm or MOVi64imm pseudo instruction to a MOVZ or MOVN of width BitSize followed by up to 3 MOVK instructions.

Definition at line 246 of file AArch64ExpandImm.cpp.

References llvm::countLeadingZeros(), llvm::countTrailingZeros(), llvm::AArch64_AM::getShifterImm(), llvm::X86II::Imm16, llvm::AArch64_AM::LSL, llvm::BitmaskEnumDetail::Mask(), and llvm::SmallVectorTemplateBase< T >::push_back().

Referenced by expandMOVImm().

◆ getChunk()

static uint64_t llvm::AArch64_IMM::getChunk ( uint64_t  Imm,
unsigned  ChunkIdx 
)
static

Helper function which extracts the specified 16-bit chunk from a 64-bit value.

Definition at line 23 of file AArch64ExpandImm.cpp.

References assert().

Referenced by expandMOVImm(), trySequenceOfOnes(), and tryToreplicateChunks().

◆ isEndChunk()

static bool llvm::AArch64_IMM::isEndChunk ( uint64_t  Chunk)
static

Check whether this chunk matches the pattern '0...1...' This pattern ends a contiguous sequence of ones if we look at the bits from the LSB towards the MSB.

Definition at line 118 of file AArch64ExpandImm.cpp.

References llvm::isMask_64(), and llvm::max().

Referenced by trySequenceOfOnes().

◆ isStartChunk()

static bool llvm::AArch64_IMM::isStartChunk ( uint64_t  Chunk)
static

Check whether this chunk matches the pattern '1...0...'.

This pattern starts a contiguous sequence of ones if we look at the bits from the LSB towards the MSB.

Definition at line 108 of file AArch64ExpandImm.cpp.

References llvm::isMask_64(), and llvm::max().

Referenced by trySequenceOfOnes().

◆ trySequenceOfOnes()

static bool llvm::AArch64_IMM::trySequenceOfOnes ( uint64_t  UImm,
SmallVectorImpl< ImmInsnModel > &  Insn 
)
static

Check whether the constant contains a sequence of contiguous ones, which might be interrupted by one or two chunks.

If so, materialize the sequence of contiguous ones with an ORR instruction. Materialize the chunks which are either interrupting the sequence or outside of the sequence with a MOVK instruction.

Assuming S is a chunk which starts the sequence (1...0...), E is a chunk which ends the sequence (0...1...). Then we are looking for constants which contain at least one S and E chunk. E.g. |E|A|B|S|, |A|E|B|S| or |A|B|E|S|.

We are also looking for constants like |S|A|B|E| where the contiguous sequence of ones wraps around the MSB into the LSB.

Definition at line 152 of file AArch64ExpandImm.cpp.

References assert(), getChunk(), llvm::AArch64_AM::getShifterImm(), isEndChunk(), isStartChunk(), llvm::AArch64_AM::LSL, llvm::BitmaskEnumDetail::Mask(), llvm::AArch64_AM::processLogicalImmediate(), llvm::SmallVectorTemplateBase< T >::push_back(), std::swap(), and updateImm().

Referenced by expandMOVImm().

◆ tryToreplicateChunks()

static bool llvm::AArch64_IMM::tryToreplicateChunks ( uint64_t  UImm,
SmallVectorImpl< ImmInsnModel > &  Insn 
)
static

Check for identical 16-bit chunks within the constant and if so materialize them with a single ORR instruction.

The remaining one or two 16-bit chunks will be materialized with MOVK instructions.

This allows us to materialize constants like |A|B|A|A| or |A|B|C|A| (order of the chunks doesn't matter), assuming |A|A|A|A| can be materialized with an ORR instruction.

Definition at line 44 of file AArch64ExpandImm.cpp.

References getChunk().

Referenced by expandMOVImm().

◆ updateImm()

static uint64_t llvm::AArch64_IMM::updateImm ( uint64_t  Imm,
unsigned  Idx,
bool  Clear 
)
static

Clear or set all bits in the chunk at the given index.

Definition at line 126 of file AArch64ExpandImm.cpp.

References llvm::BitmaskEnumDetail::Mask().

Referenced by trySequenceOfOnes().