LLVM API Documentation

ARMInstrInfo.cpp

Go to the documentation of this file.
00001 //===- ARMInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the ARM implementation of the TargetInstrInfo class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "ARMInstrInfo.h"
00015 #include "ARM.h"
00016 #include "ARMAddressingModes.h"
00017 #include "ARMGenInstrInfo.inc"
00018 #include "ARMMachineFunctionInfo.h"
00019 #include "llvm/ADT/STLExtras.h"
00020 #include "llvm/CodeGen/LiveVariables.h"
00021 #include "llvm/CodeGen/MachineFrameInfo.h"
00022 #include "llvm/CodeGen/MachineInstrBuilder.h"
00023 #include "llvm/CodeGen/MachineJumpTableInfo.h"
00024 #include "llvm/Target/TargetAsmInfo.h"
00025 #include "llvm/Support/CommandLine.h"
00026 using namespace llvm;
00027 
00028 ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI)
00029   : RI(*this, STI), Subtarget(STI) {
00030 }
00031 
00032 unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const {
00033   switch (Opc) {
00034   default: break;
00035   case ARM::LDR_PRE:
00036   case ARM::LDR_POST:
00037     return ARM::LDR;
00038   case ARM::LDRH_PRE:
00039   case ARM::LDRH_POST:
00040     return ARM::LDRH;
00041   case ARM::LDRB_PRE:
00042   case ARM::LDRB_POST:
00043     return ARM::LDRB;
00044   case ARM::LDRSH_PRE:
00045   case ARM::LDRSH_POST:
00046     return ARM::LDRSH;
00047   case ARM::LDRSB_PRE:
00048   case ARM::LDRSB_POST:
00049     return ARM::LDRSB;
00050   case ARM::STR_PRE:
00051   case ARM::STR_POST:
00052     return ARM::STR;
00053   case ARM::STRH_PRE:
00054   case ARM::STRH_POST:
00055     return ARM::STRH;
00056   case ARM::STRB_PRE:
00057   case ARM::STRB_POST:
00058     return ARM::STRB;
00059   }
00060 
00061   return 0;
00062 }
00063 
00064 bool ARMInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
00065   if (MBB.empty()) return false;
00066 
00067   switch (MBB.back().getOpcode()) {
00068   case ARM::BX_RET:   // Return.
00069   case ARM::LDM_RET:
00070   case ARM::B:
00071   case ARM::BR_JTr:   // Jumptable branch.
00072   case ARM::BR_JTm:   // Jumptable branch through mem.
00073   case ARM::BR_JTadd: // Jumptable branch add to pc.
00074     return true;
00075   default:
00076     break;
00077   }
00078 
00079   return false;
00080 }
00081 
00082 void ARMInstrInfo::
00083 reMaterialize(MachineBasicBlock &MBB,
00084               MachineBasicBlock::iterator I,
00085               unsigned DestReg, unsigned SubIdx,
00086               const MachineInstr *Orig) const {
00087   DebugLoc dl = Orig->getDebugLoc();
00088   if (Orig->getOpcode() == ARM::MOVi2pieces) {
00089     RI.emitLoadConstPool(MBB, I, dl,
00090                          DestReg, SubIdx,
00091                          Orig->getOperand(1).getImm(),
00092                          (ARMCC::CondCodes)Orig->getOperand(2).getImm(),
00093                          Orig->getOperand(3).getReg());
00094     return;
00095   }
00096 
00097   MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig);
00098   MI->getOperand(0).setReg(DestReg);
00099   MBB.insert(I, MI);
00100 }
00101