LLVM API Documentation

Functions
AArch64ExpandPseudoInsts.cpp File Reference
#include "MCTargetDesc/AArch64AddressingModes.h"
#include "AArch64InstrInfo.h"
#include "AArch64Subtarget.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Support/MathExtras.h"
Include dependency graph for AArch64ExpandPseudoInsts.cpp:

Go to the source code of this file.

Functions

static void transferImpOps (MachineInstr &OldMI, MachineInstrBuilder &UseMI, MachineInstrBuilder &DefMI)
 Transfer implicit operands on the pseudo instruction to the instructions created from the expansion.
static uint64_t getChunk (uint64_t Imm, unsigned ChunkIdx)
 Helper function which extracts the specified 16-bit chunk from a 64-bit value.
static uint64_t replicateChunk (uint64_t Imm, unsigned FromIdx, unsigned ToIdx)
 Helper function which replicates a 16-bit chunk within a 64-bit value. Indices correspond to element numbers in a v4i16.
static bool tryOrrMovk (uint64_t UImm, uint64_t OrrImm, MachineInstr &MI, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const AArch64InstrInfo *TII, unsigned ChunkIdx)
 Helper function which tries to materialize a 64-bit value with an ORR + MOVK instruction sequence.
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.
static bool tryToreplicateChunks (uint64_t UImm, MachineInstr &MI, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const AArch64InstrInfo *TII)
 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.
static bool isStartChunk (uint64_t Chunk)
 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.
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.
static uint64_t updateImm (uint64_t Imm, unsigned Idx, bool Clear)
 Clear or set all bits in the chunk at the given index.
static bool trySequenceOfOnes (uint64_t UImm, MachineInstr &MI, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const AArch64InstrInfo *TII)
 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.

Function Documentation

static bool 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 125 of file AArch64ExpandPseudoInsts.cpp.

References llvm::AArch64_AM::processLogicalImmediate().

Referenced by tryToreplicateChunks().

static uint64_t getChunk ( uint64_t  Imm,
unsigned  ChunkIdx 
) [static]

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

Definition at line 66 of file AArch64ExpandPseudoInsts.cpp.

Referenced by replicateChunk(), tryOrrMovk(), trySequenceOfOnes(), and tryToreplicateChunks().

static bool 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 238 of file AArch64ExpandPseudoInsts.cpp.

References llvm::countLeadingZeros(), llvm::CountTrailingOnes_64(), and UINT64_MAX.

Referenced by trySequenceOfOnes().

static bool 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 228 of file AArch64ExpandPseudoInsts.cpp.

References llvm::CountLeadingOnes_64(), llvm::countTrailingZeros(), and UINT64_MAX.

Referenced by trySequenceOfOnes().

static uint64_t replicateChunk ( uint64_t  Imm,
unsigned  FromIdx,
unsigned  ToIdx 
) [static]

Helper function which replicates a 16-bit chunk within a 64-bit value. Indices correspond to element numbers in a v4i16.

Definition at line 74 of file AArch64ExpandPseudoInsts.cpp.

References getChunk().

static void transferImpOps ( MachineInstr OldMI,
MachineInstrBuilder UseMI,
MachineInstrBuilder DefMI 
) [static]
static bool tryOrrMovk ( uint64_t  UImm,
uint64_t  OrrImm,
MachineInstr MI,
MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
const AArch64InstrInfo TII,
unsigned  ChunkIdx 
) [static]
static bool trySequenceOfOnes ( uint64_t  UImm,
MachineInstr MI,
MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
const AArch64InstrInfo TII 
) [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 273 of file AArch64ExpandPseudoInsts.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::BuildMI(), llvm::RegState::Define, llvm::MachineInstr::eraseFromParent(), getChunk(), llvm::getDeadRegState(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::AArch64_AM::getShifterImm(), llvm::MachineOperand::isDead(), isEndChunk(), isStartChunk(), llvm::AArch64_AM::LSL, llvm::AArch64_AM::processLogicalImmediate(), std::swap(), transferImpOps(), and updateImm().

static bool tryToreplicateChunks ( uint64_t  UImm,
MachineInstr MI,
MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
const AArch64InstrInfo TII 
) [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 139 of file AArch64ExpandPseudoInsts.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::BuildMI(), canUseOrr(), llvm::RegState::Define, llvm::MachineInstr::eraseFromParent(), getChunk(), llvm::getDeadRegState(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::AArch64_AM::getShifterImm(), llvm::X86II::Imm16, llvm::MachineOperand::isDead(), llvm::AArch64_AM::LSL, and transferImpOps().

static uint64_t updateImm ( uint64_t  Imm,
unsigned  Idx,
bool  Clear 
) [static]

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

Definition at line 246 of file AArch64ExpandPseudoInsts.cpp.

Referenced by trySequenceOfOnes().