Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 1 | //===- ARMInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the "Instituto Nokia de Tecnologia" and |
| 6 | // is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // |
| 11 | // This file contains the ARM implementation of the TargetInstrInfo class. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "ARMInstrInfo.h" |
| 16 | #include "ARM.h" |
| 17 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 18 | #include "ARMGenInstrInfo.inc" |
| 19 | using namespace llvm; |
| 20 | |
| 21 | ARMInstrInfo::ARMInstrInfo() |
Evan Cheng | c0f64ff | 2006-11-27 23:37:22 +0000 | [diff] [blame] | 22 | : TargetInstrInfo(ARMInsts, sizeof(ARMInsts)/sizeof(ARMInsts[0])), |
| 23 | RI(*this) { |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 24 | } |
| 25 | |
Rafael Espindola | 46adf81 | 2006-08-08 20:35:03 +0000 | [diff] [blame] | 26 | const TargetRegisterClass *ARMInstrInfo::getPointerRegClass() const { |
| 27 | return &ARM::IntRegsRegClass; |
| 28 | } |
| 29 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 30 | /// Return true if the instruction is a register to register move and |
| 31 | /// leave the source and dest operands in the passed parameters. |
| 32 | /// |
| 33 | bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI, |
| 34 | unsigned &SrcReg, unsigned &DstReg) const { |
Rafael Espindola | 49e4415 | 2006-06-27 21:52:45 +0000 | [diff] [blame] | 35 | MachineOpCode oc = MI.getOpcode(); |
| 36 | switch (oc) { |
Rafael Espindola | 3ad5e5c | 2006-09-13 12:09:43 +0000 | [diff] [blame] | 37 | case ARM::MOV: { |
| 38 | assert(MI.getNumOperands() == 4 && |
Rafael Espindola | 49e4415 | 2006-06-27 21:52:45 +0000 | [diff] [blame] | 39 | MI.getOperand(0).isRegister() && |
Rafael Espindola | 49e4415 | 2006-06-27 21:52:45 +0000 | [diff] [blame] | 40 | "Invalid ARM MOV instruction"); |
Rafael Espindola | 3ad5e5c | 2006-09-13 12:09:43 +0000 | [diff] [blame] | 41 | const MachineOperand &Arg = MI.getOperand(1); |
| 42 | const MachineOperand &Shift = MI.getOperand(2); |
| 43 | if (Arg.isRegister() && Shift.isImmediate() && Shift.getImmedValue() == 0) { |
Rafael Espindola | 7cca7c5 | 2006-09-11 17:25:40 +0000 | [diff] [blame] | 44 | SrcReg = MI.getOperand(1).getReg(); |
| 45 | DstReg = MI.getOperand(0).getReg(); |
| 46 | return true; |
| 47 | } |
Rafael Espindola | 49e4415 | 2006-06-27 21:52:45 +0000 | [diff] [blame] | 48 | } |
Rafael Espindola | 3ad5e5c | 2006-09-13 12:09:43 +0000 | [diff] [blame] | 49 | } |
Rafael Espindola | 7cca7c5 | 2006-09-11 17:25:40 +0000 | [diff] [blame] | 50 | return false; |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 51 | } |
Chris Lattner | 578e64a | 2006-10-24 16:47:57 +0000 | [diff] [blame] | 52 | |
| 53 | void ARMInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB, |
| 54 | MachineBasicBlock *FBB, |
| 55 | const std::vector<MachineOperand> &Cond)const{ |
| 56 | // Can only insert uncond branches so far. |
| 57 | assert(Cond.empty() && !FBB && TBB && "Can only handle uncond branches!"); |
Evan Cheng | c0f64ff | 2006-11-27 23:37:22 +0000 | [diff] [blame] | 58 | BuildMI(&MBB, get(ARM::b)).addMBB(TBB); |
Rafael Espindola | 3d7d39a | 2006-10-24 17:07:11 +0000 | [diff] [blame] | 59 | } |