LLVM API Documentation

Thumb2RegisterInfo.cpp

Go to the documentation of this file.
00001 //===- Thumb2RegisterInfo.cpp - Thumb-2 Register 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 Thumb-2 implementation of the TargetRegisterInfo class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "ARM.h"
00015 #include "ARMAddressingModes.h"
00016 #include "ARMBaseInstrInfo.h"
00017 #include "ARMMachineFunctionInfo.h"
00018 #include "ARMSubtarget.h"
00019 #include "Thumb2InstrInfo.h"
00020 #include "Thumb2RegisterInfo.h"
00021 #include "llvm/Constants.h"
00022 #include "llvm/DerivedTypes.h"
00023 #include "llvm/Function.h"
00024 #include "llvm/LLVMContext.h"
00025 #include "llvm/CodeGen/MachineConstantPool.h"
00026 #include "llvm/CodeGen/MachineFrameInfo.h"
00027 #include "llvm/CodeGen/MachineFunction.h"
00028 #include "llvm/CodeGen/MachineInstrBuilder.h"
00029 #include "llvm/CodeGen/MachineLocation.h"
00030 #include "llvm/CodeGen/MachineRegisterInfo.h"
00031 #include "llvm/Target/TargetFrameInfo.h"
00032 #include "llvm/Target/TargetMachine.h"
00033 #include "llvm/ADT/BitVector.h"
00034 #include "llvm/ADT/SmallVector.h"
00035 #include "llvm/Support/CommandLine.h"
00036 #include "llvm/Support/ErrorHandling.h"
00037 using namespace llvm;
00038 
00039 Thumb2RegisterInfo::Thumb2RegisterInfo(const ARMBaseInstrInfo &tii,
00040                                        const ARMSubtarget &sti)
00041   : ARMBaseRegisterInfo(tii, sti) {
00042 }
00043 
00044 /// emitLoadConstPool - Emits a load from constpool to materialize the
00045 /// specified immediate.
00046 void Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB,
00047                                            MachineBasicBlock::iterator &MBBI,
00048                                            DebugLoc dl,
00049                                            unsigned DestReg, unsigned SubIdx,
00050                                            int Val,
00051                                            ARMCC::CondCodes Pred,
00052                                            unsigned PredReg) const {
00053   MachineFunction &MF = *MBB.getParent();
00054   MachineConstantPool *ConstantPool = MF.getConstantPool();
00055   Constant *C = ConstantInt::get(
00056            Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val);
00057   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
00058 
00059   BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci))
00060     .addReg(DestReg, getDefRegState(true), SubIdx)
00061     .addConstantPoolIndex(Idx).addImm((int64_t)ARMCC::AL).addReg(0);
00062 }
00063 
00064 bool Thumb2RegisterInfo::
00065 requiresRegisterScavenging(const MachineFunction &MF) const {
00066   return true;
00067 }