1 //===-- Thumb2RegisterInfo.cpp - Thumb-2 Register Information -------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file contains the Thumb-2 implementation of the TargetRegisterInfo 11 // class. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #include "Thumb2RegisterInfo.h" 16 #include "ARM.h" 17 #include "ARMBaseInstrInfo.h" 18 #include "ARMSubtarget.h" 19 #include "llvm/CodeGen/MachineConstantPool.h" 20 #include "llvm/CodeGen/MachineFunction.h" 21 #include "llvm/CodeGen/MachineInstrBuilder.h" 22 #include "llvm/IR/Constants.h" 23 #include "llvm/IR/DerivedTypes.h" 24 #include "llvm/IR/Function.h" 25 using namespace llvm; 26 27 Thumb2RegisterInfo::Thumb2RegisterInfo(const ARMSubtarget &sti) 28 : ARMBaseRegisterInfo(sti) { 29 } 30 31 /// emitLoadConstPool - Emits a load from constpool to materialize the 32 /// specified immediate. 33 void 34 Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB, 35 MachineBasicBlock::iterator &MBBI, 36 DebugLoc dl, 37 unsigned DestReg, unsigned SubIdx, 38 int Val, 39 ARMCC::CondCodes Pred, unsigned PredReg, 40 unsigned MIFlags) const { 41 MachineFunction &MF = *MBB.getParent(); 42 const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); 43 MachineConstantPool *ConstantPool = MF.getConstantPool(); 44 const Constant *C = ConstantInt::get( 45 Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val); 46 unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4); 47 48 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci)) 49 .addReg(DestReg, getDefRegState(true), SubIdx) 50 .addConstantPoolIndex(Idx).addImm((int64_t)ARMCC::AL).addReg(0) 51 .setMIFlags(MIFlags); 52 } 53