blob: ebb7174002d18f0e4259a7e286aba9af4ec039c8 [file] [log] [blame]
Alex Bradbury89718422017-10-19 21:37:38 +00001//===-- RISCVInstrInfo.cpp - RISCV 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 RISCV implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "RISCVInstrInfo.h"
15#include "RISCV.h"
16#include "RISCVSubtarget.h"
17#include "RISCVTargetMachine.h"
18#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallVector.h"
20#include "llvm/CodeGen/MachineFunctionPass.h"
21#include "llvm/CodeGen/MachineInstrBuilder.h"
22#include "llvm/CodeGen/MachineRegisterInfo.h"
23#include "llvm/Support/ErrorHandling.h"
24#include "llvm/Support/TargetRegistry.h"
25
26#define GET_INSTRINFO_CTOR_DTOR
27#include "RISCVGenInstrInfo.inc"
28
29using namespace llvm;
30
31RISCVInstrInfo::RISCVInstrInfo() : RISCVGenInstrInfo() {}
Alex Bradburycfa62912017-11-08 12:20:01 +000032
33void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
34 MachineBasicBlock::iterator MBBI,
35 const DebugLoc &DL, unsigned DstReg,
36 unsigned SrcReg, bool KillSrc) const {
37 assert(RISCV::GPRRegClass.contains(DstReg, SrcReg) &&
38 "Impossible reg-to-reg copy");
39
40 BuildMI(MBB, MBBI, DL, get(RISCV::ADDI), DstReg)
41 .addReg(SrcReg, getKillRegState(KillSrc))
42 .addImm(0);
43}