LLVM API Documentation

ARMFeatures.h
Go to the documentation of this file.
00001 //===-- ARMFeatures.h - Checks for ARM instruction features -----*- 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 code shared between ARM CodeGen and ARM MC
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_ARM_ARMFEATURES_H
00015 #define LLVM_LIB_TARGET_ARM_ARMFEATURES_H
00016 
00017 #include "MCTargetDesc/ARMMCTargetDesc.h"
00018 
00019 namespace llvm {
00020 
00021 template<typename InstrType> // could be MachineInstr or MCInst
00022 bool IsCPSRDead(InstrType *Instr);
00023 
00024 template<typename InstrType> // could be MachineInstr or MCInst
00025 inline bool isV8EligibleForIT(InstrType *Instr) {
00026   switch (Instr->getOpcode()) {
00027   default:
00028     return false;
00029   case ARM::tADC:
00030   case ARM::tADDi3:
00031   case ARM::tADDi8:
00032   case ARM::tADDrr:
00033   case ARM::tAND:
00034   case ARM::tASRri:
00035   case ARM::tASRrr:
00036   case ARM::tBIC:
00037   case ARM::tEOR:
00038   case ARM::tLSLri:
00039   case ARM::tLSLrr:
00040   case ARM::tLSRri:
00041   case ARM::tLSRrr:
00042   case ARM::tMOVi8:
00043   case ARM::tMUL:
00044   case ARM::tMVN:
00045   case ARM::tORR:
00046   case ARM::tROR:
00047   case ARM::tRSB:
00048   case ARM::tSBC:
00049   case ARM::tSUBi3:
00050   case ARM::tSUBi8:
00051   case ARM::tSUBrr:
00052     // Outside of an IT block, these set CPSR.
00053     return IsCPSRDead(Instr);
00054   case ARM::tADDrSPi:
00055   case ARM::tCMNz:
00056   case ARM::tCMPi8:
00057   case ARM::tCMPr:
00058   case ARM::tLDRBi:
00059   case ARM::tLDRBr:
00060   case ARM::tLDRHi:
00061   case ARM::tLDRHr:
00062   case ARM::tLDRSB:
00063   case ARM::tLDRSH:
00064   case ARM::tLDRi:
00065   case ARM::tLDRr:
00066   case ARM::tLDRspi:
00067   case ARM::tSTRBi:
00068   case ARM::tSTRBr:
00069   case ARM::tSTRHi:
00070   case ARM::tSTRHr:
00071   case ARM::tSTRi:
00072   case ARM::tSTRr:
00073   case ARM::tSTRspi:
00074   case ARM::tTST:
00075     return true;
00076 // there are some "conditionally deprecated" opcodes
00077   case ARM::tADDspr:
00078   case ARM::tBLXr:
00079     return Instr->getOperand(2).getReg() != ARM::PC;
00080   // ADD PC, SP and BLX PC were always unpredictable,
00081   // now on top of it they're deprecated
00082   case ARM::tADDrSP:
00083   case ARM::tBX:
00084     return Instr->getOperand(0).getReg() != ARM::PC;
00085   case ARM::tADDhirr:
00086     return Instr->getOperand(0).getReg() != ARM::PC &&
00087            Instr->getOperand(2).getReg() != ARM::PC;
00088   case ARM::tCMPhir:
00089   case ARM::tMOVr:
00090     return Instr->getOperand(0).getReg() != ARM::PC &&
00091            Instr->getOperand(1).getReg() != ARM::PC;
00092   }
00093 }
00094 
00095 }
00096 
00097 #endif