1 //===-- CSKYMCTargetDesc.cpp - CSKY Target Descriptions -------------------===// 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 provides CSKY specific target descriptions. 10 /// 11 //===----------------------------------------------------------------------===// 12 13 #include "CSKYMCTargetDesc.h" 14 #include "CSKYAsmBackend.h" 15 #include "CSKYMCAsmInfo.h" 16 #include "CSKYMCCodeEmitter.h" 17 #include "TargetInfo/CSKYTargetInfo.h" 18 #include "llvm/MC/MCInstrInfo.h" 19 #include "llvm/MC/MCRegisterInfo.h" 20 #include "llvm/MC/MCSubtargetInfo.h" 21 #include "llvm/Support/TargetRegistry.h" 22 23 #define GET_INSTRINFO_MC_DESC 24 #include "CSKYGenInstrInfo.inc" 25 26 #define GET_REGINFO_MC_DESC 27 #include "CSKYGenRegisterInfo.inc" 28 29 using namespace llvm; 30 31 static MCAsmInfo *createCSKYMCAsmInfo(const MCRegisterInfo &MRI, 32 const Triple &TT, 33 const MCTargetOptions &Options) { 34 MCAsmInfo *MAI = new CSKYMCAsmInfo(TT); 35 36 // Initial state of the frame pointer is SP. 37 unsigned Reg = MRI.getDwarfRegNum(CSKY::R14, true); 38 MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); 39 MAI->addInitialFrameState(Inst); 40 return MAI; 41 } 42 43 static MCInstrInfo *createCSKYMCInstrInfo() { 44 MCInstrInfo *Info = new MCInstrInfo(); 45 InitCSKYMCInstrInfo(Info); 46 return Info; 47 } 48 49 static MCRegisterInfo *createCSKYMCRegisterInfo(const Triple &TT) { 50 MCRegisterInfo *Info = new MCRegisterInfo(); 51 InitCSKYMCRegisterInfo(Info, CSKY::R15); 52 return Info; 53 } 54 55 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTargetMC() { 56 auto &CSKYTarget = getTheCSKYTarget(); 57 TargetRegistry::RegisterMCAsmBackend(CSKYTarget, createCSKYAsmBackend); 58 TargetRegistry::RegisterMCAsmInfo(CSKYTarget, createCSKYMCAsmInfo); 59 TargetRegistry::RegisterMCInstrInfo(CSKYTarget, createCSKYMCInstrInfo); 60 TargetRegistry::RegisterMCRegInfo(CSKYTarget, createCSKYMCRegisterInfo); 61 TargetRegistry::RegisterMCCodeEmitter(CSKYTarget, createCSKYMCCodeEmitter); 62 } 63