1 //===- ARMInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
9 //===----------------------------------------------------------------------===//
11 // This file contains the ARM implementation of the TargetInstrInfo class.
13 //===----------------------------------------------------------------------===//
15 #include "ARMInstrInfo.h"
17 #include "llvm/CodeGen/MachineInstrBuilder.h"
18 #include "ARMGenInstrInfo.inc"
21 ARMInstrInfo::ARMInstrInfo()
22 : TargetInstrInfo(ARMInsts, sizeof(ARMInsts)/sizeof(ARMInsts[0])),
26 const TargetRegisterClass *ARMInstrInfo::getPointerRegClass() const {
27 return &ARM::IntRegsRegClass;
30 /// Return true if the instruction is a register to register move and
31 /// leave the source and dest operands in the passed parameters.
33 bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI,
34 unsigned &SrcReg, unsigned &DstReg) const {
35 MachineOpCode oc = MI.getOpcode();
38 assert(MI.getNumOperands() == 4 &&
39 MI.getOperand(0).isRegister() &&
40 "Invalid ARM MOV instruction");
41 const MachineOperand &Arg = MI.getOperand(1);
42 const MachineOperand &Shift = MI.getOperand(2);
43 if (Arg.isRegister() && Shift.isImmediate() && Shift.getImmedValue() == 0) {
44 SrcReg = MI.getOperand(1).getReg();
45 DstReg = MI.getOperand(0).getReg();
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!");
58 BuildMI(&MBB, get(ARM::b)).addMBB(TBB);