2012-02-18 12:03:15 +00:00
|
|
|
//===-- ARMBaseInstrInfo.h - ARM Base Instruction Information ---*- C++ -*-===//
|
2009-07-08 16:09:28 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2009-07-08 16:09:28 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the Base ARM implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_ARM_ARMBASEINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_ARM_ARMBASEINSTRINFO_H
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2014-03-22 23:51:00 +00:00
|
|
|
#include "MCTargetDesc/ARMBaseInfo.h"
|
2010-12-05 22:04:16 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2017-01-31 00:56:17 +00:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2017-01-31 00:56:17 +00:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2017-11-08 01:01:31 +00:00
|
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
2017-01-31 00:56:17 +00:00
|
|
|
#include <array>
|
|
|
|
#include <cstdint>
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "ARMGenInstrInfo.inc"
|
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
namespace llvm {
|
2017-01-31 00:56:17 +00:00
|
|
|
|
|
|
|
class ARMBaseRegisterInfo;
|
|
|
|
class ARMSubtarget;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
class ARMBaseInstrInfo : public ARMGenInstrInfo {
|
2010-07-20 21:17:29 +00:00
|
|
|
const ARMSubtarget &Subtarget;
|
2010-12-05 22:04:16 +00:00
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
protected:
|
|
|
|
// Can be only subclassed.
|
2009-11-02 00:10:38 +00:00
|
|
|
explicit ARMBaseInstrInfo(const ARMSubtarget &STI);
|
2010-12-05 22:04:16 +00:00
|
|
|
|
2014-07-25 19:31:34 +00:00
|
|
|
void expandLoadStackGuardBase(MachineBasicBlock::iterator MI,
|
2016-06-28 15:18:26 +00:00
|
|
|
unsigned LoadImmOpc, unsigned LoadOpc) const;
|
2014-07-25 19:31:34 +00:00
|
|
|
|
2014-08-22 18:05:22 +00:00
|
|
|
/// Build the equivalent inputs of a REG_SEQUENCE for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [out] InputRegs of the equivalent REG_SEQUENCE. Each element of
|
|
|
|
/// the list is modeled as <Reg:SubReg, SubIdx>.
|
2017-11-30 12:12:19 +00:00
|
|
|
/// E.g., REG_SEQUENCE %1:sub1, sub0, %2, sub1 would produce
|
2014-08-22 18:05:22 +00:00
|
|
|
/// two elements:
|
2017-11-30 12:12:19 +00:00
|
|
|
/// - %1:sub1, sub0
|
|
|
|
/// - %2<:0>, sub1
|
2014-08-22 18:05:22 +00:00
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build such an input sequence
|
|
|
|
/// with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isRegSequenceLike().
|
|
|
|
bool getRegSequenceLikeInputs(
|
|
|
|
const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const override;
|
|
|
|
|
|
|
|
/// Build the equivalent inputs of a EXTRACT_SUBREG for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [out] InputReg of the equivalent EXTRACT_SUBREG.
|
2017-11-30 12:12:19 +00:00
|
|
|
/// E.g., EXTRACT_SUBREG %1:sub1, sub0, sub1 would produce:
|
|
|
|
/// - %1:sub1, sub0
|
2014-08-22 18:05:22 +00:00
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build such an input sequence
|
|
|
|
/// with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isExtractSubregLike().
|
|
|
|
bool getExtractSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPairAndIdx &InputReg) const override;
|
|
|
|
|
|
|
|
/// Build the equivalent inputs of a INSERT_SUBREG for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [out] BaseReg and \p [out] InsertedReg contain
|
|
|
|
/// the equivalent inputs of INSERT_SUBREG.
|
2017-11-30 12:12:19 +00:00
|
|
|
/// E.g., INSERT_SUBREG %0:sub0, %1:sub1, sub3 would produce:
|
|
|
|
/// - BaseReg: %0:sub0
|
|
|
|
/// - InsertedReg: %1:sub1, sub3
|
2014-08-22 18:05:22 +00:00
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build such an input sequence
|
|
|
|
/// with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isInsertSubregLike().
|
|
|
|
bool
|
|
|
|
getInsertSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPair &BaseReg,
|
|
|
|
RegSubRegPairAndIdx &InsertedReg) const override;
|
|
|
|
|
2015-09-28 20:33:22 +00:00
|
|
|
/// Commutes the operands in the given instruction.
|
|
|
|
/// The commutable operands are specified by their indices OpIdx1 and OpIdx2.
|
|
|
|
///
|
|
|
|
/// Do not call this method for a non-commutable instruction or for
|
|
|
|
/// non-commutable pair of operand indices OpIdx1 and OpIdx2.
|
|
|
|
/// Even though the instruction is commutable, the method may still
|
|
|
|
/// fail to commute the operands, null pointer is returned in such cases.
|
2016-06-30 00:01:54 +00:00
|
|
|
MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
|
2015-09-28 20:33:22 +00:00
|
|
|
unsigned OpIdx1,
|
|
|
|
unsigned OpIdx2) const override;
|
|
|
|
|
2018-08-30 14:32:47 +00:00
|
|
|
/// If the specific machine instruction is a instruction that moves/copies
|
|
|
|
/// value from one register to another register return true along with
|
|
|
|
/// @Source machine operand and @Destination machine operand.
|
|
|
|
bool isCopyInstrImpl(const MachineInstr &MI, const MachineOperand *&Source,
|
|
|
|
const MachineOperand *&Destination) const override;
|
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
public:
|
2012-02-28 23:53:30 +00:00
|
|
|
// Return whether the target has an explicit NOP encoding.
|
|
|
|
bool hasNOP() const;
|
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
// Return the non-pre/post incrementing version of 'Opc'. Return 0
|
|
|
|
// if there is not such an opcode.
|
2017-01-31 00:56:17 +00:00
|
|
|
virtual unsigned getUnindexedOpcode(unsigned Opc) const = 0;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
|
2016-06-30 00:01:54 +00:00
|
|
|
MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
LiveVariables *LV) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2013-06-07 05:54:19 +00:00
|
|
|
virtual const ARMBaseRegisterInfo &getRegisterInfo() const = 0;
|
2009-11-02 00:10:38 +00:00
|
|
|
const ARMSubtarget &getSubtarget() const { return Subtarget; }
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2010-12-05 22:04:16 +00:00
|
|
|
ScheduleHazardRecognizer *
|
2014-06-13 22:38:52 +00:00
|
|
|
CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI,
|
2014-03-10 02:09:33 +00:00
|
|
|
const ScheduleDAG *DAG) const override;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
|
|
|
|
ScheduleHazardRecognizer *
|
|
|
|
CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
|
2014-03-10 02:09:33 +00:00
|
|
|
const ScheduleDAG *DAG) const override;
|
2010-12-05 22:04:16 +00:00
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
// Branch analysis.
|
2016-07-15 14:41:04 +00:00
|
|
|
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
2014-03-10 02:09:33 +00:00
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify = false) const override;
|
2016-09-14 20:43:16 +00:00
|
|
|
unsigned removeBranch(MachineBasicBlock &MBB,
|
2016-09-14 17:23:48 +00:00
|
|
|
int *BytesRemoved = nullptr) const override;
|
2016-09-14 17:24:15 +00:00
|
|
|
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2015-06-11 19:30:37 +00:00
|
|
|
MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
|
2016-09-14 17:23:48 +00:00
|
|
|
const DebugLoc &DL,
|
|
|
|
int *BytesAdded = nullptr) const override;
|
2014-03-10 02:09:33 +00:00
|
|
|
|
|
|
|
bool
|
2016-09-14 20:43:16 +00:00
|
|
|
reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
|
|
|
// Predication support.
|
2016-02-23 02:46:52 +00:00
|
|
|
bool isPredicated(const MachineInstr &MI) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2016-02-23 02:46:52 +00:00
|
|
|
ARMCC::CondCodes getPredicate(const MachineInstr &MI) const {
|
|
|
|
int PIdx = MI.findFirstPredOperandIdx();
|
|
|
|
return PIdx != -1 ? (ARMCC::CondCodes)MI.getOperand(PIdx).getImm()
|
2009-07-08 16:09:28 +00:00
|
|
|
: ARMCC::AL;
|
|
|
|
}
|
|
|
|
|
2016-02-23 02:46:52 +00:00
|
|
|
bool PredicateInstruction(MachineInstr &MI,
|
|
|
|
ArrayRef<MachineOperand> Pred) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2015-06-11 19:30:37 +00:00
|
|
|
bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1,
|
|
|
|
ArrayRef<MachineOperand> Pred2) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2016-02-23 02:46:52 +00:00
|
|
|
bool DefinesPredicate(MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
std::vector<MachineOperand> &Pred) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2017-03-03 18:30:54 +00:00
|
|
|
bool isPredicable(const MachineInstr &MI) const override;
|
2009-11-21 06:21:52 +00:00
|
|
|
|
2017-06-02 08:53:19 +00:00
|
|
|
// CPSR defined in instruction
|
|
|
|
static bool isCPSRDefined(const MachineInstr &MI);
|
|
|
|
bool isAddrMode3OpImm(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
bool isAddrMode3OpMinusReg(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
|
|
|
|
// Load, scaled register offset
|
|
|
|
bool isLdstScaledReg(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
// Load, scaled register offset, not plus LSL2
|
|
|
|
bool isLdstScaledRegNotPlusLsl2(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
// Minus reg for ldstso addr mode
|
|
|
|
bool isLdstSoMinusReg(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
// Scaled register offset in address mode 2
|
|
|
|
bool isAm2ScaledReg(const MachineInstr &MI, unsigned Op) const;
|
|
|
|
// Load multiple, base reg in list
|
|
|
|
bool isLDMBaseRegInList(const MachineInstr &MI) const;
|
|
|
|
// get LDM variable defs size
|
|
|
|
unsigned getLDMVariableDefsSize(const MachineInstr &MI) const;
|
|
|
|
|
2009-07-08 16:09:28 +00:00
|
|
|
/// GetInstSize - Returns the size of the specified MachineInstr.
|
|
|
|
///
|
2016-07-29 09:57:37 +00:00
|
|
|
unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
int &FrameIndex) const override;
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned isStoreToStackSlot(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
int &FrameIndex) const override;
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
int &FrameIndex) const override;
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned isStoreToStackSlotPostFE(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
int &FrameIndex) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2014-10-01 19:21:03 +00:00
|
|
|
void copyToCPSR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
|
|
unsigned SrcReg, bool KillSrc,
|
|
|
|
const ARMSubtarget &Subtarget) const;
|
|
|
|
void copyFromCPSR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
|
|
unsigned DestReg, bool KillSrc,
|
|
|
|
const ARMSubtarget &Subtarget) const;
|
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
2016-06-12 15:39:02 +00:00
|
|
|
const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
|
2014-03-10 02:09:33 +00:00
|
|
|
bool KillSrc) const override;
|
2009-07-27 03:14:20 +00:00
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2009-07-08 16:09:28 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
bool expandPostRAPseudo(MachineInstr &MI) const override;
|
2011-10-11 00:59:06 +00:00
|
|
|
|
2018-01-17 19:19:05 +00:00
|
|
|
bool shouldSink(const MachineInstr &MI) const override;
|
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, unsigned SubIdx,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &Orig,
|
2014-03-10 02:09:33 +00:00
|
|
|
const TargetRegisterInfo &TRI) const override;
|
2009-11-08 00:15:23 +00:00
|
|
|
|
2017-08-22 23:56:30 +00:00
|
|
|
MachineInstr &
|
|
|
|
duplicate(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,
|
|
|
|
const MachineInstr &Orig) const override;
|
2010-01-06 23:47:07 +00:00
|
|
|
|
2013-04-21 11:57:07 +00:00
|
|
|
const MachineInstrBuilder &AddDReg(MachineInstrBuilder &MIB, unsigned Reg,
|
|
|
|
unsigned SubIdx, unsigned State,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
bool produceSameValue(const MachineInstr &MI0, const MachineInstr &MI1,
|
2014-03-10 02:09:33 +00:00
|
|
|
const MachineRegisterInfo *MRI) const override;
|
2010-06-18 23:09:54 +00:00
|
|
|
|
2010-06-23 23:00:16 +00:00
|
|
|
/// areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler to
|
|
|
|
/// determine if two loads are loading from the same base address. It should
|
|
|
|
/// only return true if the base pointers are the same and the only
|
|
|
|
/// differences between the two addresses is the offset. It also returns the
|
|
|
|
/// offsets by reference.
|
2014-03-10 02:09:33 +00:00
|
|
|
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1,
|
|
|
|
int64_t &Offset2) const override;
|
2010-06-23 23:00:16 +00:00
|
|
|
|
|
|
|
/// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
|
2011-06-13 22:54:22 +00:00
|
|
|
/// determine (in conjunction with areLoadsFromSameBasePtr) if two loads
|
|
|
|
/// should be scheduled togther. On some targets if two loads are loading from
|
2010-06-23 23:00:16 +00:00
|
|
|
/// addresses in the same cache line, it's better if they are scheduled
|
|
|
|
/// together. This function takes two integers that represent the load offsets
|
|
|
|
/// from the common base address. It returns true if it decides it's desirable
|
|
|
|
/// to schedule the two loads together. "NumLoads" is the number of loads that
|
|
|
|
/// have already been scheduled after Load1.
|
2014-03-10 02:09:33 +00:00
|
|
|
bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
|
|
|
|
int64_t Offset1, int64_t Offset2,
|
|
|
|
unsigned NumLoads) const override;
|
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
bool isSchedulingBoundary(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
const MachineBasicBlock *MBB,
|
|
|
|
const MachineFunction &MF) const override;
|
|
|
|
|
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &MBB,
|
|
|
|
unsigned NumCycles, unsigned ExtraPredCycles,
|
2015-09-10 23:10:42 +00:00
|
|
|
BranchProbability Probability) const override;
|
2014-03-10 02:09:33 +00:00
|
|
|
|
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &TMBB, unsigned NumT,
|
|
|
|
unsigned ExtraT, MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumF, unsigned ExtraF,
|
2015-09-10 23:10:42 +00:00
|
|
|
BranchProbability Probability) const override;
|
2014-03-10 02:09:33 +00:00
|
|
|
|
|
|
|
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
2015-09-10 23:10:42 +00:00
|
|
|
BranchProbability Probability) const override {
|
2011-04-13 06:39:16 +00:00
|
|
|
return NumCycles == 1;
|
2010-06-25 22:42:03 +00:00
|
|
|
}
|
2010-08-06 01:32:48 +00:00
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
bool isProfitableToUnpredicate(MachineBasicBlock &TMBB,
|
|
|
|
MachineBasicBlock &FMBB) const override;
|
2012-09-29 21:43:49 +00:00
|
|
|
|
2012-06-29 21:33:59 +00:00
|
|
|
/// analyzeCompare - For a comparison instruction, return the source registers
|
|
|
|
/// in SrcReg and SrcReg2 if having two register operands, and the value it
|
|
|
|
/// compares against in CmpValue. Return true if the comparison instruction
|
|
|
|
/// can be analyzed.
|
2016-06-30 00:01:54 +00:00
|
|
|
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned &SrcReg2, int &CmpMask,
|
|
|
|
int &CmpValue) const override;
|
2012-06-29 21:33:59 +00:00
|
|
|
|
|
|
|
/// optimizeCompareInstr - Convert the instruction to set the zero flag so
|
|
|
|
/// that we can remove a "comparison with zero"; Remove a redundant CMP
|
|
|
|
/// instruction if the flags can be updated in the same way by an earlier
|
|
|
|
/// instruction such as SUB.
|
2016-06-30 00:01:54 +00:00
|
|
|
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg,
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned SrcReg2, int CmpMask, int CmpValue,
|
|
|
|
const MachineRegisterInfo *MRI) const override;
|
2010-09-09 18:18:55 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
bool analyzeSelect(const MachineInstr &MI,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond, unsigned &TrueOp,
|
|
|
|
unsigned &FalseOp, bool &Optimizable) const override;
|
2012-08-16 23:14:20 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
MachineInstr *optimizeSelect(MachineInstr &MI,
|
2015-01-13 07:07:13 +00:00
|
|
|
SmallPtrSetImpl<MachineInstr *> &SeenMIs,
|
|
|
|
bool) const override;
|
2012-08-16 23:14:20 +00:00
|
|
|
|
2010-11-17 20:13:28 +00:00
|
|
|
/// FoldImmediate - 'Reg' is known to be defined by a move immediate
|
|
|
|
/// instruction, try to fold the immediate into the use instruction.
|
2016-06-30 00:01:54 +00:00
|
|
|
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg,
|
|
|
|
MachineRegisterInfo *MRI) const override;
|
2010-11-17 20:13:28 +00:00
|
|
|
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned getNumMicroOps(const InstrItineraryData *ItinData,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &MI) const override;
|
2010-10-06 06:27:31 +00:00
|
|
|
|
|
|
|
int getOperandLatency(const InstrItineraryData *ItinData,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr &UseMI,
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned UseIdx) const override;
|
2010-10-06 06:27:31 +00:00
|
|
|
int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
SDNode *DefNode, unsigned DefIdx,
|
2014-03-10 02:09:33 +00:00
|
|
|
SDNode *UseNode, unsigned UseIdx) const override;
|
2011-09-27 22:57:21 +00:00
|
|
|
|
|
|
|
/// VFP/NEON execution domains.
|
|
|
|
std::pair<uint16_t, uint16_t>
|
2016-06-30 00:01:54 +00:00
|
|
|
getExecutionDomain(const MachineInstr &MI) const override;
|
|
|
|
void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override;
|
2011-09-27 22:57:21 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned
|
|
|
|
getPartialRegUpdateClearance(const MachineInstr &, unsigned,
|
|
|
|
const TargetRegisterInfo *) const override;
|
|
|
|
void breakPartialRegDependency(MachineInstr &, unsigned,
|
2014-03-10 02:09:33 +00:00
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2014-06-05 19:29:43 +00:00
|
|
|
|
2012-09-14 18:48:46 +00:00
|
|
|
/// Get the number of addresses by LDM or VLDM or zero for unknown.
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned getNumLDMAddresses(const MachineInstr &MI) const;
|
2012-09-14 18:48:46 +00:00
|
|
|
|
2018-08-22 20:34:06 +00:00
|
|
|
std::pair<unsigned, unsigned>
|
|
|
|
decomposeMachineOperandsTargetFlags(unsigned TF) const override;
|
|
|
|
ArrayRef<std::pair<unsigned, const char *>>
|
|
|
|
getSerializableDirectMachineOperandTargetFlags() const override;
|
|
|
|
ArrayRef<std::pair<unsigned, const char *>>
|
|
|
|
getSerializableBitmaskMachineOperandTargetFlags() const override;
|
|
|
|
|
2010-10-06 06:27:31 +00:00
|
|
|
private:
|
2016-06-30 00:01:54 +00:00
|
|
|
unsigned getInstBundleLength(const MachineInstr &MI) const;
|
2011-12-14 02:11:42 +00:00
|
|
|
|
2010-10-07 23:12:15 +00:00
|
|
|
int getVLDMDefCycle(const InstrItineraryData *ItinData,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &DefMCID,
|
2010-10-07 23:12:15 +00:00
|
|
|
unsigned DefClass,
|
|
|
|
unsigned DefIdx, unsigned DefAlign) const;
|
|
|
|
int getLDMDefCycle(const InstrItineraryData *ItinData,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &DefMCID,
|
2010-10-07 23:12:15 +00:00
|
|
|
unsigned DefClass,
|
|
|
|
unsigned DefIdx, unsigned DefAlign) const;
|
|
|
|
int getVSTMUseCycle(const InstrItineraryData *ItinData,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &UseMCID,
|
2010-10-07 23:12:15 +00:00
|
|
|
unsigned UseClass,
|
|
|
|
unsigned UseIdx, unsigned UseAlign) const;
|
|
|
|
int getSTMUseCycle(const InstrItineraryData *ItinData,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &UseMCID,
|
2010-10-07 23:12:15 +00:00
|
|
|
unsigned UseClass,
|
|
|
|
unsigned UseIdx, unsigned UseAlign) const;
|
2010-10-06 06:27:31 +00:00
|
|
|
int getOperandLatency(const InstrItineraryData *ItinData,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &DefMCID,
|
2010-10-06 06:27:31 +00:00
|
|
|
unsigned DefIdx, unsigned DefAlign,
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &UseMCID,
|
2010-10-06 06:27:31 +00:00
|
|
|
unsigned UseIdx, unsigned UseAlign) const;
|
2010-10-19 18:58:51 +00:00
|
|
|
|
2016-06-30 00:01:54 +00:00
|
|
|
int getOperandLatencyImpl(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr &DefMI, unsigned DefIdx,
|
|
|
|
const MCInstrDesc &DefMCID, unsigned DefAdj,
|
|
|
|
const MachineOperand &DefMO, unsigned Reg,
|
|
|
|
const MachineInstr &UseMI, unsigned UseIdx,
|
|
|
|
const MCInstrDesc &UseMCID, unsigned UseAdj) const;
|
|
|
|
|
2016-02-23 02:46:52 +00:00
|
|
|
unsigned getPredicationCost(const MachineInstr &MI) const override;
|
2013-09-30 15:28:56 +00:00
|
|
|
|
2012-06-05 21:11:27 +00:00
|
|
|
unsigned getInstrLatency(const InstrItineraryData *ItinData,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &MI,
|
2014-04-28 04:05:08 +00:00
|
|
|
unsigned *PredCost = nullptr) const override;
|
2010-11-03 00:45:17 +00:00
|
|
|
|
|
|
|
int getInstrLatency(const InstrItineraryData *ItinData,
|
2014-03-10 02:09:33 +00:00
|
|
|
SDNode *Node) const override;
|
2010-11-03 00:45:17 +00:00
|
|
|
|
2015-06-13 03:42:11 +00:00
|
|
|
bool hasHighOperandLatency(const TargetSchedModel &SchedModel,
|
2010-10-19 18:58:51 +00:00
|
|
|
const MachineRegisterInfo *MRI,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr &UseMI,
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned UseIdx) const override;
|
2015-06-13 03:42:11 +00:00
|
|
|
bool hasLowDefLatency(const TargetSchedModel &SchedModel,
|
2016-06-30 00:01:54 +00:00
|
|
|
const MachineInstr &DefMI,
|
2014-03-10 02:09:33 +00:00
|
|
|
unsigned DefIdx) const override;
|
2010-12-05 22:04:16 +00:00
|
|
|
|
2011-09-21 02:20:46 +00:00
|
|
|
/// verifyInstruction - Perform target specific instruction verification.
|
2016-06-30 00:01:54 +00:00
|
|
|
bool verifyInstruction(const MachineInstr &MI,
|
2014-03-10 02:09:33 +00:00
|
|
|
StringRef &ErrInfo) const override;
|
2011-09-21 02:20:46 +00:00
|
|
|
|
2016-06-28 15:18:26 +00:00
|
|
|
virtual void expandLoadStackGuard(MachineBasicBlock::iterator MI) const = 0;
|
2014-07-25 19:31:34 +00:00
|
|
|
|
2015-10-05 14:49:54 +00:00
|
|
|
void expandMEMCPY(MachineBasicBlock::iterator) const;
|
|
|
|
|
[ARM] Comply with rules on ARMv8-A thumb mode partial deprecation of IT.
Summary:
When identifing instructions that can be folded into a MOVCC instruction,
checking for a predicate operand is not enough, also need to check for
thumb2 function, with restrict-IT, is the machine instruction eligible for
ARMv8 IT or not.
Notes in ARMv8-A Architecture Reference Manual, section "Partial deprecation of IT"
https://usermanual.wiki/Pdf/ARM20Architecture20Reference20ManualARMv8.1667877052.pdf
"ARMv8-A deprecates some uses of the T32 IT instruction. All uses of IT that apply to
instructions other than a single subsequent 16-bit instruction from a restricted set
are deprecated, as are explicit references to the PC within that single 16-bit
instruction. This permits the non-deprecated forms of IT and subsequent instructions
to be treated as a single 32-bit conditional instruction."
Reviewers: efriedma, lebedev.ri, t.p.northover, jmolloy, aemerson, compnerd, stoklund, ostannard
Reviewed By: ostannard
Subscribers: ostannard, javed.absar, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63474
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363739 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-18 20:55:09 +00:00
|
|
|
/// Identify instructions that can be folded into a MOVCC instruction, and
|
|
|
|
/// return the defining instruction.
|
|
|
|
MachineInstr *canFoldIntoMOVCC(unsigned Reg, const MachineRegisterInfo &MRI,
|
|
|
|
const TargetInstrInfo *TII) const;
|
|
|
|
|
2010-12-05 22:04:16 +00:00
|
|
|
private:
|
|
|
|
/// Modeling special VFP / NEON fp MLA / MLS hazards.
|
|
|
|
|
|
|
|
/// MLxEntryMap - Map fp MLA / MLS to the corresponding entry in the internal
|
|
|
|
/// MLx table.
|
|
|
|
DenseMap<unsigned, unsigned> MLxEntryMap;
|
|
|
|
|
|
|
|
/// MLxHazardOpcodes - Set of add / sub and multiply opcodes that would cause
|
|
|
|
/// stalls when scheduled together with fp MLA / MLS opcodes.
|
|
|
|
SmallSet<unsigned, 16> MLxHazardOpcodes;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// isFpMLxInstruction - Return true if the specified opcode is a fp MLA / MLS
|
|
|
|
/// instruction.
|
|
|
|
bool isFpMLxInstruction(unsigned Opcode) const {
|
|
|
|
return MLxEntryMap.count(Opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// isFpMLxInstruction - This version also returns the multiply opcode and the
|
|
|
|
/// addition / subtraction opcode to expand to. Return true for 'HasLane' for
|
|
|
|
/// the MLX instructions with an extra lane operand.
|
|
|
|
bool isFpMLxInstruction(unsigned Opcode, unsigned &MulOpc,
|
|
|
|
unsigned &AddSubOpc, bool &NegAcc,
|
|
|
|
bool &HasLane) const;
|
|
|
|
|
|
|
|
/// canCauseFpMLxStall - Return true if an instruction of the specified opcode
|
|
|
|
/// will cause stalls when scheduled after (within 4-cycle window) a fp
|
|
|
|
/// MLA / MLS instruction.
|
|
|
|
bool canCauseFpMLxStall(unsigned Opcode) const {
|
|
|
|
return MLxHazardOpcodes.count(Opcode);
|
|
|
|
}
|
2013-04-05 04:42:00 +00:00
|
|
|
|
|
|
|
/// Returns true if the instruction has a shift by immediate that can be
|
|
|
|
/// executed in one cycle less.
|
|
|
|
bool isSwiftFastImmShift(const MachineInstr *MI) const;
|
2017-04-19 03:12:05 +00:00
|
|
|
|
|
|
|
/// Returns predicate register associated with the given frame instruction.
|
|
|
|
unsigned getFramePred(const MachineInstr &MI) const {
|
|
|
|
assert(isFrameInstr(MI));
|
2017-05-09 13:35:13 +00:00
|
|
|
// Operands of ADJCALLSTACKDOWN/ADJCALLSTACKUP:
|
|
|
|
// - argument declared in the pattern:
|
2017-04-19 03:12:05 +00:00
|
|
|
// 0 - frame size
|
2017-05-09 13:35:13 +00:00
|
|
|
// 1 - arg of CALLSEQ_START/CALLSEQ_END
|
|
|
|
// 2 - predicate code (like ARMCC::AL)
|
2017-04-19 03:12:05 +00:00
|
|
|
// - added by predOps:
|
|
|
|
// 3 - predicate reg
|
|
|
|
return MI.getOperand(3).getReg();
|
|
|
|
}
|
2009-07-28 05:48:47 +00:00
|
|
|
};
|
2009-07-27 18:20:05 +00:00
|
|
|
|
2017-01-13 09:37:56 +00:00
|
|
|
/// Get the operands corresponding to the given \p Pred value. By default, the
|
|
|
|
/// predicate register is assumed to be 0 (no register), but you can pass in a
|
|
|
|
/// \p PredReg if that is not the case.
|
|
|
|
static inline std::array<MachineOperand, 2> predOps(ARMCC::CondCodes Pred,
|
|
|
|
unsigned PredReg = 0) {
|
|
|
|
return {{MachineOperand::CreateImm(static_cast<int64_t>(Pred)),
|
2017-01-31 00:56:17 +00:00
|
|
|
MachineOperand::CreateReg(PredReg, false)}};
|
2009-07-28 05:48:47 +00:00
|
|
|
}
|
2009-07-27 18:20:05 +00:00
|
|
|
|
2017-01-13 10:18:01 +00:00
|
|
|
/// Get the operand corresponding to the conditional code result. By default,
|
|
|
|
/// this is 0 (no register).
|
|
|
|
static inline MachineOperand condCodeOp(unsigned CCReg = 0) {
|
2017-01-31 00:56:17 +00:00
|
|
|
return MachineOperand::CreateReg(CCReg, false);
|
2009-07-28 05:48:47 +00:00
|
|
|
}
|
2009-07-27 18:25:24 +00:00
|
|
|
|
2017-01-13 10:37:37 +00:00
|
|
|
/// Get the operand corresponding to the conditional code result for Thumb1.
|
|
|
|
/// This operand will always refer to CPSR and it will have the Define flag set.
|
|
|
|
/// You can optionally set the Dead flag by means of \p isDead.
|
|
|
|
static inline MachineOperand t1CondCodeOp(bool isDead = false) {
|
|
|
|
return MachineOperand::CreateReg(ARM::CPSR,
|
|
|
|
/*Define*/ true, /*Implicit*/ false,
|
|
|
|
/*Kill*/ false, isDead);
|
2009-08-15 07:59:10 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:48:47 +00:00
|
|
|
static inline
|
|
|
|
bool isUncondBranchOpcode(int Opc) {
|
|
|
|
return Opc == ARM::B || Opc == ARM::tB || Opc == ARM::t2B;
|
2009-07-08 16:09:28 +00:00
|
|
|
}
|
|
|
|
|
[ARM] Set up infrastructure for MVE vector instructions.
This commit prepares the way to start adding the main collection of
MVE instructions, which operate on the 128-bit vector registers.
The most obvious thing that's needed, and the simplest, is to add the
MQPR register class, which is like the existing QPR except that it has
fewer registers in it.
The more complicated part: MVE defines a system of vector predication,
in which instructions operating on 128-bit vector registers can be
constrained to operate on only a subset of the lanes, using a system
of prefix instructions similar to the existing Thumb IT, in that you
have one prefix instruction which designates up to 4 following
instructions as subject to predication, and within that sequence, the
predicate can be inverted by means of T/E suffixes ('Then' / 'Else').
To support instructions of this type, we've added two new Tablegen
classes `vpred_n` and `vpred_r` for standard clusters of MC operands
to add to a predicated instruction. Both include a flag indicating how
the instruction is predicated at all (options are T, E and 'not
predicated'), and an input register field for the register controlling
the set of active lanes. They differ from each other in that `vpred_r`
also includes an input operand for the previous value of the output
register, for instructions that leave inactive lanes unchanged.
`vpred_n` lacks that extra operand; it will be used for instructions
that don't preserve inactive lanes in their output register (either
because inactive lanes are zeroed, as the MVE load instructions do, or
because the output register isn't a vector at all).
This commit also adds the family of prefix instructions themselves
(VPT / VPST), and all the machinery needed to work with them in
assembly and disassembly (e.g. generating the 't' and 'e' mnemonic
suffixes on disassembled instructions within a predicated block)
I've added a couple of demo instructions that derive from the new
Tablegen base classes and use those two operand clusters. The bulk of
the vector instructions will come in followup commits small enough to
be manageable. (One exception is that I've added the full version of
`isMnemonicVPTPredicable` in the AsmParser, because it seemed
pointless to carefully split it up.)
Reviewers: dmgreen, samparker, SjoerdMeijer, t.p.northover
Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62669
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363258 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-13 13:11:13 +00:00
|
|
|
static inline bool isVPTOpcode(int Opc) {
|
2019-06-18 15:05:42 +00:00
|
|
|
return Opc == ARM::MVE_VPTv16i8 || Opc == ARM::MVE_VPTv16u8 ||
|
|
|
|
Opc == ARM::MVE_VPTv16s8 || Opc == ARM::MVE_VPTv8i16 ||
|
|
|
|
Opc == ARM::MVE_VPTv8u16 || Opc == ARM::MVE_VPTv8s16 ||
|
|
|
|
Opc == ARM::MVE_VPTv4i32 || Opc == ARM::MVE_VPTv4u32 ||
|
|
|
|
Opc == ARM::MVE_VPTv4s32 || Opc == ARM::MVE_VPTv4f32 ||
|
|
|
|
Opc == ARM::MVE_VPTv8f16 || Opc == ARM::MVE_VPTv16i8r ||
|
|
|
|
Opc == ARM::MVE_VPTv16u8r || Opc == ARM::MVE_VPTv16s8r ||
|
|
|
|
Opc == ARM::MVE_VPTv8i16r || Opc == ARM::MVE_VPTv8u16r ||
|
|
|
|
Opc == ARM::MVE_VPTv8s16r || Opc == ARM::MVE_VPTv4i32r ||
|
|
|
|
Opc == ARM::MVE_VPTv4u32r || Opc == ARM::MVE_VPTv4s32r ||
|
|
|
|
Opc == ARM::MVE_VPTv4f32r || Opc == ARM::MVE_VPTv8f16r ||
|
|
|
|
Opc == ARM::MVE_VPST;
|
[ARM] Set up infrastructure for MVE vector instructions.
This commit prepares the way to start adding the main collection of
MVE instructions, which operate on the 128-bit vector registers.
The most obvious thing that's needed, and the simplest, is to add the
MQPR register class, which is like the existing QPR except that it has
fewer registers in it.
The more complicated part: MVE defines a system of vector predication,
in which instructions operating on 128-bit vector registers can be
constrained to operate on only a subset of the lanes, using a system
of prefix instructions similar to the existing Thumb IT, in that you
have one prefix instruction which designates up to 4 following
instructions as subject to predication, and within that sequence, the
predicate can be inverted by means of T/E suffixes ('Then' / 'Else').
To support instructions of this type, we've added two new Tablegen
classes `vpred_n` and `vpred_r` for standard clusters of MC operands
to add to a predicated instruction. Both include a flag indicating how
the instruction is predicated at all (options are T, E and 'not
predicated'), and an input register field for the register controlling
the set of active lanes. They differ from each other in that `vpred_r`
also includes an input operand for the previous value of the output
register, for instructions that leave inactive lanes unchanged.
`vpred_n` lacks that extra operand; it will be used for instructions
that don't preserve inactive lanes in their output register (either
because inactive lanes are zeroed, as the MVE load instructions do, or
because the output register isn't a vector at all).
This commit also adds the family of prefix instructions themselves
(VPT / VPST), and all the machinery needed to work with them in
assembly and disassembly (e.g. generating the 't' and 'e' mnemonic
suffixes on disassembled instructions within a predicated block)
I've added a couple of demo instructions that derive from the new
Tablegen base classes and use those two operand clusters. The bulk of
the vector instructions will come in followup commits small enough to
be manageable. (One exception is that I've added the full version of
`isMnemonicVPTPredicable` in the AsmParser, because it seemed
pointless to carefully split it up.)
Reviewers: dmgreen, samparker, SjoerdMeijer, t.p.northover
Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62669
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363258 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-13 13:11:13 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:48:47 +00:00
|
|
|
static inline
|
|
|
|
bool isCondBranchOpcode(int Opc) {
|
|
|
|
return Opc == ARM::Bcc || Opc == ARM::tBcc || Opc == ARM::t2Bcc;
|
|
|
|
}
|
|
|
|
|
2017-11-15 12:02:55 +00:00
|
|
|
static inline bool isJumpTableBranchOpcode(int Opc) {
|
|
|
|
return Opc == ARM::BR_JTr || Opc == ARM::BR_JTm_i12 ||
|
|
|
|
Opc == ARM::BR_JTm_rs || Opc == ARM::BR_JTadd || Opc == ARM::tBR_JTr ||
|
|
|
|
Opc == ARM::t2BR_JT;
|
2009-07-28 05:48:47 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 18:26:41 +00:00
|
|
|
static inline
|
|
|
|
bool isIndirectBranchOpcode(int Opc) {
|
2010-11-30 00:48:15 +00:00
|
|
|
return Opc == ARM::BX || Opc == ARM::MOVPCRX || Opc == ARM::tBRIND;
|
2009-10-28 18:26:41 +00:00
|
|
|
}
|
|
|
|
|
2013-11-08 17:18:07 +00:00
|
|
|
static inline bool isPopOpcode(int Opc) {
|
|
|
|
return Opc == ARM::tPOP_RET || Opc == ARM::LDMIA_RET ||
|
|
|
|
Opc == ARM::t2LDMIA_RET || Opc == ARM::tPOP || Opc == ARM::LDMIA_UPD ||
|
|
|
|
Opc == ARM::t2LDMIA_UPD || Opc == ARM::VLDMDIA_UPD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool isPushOpcode(int Opc) {
|
|
|
|
return Opc == ARM::tPUSH || Opc == ARM::t2STMDB_UPD ||
|
|
|
|
Opc == ARM::STMDB_UPD || Opc == ARM::VSTMDDB_UPD;
|
|
|
|
}
|
|
|
|
|
2009-08-08 03:20:32 +00:00
|
|
|
/// getInstrPredicate - If instruction is predicated, returns its predicate
|
|
|
|
/// condition, otherwise returns AL. It also returns the condition code
|
|
|
|
/// register by reference.
|
2016-02-23 02:46:52 +00:00
|
|
|
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, unsigned &PredReg);
|
2009-08-08 03:20:32 +00:00
|
|
|
|
2015-05-18 20:27:55 +00:00
|
|
|
unsigned getMatchingCondBranchOpcode(unsigned Opc);
|
2009-07-28 05:48:47 +00:00
|
|
|
|
2011-09-21 02:20:46 +00:00
|
|
|
/// Map pseudo instructions that imply an 'S' bit onto real opcodes. Whether
|
|
|
|
/// the instruction is encoded with an 'S' bit is determined by the optional
|
|
|
|
/// CPSR def operand.
|
|
|
|
unsigned convertAddSubFlagsOpcode(unsigned OldOpc);
|
|
|
|
|
2009-07-28 05:48:47 +00:00
|
|
|
/// emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of
|
|
|
|
/// instructions to materializea destreg = basereg + immediate in ARM / Thumb2
|
|
|
|
/// code.
|
|
|
|
void emitARMRegPlusImmediate(MachineBasicBlock &MBB,
|
2016-06-12 15:39:02 +00:00
|
|
|
MachineBasicBlock::iterator &MBBI,
|
|
|
|
const DebugLoc &dl, unsigned DestReg,
|
|
|
|
unsigned BaseReg, int NumBytes,
|
2009-07-28 05:48:47 +00:00
|
|
|
ARMCC::CondCodes Pred, unsigned PredReg,
|
2011-03-05 18:43:32 +00:00
|
|
|
const ARMBaseInstrInfo &TII, unsigned MIFlags = 0);
|
2009-07-28 05:48:47 +00:00
|
|
|
|
|
|
|
void emitT2RegPlusImmediate(MachineBasicBlock &MBB,
|
2016-06-12 15:39:02 +00:00
|
|
|
MachineBasicBlock::iterator &MBBI,
|
|
|
|
const DebugLoc &dl, unsigned DestReg,
|
|
|
|
unsigned BaseReg, int NumBytes,
|
2009-07-28 05:48:47 +00:00
|
|
|
ARMCC::CondCodes Pred, unsigned PredReg,
|
2011-03-05 18:43:32 +00:00
|
|
|
const ARMBaseInstrInfo &TII, unsigned MIFlags = 0);
|
2010-10-19 23:27:08 +00:00
|
|
|
void emitThumbRegPlusImmediate(MachineBasicBlock &MBB,
|
2016-06-12 15:39:02 +00:00
|
|
|
MachineBasicBlock::iterator &MBBI,
|
|
|
|
const DebugLoc &dl, unsigned DestReg,
|
|
|
|
unsigned BaseReg, int NumBytes,
|
|
|
|
const TargetInstrInfo &TII,
|
|
|
|
const ARMBaseRegisterInfo &MRI,
|
2011-03-05 18:43:32 +00:00
|
|
|
unsigned MIFlags = 0);
|
2009-07-28 05:48:47 +00:00
|
|
|
|
2013-11-08 17:18:07 +00:00
|
|
|
/// Tries to add registers to the reglist of a given base-updating
|
|
|
|
/// push/pop instruction to adjust the stack by an additional
|
|
|
|
/// NumBytes. This can save a few bytes per function in code-size, but
|
|
|
|
/// obviously generates more memory traffic. As such, it only takes
|
|
|
|
/// effect in functions being optimised for size.
|
2013-12-02 14:46:26 +00:00
|
|
|
bool tryFoldSPUpdateIntoPushPop(const ARMSubtarget &Subtarget,
|
|
|
|
MachineFunction &MF, MachineInstr *MI,
|
2013-11-08 17:18:07 +00:00
|
|
|
unsigned NumBytes);
|
2009-07-28 05:48:47 +00:00
|
|
|
|
2009-08-11 15:33:49 +00:00
|
|
|
/// rewriteARMFrameIndex / rewriteT2FrameIndex -
|
2009-08-27 01:23:50 +00:00
|
|
|
/// Rewrite MI to access 'Offset' bytes from the FP. Return false if the
|
|
|
|
/// offset could not be handled directly in MI, and return the left-over
|
|
|
|
/// portion by reference.
|
|
|
|
bool rewriteARMFrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
|
|
|
|
unsigned FrameReg, int &Offset,
|
|
|
|
const ARMBaseInstrInfo &TII);
|
|
|
|
|
|
|
|
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
|
|
|
|
unsigned FrameReg, int &Offset,
|
|
|
|
const ARMBaseInstrInfo &TII);
|
2009-07-28 05:48:47 +00:00
|
|
|
|
2019-04-23 12:11:26 +00:00
|
|
|
/// Return true if Reg is defd between From and To
|
|
|
|
bool registerDefinedBetween(unsigned Reg, MachineBasicBlock::iterator From,
|
|
|
|
MachineBasicBlock::iterator To,
|
|
|
|
const TargetRegisterInfo *TRI);
|
|
|
|
|
|
|
|
/// Search backwards from a tBcc to find a tCMPi8 against 0, meaning
|
|
|
|
/// we can convert them to a tCBZ or tCBNZ. Return nullptr if not found.
|
|
|
|
MachineInstr *findCMPToFoldIntoCBZ(MachineInstr *Br,
|
|
|
|
const TargetRegisterInfo *TRI);
|
|
|
|
|
[ARM] Code-generation infrastructure for MVE.
This provides the low-level support to start using MVE vector types in
LLVM IR, loading and storing them, passing them to __asm__ statements
containing hand-written MVE vector instructions, and *if* you have the
hard-float ABI turned on, using them as function parameters.
(In the soft-float ABI, vector types are passed in integer registers,
and combining all those 32-bit integers into a q-reg requires support
for selection DAG nodes like insert_vector_elt and build_vector which
aren't implemented yet for MVE. In fact I've also had to add
`arm_aapcs_vfpcc` to a couple of existing tests to avoid that
problem.)
Specifically, this commit adds support for:
* spills, reloads and register moves for MVE vector registers
* ditto for the VPT predication mask that lives in VPR.P0
* make all the MVE vector types legal in ISel, and provide selection
DAG patterns for BITCAST, LOAD and STORE
* make loads and stores of scalar FP types conditional on
`hasFPRegs()` rather than `hasVFP2Base()`. As a result a few
existing tests needed their llc command lines updating to use
`-mattr=-fpregs` as their method of turning off all hardware FP
support.
Reviewers: dmgreen, samparker, SjoerdMeijer
Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60708
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364329 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-25 16:48:46 +00:00
|
|
|
void addUnpredicatedMveVpredNOp(MachineInstrBuilder &MIB);
|
|
|
|
void addUnpredicatedMveVpredROp(MachineInstrBuilder &MIB, unsigned DestReg);
|
|
|
|
|
|
|
|
void addPredicatedMveVpredNOp(MachineInstrBuilder &MIB, unsigned Cond);
|
|
|
|
void addPredicatedMveVpredROp(MachineInstrBuilder &MIB, unsigned Cond,
|
|
|
|
unsigned Inactive);
|
|
|
|
|
2017-01-31 00:56:17 +00:00
|
|
|
} // end namespace llvm
|
2009-07-28 05:48:47 +00:00
|
|
|
|
2017-01-31 00:56:17 +00:00
|
|
|
#endif // LLVM_LIB_TARGET_ARM_ARMBASEINSTRINFO_H
|