blob: d51b6805e6c62a4201d2c13e3bda56c734a5fb38 [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.
Evan Cheng277f0742007-06-19 21:05:09 +000037 CALL_PRED, // Function call that's predicable.
Evan Chenga8e29892007-01-19 07:51:42 +000038 CALL_NOLINK, // Function call with branch not branch-and-link.
39 tCALL, // Thumb function call.
40 BRCOND, // Conditional branch.
41 BR_JT, // Jumptable branch.
42 RET_FLAG, // Return with a flag operand.
43
44 PIC_ADD, // Add with a PC operand and a PIC label.
45
46 CMP, // ARM compare instructions.
Lauro Ramos Venancio99966632007-04-02 01:30:03 +000047 CMPNZ, // ARM compare that uses only N or Z flags.
Evan Chenga8e29892007-01-19 07:51:42 +000048 CMPFP, // ARM VFP compare instruction, sets FPSCR.
49 CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR.
50 FMSTAT, // ARM fmstat instruction.
51 CMOV, // ARM conditional move instructions.
52 CNEG, // ARM conditional negate instructions.
53
54 FTOSI, // FP to sint within a FP register.
55 FTOUI, // FP to uint within a FP register.
56 SITOF, // sint to FP within a FP register.
57 UITOF, // uint to FP within a FP register.
58
59 MULHILOU, // Lo,Hi = umul LHS, RHS.
60 MULHILOS, // Lo,Hi = smul LHS, RHS.
61
62 SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out.
63 SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out.
64 RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag.
65
66 FMRRD, // double to two gprs.
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000067 FMDRR, // Two gprs to double.
68
69 THREAD_POINTER
Evan Chenga8e29892007-01-19 07:51:42 +000070 };
71 }
72
73 //===----------------------------------------------------------------------===//
Dale Johannesen80dae192007-03-20 00:30:56 +000074 // ARMTargetLowering - ARM Implementation of the TargetLowering interface
Evan Chenga8e29892007-01-19 07:51:42 +000075
76 class ARMTargetLowering : public TargetLowering {
77 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
78 public:
79 ARMTargetLowering(TargetMachine &TM);
80
81 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
82 virtual const char *getTargetNodeName(unsigned Opcode) const;
83
84 virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
85 MachineBasicBlock *MBB);
86
Chris Lattnerc9addb72007-03-30 23:15:24 +000087 /// isLegalAddressingMode - Return true if the addressing mode represented
88 /// by AM is legal for this target, for a load/store of the specified type.
89 virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
90
Evan Chenga8e29892007-01-19 07:51:42 +000091 /// getPreIndexedAddressParts - returns true by value, base pointer and
92 /// offset pointer and addressing mode by reference if the node's address
93 /// can be legally represented as pre-indexed load / store address.
94 virtual bool getPreIndexedAddressParts(SDNode *N, SDOperand &Base,
95 SDOperand &Offset,
96 ISD::MemIndexedMode &AM,
97 SelectionDAG &DAG);
98
99 /// getPostIndexedAddressParts - returns true by value, base pointer and
100 /// offset pointer and addressing mode by reference if this node can be
101 /// combined with a load / store to form a post-indexed load / store.
102 virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
103 SDOperand &Base, SDOperand &Offset,
104 ISD::MemIndexedMode &AM,
105 SelectionDAG &DAG);
106
107 virtual void computeMaskedBitsForTargetNode(const SDOperand Op,
108 uint64_t Mask,
109 uint64_t &KnownZero,
110 uint64_t &KnownOne,
111 unsigned Depth) const;
Chris Lattner4234f572007-03-25 02:14:49 +0000112 ConstraintType getConstraintType(const std::string &Constraint) const;
Evan Chenga8e29892007-01-19 07:51:42 +0000113 std::pair<unsigned, const TargetRegisterClass*>
114 getRegForInlineAsmConstraint(const std::string &Constraint,
115 MVT::ValueType VT) const;
116 std::vector<unsigned>
117 getRegClassForInlineAsmConstraint(const std::string &Constraint,
118 MVT::ValueType VT) const;
119 private:
120 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
121 /// make the right decision when generating code for different targets.
122 const ARMSubtarget *Subtarget;
123
124 /// ARMPCLabelIndex - Keep track the number of ARM PC labels created.
125 ///
126 unsigned ARMPCLabelIndex;
127
128 SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG);
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +0000129 SDOperand LowerGlobalAddressDarwin(SDOperand Op, SelectionDAG &DAG);
130 SDOperand LowerGlobalAddressELF(SDOperand Op, SelectionDAG &DAG);
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000131 SDOperand LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG);
132 SDOperand LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
133 SelectionDAG &DAG);
134 SDOperand LowerToTLSExecModels(GlobalAddressSDNode *GA,
135 SelectionDAG &DAG);
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +0000136 SDOperand LowerGLOBAL_OFFSET_TABLE(SDOperand Op, SelectionDAG &DAG);
Evan Chenga8e29892007-01-19 07:51:42 +0000137 SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG);
138 SDOperand LowerBR_JT(SDOperand Op, SelectionDAG &DAG);
Dale Johannesen8dd86c12007-05-17 21:31:21 +0000139 SDOperand LowerMEMCPY(SDOperand Op, SelectionDAG &DAG);
Evan Chenga8e29892007-01-19 07:51:42 +0000140 };
141}
142
143#endif // ARMISELLOWERING_H