blob: 8846decd9bf7fef83d0be63274b30e5319c955e5 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===-- ARMISelLowering.h - ARM DAG Lowering Interface ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that ARM uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef ARMISELLOWERING_H
16#define ARMISELLOWERING_H
17
18#include "llvm/Target/TargetLowering.h"
19#include "llvm/CodeGen/SelectionDAG.h"
20#include <vector>
21
22namespace llvm {
23 class ARMConstantPoolValue;
24 class ARMSubtarget;
25
26 namespace ARMISD {
27 // ARM Specific DAG Nodes
28 enum NodeType {
29 // Start the numbering where the builting ops and target ops leave off.
30 FIRST_NUMBER = ISD::BUILTIN_OP_END+ARM::INSTRUCTION_LIST_END,
31
32 Wrapper, // Wrapper - A wrapper node for TargetConstantPool,
33 // TargetExternalSymbol, and TargetGlobalAddress.
Evan Chenga8e29892007-01-19 07:51:42 +000034 WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable
35
36 CALL, // Function call.
37 CALL_NOLINK, // Function call with branch not branch-and-link.
38 tCALL, // Thumb function call.
39 BRCOND, // Conditional branch.
40 BR_JT, // Jumptable branch.
41 RET_FLAG, // Return with a flag operand.
42
43 PIC_ADD, // Add with a PC operand and a PIC label.
44
45 CMP, // ARM compare instructions.
46 CMPFP, // ARM VFP compare instruction, sets FPSCR.
47 CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR.
48 FMSTAT, // ARM fmstat instruction.
49 CMOV, // ARM conditional move instructions.
50 CNEG, // ARM conditional negate instructions.
51
52 FTOSI, // FP to sint within a FP register.
53 FTOUI, // FP to uint within a FP register.
54 SITOF, // sint to FP within a FP register.
55 UITOF, // uint to FP within a FP register.
56
57 MULHILOU, // Lo,Hi = umul LHS, RHS.
58 MULHILOS, // Lo,Hi = smul LHS, RHS.
59
60 SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out.
61 SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out.
62 RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag.
63
64 FMRRD, // double to two gprs.
65 FMDRR // Two gprs to double.
66 };
67 }
68
69 //===----------------------------------------------------------------------===//
Dale Johannesen80dae192007-03-20 00:30:56 +000070 // ARMTargetLowering - ARM Implementation of the TargetLowering interface
Evan Chenga8e29892007-01-19 07:51:42 +000071
72 class ARMTargetLowering : public TargetLowering {
73 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
74 public:
75 ARMTargetLowering(TargetMachine &TM);
76
77 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
78 virtual const char *getTargetNodeName(unsigned Opcode) const;
79
80 virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
81 MachineBasicBlock *MBB);
82
Chris Lattnerc9addb72007-03-30 23:15:24 +000083 /// isLegalAddressingMode - Return true if the addressing mode represented
84 /// by AM is legal for this target, for a load/store of the specified type.
85 virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
86
Evan Chengb01fad62007-03-12 23:30:29 +000087 /// isLegalAddressImmediate - Return true if the integer value can be used
88 /// as the offset of the target addressing mode for load / store of the
89 /// given type.
90 virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const;
91
92 /// isLegalAddressImmediate - Return true if the GlobalValue can be used as
93 /// the offset of the target addressing mode.
Evan Chenga8e29892007-01-19 07:51:42 +000094 virtual bool isLegalAddressImmediate(GlobalValue *GV) const;
95
Evan Chengb01fad62007-03-12 23:30:29 +000096 /// isLegalAddressScale - Return true if the integer value can be used as
97 /// the scale of the target addressing mode for load / store of the given
98 /// type.
99 virtual bool isLegalAddressScale(int64_t S, const Type *Ty) const;
100
Dale Johannesen8e59e162007-03-20 21:54:54 +0000101 /// isLegalAddressScaleAndImm - Return true if S works for
102 /// IsLegalAddressScale and V works for isLegalAddressImmediate _and_
103 /// both can be applied simultaneously to the same instruction.
104 virtual bool isLegalAddressScaleAndImm(int64_t S, int64_t V,
105 const Type *Ty) const;
106
107 /// isLegalAddressScaleAndImm - Return true if S works for
108 /// IsLegalAddressScale and GV works for isLegalAddressImmediate _and_
109 /// both can be applied simultaneously to the same instruction.
Dale Johannesenfa4bce22007-03-21 21:51:52 +0000110 virtual bool isLegalAddressScaleAndImm(int64_t S, GlobalValue *GV,
111 const Type *Ty) const;
Dale Johannesen8e59e162007-03-20 21:54:54 +0000112
Evan Chenga8e29892007-01-19 07:51:42 +0000113 /// getPreIndexedAddressParts - returns true by value, base pointer and
114 /// offset pointer and addressing mode by reference if the node's address
115 /// can be legally represented as pre-indexed load / store address.
116 virtual bool getPreIndexedAddressParts(SDNode *N, SDOperand &Base,
117 SDOperand &Offset,
118 ISD::MemIndexedMode &AM,
119 SelectionDAG &DAG);
120
121 /// getPostIndexedAddressParts - returns true by value, base pointer and
122 /// offset pointer and addressing mode by reference if this node can be
123 /// combined with a load / store to form a post-indexed load / store.
124 virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
125 SDOperand &Base, SDOperand &Offset,
126 ISD::MemIndexedMode &AM,
127 SelectionDAG &DAG);
128
129 virtual void computeMaskedBitsForTargetNode(const SDOperand Op,
130 uint64_t Mask,
131 uint64_t &KnownZero,
132 uint64_t &KnownOne,
133 unsigned Depth) const;
Chris Lattner4234f572007-03-25 02:14:49 +0000134 ConstraintType getConstraintType(const std::string &Constraint) const;
Evan Chenga8e29892007-01-19 07:51:42 +0000135 std::pair<unsigned, const TargetRegisterClass*>
136 getRegForInlineAsmConstraint(const std::string &Constraint,
137 MVT::ValueType VT) const;
138 std::vector<unsigned>
139 getRegClassForInlineAsmConstraint(const std::string &Constraint,
140 MVT::ValueType VT) const;
141 private:
142 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
143 /// make the right decision when generating code for different targets.
144 const ARMSubtarget *Subtarget;
145
146 /// ARMPCLabelIndex - Keep track the number of ARM PC labels created.
147 ///
148 unsigned ARMPCLabelIndex;
149
150 SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG);
151 SDOperand LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG);
152 SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG);
153 SDOperand LowerBR_JT(SDOperand Op, SelectionDAG &DAG);
154 };
155}
156
157#endif // ARMISELLOWERING_H