blob: c61d83630c95a3d66d6380d0abf752c7e750d775 [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()
22 : TargetInstrInfo(ARMInsts, sizeof(ARMInsts)/sizeof(ARMInsts[0])) {
23}
24
Rafael Espindola46adf812006-08-08 20:35:03 +000025const TargetRegisterClass *ARMInstrInfo::getPointerRegClass() const {
26 return &ARM::IntRegsRegClass;
27}
28
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000029/// Return true if the instruction is a register to register move and
30/// leave the source and dest operands in the passed parameters.
31///
32bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI,
33 unsigned &SrcReg, unsigned &DstReg) const {
Rafael Espindola49e44152006-06-27 21:52:45 +000034 MachineOpCode oc = MI.getOpcode();
35 switch (oc) {
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000036 case ARM::MOV: {
37 assert(MI.getNumOperands() == 4 &&
Rafael Espindola49e44152006-06-27 21:52:45 +000038 MI.getOperand(0).isRegister() &&
Rafael Espindola49e44152006-06-27 21:52:45 +000039 "Invalid ARM MOV instruction");
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000040 const MachineOperand &Arg = MI.getOperand(1);
41 const MachineOperand &Shift = MI.getOperand(2);
42 if (Arg.isRegister() && Shift.isImmediate() && Shift.getImmedValue() == 0) {
Rafael Espindola7cca7c52006-09-11 17:25:40 +000043 SrcReg = MI.getOperand(1).getReg();
44 DstReg = MI.getOperand(0).getReg();
45 return true;
46 }
Rafael Espindola49e44152006-06-27 21:52:45 +000047 }
Rafael Espindola3ad5e5c2006-09-13 12:09:43 +000048 }
Rafael Espindola7cca7c52006-09-11 17:25:40 +000049 return false;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000050}
Chris Lattner578e64a2006-10-24 16:47:57 +000051
52void ARMInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB,
53 MachineBasicBlock *FBB,
54 const std::vector<MachineOperand> &Cond)const{
55 // Can only insert uncond branches so far.
56 assert(Cond.empty() && !FBB && TBB && "Can only handle uncond branches!");
57 BuildMI(&MBB, ARM::b, 1).addMBB(TBB);
58}