Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- ARMInstrInfo.cpp - ARM Instruction Information --------------------===// |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 6 | // 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 Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 16 | #include "ARMMachineFunctionInfo.h" |
Evan Cheng | ee04a6d | 2011-07-20 23:34:39 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/ARMAddressingModes.h" |
Owen Anderson | 718cb66 | 2007-09-07 04:06:50 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/STLExtras.h" |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/LiveVariables.h" |
Owen Anderson | d94b6a1 | 2008-01-04 23:57:37 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineFrameInfo.h" |
Evan Cheng | 29836c3 | 2007-01-29 23:45:17 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 22 | #include "llvm/CodeGen/MachineJumpTableInfo.h" |
Chris Lattner | af76e59 | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCAsmInfo.h" |
Jim Grosbach | c01810e | 2012-02-28 23:53:30 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCInst.h" |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 25 | using namespace llvm; |
| 26 | |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 27 | ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI) |
Anton Korobeynikov | f95215f | 2009-11-02 00:10:38 +0000 | [diff] [blame] | 28 | : ARMBaseInstrInfo(STI), RI(*this, STI) { |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 29 | } |
Rafael Espindola | 46adf81 | 2006-08-08 20:35:03 +0000 | [diff] [blame] | 30 | |
Jim Grosbach | c01810e | 2012-02-28 23:53:30 +0000 | [diff] [blame] | 31 | /// getNoopForMachoTarget - Return the noop instruction to use for a noop. |
| 32 | void ARMInstrInfo::getNoopForMachoTarget(MCInst &NopInst) const { |
| 33 | if (hasNOP()) { |
Jim Grosbach | 7e99a60 | 2012-06-18 19:45:50 +0000 | [diff] [blame^] | 34 | NopInst.setOpcode(ARM::HINT); |
| 35 | NopInst.addOperand(MCOperand::CreateImm(0)); |
Jim Grosbach | c01810e | 2012-02-28 23:53:30 +0000 | [diff] [blame] | 36 | 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 Lattner | d90183d | 2009-08-02 05:20:37 +0000 | [diff] [blame] | 48 | unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 49 | switch (Opc) { |
| 50 | default: break; |
Owen Anderson | 9ab0f25 | 2011-08-26 20:43:14 +0000 | [diff] [blame] | 51 | case ARM::LDR_PRE_IMM: |
| 52 | case ARM::LDR_PRE_REG: |
Owen Anderson | 793e796 | 2011-07-26 20:54:26 +0000 | [diff] [blame] | 53 | case ARM::LDR_POST_IMM: |
| 54 | case ARM::LDR_POST_REG: |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 55 | return ARM::LDRi12; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 56 | case ARM::LDRH_PRE: |
| 57 | case ARM::LDRH_POST: |
| 58 | return ARM::LDRH; |
Owen Anderson | 9ab0f25 | 2011-08-26 20:43:14 +0000 | [diff] [blame] | 59 | case ARM::LDRB_PRE_IMM: |
| 60 | case ARM::LDRB_PRE_REG: |
Owen Anderson | 793e796 | 2011-07-26 20:54:26 +0000 | [diff] [blame] | 61 | case ARM::LDRB_POST_IMM: |
| 62 | case ARM::LDRB_POST_REG: |
Jim Grosbach | c1d3021 | 2010-10-27 00:19:44 +0000 | [diff] [blame] | 63 | return ARM::LDRBi12; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 64 | 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 Anderson | 793e796 | 2011-07-26 20:54:26 +0000 | [diff] [blame] | 70 | case ARM::STR_PRE_IMM: |
| 71 | case ARM::STR_PRE_REG: |
| 72 | case ARM::STR_POST_IMM: |
| 73 | case ARM::STR_POST_REG: |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 74 | return ARM::STRi12; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 75 | case ARM::STRH_PRE: |
| 76 | case ARM::STRH_POST: |
| 77 | return ARM::STRH; |
Owen Anderson | 793e796 | 2011-07-26 20:54:26 +0000 | [diff] [blame] | 78 | case ARM::STRB_PRE_IMM: |
| 79 | case ARM::STRB_PRE_REG: |
| 80 | case ARM::STRB_POST_IMM: |
| 81 | case ARM::STRB_POST_REG: |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 82 | return ARM::STRBi12; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 83 | } |
David Goodwin | 334c264 | 2009-07-08 16:09:28 +0000 | [diff] [blame] | 84 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 85 | return 0; |
| 86 | } |