MipsInstrInfo.cpp (193323) | MipsInstrInfo.cpp (193399) |
---|---|
1//===- MipsInstrInfo.cpp - Mips Instruction Information ---------*- C++ -*-===// 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 Mips implementation of the TargetInstrInfo class. 11// 12//===----------------------------------------------------------------------===// 13 14#include "MipsInstrInfo.h" 15#include "MipsTargetMachine.h" | 1//===- MipsInstrInfo.cpp - Mips Instruction Information ---------*- C++ -*-===// 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 Mips implementation of the TargetInstrInfo class. 11// 12//===----------------------------------------------------------------------===// 13 14#include "MipsInstrInfo.h" 15#include "MipsTargetMachine.h" |
16#include "MipsMachineFunction.h" |
|
16#include "llvm/ADT/STLExtras.h" 17#include "llvm/CodeGen/MachineInstrBuilder.h" | 17#include "llvm/ADT/STLExtras.h" 18#include "llvm/CodeGen/MachineInstrBuilder.h" |
19#include "llvm/CodeGen/MachineRegisterInfo.h" |
|
18#include "MipsGenInstrInfo.inc" 19 20using namespace llvm; 21 22MipsInstrInfo::MipsInstrInfo(MipsTargetMachine &tm) 23 : TargetInstrInfoImpl(MipsInsts, array_lengthof(MipsInsts)), 24 TM(tm), RI(*TM.getSubtargetImpl(), *this) {} 25 --- 590 unchanged lines hidden (view full) --- 616bool MipsInstrInfo:: 617ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const 618{ 619 assert( (Cond.size() == 3 || Cond.size() == 2) && 620 "Invalid Mips branch condition!"); 621 Cond[0].setImm(GetOppositeBranchCondition((Mips::CondCode)Cond[0].getImm())); 622 return false; 623} | 20#include "MipsGenInstrInfo.inc" 21 22using namespace llvm; 23 24MipsInstrInfo::MipsInstrInfo(MipsTargetMachine &tm) 25 : TargetInstrInfoImpl(MipsInsts, array_lengthof(MipsInsts)), 26 TM(tm), RI(*TM.getSubtargetImpl(), *this) {} 27 --- 590 unchanged lines hidden (view full) --- 618bool MipsInstrInfo:: 619ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const 620{ 621 assert( (Cond.size() == 3 || Cond.size() == 2) && 622 "Invalid Mips branch condition!"); 623 Cond[0].setImm(GetOppositeBranchCondition((Mips::CondCode)Cond[0].getImm())); 624 return false; 625} |
626 627/// getGlobalBaseReg - Return a virtual register initialized with the 628/// the global base register value. Output instructions required to 629/// initialize the register in the function entry block, if necessary. 630/// 631unsigned MipsInstrInfo::getGlobalBaseReg(MachineFunction *MF) const { 632 MipsFunctionInfo *MipsFI = MF->getInfo<MipsFunctionInfo>(); 633 unsigned GlobalBaseReg = MipsFI->getGlobalBaseReg(); 634 if (GlobalBaseReg != 0) 635 return GlobalBaseReg; 636 637 // Insert the set of GlobalBaseReg into the first MBB of the function 638 MachineBasicBlock &FirstMBB = MF->front(); 639 MachineBasicBlock::iterator MBBI = FirstMBB.begin(); 640 MachineRegisterInfo &RegInfo = MF->getRegInfo(); 641 const TargetInstrInfo *TII = MF->getTarget().getInstrInfo(); 642 643 GlobalBaseReg = RegInfo.createVirtualRegister(Mips::CPURegsRegisterClass); 644 bool Ok = TII->copyRegToReg(FirstMBB, MBBI, GlobalBaseReg, Mips::GP, 645 Mips::CPURegsRegisterClass, 646 Mips::CPURegsRegisterClass); 647 assert(Ok && "Couldn't assign to global base register!"); 648 RegInfo.addLiveIn(Mips::GP); 649 650 MipsFI->setGlobalBaseReg(GlobalBaseReg); 651 return GlobalBaseReg; 652} |
|