LLVM  7.0.0
Nios2InstrInfo.cpp
Go to the documentation of this file.
1 //===-- Nios2InstrInfo.cpp - Nios2 Instruction 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 Nios2 implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Nios2InstrInfo.h"
15 #include "Nios2TargetMachine.h"
17 
18 using namespace llvm;
19 
20 #define GET_INSTRINFO_CTOR_DTOR
21 #include "Nios2GenInstrInfo.inc"
22 
23 // Pin the vtable to this file.
24 void Nios2InstrInfo::anchor() {}
25 
27  : Nios2GenInstrInfo(), RI(ST), Subtarget(ST) {}
28 
29 /// Expand Pseudo instructions into real backend instructions
31  MachineBasicBlock &MBB = *MI.getParent();
32 
33  switch (MI.getDesc().getOpcode()) {
34  default:
35  return false;
36  case Nios2::RetRA:
37  BuildMI(MBB, MI, MI.getDebugLoc(), get(Nios2::RET_R1)).addReg(Nios2::RA);
38  break;
39  }
40 
41  MBB.erase(MI);
42  return true;
43 }
44 
47  const DebugLoc &DL, unsigned DestReg,
48  unsigned SrcReg, bool KillSrc) const {
49  unsigned opc = Subtarget.hasNios2r2() ? Nios2::ADD_R2 : Nios2::ADD_R1;
50  BuildMI(MBB, I, DL, get(opc))
51  .addReg(DestReg, RegState::Define)
52  .addReg(Nios2::ZERO)
53  .addReg(SrcReg, getKillRegState(KillSrc));
54 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Definition: MachineInstr.h:285
A debug info location.
Definition: DebugLoc.h:34
SI optimize exec mask operations pre RA
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Definition: MachineInstr.h:308
bool expandPostRAPseudo(MachineInstr &MI) const override
Expand Pseudo instructions into real backend instructions.
unsigned getKillRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:156
Representation of each machine instruction.
Definition: MachineInstr.h:60
#define I(x, y, z)
Definition: MD5.cpp:58
bool hasNios2r2() const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getOpcode() const
Return the opcode number for this descriptor.
Definition: MCInstrDesc.h:202
IRTranslator LLVM IR MI
Nios2InstrInfo(Nios2Subtarget &ST)