[x86] fix assert with horizontal math + broadcast of vector (PR43402)
[llvm-core.git] / lib / Target / AVR / AVRISelLowering.h
blobed2d0835903c4c5b727275e730e68ad2e25ab763
1 //===-- AVRISelLowering.h - AVR DAG Lowering Interface ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the interfaces that AVR uses to lower LLVM code into a
10 // selection DAG.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_AVR_ISEL_LOWERING_H
15 #define LLVM_AVR_ISEL_LOWERING_H
17 #include "llvm/CodeGen/CallingConvLower.h"
18 #include "llvm/CodeGen/TargetLowering.h"
20 namespace llvm {
22 namespace AVRISD {
24 /// AVR Specific DAG Nodes
25 enum NodeType {
26 /// Start the numbering where the builtin ops leave off.
27 FIRST_NUMBER = ISD::BUILTIN_OP_END,
28 /// Return from subroutine.
29 RET_FLAG,
30 /// Return from ISR.
31 RETI_FLAG,
32 /// Represents an abstract call instruction,
33 /// which includes a bunch of information.
34 CALL,
35 /// A wrapper node for TargetConstantPool,
36 /// TargetExternalSymbol, and TargetGlobalAddress.
37 WRAPPER,
38 LSL, ///< Logical shift left.
39 LSR, ///< Logical shift right.
40 ASR, ///< Arithmetic shift right.
41 ROR, ///< Bit rotate right.
42 ROL, ///< Bit rotate left.
43 LSLLOOP, ///< A loop of single logical shift left instructions.
44 LSRLOOP, ///< A loop of single logical shift right instructions.
45 ROLLOOP, ///< A loop of single left bit rotate instructions.
46 RORLOOP, ///< A loop of single right bit rotate instructions.
47 ASRLOOP, ///< A loop of single arithmetic shift right instructions.
48 /// AVR conditional branches. Operand 0 is the chain operand, operand 1
49 /// is the block to branch if condition is true, operand 2 is the
50 /// condition code, and operand 3 is the flag operand produced by a CMP
51 /// or TEST instruction.
52 BRCOND,
53 /// Compare instruction.
54 CMP,
55 /// Compare with carry instruction.
56 CMPC,
57 /// Test for zero or minus instruction.
58 TST,
59 /// Operand 0 and operand 1 are selection variable, operand 2
60 /// is condition code and operand 3 is flag operand.
61 SELECT_CC
64 } // end of namespace AVRISD
66 class AVRSubtarget;
67 class AVRTargetMachine;
69 /// Performs target lowering for the AVR.
70 class AVRTargetLowering : public TargetLowering {
71 public:
72 explicit AVRTargetLowering(const AVRTargetMachine &TM,
73 const AVRSubtarget &STI);
75 public:
76 MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override {
77 return MVT::i8;
80 MVT::SimpleValueType getCmpLibcallReturnType() const override {
81 return MVT::i8;
84 const char *getTargetNodeName(unsigned Opcode) const override;
86 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
88 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
89 SelectionDAG &DAG) const override;
91 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
92 unsigned AS,
93 Instruction *I = nullptr) const override;
95 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
96 ISD::MemIndexedMode &AM,
97 SelectionDAG &DAG) const override;
99 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
100 SDValue &Offset, ISD::MemIndexedMode &AM,
101 SelectionDAG &DAG) const override;
103 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
105 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
106 EVT VT) const override;
108 MachineBasicBlock *
109 EmitInstrWithCustomInserter(MachineInstr &MI,
110 MachineBasicBlock *MBB) const override;
112 ConstraintType getConstraintType(StringRef Constraint) const override;
114 ConstraintWeight
115 getSingleConstraintMatchWeight(AsmOperandInfo &info,
116 const char *constraint) const override;
118 std::pair<unsigned, const TargetRegisterClass *>
119 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
120 StringRef Constraint, MVT VT) const override;
122 unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override;
124 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
125 std::vector<SDValue> &Ops,
126 SelectionDAG &DAG) const override;
128 unsigned getRegisterByName(const char* RegName, EVT VT,
129 SelectionDAG &DAG) const override;
131 bool shouldSplitFunctionArgumentsAsLittleEndian(const DataLayout &DL)
132 const override {
133 return false;
136 private:
137 SDValue getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, SDValue &AVRcc,
138 SelectionDAG &DAG, SDLoc dl) const;
139 SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;
140 SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
141 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
142 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
143 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
144 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
145 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
146 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
147 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
149 CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC) const;
151 bool CanLowerReturn(CallingConv::ID CallConv,
152 MachineFunction &MF, bool isVarArg,
153 const SmallVectorImpl<ISD::OutputArg> &Outs,
154 LLVMContext &Context) const override;
156 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
157 const SmallVectorImpl<ISD::OutputArg> &Outs,
158 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
159 SelectionDAG &DAG) const override;
160 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
161 bool isVarArg,
162 const SmallVectorImpl<ISD::InputArg> &Ins,
163 const SDLoc &dl, SelectionDAG &DAG,
164 SmallVectorImpl<SDValue> &InVals) const override;
165 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
166 SmallVectorImpl<SDValue> &InVals) const override;
167 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
168 CallingConv::ID CallConv, bool isVarArg,
169 const SmallVectorImpl<ISD::InputArg> &Ins,
170 const SDLoc &dl, SelectionDAG &DAG,
171 SmallVectorImpl<SDValue> &InVals) const;
173 protected:
175 const AVRSubtarget &Subtarget;
177 private:
178 MachineBasicBlock *insertShift(MachineInstr &MI, MachineBasicBlock *BB) const;
179 MachineBasicBlock *insertMul(MachineInstr &MI, MachineBasicBlock *BB) const;
182 } // end namespace llvm
184 #endif // LLVM_AVR_ISEL_LOWERING_H