LLVM  14.0.0git
Macros | Enumerations | Functions
M68kISelLowering.cpp File Reference
#include "M68kISelLowering.h"
#include "M68kCallingConv.h"
#include "M68kMachineFunction.h"
#include "M68kSubtarget.h"
#include "M68kTargetMachine.h"
#include "M68kTargetObjectFile.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include "M68kGenCallingConv.inc"
Include dependency graph for M68kISelLowering.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "M68k-isel"
 

Enumerations

enum  StructReturnType {
  NotStructReturn, RegStructReturn, StackStructReturn, NotStructReturn,
  RegStructReturn, StackStructReturn
}
 

Functions

 STATISTIC (NumTailCalls, "Number of tail calls")
 
static StructReturnType callIsStructReturn (const SmallVectorImpl< ISD::OutputArg > &Outs)
 
static StructReturnType argsAreStructReturn (const SmallVectorImpl< ISD::InputArg > &Ins)
 Determines whether a function uses struct return semantics. More...
 
static SDValue CreateCopyOfByValArgument (SDValue Src, SDValue Dst, SDValue Chain, ISD::ArgFlagsTy Flags, SelectionDAG &DAG, const SDLoc &DL)
 Make a copy of an aggregate at address specified by "Src" to address "Dst" with size and alignment information specified by the specific parameter attribute. More...
 
static bool canGuaranteeTCO (CallingConv::ID CC)
 Return true if the calling convention is one that we can guarantee TCO for. More...
 
static bool mayTailCallThisCC (CallingConv::ID CC)
 Return true if we might ever do TCO for calls with this calling convention. More...
 
static bool shouldGuaranteeTCO (CallingConv::ID CC, bool GuaranteedTailCallOpt)
 Return true if the function is being made into a tailcall target by changing its ABI. More...
 
static bool MatchingStackOffset (SDValue Arg, unsigned Offset, ISD::ArgFlagsTy Flags, MachineFrameInfo &MFI, const MachineRegisterInfo *MRI, const M68kInstrInfo *TII, const CCValAssign &VA)
 Return true if the given stack call argument is already available in the same position (relatively) of the caller's incoming argument stack. More...
 
static SDValue getBitTestCondition (SDValue Src, SDValue BitNo, ISD::CondCode CC, const SDLoc &DL, SelectionDAG &DAG)
 Create a BT (Bit Test) node - Test bit BitNo in Src and set condition according to equal/not-equal condition code CC. More...
 
static SDValue LowerAndToBT (SDValue And, ISD::CondCode CC, const SDLoc &DL, SelectionDAG &DAG)
 Result of 'and' is compared against zero. Change to a BT node if possible. More...
 
static M68k::CondCode TranslateIntegerM68kCC (ISD::CondCode SetCCOpcode)
 
static unsigned TranslateM68kCC (ISD::CondCode SetCCOpcode, const SDLoc &DL, bool IsFP, SDValue &LHS, SDValue &RHS, SelectionDAG &DAG)
 Do a one-to-one translation of a ISD::CondCode to the M68k-specific condition code, returning the condition code and the LHS/RHS of the comparison to make. More...
 
static SDValue LowerTruncateToBT (SDValue Op, ISD::CondCode CC, const SDLoc &DL, SelectionDAG &DAG)
 
static bool hasNonFlagsUse (SDValue Op)
 return true if Op has a use that doesn't just read flags. More...
 
static bool isM68kCCUnsigned (unsigned M68kCC)
 Return true if the condition is an unsigned comparison operation. More...
 
static bool isM68kLogicalCmp (SDValue Op)
 Return true if opcode is a M68k logical comparison. More...
 
static bool isTruncWithZeroHighBitsInput (SDValue V, SelectionDAG &DAG)
 
static bool isAndOrOfSetCCs (SDValue Op, unsigned &Opc)
 Return true if node is an ISD::AND or ISD::OR of two M68k::SETcc nodes each of which has no other use apart from the AND / OR. More...
 
static bool isXor1OfSetCC (SDValue Op)
 Return true if node is an ISD::XOR of a M68kISD::SETCC and 1 and that the SETCC node has a single use. More...
 
static bool isCMOVPseudo (MachineInstr &MI)
 
static bool checkAndUpdateCCRKill (MachineBasicBlock::iterator SelectItr, MachineBasicBlock *BB, const TargetRegisterInfo *TRI)
 
static SDValue getSETCC (M68k::CondCode Cond, SDValue CCR, const SDLoc &dl, SelectionDAG &DAG)
 
static SDValue combineCarryThroughADD (SDValue CCR)
 
static SDValue combineSetCCCCR (SDValue CCR, M68k::CondCode &CC, SelectionDAG &DAG, const M68kSubtarget &Subtarget)
 Optimize a CCR definition used according to the condition code CC into a simpler CCR value, potentially returning a new CC and replacing uses of chain values. More...
 
static SDValue combineM68kSetCC (SDNode *N, SelectionDAG &DAG, const M68kSubtarget &Subtarget)
 
static SDValue combineM68kBrCond (SDNode *N, SelectionDAG &DAG, const M68kSubtarget &Subtarget)
 
static SDValue combineSUBX (SDNode *N, SelectionDAG &DAG)
 
static SDValue combineADDX (SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI)
 

Detailed Description

This file defines the interfaces that M68k uses to lower LLVM code into a selection DAG.

Definition in file M68kISelLowering.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "M68k-isel"

Definition at line 42 of file M68kISelLowering.cpp.

Enumeration Type Documentation

◆ StructReturnType

Enumerator
NotStructReturn 
RegStructReturn 
StackStructReturn 
NotStructReturn 
RegStructReturn 
StackStructReturn 

Definition at line 178 of file M68kISelLowering.cpp.

Function Documentation

◆ argsAreStructReturn()

static StructReturnType argsAreStructReturn ( const SmallVectorImpl< ISD::InputArg > &  Ins)
static

Determines whether a function uses struct return semantics.

Definition at line 195 of file M68kISelLowering.cpp.

References llvm::MipsISD::Ins, llvm::ISD::ArgFlagsTy::isInReg(), llvm::ISD::ArgFlagsTy::isSRet(), NotStructReturn, RegStructReturn, and StackStructReturn.

◆ callIsStructReturn()

static StructReturnType callIsStructReturn ( const SmallVectorImpl< ISD::OutputArg > &  Outs)
static

◆ canGuaranteeTCO()

static bool canGuaranteeTCO ( CallingConv::ID  CC)
static

Return true if the calling convention is one that we can guarantee TCO for.

Definition at line 222 of file M68kISelLowering.cpp.

Referenced by mayTailCallThisCC(), and shouldGuaranteeTCO().

◆ checkAndUpdateCCRKill()

static bool checkAndUpdateCCRKill ( MachineBasicBlock::iterator  SelectItr,
MachineBasicBlock BB,
const TargetRegisterInfo TRI 
)
static

◆ combineADDX()

static SDValue combineADDX ( SDNode N,
SelectionDAG DAG,
TargetLowering::DAGCombinerInfo DCI 
)
static

◆ combineCarryThroughADD()

static SDValue combineCarryThroughADD ( SDValue  CCR)
static

◆ combineM68kBrCond()

static SDValue combineM68kBrCond ( SDNode N,
SelectionDAG DAG,
const M68kSubtarget Subtarget 
)
static

◆ combineM68kSetCC()

static SDValue combineM68kSetCC ( SDNode N,
SelectionDAG DAG,
const M68kSubtarget Subtarget 
)
static

Definition at line 3290 of file M68kISelLowering.cpp.

References combineSetCCCCR(), DL, getSETCC(), and N.

◆ combineSetCCCCR()

static SDValue combineSetCCCCR ( SDValue  CCR,
M68k::CondCode CC,
SelectionDAG DAG,
const M68kSubtarget Subtarget 
)
static

Optimize a CCR definition used according to the condition code CC into a simpler CCR value, potentially returning a new CC and replacing uses of chain values.

Definition at line 3279 of file M68kISelLowering.cpp.

References combineCarryThroughADD(), and llvm::M68k::COND_CS.

Referenced by combineM68kBrCond(), and combineM68kSetCC().

◆ combineSUBX()

static SDValue combineSUBX ( SDNode N,
SelectionDAG DAG 
)
static

◆ CreateCopyOfByValArgument()

static SDValue CreateCopyOfByValArgument ( SDValue  Src,
SDValue  Dst,
SDValue  Chain,
ISD::ArgFlagsTy  Flags,
SelectionDAG DAG,
const SDLoc DL 
)
static

Make a copy of an aggregate at address specified by "Src" to address "Dst" with size and alignment information specified by the specific parameter attribute.

The copy will be passed as a byval function parameter.

Definition at line 210 of file M68kISelLowering.cpp.

References DL, llvm::ISD::ArgFlagsTy::getByValSize(), llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getMemcpy(), llvm::ISD::ArgFlagsTy::getNonZeroByValAlign(), and llvm::MVT::i32.

◆ getBitTestCondition()

static SDValue getBitTestCondition ( SDValue  Src,
SDValue  BitNo,
ISD::CondCode  CC,
const SDLoc DL,
SelectionDAG DAG 
)
static

Create a BT (Bit Test) node - Test bit BitNo in Src and set condition according to equal/not-equal condition code CC.

Definition at line 1414 of file M68kISelLowering.cpp.

References llvm::ISD::ANY_EXTEND, llvm::M68kISD::BT, Cond, llvm::M68k::COND_EQ, llvm::M68k::COND_NE, DL, llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getNode(), llvm::SDValue::getValueType(), llvm::MVT::i16, llvm::MVT::i32, llvm::MVT::i8, llvm::M68kISD::SETCC, and llvm::ISD::SETEQ.

Referenced by LowerAndToBT(), and LowerTruncateToBT().

◆ getSETCC()

static SDValue getSETCC ( M68k::CondCode  Cond,
SDValue  CCR,
const SDLoc dl,
SelectionDAG DAG 
)
static

◆ hasNonFlagsUse()

static bool hasNonFlagsUse ( SDValue  Op)
static

return true if Op has a use that doesn't just read flags.

Definition at line 1610 of file M68kISelLowering.cpp.

References llvm::ISD::BRCOND, llvm::Value::hasOneUse(), llvm::ISD::SELECT, llvm::ISD::SETCC, llvm::ISD::TRUNCATE, and llvm::Value::use_begin().

◆ isAndOrOfSetCCs()

static bool isAndOrOfSetCCs ( SDValue  Op,
unsigned &  Opc 
)
static

Return true if node is an ISD::AND or ISD::OR of two M68k::SETcc nodes each of which has no other use apart from the AND / OR.

Definition at line 2223 of file M68kISelLowering.cpp.

References llvm::ISD::AND, llvm::M68k::IsSETCC(), and llvm::ISD::OR.

◆ isCMOVPseudo()

static bool isCMOVPseudo ( MachineInstr MI)
static

Definition at line 2892 of file M68kISelLowering.cpp.

References MI.

◆ isM68kCCUnsigned()

static bool isM68kCCUnsigned ( unsigned  M68kCC)
static

◆ isM68kLogicalCmp()

static bool isM68kLogicalCmp ( SDValue  Op)
static

◆ isTruncWithZeroHighBitsInput()

static bool isTruncWithZeroHighBitsInput ( SDValue  V,
SelectionDAG DAG 
)
static

◆ isXor1OfSetCC()

static bool isXor1OfSetCC ( SDValue  Op)
static

Return true if node is an ISD::XOR of a M68kISD::SETCC and 1 and that the SETCC node has a single use.

Definition at line 2235 of file M68kISelLowering.cpp.

References llvm::isOneConstant(), llvm::M68kISD::SETCC, and llvm::ISD::XOR.

◆ LowerAndToBT()

static SDValue LowerAndToBT ( SDValue  And,
ISD::CondCode  CC,
const SDLoc DL,
SelectionDAG DAG 
)
static

◆ LowerTruncateToBT()

static SDValue LowerTruncateToBT ( SDValue  Op,
ISD::CondCode  CC,
const SDLoc DL,
SelectionDAG DAG 
)
static

◆ MatchingStackOffset()

static bool MatchingStackOffset ( SDValue  Arg,
unsigned  Offset,
ISD::ArgFlagsTy  Flags,
MachineFrameInfo MFI,
const MachineRegisterInfo MRI,
const M68kInstrInfo TII,
const CCValAssign VA 
)
static

◆ mayTailCallThisCC()

static bool mayTailCallThisCC ( CallingConv::ID  CC)
static

Return true if we might ever do TCO for calls with this calling convention.

Definition at line 225 of file M68kISelLowering.cpp.

References llvm::CallingConv::C, and canGuaranteeTCO().

◆ shouldGuaranteeTCO()

static bool shouldGuaranteeTCO ( CallingConv::ID  CC,
bool  GuaranteedTailCallOpt 
)
static

Return true if the function is being made into a tailcall target by changing its ABI.

Definition at line 237 of file M68kISelLowering.cpp.

References canGuaranteeTCO().

◆ STATISTIC()

STATISTIC ( NumTailCalls  ,
"Number of tail calls  
)

◆ TranslateIntegerM68kCC()

static M68k::CondCode TranslateIntegerM68kCC ( ISD::CondCode  SetCCOpcode)
static

◆ TranslateM68kCC()

static unsigned TranslateM68kCC ( ISD::CondCode  SetCCOpcode,
const SDLoc DL,
bool  IsFP,
SDValue LHS,
SDValue RHS,
SelectionDAG DAG 
)
static