Thumb2RegisterInfo.cpp revision 263508
198944Sobrien//===-- Thumb2RegisterInfo.cpp - Thumb-2 Register Information -------------===// 298944Sobrien// 3130803Smarcel// The LLVM Compiler Infrastructure 4130803Smarcel// 598944Sobrien// This file is distributed under the University of Illinois Open Source 698944Sobrien// License. See LICENSE.TXT for details. 798944Sobrien// 898944Sobrien//===----------------------------------------------------------------------===// 998944Sobrien// 1098944Sobrien// This file contains the Thumb-2 implementation of the TargetRegisterInfo 1198944Sobrien// class. 1298944Sobrien// 1398944Sobrien//===----------------------------------------------------------------------===// 1498944Sobrien 1598944Sobrien#include "Thumb2RegisterInfo.h" 1698944Sobrien#include "ARM.h" 1798944Sobrien#include "ARMBaseInstrInfo.h" 1898944Sobrien#include "ARMSubtarget.h" 1998944Sobrien#include "llvm/CodeGen/MachineConstantPool.h" 2098944Sobrien#include "llvm/CodeGen/MachineFunction.h" 2198944Sobrien#include "llvm/CodeGen/MachineInstrBuilder.h" 2298944Sobrien#include "llvm/IR/Constants.h" 2398944Sobrien#include "llvm/IR/DerivedTypes.h" 2498944Sobrien#include "llvm/IR/Function.h" 2598944Sobrienusing namespace llvm; 2698944Sobrien 2798944SobrienThumb2RegisterInfo::Thumb2RegisterInfo(const ARMSubtarget &sti) 2898944Sobrien : ARMBaseRegisterInfo(sti) { 2998944Sobrien} 3098944Sobrien 3198944Sobrien/// emitLoadConstPool - Emits a load from constpool to materialize the 3298944Sobrien/// specified immediate. 3398944Sobrienvoid 3498944SobrienThumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, 3598944Sobrien MachineBasicBlock::iterator &MBBI, 3698944Sobrien DebugLoc dl, 3798944Sobrien unsigned DestReg, unsigned SubIdx, 3898944Sobrien int Val, 3998944Sobrien ARMCC::CondCodes Pred, unsigned PredReg, 4098944Sobrien unsigned MIFlags) const { 4198944Sobrien MachineFunction &MF = *MBB.getParent(); 4298944Sobrien const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); 4398944Sobrien MachineConstantPool *ConstantPool = MF.getConstantPool(); 4498944Sobrien const Constant *C = ConstantInt::get( 4598944Sobrien Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val); 4698944Sobrien unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); 4798944Sobrien 4898944Sobrien BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci)) 4998944Sobrien .addReg(DestReg, getDefRegState(true), SubIdx) 5098944Sobrien .addConstantPoolIndex(Idx).addImm((int64_t)ARMCC::AL).addReg(0) 5198944Sobrien .setMIFlags(MIFlags); 5298944Sobrien} 5398944Sobrien