blob: f99615b5722348615b5f342d6c87629aea75dcd9 [file] [log] [blame]
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00001//===- 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"
19using namespace llvm;
20
21ARMInstrInfo::ARMInstrInfo()
Evan Chengc0f64ff2006-11-27 23:37:22 +000022 : TargetInstrInfo(ARMInsts, sizeof(ARMInsts)/sizeof(ARMInsts[0])),
23 RI(*this) {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000024}
25
Rafael Espindola46adf812006-08-08 20:35:03 +000026const TargetRegisterClass *ARMInstrInfo::getPointerRegClass() const {
27 return &ARM::IntRegsRegClass;
28}
29
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000030/// Return true if the instruction is a register to register move and
31/// leave the source and dest operands in the passed parameters.
32///
33bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI,
34 unsigned &SrcReg, unsigned &DstReg) const {
Rafael Espindola49e44152006-06-27 21:52:45 +000035 MachineOpCode oc = MI.getOpcode();
36 switch (oc) {
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000037 case ARM::MOV: {
38 assert(MI.getNumOperands() == 4 &&
Rafael Espindola49e44152006-06-27 21:52:45 +000039 MI.getOperand(0).isRegister() &&
Rafael Espindola49e44152006-06-27 21:52:45 +000040 "Invalid ARM MOV instruction");
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000041 const MachineOperand &Arg = MI.getOperand(1);
42 const MachineOperand &Shift = MI.getOperand(2);
43 if (Arg.isRegister() && Shift.isImmediate() && Shift.getImmedValue() == 0) {
Rafael Espindola7cca7c52006-09-11 17:25:40 +000044 SrcReg = MI.getOperand(1).getReg();
45 DstReg = MI.getOperand(0).getReg();
46 return true;
47 }
Rafael Espindola49e44152006-06-27 21:52:45 +000048 }
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000049 }
Rafael Espindola7cca7c52006-09-11 17:25:40 +000050 return false;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000051}
Chris Lattner578e64a2006-10-24 16:47:57 +000052
53void 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 Chengc0f64ff2006-11-27 23:37:22 +000058 BuildMI(&MBB, get(ARM::b)).addMBB(TBB);
Rafael Espindola3d7d39a2006-10-24 17:07:11 +000059}