blob: 31b0c41f08f52e37c2aed8dd8dd15ec3791f8780 [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()) {
Jim Grosbach7e99a602012-06-18 19:45:50 +000034 NopInst.setOpcode(ARM::HINT);
35 NopInst.addOperand(MCOperand::CreateImm(0));
Jim Grosbachc01810e2012-02-28 23:53:30 +000036 NopInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
37 NopInst.addOperand(MCOperand::CreateReg(0));
38 } else {
39 NopInst.setOpcode(ARM::MOVr);
40 NopInst.addOperand(MCOperand::CreateReg(ARM::R0));
41 NopInst.addOperand(MCOperand::CreateReg(ARM::R0));
42 NopInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
43 NopInst.addOperand(MCOperand::CreateReg(0));
44 NopInst.addOperand(MCOperand::CreateReg(0));
45 }
46}
47
Chris Lattnerd90183d2009-08-02 05:20:37 +000048unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const {
Evan Chenga8e29892007-01-19 07:51:42 +000049 switch (Opc) {
50 default: break;
Owen Anderson9ab0f252011-08-26 20:43:14 +000051 case ARM::LDR_PRE_IMM:
52 case ARM::LDR_PRE_REG:
Owen Anderson793e7962011-07-26 20:54:26 +000053 case ARM::LDR_POST_IMM:
54 case ARM::LDR_POST_REG:
Jim Grosbach3e556122010-10-26 22:37:02 +000055 return ARM::LDRi12;
Evan Chenga8e29892007-01-19 07:51:42 +000056 case ARM::LDRH_PRE:
57 case ARM::LDRH_POST:
58 return ARM::LDRH;
Owen Anderson9ab0f252011-08-26 20:43:14 +000059 case ARM::LDRB_PRE_IMM:
60 case ARM::LDRB_PRE_REG:
Owen Anderson793e7962011-07-26 20:54:26 +000061 case ARM::LDRB_POST_IMM:
62 case ARM::LDRB_POST_REG:
Jim Grosbachc1d30212010-10-27 00:19:44 +000063 return ARM::LDRBi12;
Evan Chenga8e29892007-01-19 07:51:42 +000064 case ARM::LDRSH_PRE:
65 case ARM::LDRSH_POST:
66 return ARM::LDRSH;
67 case ARM::LDRSB_PRE:
68 case ARM::LDRSB_POST:
69 return ARM::LDRSB;
Owen Anderson793e7962011-07-26 20:54:26 +000070 case ARM::STR_PRE_IMM:
71 case ARM::STR_PRE_REG:
72 case ARM::STR_POST_IMM:
73 case ARM::STR_POST_REG:
Jim Grosbach7e3383c2010-10-27 23:12:14 +000074 return ARM::STRi12;
Evan Chenga8e29892007-01-19 07:51:42 +000075 case ARM::STRH_PRE:
76 case ARM::STRH_POST:
77 return ARM::STRH;
Owen Anderson793e7962011-07-26 20:54:26 +000078 case ARM::STRB_PRE_IMM:
79 case ARM::STRB_PRE_REG:
80 case ARM::STRB_POST_IMM:
81 case ARM::STRB_POST_REG:
Jim Grosbach7e3383c2010-10-27 23:12:14 +000082 return ARM::STRBi12;
Evan Chenga8e29892007-01-19 07:51:42 +000083 }
David Goodwin334c2642009-07-08 16:09:28 +000084
Evan Chenga8e29892007-01-19 07:51:42 +000085 return 0;
86}