1 //=- LoongArchInstrInfo.cpp - LoongArch Instruction Information -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the LoongArch implementation of the TargetInstrInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "LoongArchInstrInfo.h"
14 #include "LoongArch.h"
15 
16 using namespace llvm;
17 
18 #define GET_INSTRINFO_CTOR_DTOR
19 #include "LoongArchGenInstrInfo.inc"
20 
21 LoongArchInstrInfo::LoongArchInstrInfo(LoongArchSubtarget &STI)
22     // FIXME: add CFSetup and CFDestroy Inst when we implement function call.
23     : LoongArchGenInstrInfo() {}
24 
25 void LoongArchInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
26                                      MachineBasicBlock::iterator MBBI,
27                                      const DebugLoc &DL, MCRegister DstReg,
28                                      MCRegister SrcReg, bool KillSrc) const {
29   if (LoongArch::GPRRegClass.contains(DstReg, SrcReg)) {
30     BuildMI(MBB, MBBI, DL, get(LoongArch::OR), DstReg)
31         .addReg(SrcReg, getKillRegState(KillSrc))
32         .addReg(LoongArch::R0);
33     return;
34   }
35 
36   // TODO: Now, we only support GPR->GPR copies.
37   llvm_unreachable("LoongArch didn't implement copyPhysReg");
38 }
39