blob: 2a5f3e360cae2337f99876ecafccd2a914d3e292 [file] [log] [blame]
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00001//===-- ARMISelDAGToDAG.cpp - A dag to dag inst selector for ARM ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the ARM target.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ARM.h"
15#include "ARMTargetMachine.h"
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +000016#include "ARMCommon.h"
Rafael Espindola84b19be2006-07-16 01:02:57 +000017#include "llvm/CallingConv.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000018#include "llvm/DerivedTypes.h"
19#include "llvm/Function.h"
Rafael Espindola7246d332006-09-21 11:29:52 +000020#include "llvm/Constants.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000021#include "llvm/Intrinsics.h"
Rafael Espindola462af9a2006-12-05 17:37:31 +000022#include "llvm/ADT/VectorExtras.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000023#include "llvm/CodeGen/MachineFrameInfo.h"
24#include "llvm/CodeGen/MachineFunction.h"
25#include "llvm/CodeGen/MachineInstrBuilder.h"
26#include "llvm/CodeGen/SelectionDAG.h"
27#include "llvm/CodeGen/SelectionDAGISel.h"
28#include "llvm/CodeGen/SSARegMap.h"
29#include "llvm/Target/TargetLowering.h"
30#include "llvm/Support/Debug.h"
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +000031#include "llvm/Support/MathExtras.h"
Rafael Espindolaa2845842006-10-05 16:48:49 +000032#include <vector>
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000033using namespace llvm;
34
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000035namespace {
36 class ARMTargetLowering : public TargetLowering {
Rafael Espindola755be9b2006-08-25 17:55:16 +000037 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000038 public:
39 ARMTargetLowering(TargetMachine &TM);
40 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
Rafael Espindola84b19be2006-07-16 01:02:57 +000041 virtual const char *getTargetNodeName(unsigned Opcode) const;
Rafael Espindola462af9a2006-12-05 17:37:31 +000042 std::vector<unsigned>
43 getRegClassForInlineAsmConstraint(const std::string &Constraint,
44 MVT::ValueType VT) const;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000045 };
46
47}
48
49ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
50 : TargetLowering(TM) {
Rafael Espindola3717ca92006-08-20 01:49:49 +000051 addRegisterClass(MVT::i32, ARM::IntRegsRegisterClass);
Rafael Espindola27185192006-09-29 21:20:16 +000052 addRegisterClass(MVT::f32, ARM::FPRegsRegisterClass);
53 addRegisterClass(MVT::f64, ARM::DFPRegsRegisterClass);
Rafael Espindola3717ca92006-08-20 01:49:49 +000054
Rafael Espindolaad557f92006-10-09 14:13:40 +000055 setLoadXAction(ISD::EXTLOAD, MVT::f32, Expand);
56
Rafael Espindolab47e1d02006-10-10 18:55:14 +000057 setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
Rafael Espindola27185192006-09-29 21:20:16 +000058 setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
Rafael Espindola3717ca92006-08-20 01:49:49 +000059
Rafael Espindola493a7fc2006-10-10 20:38:57 +000060 setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +000061 setOperationAction(ISD::UINT_TO_FP, MVT::i32, Custom);
62
Rafael Espindola06c1e7e2006-08-01 12:58:43 +000063 setOperationAction(ISD::RET, MVT::Other, Custom);
64 setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
65 setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
Rafael Espindola341b8642006-08-04 12:48:42 +000066
Rafael Espindola6495bdd2006-10-19 12:06:50 +000067 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand);
68 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i8 , Expand);
69 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1 , Expand);
70
Rafael Espindola48bc9fb2006-10-09 16:28:33 +000071 setOperationAction(ISD::SELECT, MVT::i32, Expand);
Lauro Ramos Venancioca1f66d2007-01-04 14:01:38 +000072 setOperationAction(ISD::SELECT, MVT::f32, Expand);
73 setOperationAction(ISD::SELECT, MVT::f64, Expand);
Rafael Espindola48bc9fb2006-10-09 16:28:33 +000074
Rafael Espindola3c000bf2006-08-21 22:00:32 +000075 setOperationAction(ISD::SETCC, MVT::i32, Expand);
Rafael Espindola4b20fbc2006-10-10 12:56:00 +000076 setOperationAction(ISD::SETCC, MVT::f32, Expand);
77 setOperationAction(ISD::SETCC, MVT::f64, Expand);
78
Rafael Espindola3c000bf2006-08-21 22:00:32 +000079 setOperationAction(ISD::SELECT_CC, MVT::i32, Custom);
Lauro Ramos Venancio301009a2006-12-28 13:11:14 +000080 setOperationAction(ISD::SELECT_CC, MVT::f32, Custom);
81 setOperationAction(ISD::SELECT_CC, MVT::f64, Custom);
Rafael Espindolad8ed7f82006-10-23 20:08:22 +000082
Rafael Espindola97815c62006-12-05 17:57:23 +000083 setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
Rafael Espindolad8ed7f82006-10-23 20:08:22 +000084 setOperationAction(ISD::MEMSET, MVT::Other, Expand);
Rafael Espindola97815c62006-12-05 17:57:23 +000085 setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
Rafael Espindolad8ed7f82006-10-23 20:08:22 +000086
Evan Chengc35497f2006-10-30 08:02:39 +000087 setOperationAction(ISD::BR_JT, MVT::Other, Expand);
88 setOperationAction(ISD::BRIND, MVT::Other, Expand);
Rafael Espindola687bc492006-08-24 13:45:55 +000089 setOperationAction(ISD::BR_CC, MVT::i32, Custom);
Rafael Espindola4b20fbc2006-10-10 12:56:00 +000090 setOperationAction(ISD::BR_CC, MVT::f32, Custom);
91 setOperationAction(ISD::BR_CC, MVT::f64, Custom);
Rafael Espindola3c000bf2006-08-21 22:00:32 +000092
Rafael Espindolad2b56682006-10-14 17:59:54 +000093 setOperationAction(ISD::BRCOND, MVT::Other, Expand);
94
Rafael Espindola0505be02006-10-16 21:10:32 +000095 setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand);
96 setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand);
97 setOperationAction(ISD::SRL_PARTS, MVT::i32, Expand);
Rafael Espindola226f8bc2006-10-17 21:05:33 +000098 setOperationAction(ISD::SDIV, MVT::i32, Expand);
99 setOperationAction(ISD::UDIV, MVT::i32, Expand);
100 setOperationAction(ISD::SREM, MVT::i32, Expand);
101 setOperationAction(ISD::UREM, MVT::i32, Expand);
Rafael Espindola0505be02006-10-16 21:10:32 +0000102
Rafael Espindola755be9b2006-08-25 17:55:16 +0000103 setOperationAction(ISD::VASTART, MVT::Other, Custom);
Rafael Espindola0e5e3aa2006-10-24 20:15:21 +0000104 setOperationAction(ISD::VACOPY, MVT::Other, Expand);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000105 setOperationAction(ISD::VAEND, MVT::Other, Expand);
Rafael Espindola7ae68ab2006-10-26 13:31:26 +0000106 setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000107
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +0000108 setOperationAction(ISD::ConstantFP, MVT::f64, Custom);
109 setOperationAction(ISD::ConstantFP, MVT::f32, Custom);
Rafael Espindolacd71da52006-10-03 17:27:58 +0000110
Lauro Ramos Venancioca1f66d2007-01-04 14:01:38 +0000111 setOperationAction(ISD::FCOPYSIGN, MVT::f64, Expand);
112 setOperationAction(ISD::FCOPYSIGN, MVT::f32, Expand);
113
Rafael Espindola7ae68ab2006-10-26 13:31:26 +0000114 setStackPointerRegisterToSaveRestore(ARM::R13);
115
Rafael Espindola341b8642006-08-04 12:48:42 +0000116 setSchedulingPreference(SchedulingForRegPressure);
Rafael Espindola3717ca92006-08-20 01:49:49 +0000117 computeRegisterProperties();
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000118}
119
Rafael Espindola84b19be2006-07-16 01:02:57 +0000120namespace llvm {
121 namespace ARMISD {
122 enum NodeType {
123 // Start the numbering where the builting ops and target ops leave off.
124 FIRST_NUMBER = ISD::BUILTIN_OP_END+ARM::INSTRUCTION_LIST_END,
125 /// CALL - A direct function call.
Rafael Espindolaf4fda802006-08-03 17:02:20 +0000126 CALL,
127
128 /// Return with a flag operand.
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000129 RET_FLAG,
130
131 CMP,
132
Rafael Espindola687bc492006-08-24 13:45:55 +0000133 SELECT,
134
Rafael Espindola27185192006-09-29 21:20:16 +0000135 BR,
136
Rafael Espindola9e071f02006-10-02 19:30:56 +0000137 FSITOS,
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000138 FTOSIS,
Rafael Espindola9e071f02006-10-02 19:30:56 +0000139
140 FSITOD,
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000141 FTOSID,
Rafael Espindola9e071f02006-10-02 19:30:56 +0000142
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000143 FUITOS,
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000144 FTOUIS,
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000145
146 FUITOD,
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000147 FTOUID,
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000148
Rafael Espindolaa2845842006-10-05 16:48:49 +0000149 FMRRD,
150
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000151 FMDRR,
152
153 FMSTAT
Rafael Espindola84b19be2006-07-16 01:02:57 +0000154 };
155 }
156}
157
Rafael Espindola42b62f32006-10-13 13:14:59 +0000158/// DAGFPCCToARMCC - Convert a DAG fp condition code to an ARM CC
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000159// Unordered = !N & !Z & C & V = V
160// Ordered = N | Z | !C | !V = N | Z | !V
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000161static std::vector<unsigned> DAGFPCCToARMCC(ISD::CondCode CC) {
Rafael Espindola6f602de2006-08-24 16:13:15 +0000162 switch (CC) {
Rafael Espindolaebdabda2006-09-21 13:06:26 +0000163 default:
Rafael Espindola42b62f32006-10-13 13:14:59 +0000164 assert(0 && "Unknown fp condition code!");
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000165// SETOEQ = (N | Z | !V) & Z = Z = EQ
166 case ISD::SETEQ:
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000167 case ISD::SETOEQ: return make_vector<unsigned>(ARMCC::EQ, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000168// SETOGT = (N | Z | !V) & !N & !Z = !V &!N &!Z = (N = V) & !Z = GT
169 case ISD::SETGT:
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000170 case ISD::SETOGT: return make_vector<unsigned>(ARMCC::GT, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000171// SETOGE = (N | Z | !V) & !N = (Z | !V) & !N = !V & !N = GE
172 case ISD::SETGE:
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000173 case ISD::SETOGE: return make_vector<unsigned>(ARMCC::GE, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000174// SETOLT = (N | Z | !V) & N = N = MI
175 case ISD::SETLT:
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000176 case ISD::SETOLT: return make_vector<unsigned>(ARMCC::MI, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000177// SETOLE = (N | Z | !V) & (N | Z) = N | Z = !C | Z = LS
178 case ISD::SETLE:
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000179 case ISD::SETOLE: return make_vector<unsigned>(ARMCC::LS, 0);
180// SETONE = OGT | OLT
181 case ISD::SETONE: return make_vector<unsigned>(ARMCC::GT, ARMCC::MI, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000182// SETO = N | Z | !V = Z | !V = !V = VC
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000183 case ISD::SETO: return make_vector<unsigned>(ARMCC::VC, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000184// SETUO = V = VS
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000185 case ISD::SETUO: return make_vector<unsigned>(ARMCC::VS, 0);
186// SETUEQ = V | Z (need two instructions) = EQ/VS
187 case ISD::SETUEQ: return make_vector<unsigned>(ARMCC::EQ, ARMCC::VS, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000188// SETUGT = V | (!Z & !N) = !Z & !N = !Z & C = HI
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000189 case ISD::SETUGT: return make_vector<unsigned>(ARMCC::HI, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000190// SETUGE = V | !N = !N = PL
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000191 case ISD::SETUGE: return make_vector<unsigned>(ARMCC::PL, 0);
192// SETULT = V | N = LT
193 case ISD::SETULT: return make_vector<unsigned>(ARMCC::LT, 0);
194// SETULE = V | Z | N = LE
195 case ISD::SETULE: return make_vector<unsigned>(ARMCC::LE, 0);
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000196// SETUNE = V | !Z = !Z = NE
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000197 case ISD::SETNE:
198 case ISD::SETUNE: return make_vector<unsigned>(ARMCC::NE, 0);
Rafael Espindola42b62f32006-10-13 13:14:59 +0000199 }
200}
201
202/// DAGIntCCToARMCC - Convert a DAG integer condition code to an ARM CC
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000203static std::vector<unsigned> DAGIntCCToARMCC(ISD::CondCode CC) {
Rafael Espindola42b62f32006-10-13 13:14:59 +0000204 switch (CC) {
205 default:
206 assert(0 && "Unknown integer condition code!");
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000207 case ISD::SETEQ: return make_vector<unsigned>(ARMCC::EQ, 0);
208 case ISD::SETNE: return make_vector<unsigned>(ARMCC::NE, 0);
209 case ISD::SETLT: return make_vector<unsigned>(ARMCC::LT, 0);
210 case ISD::SETLE: return make_vector<unsigned>(ARMCC::LE, 0);
211 case ISD::SETGT: return make_vector<unsigned>(ARMCC::GT, 0);
212 case ISD::SETGE: return make_vector<unsigned>(ARMCC::GE, 0);
213 case ISD::SETULT: return make_vector<unsigned>(ARMCC::CC, 0);
214 case ISD::SETULE: return make_vector<unsigned>(ARMCC::LS, 0);
215 case ISD::SETUGT: return make_vector<unsigned>(ARMCC::HI, 0);
216 case ISD::SETUGE: return make_vector<unsigned>(ARMCC::CS, 0);
Rafael Espindola6f602de2006-08-24 16:13:15 +0000217 }
218}
219
Rafael Espindola462af9a2006-12-05 17:37:31 +0000220std::vector<unsigned> ARMTargetLowering::
221getRegClassForInlineAsmConstraint(const std::string &Constraint,
222 MVT::ValueType VT) const {
223 if (Constraint.size() == 1) {
224 // FIXME: handling only r regs
225 switch (Constraint[0]) {
226 default: break; // Unknown constraint letter
227
228 case 'r': // GENERAL_REGS
229 case 'R': // LEGACY_REGS
230 if (VT == MVT::i32)
231 return make_vector<unsigned>(ARM::R0, ARM::R1, ARM::R2, ARM::R3,
232 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
233 ARM::R8, ARM::R9, ARM::R10, ARM::R11,
234 ARM::R12, ARM::R13, ARM::R14, 0);
235 break;
236
237 }
238 }
239
240 return std::vector<unsigned>();
241}
242
Rafael Espindola84b19be2006-07-16 01:02:57 +0000243const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const {
244 switch (Opcode) {
245 default: return 0;
246 case ARMISD::CALL: return "ARMISD::CALL";
Rafael Espindolaf4fda802006-08-03 17:02:20 +0000247 case ARMISD::RET_FLAG: return "ARMISD::RET_FLAG";
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000248 case ARMISD::SELECT: return "ARMISD::SELECT";
249 case ARMISD::CMP: return "ARMISD::CMP";
Rafael Espindola687bc492006-08-24 13:45:55 +0000250 case ARMISD::BR: return "ARMISD::BR";
Rafael Espindola27185192006-09-29 21:20:16 +0000251 case ARMISD::FSITOS: return "ARMISD::FSITOS";
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000252 case ARMISD::FTOSIS: return "ARMISD::FTOSIS";
Rafael Espindola9e071f02006-10-02 19:30:56 +0000253 case ARMISD::FSITOD: return "ARMISD::FSITOD";
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000254 case ARMISD::FTOSID: return "ARMISD::FTOSID";
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000255 case ARMISD::FUITOS: return "ARMISD::FUITOS";
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000256 case ARMISD::FTOUIS: return "ARMISD::FTOUIS";
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000257 case ARMISD::FUITOD: return "ARMISD::FUITOD";
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000258 case ARMISD::FTOUID: return "ARMISD::FTOUID";
Rafael Espindola9e071f02006-10-02 19:30:56 +0000259 case ARMISD::FMRRD: return "ARMISD::FMRRD";
Rafael Espindolaa2845842006-10-05 16:48:49 +0000260 case ARMISD::FMDRR: return "ARMISD::FMDRR";
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000261 case ARMISD::FMSTAT: return "ARMISD::FMSTAT";
Rafael Espindola84b19be2006-07-16 01:02:57 +0000262 }
263}
264
Rafael Espindolaa2845842006-10-05 16:48:49 +0000265class ArgumentLayout {
266 std::vector<bool> is_reg;
267 std::vector<unsigned> pos;
268 std::vector<MVT::ValueType> types;
269public:
Rafael Espindola39b5a212006-10-05 17:46:48 +0000270 ArgumentLayout(const std::vector<MVT::ValueType> &Types) {
Rafael Espindolaa2845842006-10-05 16:48:49 +0000271 types = Types;
272
273 unsigned RegNum = 0;
274 unsigned StackOffset = 0;
Rafael Espindola39b5a212006-10-05 17:46:48 +0000275 for(std::vector<MVT::ValueType>::const_iterator I = Types.begin();
Rafael Espindolaa2845842006-10-05 16:48:49 +0000276 I != Types.end();
277 ++I) {
278 MVT::ValueType VT = *I;
279 assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
280 unsigned size = MVT::getSizeInBits(VT)/32;
281
282 RegNum = ((RegNum + size - 1) / size) * size;
283 if (RegNum < 4) {
284 pos.push_back(RegNum);
285 is_reg.push_back(true);
286 RegNum += size;
287 } else {
288 unsigned bytes = size * 32/8;
289 StackOffset = ((StackOffset + bytes - 1) / bytes) * bytes;
290 pos.push_back(StackOffset);
291 is_reg.push_back(false);
292 StackOffset += bytes;
293 }
294 }
295 }
296 unsigned getRegisterNum(unsigned argNum) {
297 assert(isRegister(argNum));
298 return pos[argNum];
299 }
300 unsigned getOffset(unsigned argNum) {
301 assert(isOffset(argNum));
302 return pos[argNum];
303 }
304 unsigned isRegister(unsigned argNum) {
305 assert(argNum < is_reg.size());
306 return is_reg[argNum];
307 }
308 unsigned isOffset(unsigned argNum) {
309 return !isRegister(argNum);
310 }
311 MVT::ValueType getType(unsigned argNum) {
312 assert(argNum < types.size());
313 return types[argNum];
314 }
315 unsigned getStackSize(void) {
316 int last = is_reg.size() - 1;
Rafael Espindolaaf1dabe2006-10-06 17:26:30 +0000317 if (last < 0)
318 return 0;
Rafael Espindolaa2845842006-10-05 16:48:49 +0000319 if (isRegister(last))
320 return 0;
321 return getOffset(last) + MVT::getSizeInBits(getType(last))/8;
322 }
323 int lastRegArg(void) {
324 int size = is_reg.size();
325 int last = 0;
326 while(last < size && isRegister(last))
327 last++;
328 last--;
329 return last;
330 }
Rafael Espindolaaf1dabe2006-10-06 17:26:30 +0000331 int lastRegNum(void) {
Rafael Espindolaa2845842006-10-05 16:48:49 +0000332 int l = lastRegArg();
333 if (l < 0)
334 return -1;
335 unsigned r = getRegisterNum(l);
336 MVT::ValueType t = getType(l);
337 assert(t == MVT::i32 || t == MVT::f32 || t == MVT::f64);
338 if (t == MVT::f64)
339 return r + 1;
340 return r;
341 }
342};
343
Rafael Espindola84b19be2006-07-16 01:02:57 +0000344// This transforms a ISD::CALL node into a
345// callseq_star <- ARMISD:CALL <- callseq_end
346// chain
Rafael Espindolac3c1a862006-05-25 11:00:18 +0000347static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) {
Rafael Espindola84b19be2006-07-16 01:02:57 +0000348 SDOperand Chain = Op.getOperand(0);
349 unsigned CallConv = cast<ConstantSDNode>(Op.getOperand(1))->getValue();
Rafael Espindola5f1b6982006-10-18 12:03:07 +0000350 assert((CallConv == CallingConv::C ||
351 CallConv == CallingConv::Fast)
352 && "unknown calling convention");
Rafael Espindola84b19be2006-07-16 01:02:57 +0000353 SDOperand Callee = Op.getOperand(4);
354 unsigned NumOps = (Op.getNumOperands() - 5) / 2;
Rafael Espindola1a009462006-08-08 13:02:29 +0000355 SDOperand StackPtr = DAG.getRegister(ARM::R13, MVT::i32);
Rafael Espindolaa2845842006-10-05 16:48:49 +0000356 static const unsigned regs[] = {
Rafael Espindolafac00a92006-07-25 20:17:20 +0000357 ARM::R0, ARM::R1, ARM::R2, ARM::R3
358 };
359
Rafael Espindolaa2845842006-10-05 16:48:49 +0000360 std::vector<MVT::ValueType> Types;
361 for (unsigned i = 0; i < NumOps; ++i) {
362 MVT::ValueType VT = Op.getOperand(5+2*i).getValueType();
363 Types.push_back(VT);
364 }
365 ArgumentLayout Layout(Types);
Rafael Espindolafac00a92006-07-25 20:17:20 +0000366
Rafael Espindolaa2845842006-10-05 16:48:49 +0000367 unsigned NumBytes = Layout.getStackSize();
368
369 Chain = DAG.getCALLSEQ_START(Chain,
370 DAG.getConstant(NumBytes, MVT::i32));
371
372 //Build a sequence of stores
373 std::vector<SDOperand> MemOpChains;
374 for (unsigned i = Layout.lastRegArg() + 1; i < NumOps; ++i) {
375 SDOperand Arg = Op.getOperand(5+2*i);
376 unsigned ArgOffset = Layout.getOffset(i);
377 SDOperand PtrOff = DAG.getConstant(ArgOffset, StackPtr.getValueType());
378 PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
Evan Cheng8b2794a2006-10-13 21:14:26 +0000379 MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0));
Rafael Espindolafac00a92006-07-25 20:17:20 +0000380 }
Rafael Espindola1a009462006-08-08 13:02:29 +0000381 if (!MemOpChains.empty())
Chris Lattnere2199452006-08-11 17:38:39 +0000382 Chain = DAG.getNode(ISD::TokenFactor, MVT::Other,
383 &MemOpChains[0], MemOpChains.size());
Rafael Espindolafac00a92006-07-25 20:17:20 +0000384
Rafael Espindola0505be02006-10-16 21:10:32 +0000385 // If the callee is a GlobalAddress node (quite common, every direct call is)
386 // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
387 // Likewise ExternalSymbol -> TargetExternalSymbol.
388 assert(Callee.getValueType() == MVT::i32);
Rafael Espindola84b19be2006-07-16 01:02:57 +0000389 if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
Rafael Espindola0505be02006-10-16 21:10:32 +0000390 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), MVT::i32);
391 else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee))
392 Callee = DAG.getTargetExternalSymbol(E->getSymbol(), MVT::i32);
Rafael Espindola84b19be2006-07-16 01:02:57 +0000393
394 // If this is a direct call, pass the chain and the callee.
395 assert (Callee.Val);
396 std::vector<SDOperand> Ops;
397 Ops.push_back(Chain);
398 Ops.push_back(Callee);
399
Rafael Espindolaa2845842006-10-05 16:48:49 +0000400 // Build a sequence of copy-to-reg nodes chained together with token chain
401 // and flag operands which copy the outgoing args into the appropriate regs.
402 SDOperand InFlag;
Rafael Espindolaaf1dabe2006-10-06 17:26:30 +0000403 for (int i = 0, e = Layout.lastRegArg(); i <= e; ++i) {
Rafael Espindola4a408d42006-10-06 12:50:22 +0000404 SDOperand Arg = Op.getOperand(5+2*i);
405 unsigned RegNum = Layout.getRegisterNum(i);
406 unsigned Reg1 = regs[RegNum];
407 MVT::ValueType VT = Layout.getType(i);
408 assert(VT == Arg.getValueType());
409 assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
Rafael Espindolaa2845842006-10-05 16:48:49 +0000410
411 // Add argument register to the end of the list so that it is known live
412 // into the call.
Rafael Espindola4a408d42006-10-06 12:50:22 +0000413 Ops.push_back(DAG.getRegister(Reg1, MVT::i32));
414 if (VT == MVT::f64) {
415 unsigned Reg2 = regs[RegNum + 1];
416 SDOperand SDReg1 = DAG.getRegister(Reg1, MVT::i32);
417 SDOperand SDReg2 = DAG.getRegister(Reg2, MVT::i32);
418
419 Ops.push_back(DAG.getRegister(Reg2, MVT::i32));
420 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Flag);
Rafael Espindola935b1f82006-10-06 20:33:26 +0000421 SDOperand Ops[] = {Chain, SDReg1, SDReg2, Arg, InFlag};
422 Chain = DAG.getNode(ARMISD::FMRRD, VTs, Ops, InFlag.Val ? 5 : 4);
Rafael Espindola4a408d42006-10-06 12:50:22 +0000423 } else {
424 if (VT == MVT::f32)
425 Arg = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Arg);
426 Chain = DAG.getCopyToReg(Chain, Reg1, Arg, InFlag);
427 }
428 InFlag = Chain.getValue(1);
Rafael Espindolaa2845842006-10-05 16:48:49 +0000429 }
430
431 std::vector<MVT::ValueType> NodeTys;
432 NodeTys.push_back(MVT::Other); // Returns a chain
433 NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use.
Rafael Espindola7a53bd02006-08-09 16:41:12 +0000434
Rafael Espindola84b19be2006-07-16 01:02:57 +0000435 unsigned CallOpc = ARMISD::CALL;
Rafael Espindolafac00a92006-07-25 20:17:20 +0000436 if (InFlag.Val)
437 Ops.push_back(InFlag);
Chris Lattner87428672006-08-11 17:22:35 +0000438 Chain = DAG.getNode(CallOpc, NodeTys, &Ops[0], Ops.size());
Rafael Espindolafac00a92006-07-25 20:17:20 +0000439 InFlag = Chain.getValue(1);
Rafael Espindola84b19be2006-07-16 01:02:57 +0000440
Rafael Espindolafac00a92006-07-25 20:17:20 +0000441 std::vector<SDOperand> ResultVals;
442 NodeTys.clear();
443
444 // If the call has results, copy the values out of the ret val registers.
Rafael Espindola614057b2006-10-06 19:10:05 +0000445 MVT::ValueType VT = Op.Val->getValueType(0);
446 if (VT != MVT::Other) {
447 assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
Rafael Espindola614057b2006-10-06 19:10:05 +0000448
449 SDOperand Value1 = DAG.getCopyFromReg(Chain, ARM::R0, MVT::i32, InFlag);
450 Chain = Value1.getValue(1);
451 InFlag = Value1.getValue(2);
Rafael Espindola26a76d12006-10-13 16:47:22 +0000452 NodeTys.push_back(VT);
453 if (VT == MVT::i32) {
454 ResultVals.push_back(Value1);
455 if (Op.Val->getValueType(1) == MVT::i32) {
456 SDOperand Value2 = DAG.getCopyFromReg(Chain, ARM::R1, MVT::i32, InFlag);
457 Chain = Value2.getValue(1);
458 ResultVals.push_back(Value2);
459 NodeTys.push_back(VT);
460 }
461 }
462 if (VT == MVT::f32) {
463 SDOperand Value = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, Value1);
464 ResultVals.push_back(Value);
465 }
Rafael Espindola614057b2006-10-06 19:10:05 +0000466 if (VT == MVT::f64) {
467 SDOperand Value2 = DAG.getCopyFromReg(Chain, ARM::R1, MVT::i32, InFlag);
468 Chain = Value2.getValue(1);
Rafael Espindola26a76d12006-10-13 16:47:22 +0000469 SDOperand Value = DAG.getNode(ARMISD::FMDRR, MVT::f64, Value1, Value2);
470 ResultVals.push_back(Value);
Rafael Espindola614057b2006-10-06 19:10:05 +0000471 }
Rafael Espindolafac00a92006-07-25 20:17:20 +0000472 }
Rafael Espindola84b19be2006-07-16 01:02:57 +0000473
474 Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain,
475 DAG.getConstant(NumBytes, MVT::i32));
Rafael Espindolafac00a92006-07-25 20:17:20 +0000476 NodeTys.push_back(MVT::Other);
Rafael Espindola84b19be2006-07-16 01:02:57 +0000477
Rafael Espindolafac00a92006-07-25 20:17:20 +0000478 if (ResultVals.empty())
479 return Chain;
480
481 ResultVals.push_back(Chain);
Chris Lattner87428672006-08-11 17:22:35 +0000482 SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0],
483 ResultVals.size());
Rafael Espindolafac00a92006-07-25 20:17:20 +0000484 return Res.getValue(Op.ResNo);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000485}
486
487static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG) {
488 SDOperand Copy;
Rafael Espindola4b023672006-06-05 22:26:14 +0000489 SDOperand Chain = Op.getOperand(0);
Rafael Espindola9e071f02006-10-02 19:30:56 +0000490 SDOperand R0 = DAG.getRegister(ARM::R0, MVT::i32);
491 SDOperand R1 = DAG.getRegister(ARM::R1, MVT::i32);
492
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000493 switch(Op.getNumOperands()) {
494 default:
495 assert(0 && "Do not know how to return this many arguments!");
496 abort();
Rafael Espindola4b023672006-06-05 22:26:14 +0000497 case 1: {
498 SDOperand LR = DAG.getRegister(ARM::R14, MVT::i32);
Rafael Espindola6312da02006-08-03 22:50:11 +0000499 return DAG.getNode(ARMISD::RET_FLAG, MVT::Other, Chain);
Rafael Espindola4b023672006-06-05 22:26:14 +0000500 }
Rafael Espindola27185192006-09-29 21:20:16 +0000501 case 3: {
502 SDOperand Val = Op.getOperand(1);
503 assert(Val.getValueType() == MVT::i32 ||
Rafael Espindola9e071f02006-10-02 19:30:56 +0000504 Val.getValueType() == MVT::f32 ||
505 Val.getValueType() == MVT::f64);
Rafael Espindola27185192006-09-29 21:20:16 +0000506
Rafael Espindola9e071f02006-10-02 19:30:56 +0000507 if (Val.getValueType() == MVT::f64) {
508 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Flag);
509 SDOperand Ops[] = {Chain, R0, R1, Val};
510 Copy = DAG.getNode(ARMISD::FMRRD, VTs, Ops, 4);
511 } else {
512 if (Val.getValueType() == MVT::f32)
513 Val = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Val);
514 Copy = DAG.getCopyToReg(Chain, R0, Val, SDOperand());
515 }
516
517 if (DAG.getMachineFunction().liveout_empty()) {
Rafael Espindola4b023672006-06-05 22:26:14 +0000518 DAG.getMachineFunction().addLiveOut(ARM::R0);
Rafael Espindola9e071f02006-10-02 19:30:56 +0000519 if (Val.getValueType() == MVT::f64)
520 DAG.getMachineFunction().addLiveOut(ARM::R1);
521 }
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000522 break;
Rafael Espindola27185192006-09-29 21:20:16 +0000523 }
Rafael Espindola3a02f022006-09-04 19:05:01 +0000524 case 5:
525 Copy = DAG.getCopyToReg(Chain, ARM::R1, Op.getOperand(3), SDOperand());
526 Copy = DAG.getCopyToReg(Copy, ARM::R0, Op.getOperand(1), Copy.getValue(1));
527 // If we haven't noted the R0+R1 are live out, do so now.
528 if (DAG.getMachineFunction().liveout_empty()) {
529 DAG.getMachineFunction().addLiveOut(ARM::R0);
530 DAG.getMachineFunction().addLiveOut(ARM::R1);
531 }
532 break;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000533 }
Rafael Espindola4b023672006-06-05 22:26:14 +0000534
Rafael Espindolaf4fda802006-08-03 17:02:20 +0000535 //We must use RET_FLAG instead of BRIND because BRIND doesn't have a flag
536 return DAG.getNode(ARMISD::RET_FLAG, MVT::Other, Copy, Copy.getValue(1));
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000537}
538
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000539static SDOperand LowerConstantPool(SDOperand Op, SelectionDAG &DAG) {
540 MVT::ValueType PtrVT = Op.getValueType();
541 ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
Evan Chengc356a572006-09-12 21:04:05 +0000542 Constant *C = CP->getConstVal();
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000543 SDOperand CPI = DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment());
544
545 return CPI;
546}
547
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +0000548SDOperand LegalizeImmediate(uint32_t immediate, SelectionDAG &DAG,
549 bool canReturnConstant){
550 SDOperand Shift = DAG.getTargetConstant(0, MVT::i32);
551 SDOperand ShiftType = DAG.getTargetConstant(ARMShift::LSL, MVT::i32);
552 std::vector<unsigned>immediatePieces = splitImmediate(immediate);
553 if (immediatePieces.size()>1){
554 unsigned movInst = ARM::MOV;
555 unsigned orInst = ARM::ORR;
556 SDNode *node;
557 //try mvn
558 std::vector<unsigned>immediateNegPieces = splitImmediate(~immediate);
559 if (immediatePieces.size() > immediateNegPieces.size()) {
560 //use mvn/eor
561 movInst = ARM::MVN;
562 orInst = ARM::EOR;
563 immediatePieces = immediateNegPieces;
564 }
565 SDOperand n = DAG.getTargetConstant(immediatePieces[0], MVT::i32);
566 node = DAG.getTargetNode(movInst, MVT::i32, n, Shift, ShiftType);
567 std::vector<unsigned>::iterator it;
568 for (it=immediatePieces.begin()+1; it != immediatePieces.end(); ++it){
569 n = DAG.getTargetConstant(*it, MVT::i32);
570 SDOperand ops[] = {SDOperand(node, 0), n, Shift, ShiftType};
571 node = DAG.getTargetNode(orInst, MVT::i32, ops, 4);
572 }
573 return SDOperand(node, 0);
574 } else {
575 if (canReturnConstant)
576 return DAG.getTargetConstant(immediate, MVT::i32);
577 else {
578 SDOperand n = DAG.getTargetConstant(immediate, MVT::i32);
579 SDNode *node = DAG.getTargetNode(ARM::MOV, MVT::i32, n, Shift,
580 ShiftType);
581 return SDOperand(node, 0);
582 }
583 }
584}
585
586static SDOperand LowerConstantFP(SDOperand Op, SelectionDAG &DAG) {
587 MVT::ValueType VT = Op.getValueType();
588 SDOperand Shift = DAG.getTargetConstant(0, MVT::i32);
589 SDOperand ShiftType = DAG.getTargetConstant(ARMShift::LSL, MVT::i32);
590 SDNode *node;
591 switch (VT) {
592 default: assert(0 && "VT!=f32 && VT!=f64");
593 case MVT::f32: {
594 float val = cast<ConstantFPSDNode>(Op)->getValue();
595 uint32_t i32_val = FloatToBits(val);
596 SDOperand c = LegalizeImmediate(i32_val, DAG, false);
597 node = DAG.getTargetNode(ARM::FMSR, MVT::f32, c);
598 break;
599 }
600 case MVT::f64: {
601 double val = cast<ConstantFPSDNode>(Op)->getValue();
602 uint64_t i64_val = DoubleToBits(val);
603 SDOperand hi = LegalizeImmediate(Hi_32(i64_val), DAG, false);
604 SDOperand lo = LegalizeImmediate(Lo_32(i64_val), DAG, false);
605 node = DAG.getTargetNode(ARM::FMDRR, MVT::f64, lo, hi);
606 break;
607 }
608 }
609 return SDOperand(node, 0);
610}
611
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000612static SDOperand LowerGlobalAddress(SDOperand Op,
613 SelectionDAG &DAG) {
614 GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
Rafael Espindola61369da2006-08-14 19:01:24 +0000615 int alignment = 2;
616 SDOperand CPAddr = DAG.getConstantPool(GV, MVT::i32, alignment);
Evan Cheng466685d2006-10-09 20:57:25 +0000617 return DAG.getLoad(MVT::i32, DAG.getEntryNode(), CPAddr, NULL, 0);
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000618}
619
Rafael Espindola755be9b2006-08-25 17:55:16 +0000620static SDOperand LowerVASTART(SDOperand Op, SelectionDAG &DAG,
621 unsigned VarArgsFrameIndex) {
622 // vastart just stores the address of the VarArgsFrameIndex slot into the
623 // memory location argument.
624 MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
625 SDOperand FR = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT);
Evan Cheng8b2794a2006-10-13 21:14:26 +0000626 SrcValueSDNode *SV = cast<SrcValueSDNode>(Op.getOperand(2));
627 return DAG.getStore(Op.getOperand(0), FR, Op.getOperand(1), SV->getValue(),
628 SV->getOffset());
Rafael Espindola755be9b2006-08-25 17:55:16 +0000629}
630
631static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
632 int &VarArgsFrameIndex) {
Rafael Espindolaa2845842006-10-05 16:48:49 +0000633 MachineFunction &MF = DAG.getMachineFunction();
634 MachineFrameInfo *MFI = MF.getFrameInfo();
635 SSARegMap *RegMap = MF.getSSARegMap();
636 unsigned NumArgs = Op.Val->getNumValues()-1;
637 SDOperand Root = Op.getOperand(0);
638 bool isVarArg = cast<ConstantSDNode>(Op.getOperand(2))->getValue() != 0;
639 static const unsigned REGS[] = {
640 ARM::R0, ARM::R1, ARM::R2, ARM::R3
641 };
642
643 std::vector<MVT::ValueType> Types(Op.Val->value_begin(), Op.Val->value_end() - 1);
644 ArgumentLayout Layout(Types);
645
Rafael Espindola337c4ad62006-06-12 12:28:08 +0000646 std::vector<SDOperand> ArgValues;
Rafael Espindola755be9b2006-08-25 17:55:16 +0000647 for (unsigned ArgNo = 0; ArgNo < NumArgs; ++ArgNo) {
Rafael Espindolaa2845842006-10-05 16:48:49 +0000648 MVT::ValueType VT = Types[ArgNo];
Rafael Espindola4b442b52006-05-23 02:48:20 +0000649
Rafael Espindolaa2845842006-10-05 16:48:49 +0000650 SDOperand Value;
651 if (Layout.isRegister(ArgNo)) {
652 assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
653 unsigned RegNum = Layout.getRegisterNum(ArgNo);
654 unsigned Reg1 = REGS[RegNum];
655 unsigned VReg1 = RegMap->createVirtualRegister(&ARM::IntRegsRegClass);
656 SDOperand Value1 = DAG.getCopyFromReg(Root, VReg1, MVT::i32);
657 MF.addLiveIn(Reg1, VReg1);
658 if (VT == MVT::f64) {
659 unsigned Reg2 = REGS[RegNum + 1];
660 unsigned VReg2 = RegMap->createVirtualRegister(&ARM::IntRegsRegClass);
661 SDOperand Value2 = DAG.getCopyFromReg(Root, VReg2, MVT::i32);
662 MF.addLiveIn(Reg2, VReg2);
663 Value = DAG.getNode(ARMISD::FMDRR, MVT::f64, Value1, Value2);
664 } else {
665 Value = Value1;
666 if (VT == MVT::f32)
667 Value = DAG.getNode(ISD::BIT_CONVERT, VT, Value);
668 }
669 } else {
670 // If the argument is actually used, emit a load from the right stack
671 // slot.
672 if (!Op.Val->hasNUsesOfValue(0, ArgNo)) {
673 unsigned Offset = Layout.getOffset(ArgNo);
674 unsigned Size = MVT::getSizeInBits(VT)/8;
675 int FI = MFI->CreateFixedObject(Size, Offset);
676 SDOperand FIN = DAG.getFrameIndex(FI, VT);
Evan Cheng466685d2006-10-09 20:57:25 +0000677 Value = DAG.getLoad(VT, Root, FIN, NULL, 0);
Rafael Espindolaa2845842006-10-05 16:48:49 +0000678 } else {
679 Value = DAG.getNode(ISD::UNDEF, VT);
680 }
681 }
682 ArgValues.push_back(Value);
Rafael Espindola4b442b52006-05-23 02:48:20 +0000683 }
684
Rafael Espindolaa2845842006-10-05 16:48:49 +0000685 unsigned NextRegNum = Layout.lastRegNum() + 1;
686
Rafael Espindola755be9b2006-08-25 17:55:16 +0000687 if (isVarArg) {
Rafael Espindolaa2845842006-10-05 16:48:49 +0000688 //If this function is vararg we must store the remaing
689 //registers so that they can be acessed with va_start
Rafael Espindola755be9b2006-08-25 17:55:16 +0000690 VarArgsFrameIndex = MFI->CreateFixedObject(MVT::getSizeInBits(MVT::i32)/8,
Rafael Espindolaa2845842006-10-05 16:48:49 +0000691 -16 + NextRegNum * 4);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000692
Rafael Espindola755be9b2006-08-25 17:55:16 +0000693 SmallVector<SDOperand, 4> MemOps;
Rafael Espindolaa2845842006-10-05 16:48:49 +0000694 for (unsigned RegNo = NextRegNum; RegNo < 4; ++RegNo) {
695 int RegOffset = - (4 - RegNo) * 4;
Rafael Espindola755be9b2006-08-25 17:55:16 +0000696 int FI = MFI->CreateFixedObject(MVT::getSizeInBits(MVT::i32)/8,
Rafael Espindolaa2845842006-10-05 16:48:49 +0000697 RegOffset);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000698 SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
699
Rafael Espindolaa2845842006-10-05 16:48:49 +0000700 unsigned VReg = RegMap->createVirtualRegister(&ARM::IntRegsRegClass);
701 MF.addLiveIn(REGS[RegNo], VReg);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000702
703 SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::i32);
Evan Cheng8b2794a2006-10-13 21:14:26 +0000704 SDOperand Store = DAG.getStore(Val.getValue(1), Val, FIN, NULL, 0);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000705 MemOps.push_back(Store);
706 }
707 Root = DAG.getNode(ISD::TokenFactor, MVT::Other,&MemOps[0],MemOps.size());
708 }
Rafael Espindola4b442b52006-05-23 02:48:20 +0000709
710 ArgValues.push_back(Root);
711
712 // Return the new list of results.
713 std::vector<MVT::ValueType> RetVT(Op.Val->value_begin(),
714 Op.Val->value_end());
Chris Lattner87428672006-08-11 17:22:35 +0000715 return DAG.getNode(ISD::MERGE_VALUES, RetVT, &ArgValues[0], ArgValues.size());
Rafael Espindoladc124a22006-05-18 21:45:49 +0000716}
717
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000718static SDOperand GetCMP(ISD::CondCode CC, SDOperand LHS, SDOperand RHS,
719 SelectionDAG &DAG) {
720 MVT::ValueType vt = LHS.getValueType();
Rafael Espindola0d9fe762006-10-10 16:33:47 +0000721 assert(vt == MVT::i32 || vt == MVT::f32 || vt == MVT::f64);
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000722
Rafael Espindola6c5ae3e2006-10-14 13:42:53 +0000723 SDOperand Cmp = DAG.getNode(ARMISD::CMP, MVT::Flag, LHS, RHS);
Rafael Espindola42b62f32006-10-13 13:14:59 +0000724
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000725 if (vt != MVT::i32)
726 Cmp = DAG.getNode(ARMISD::FMSTAT, MVT::Flag, Cmp);
727 return Cmp;
728}
729
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000730static std::vector<SDOperand> GetARMCC(ISD::CondCode CC, MVT::ValueType vt,
Rafael Espindola42b62f32006-10-13 13:14:59 +0000731 SelectionDAG &DAG) {
732 assert(vt == MVT::i32 || vt == MVT::f32 || vt == MVT::f64);
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000733 std::vector<unsigned> vcc;
Rafael Espindola42b62f32006-10-13 13:14:59 +0000734 if (vt == MVT::i32)
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000735 vcc = DAGIntCCToARMCC(CC);
Rafael Espindola42b62f32006-10-13 13:14:59 +0000736 else
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000737 vcc = DAGFPCCToARMCC(CC);
738
739 std::vector<unsigned>::iterator it;
740 std::vector<SDOperand> result;
741 for( it = vcc.begin(); it != vcc.end(); it++ )
742 result.push_back(DAG.getConstant(*it,MVT::i32));
743 return result;
Rafael Espindola42b62f32006-10-13 13:14:59 +0000744}
745
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000746static bool isUInt8Immediate(uint32_t x) {
747 return x < (1 << 8);
748}
749
750static uint32_t rotateL(uint32_t x) {
751 uint32_t bit31 = (x & (1 << 31)) >> 31;
752 uint32_t t = x << 1;
753 return t | bit31;
754}
755
756static bool isRotInt8Immediate(uint32_t x) {
757 int r;
758 for (r = 0; r < 16; r++) {
759 if (isUInt8Immediate(x))
760 return true;
761 x = rotateL(rotateL(x));
762 }
763 return false;
764}
765
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000766static void LowerCMP(SDOperand &Cmp, std::vector<SDOperand> &ARMCC,
767 SDOperand LHS, SDOperand RHS, ISD::CondCode CC,
768 SelectionDAG &DAG) {
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000769 MVT::ValueType vt = LHS.getValueType();
770 if (vt == MVT::i32) {
771 assert(!isa<ConstantSDNode>(LHS));
772 if (ConstantSDNode *SD_C = dyn_cast<ConstantSDNode>(RHS.Val)) {
773 uint32_t C = SD_C->getValue();
774
775 uint32_t NC;
776 switch(CC) {
777 default:
778 NC = C; break;
779 case ISD::SETLT:
780 case ISD::SETULT:
781 case ISD::SETGE:
782 case ISD::SETUGE:
783 NC = C - 1; break;
784 case ISD::SETLE:
785 case ISD::SETULE:
786 case ISD::SETGT:
787 case ISD::SETUGT:
788 NC = C + 1; break;
789 }
790
791 ISD::CondCode NCC;
792 switch(CC) {
793 default:
794 NCC = CC; break;
795 case ISD::SETLT:
796 NCC = ISD::SETLE; break;
797 case ISD::SETULT:
798 NCC = ISD::SETULE; break;
799 case ISD::SETGE:
800 NCC = ISD::SETGT; break;
801 case ISD::SETUGE:
802 NCC = ISD::SETUGT; break;
803 case ISD::SETLE:
804 NCC = ISD::SETLT; break;
805 case ISD::SETULE:
806 NCC = ISD::SETULT; break;
807 case ISD::SETGT:
808 NCC = ISD::SETGE; break;
809 case ISD::SETUGT:
810 NCC = ISD::SETUGE; break;
811 }
812
813 if (!isRotInt8Immediate(C) && isRotInt8Immediate(NC)) {
814 RHS = DAG.getConstant(NC, MVT::i32);
815 CC = NCC;
816 }
817 }
818 }
819 Cmp = GetCMP(CC, LHS, RHS, DAG);
820 ARMCC = GetARMCC(CC, vt, DAG);
821}
822
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000823static SDOperand LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG) {
824 SDOperand LHS = Op.getOperand(0);
825 SDOperand RHS = Op.getOperand(1);
826 ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(4))->get();
827 SDOperand TrueVal = Op.getOperand(2);
828 SDOperand FalseVal = Op.getOperand(3);
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000829 SDOperand Cmp;
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000830 std::vector<SDOperand> ARMCC;
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000831 LowerCMP(Cmp, ARMCC, LHS, RHS, CC, DAG);
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000832
833 SDOperand Aux = FalseVal;
834 SDVTList VTs = DAG.getVTList(Op.getValueType(), MVT::Flag);
835 std::vector<SDOperand>::iterator it;
836 for (it = ARMCC.begin(); it != ARMCC.end(); ++it){
837 SDOperand Flag = it == ARMCC.begin() ? Cmp : Aux.getValue(1);
838 SDOperand Ops[] = {TrueVal, Aux, *it, Flag};
839 Aux = DAG.getNode(ARMISD::SELECT, VTs, Ops, 4);
840 }
841 return Aux;
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000842}
843
Rafael Espindola687bc492006-08-24 13:45:55 +0000844static SDOperand LowerBR_CC(SDOperand Op, SelectionDAG &DAG) {
845 SDOperand Chain = Op.getOperand(0);
846 ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(1))->get();
847 SDOperand LHS = Op.getOperand(2);
848 SDOperand RHS = Op.getOperand(3);
849 SDOperand Dest = Op.getOperand(4);
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000850 SDOperand Cmp;
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000851 std::vector<SDOperand> ARMCC;
Rafael Espindola8897a7b2006-12-14 18:58:37 +0000852 LowerCMP(Cmp, ARMCC, LHS, RHS, CC, DAG);
Rafael Espindola9985f9f2006-12-31 18:52:39 +0000853
854 SDOperand Aux = Chain;
855 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Flag);
856 std::vector<SDOperand>::iterator it;
857 for (it = ARMCC.begin(); it != ARMCC.end(); it++){
858 SDOperand Flag = it == ARMCC.begin() ? Cmp : Aux.getValue(1);
859 SDOperand Ops[] = {Aux, Dest, *it, Flag};
860 Aux = DAG.getNode(ARMISD::BR, VTs, Ops, 4);
861 }
862 return Aux;
Rafael Espindola687bc492006-08-24 13:45:55 +0000863}
864
Rafael Espindola27185192006-09-29 21:20:16 +0000865static SDOperand LowerSINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
Rafael Espindola9e071f02006-10-02 19:30:56 +0000866 SDOperand IntVal = Op.getOperand(0);
Rafael Espindola27185192006-09-29 21:20:16 +0000867 assert(IntVal.getValueType() == MVT::i32);
Rafael Espindola9e071f02006-10-02 19:30:56 +0000868 MVT::ValueType vt = Op.getValueType();
869 assert(vt == MVT::f32 ||
870 vt == MVT::f64);
Rafael Espindola27185192006-09-29 21:20:16 +0000871
872 SDOperand Tmp = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, IntVal);
Rafael Espindola9e071f02006-10-02 19:30:56 +0000873 ARMISD::NodeType op = vt == MVT::f32 ? ARMISD::FSITOS : ARMISD::FSITOD;
874 return DAG.getNode(op, vt, Tmp);
Rafael Espindola27185192006-09-29 21:20:16 +0000875}
876
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000877static SDOperand LowerFP_TO_SINT(SDOperand Op, SelectionDAG &DAG) {
878 assert(Op.getValueType() == MVT::i32);
879 SDOperand FloatVal = Op.getOperand(0);
880 MVT::ValueType vt = FloatVal.getValueType();
881 assert(vt == MVT::f32 || vt == MVT::f64);
882
883 ARMISD::NodeType op = vt == MVT::f32 ? ARMISD::FTOSIS : ARMISD::FTOSID;
884 SDOperand Tmp = DAG.getNode(op, MVT::f32, FloatVal);
885 return DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Tmp);
886}
887
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000888static SDOperand LowerUINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
889 SDOperand IntVal = Op.getOperand(0);
890 assert(IntVal.getValueType() == MVT::i32);
891 MVT::ValueType vt = Op.getValueType();
892 assert(vt == MVT::f32 ||
893 vt == MVT::f64);
894
895 SDOperand Tmp = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, IntVal);
896 ARMISD::NodeType op = vt == MVT::f32 ? ARMISD::FUITOS : ARMISD::FUITOD;
897 return DAG.getNode(op, vt, Tmp);
898}
899
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000900static SDOperand LowerFP_TO_UINT(SDOperand Op, SelectionDAG &DAG) {
901 assert(Op.getValueType() == MVT::i32);
902 SDOperand FloatVal = Op.getOperand(0);
903 MVT::ValueType vt = FloatVal.getValueType();
904 assert(vt == MVT::f32 || vt == MVT::f64);
905
906 ARMISD::NodeType op = vt == MVT::f32 ? ARMISD::FTOUIS : ARMISD::FTOUID;
907 SDOperand Tmp = DAG.getNode(op, MVT::f32, FloatVal);
908 return DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Tmp);
909}
910
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000911SDOperand ARMTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
912 switch (Op.getOpcode()) {
913 default:
914 assert(0 && "Should not custom lower this!");
Rafael Espindola1c8f0532006-05-15 22:34:39 +0000915 abort();
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000916 case ISD::ConstantPool:
917 return LowerConstantPool(Op, DAG);
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +0000918 case ISD::ConstantFP:
919 return LowerConstantFP(Op, DAG);
Rafael Espindola06c1e7e2006-08-01 12:58:43 +0000920 case ISD::GlobalAddress:
921 return LowerGlobalAddress(Op, DAG);
Rafael Espindolab47e1d02006-10-10 18:55:14 +0000922 case ISD::FP_TO_SINT:
923 return LowerFP_TO_SINT(Op, DAG);
Rafael Espindola27185192006-09-29 21:20:16 +0000924 case ISD::SINT_TO_FP:
925 return LowerSINT_TO_FP(Op, DAG);
Rafael Espindola493a7fc2006-10-10 20:38:57 +0000926 case ISD::FP_TO_UINT:
927 return LowerFP_TO_UINT(Op, DAG);
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +0000928 case ISD::UINT_TO_FP:
929 return LowerUINT_TO_FP(Op, DAG);
Rafael Espindoladc124a22006-05-18 21:45:49 +0000930 case ISD::FORMAL_ARGUMENTS:
Rafael Espindola755be9b2006-08-25 17:55:16 +0000931 return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex);
Rafael Espindolac3c1a862006-05-25 11:00:18 +0000932 case ISD::CALL:
933 return LowerCALL(Op, DAG);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000934 case ISD::RET:
935 return LowerRET(Op, DAG);
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000936 case ISD::SELECT_CC:
937 return LowerSELECT_CC(Op, DAG);
Rafael Espindola687bc492006-08-24 13:45:55 +0000938 case ISD::BR_CC:
939 return LowerBR_CC(Op, DAG);
Rafael Espindola755be9b2006-08-25 17:55:16 +0000940 case ISD::VASTART:
941 return LowerVASTART(Op, DAG, VarArgsFrameIndex);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000942 }
943}
944
945//===----------------------------------------------------------------------===//
946// Instruction Selector Implementation
947//===----------------------------------------------------------------------===//
948
949//===--------------------------------------------------------------------===//
950/// ARMDAGToDAGISel - ARM specific code to select ARM machine
951/// instructions for SelectionDAG operations.
952///
953namespace {
954class ARMDAGToDAGISel : public SelectionDAGISel {
955 ARMTargetLowering Lowering;
956
957public:
958 ARMDAGToDAGISel(TargetMachine &TM)
959 : SelectionDAGISel(Lowering), Lowering(TM) {
960 }
961
Evan Cheng9ade2182006-08-26 05:34:46 +0000962 SDNode *Select(SDOperand Op);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000963 virtual void InstructionSelectBasicBlock(SelectionDAG &DAG);
Evan Cheng0d538262006-11-08 20:34:28 +0000964 bool SelectAddrMode1(SDOperand Op, SDOperand N, SDOperand &Arg,
965 SDOperand &Shift, SDOperand &ShiftType);
Rafael Espindolaf64945d2006-12-12 01:03:11 +0000966 bool SelectAddrMode1a(SDOperand Op, SDOperand N, SDOperand &Arg,
967 SDOperand &Shift, SDOperand &ShiftType);
Evan Cheng0d538262006-11-08 20:34:28 +0000968 bool SelectAddrMode2(SDOperand Op, SDOperand N, SDOperand &Arg,
969 SDOperand &Offset);
970 bool SelectAddrMode5(SDOperand Op, SDOperand N, SDOperand &Arg,
971 SDOperand &Offset);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000972
973 // Include the pieces autogenerated from the target description.
974#include "ARMGenDAGISel.inc"
975};
976
977void ARMDAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) {
978 DEBUG(BB->dump());
979
980 DAG.setRoot(SelectRoot(DAG.getRoot()));
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000981 DAG.RemoveDeadNodes();
982
983 ScheduleAndEmitDAG(DAG);
984}
985
Rafael Espindola61369da2006-08-14 19:01:24 +0000986static bool isInt12Immediate(SDNode *N, short &Imm) {
987 if (N->getOpcode() != ISD::Constant)
988 return false;
989
990 int32_t t = cast<ConstantSDNode>(N)->getValue();
Rafael Espindola7246d332006-09-21 11:29:52 +0000991 int max = 1<<12;
Rafael Espindola61369da2006-08-14 19:01:24 +0000992 int min = -max;
993 if (t > min && t < max) {
994 Imm = t;
995 return true;
996 }
997 else
998 return false;
999}
1000
1001static bool isInt12Immediate(SDOperand Op, short &Imm) {
1002 return isInt12Immediate(Op.Val, Imm);
1003}
1004
Evan Cheng0d538262006-11-08 20:34:28 +00001005bool ARMDAGToDAGISel::SelectAddrMode1(SDOperand Op,
1006 SDOperand N,
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +00001007 SDOperand &Arg,
1008 SDOperand &Shift,
1009 SDOperand &ShiftType) {
Rafael Espindola7cca7c52006-09-11 17:25:40 +00001010 switch(N.getOpcode()) {
Rafael Espindola7cca7c52006-09-11 17:25:40 +00001011 case ISD::Constant: {
Rafael Espindola7246d332006-09-21 11:29:52 +00001012 uint32_t val = cast<ConstantSDNode>(N)->getValue();
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +00001013 Shift = CurDAG->getTargetConstant(0, MVT::i32);
1014 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
1015 Arg = LegalizeImmediate(val, *CurDAG, true);
Rafael Espindola7cca7c52006-09-11 17:25:40 +00001016 return true;
1017 }
Lauro Ramos Venancioa38bbf72007-01-12 20:35:49 +00001018
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +00001019 case ISD::SRA:
1020 Arg = N.getOperand(0);
1021 Shift = N.getOperand(1);
1022 ShiftType = CurDAG->getTargetConstant(ARMShift::ASR, MVT::i32);
1023 return true;
1024 case ISD::SRL:
1025 Arg = N.getOperand(0);
1026 Shift = N.getOperand(1);
1027 ShiftType = CurDAG->getTargetConstant(ARMShift::LSR, MVT::i32);
1028 return true;
1029 case ISD::SHL:
1030 Arg = N.getOperand(0);
1031 Shift = N.getOperand(1);
1032 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
1033 return true;
Rafael Espindola7cca7c52006-09-11 17:25:40 +00001034 }
Rafael Espindola1b3956b2006-09-11 19:23:32 +00001035
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +00001036 Arg = N;
1037 Shift = CurDAG->getTargetConstant(0, MVT::i32);
1038 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
Rafael Espindola1b3956b2006-09-11 19:23:32 +00001039 return true;
Rafael Espindola7cca7c52006-09-11 17:25:40 +00001040}
1041
Evan Cheng0d538262006-11-08 20:34:28 +00001042bool ARMDAGToDAGISel::SelectAddrMode2(SDOperand Op, SDOperand N,
1043 SDOperand &Arg, SDOperand &Offset) {
Rafael Espindola6e8c6492006-11-08 17:07:32 +00001044 //TODO: complete and cleanup!
1045 SDOperand Zero = CurDAG->getTargetConstant(0, MVT::i32);
1046 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N)) {
1047 Arg = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
1048 Offset = Zero;
1049 return true;
1050 }
1051 if (N.getOpcode() == ISD::ADD) {
1052 short imm = 0;
1053 if (isInt12Immediate(N.getOperand(1), imm)) {
1054 Offset = CurDAG->getTargetConstant(imm, MVT::i32);
1055 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) {
1056 Arg = CurDAG->getTargetFrameIndex(FI->getIndex(), N.getValueType());
1057 } else {
1058 Arg = N.getOperand(0);
1059 }
1060 return true; // [r+i]
1061 }
1062 }
1063 Offset = Zero;
1064 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N))
1065 Arg = CurDAG->getTargetFrameIndex(FI->getIndex(), N.getValueType());
1066 else
1067 Arg = N;
1068 return true;
1069}
1070
Evan Cheng0d538262006-11-08 20:34:28 +00001071bool ARMDAGToDAGISel::SelectAddrMode5(SDOperand Op,
1072 SDOperand N, SDOperand &Arg,
Rafael Espindola32bd5f42006-10-17 18:04:53 +00001073 SDOperand &Offset) {
1074 //TODO: detect offset
1075 Offset = CurDAG->getTargetConstant(0, MVT::i32);
1076 Arg = N;
1077 return true;
1078}
1079
Evan Cheng9ade2182006-08-26 05:34:46 +00001080SDNode *ARMDAGToDAGISel::Select(SDOperand Op) {
Rafael Espindola337c4ad62006-06-12 12:28:08 +00001081 SDNode *N = Op.Val;
1082
1083 switch (N->getOpcode()) {
1084 default:
Evan Cheng9ade2182006-08-26 05:34:46 +00001085 return SelectCode(Op);
Rafael Espindola337c4ad62006-06-12 12:28:08 +00001086 break;
Rafael Espindolaf819a492006-11-09 13:58:55 +00001087 case ISD::FrameIndex: {
1088 int FI = cast<FrameIndexSDNode>(N)->getIndex();
1089 SDOperand Ops[] = {CurDAG->getTargetFrameIndex(FI, MVT::i32),
1090 CurDAG->getTargetConstant(0, MVT::i32),
1091 CurDAG->getTargetConstant(0, MVT::i32),
1092 CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32)};
1093
1094 return CurDAG->SelectNodeTo(N, ARM::ADD, MVT::i32, Ops,
1095 sizeof(Ops)/sizeof(SDOperand));
1096 break;
Rafael Espindola337c4ad62006-06-12 12:28:08 +00001097 }
Rafael Espindolaf819a492006-11-09 13:58:55 +00001098 }
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00001099}
1100
1101} // end anonymous namespace
1102
1103/// createARMISelDag - This pass converts a legalized DAG into a
1104/// ARM-specific DAG, ready for instruction scheduling.
1105///
1106FunctionPass *llvm::createARMISelDag(TargetMachine &TM) {
1107 return new ARMDAGToDAGISel(TM);
1108}