blob: b8f607eb4c552aececa2bd53d01a73b069358902 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- ARMInstrInfo.cpp - ARM Instruction Information --------------------===//
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00006// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the ARM implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ARMInstrInfo.h"
15#include "ARM.h"
Evan Chenga8e29892007-01-19 07:51:42 +000016#include "ARMMachineFunctionInfo.h"
Evan Chengee04a6d2011-07-20 23:34:39 +000017#include "MCTargetDesc/ARMAddressingModes.h"
Owen Anderson718cb662007-09-07 04:06:50 +000018#include "llvm/ADT/STLExtras.h"
Evan Chenga8e29892007-01-19 07:51:42 +000019#include "llvm/CodeGen/LiveVariables.h"
Owen Andersond94b6a12008-01-04 23:57:37 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
Evan Cheng29836c32007-01-29 23:45:17 +000021#include "llvm/CodeGen/MachineInstrBuilder.h"
22#include "llvm/CodeGen/MachineJumpTableInfo.h"
Chris Lattneraf76e592009-08-22 20:48:53 +000023#include "llvm/MC/MCAsmInfo.h"
Jim Grosbachc01810e2012-02-28 23:53:30 +000024#include "llvm/MC/MCInst.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000025using namespace llvm;
26
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000027ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI)
Anton Korobeynikovf95215f2009-11-02 00:10:38 +000028 : ARMBaseInstrInfo(STI), RI(*this, STI) {
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000029}
Rafael Espindola46adf812006-08-08 20:35:03 +000030
Jim Grosbachc01810e2012-02-28 23:53:30 +000031/// getNoopForMachoTarget - Return the noop instruction to use for a noop.
32void ARMInstrInfo::getNoopForMachoTarget(MCInst &NopInst) const {
33 if (hasNOP()) {
34 NopInst.setOpcode(ARM::NOP);
35 NopInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
36 NopInst.addOperand(MCOperand::CreateReg(0));
37 } else {
38 NopInst.setOpcode(ARM::MOVr);
39 NopInst.addOperand(MCOperand::CreateReg(ARM::R0));
40 NopInst.addOperand(MCOperand::CreateReg(ARM::R0));
41 NopInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
42 NopInst.addOperand(MCOperand::CreateReg(0));
43 NopInst.addOperand(MCOperand::CreateReg(0));
44 }
45}
46
Chris Lattnerd90183d2009-08-02 05:20:37 +000047unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const {
Evan Chenga8e29892007-01-19 07:51:42 +000048 switch (Opc) {
49 default: break;
Owen Anderson9ab0f252011-08-26 20:43:14 +000050 case ARM::LDR_PRE_IMM:
51 case ARM::LDR_PRE_REG:
Owen Anderson793e7962011-07-26 20:54:26 +000052 case ARM::LDR_POST_IMM:
53 case ARM::LDR_POST_REG:
Jim Grosbach3e556122010-10-26 22:37:02 +000054 return ARM::LDRi12;
Evan Chenga8e29892007-01-19 07:51:42 +000055 case ARM::LDRH_PRE:
56 case ARM::LDRH_POST:
57 return ARM::LDRH;
Owen Anderson9ab0f252011-08-26 20:43:14 +000058 case ARM::LDRB_PRE_IMM:
59 case ARM::LDRB_PRE_REG:
Owen Anderson793e7962011-07-26 20:54:26 +000060 case ARM::LDRB_POST_IMM:
61 case ARM::LDRB_POST_REG:
Jim Grosbachc1d30212010-10-27 00:19:44 +000062 return ARM::LDRBi12;
Evan Chenga8e29892007-01-19 07:51:42 +000063 case ARM::LDRSH_PRE:
64 case ARM::LDRSH_POST:
65 return ARM::LDRSH;
66 case ARM::LDRSB_PRE:
67 case ARM::LDRSB_POST:
68 return ARM::LDRSB;
Owen Anderson793e7962011-07-26 20:54:26 +000069 case ARM::STR_PRE_IMM:
70 case ARM::STR_PRE_REG:
71 case ARM::STR_POST_IMM:
72 case ARM::STR_POST_REG:
Jim Grosbach7e3383c2010-10-27 23:12:14 +000073 return ARM::STRi12;
Evan Chenga8e29892007-01-19 07:51:42 +000074 case ARM::STRH_PRE:
75 case ARM::STRH_POST:
76 return ARM::STRH;
Owen Anderson793e7962011-07-26 20:54:26 +000077 case ARM::STRB_PRE_IMM:
78 case ARM::STRB_PRE_REG:
79 case ARM::STRB_POST_IMM:
80 case ARM::STRB_POST_REG:
Jim Grosbach7e3383c2010-10-27 23:12:14 +000081 return ARM::STRBi12;
Evan Chenga8e29892007-01-19 07:51:42 +000082 }
David Goodwin334c2642009-07-08 16:09:28 +000083
Evan Chenga8e29892007-01-19 07:51:42 +000084 return 0;
85}