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