LLVM API Documentation

Thumb2RegisterInfo.cpp
Go to the documentation of this file.
00001 //===-- Thumb2RegisterInfo.cpp - Thumb-2 Register Information -------------===//
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
00011 // class.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "Thumb2RegisterInfo.h"
00016 #include "ARM.h"
00017 #include "ARMSubtarget.h"
00018 #include "llvm/CodeGen/MachineConstantPool.h"
00019 #include "llvm/CodeGen/MachineFunction.h"
00020 #include "llvm/CodeGen/MachineInstrBuilder.h"
00021 #include "llvm/IR/Constants.h"
00022 #include "llvm/IR/DerivedTypes.h"
00023 #include "llvm/IR/Function.h"
00024 #include "llvm/Target/TargetInstrInfo.h"
00025 #include "llvm/Target/TargetMachine.h"
00026 using namespace llvm;
00027 
00028 Thumb2RegisterInfo::Thumb2RegisterInfo(const ARMSubtarget &sti)
00029   : ARMBaseRegisterInfo(sti) {
00030 }
00031 
00032 /// emitLoadConstPool - Emits a load from constpool to materialize the
00033 /// specified immediate.
00034 void
00035 Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB,
00036                                       MachineBasicBlock::iterator &MBBI,
00037                                       DebugLoc dl,
00038                                       unsigned DestReg, unsigned SubIdx,
00039                                       int Val,
00040                                       ARMCC::CondCodes Pred, unsigned PredReg,
00041                                       unsigned MIFlags) const {
00042   MachineFunction &MF = *MBB.getParent();
00043   const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
00044   MachineConstantPool *ConstantPool = MF.getConstantPool();
00045   const Constant *C = ConstantInt::get(
00046            Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val);
00047   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
00048 
00049   BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci))
00050     .addReg(DestReg, getDefRegState(true), SubIdx)
00051     .addConstantPoolIndex(Idx).addImm((int64_t)ARMCC::AL).addReg(0)
00052     .setMIFlags(MIFlags);
00053 }