xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===- ARCMCTargetDesc.cpp - ARC Target Descriptions ------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file provides ARC specific target descriptions.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #include "ARCMCTargetDesc.h"
140b57cec5SDimitry Andric #include "ARCInstPrinter.h"
150b57cec5SDimitry Andric #include "ARCMCAsmInfo.h"
160b57cec5SDimitry Andric #include "ARCTargetStreamer.h"
170b57cec5SDimitry Andric #include "TargetInfo/ARCTargetInfo.h"
180b57cec5SDimitry Andric #include "llvm/MC/MCDwarf.h"
190b57cec5SDimitry Andric #include "llvm/MC/MCInstrInfo.h"
200b57cec5SDimitry Andric #include "llvm/MC/MCRegisterInfo.h"
210b57cec5SDimitry Andric #include "llvm/MC/MCSubtargetInfo.h"
22349cc55cSDimitry Andric #include "llvm/MC/TargetRegistry.h"
230b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h"
240b57cec5SDimitry Andric #include "llvm/Support/FormattedStream.h"
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric using namespace llvm;
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric #define GET_INSTRINFO_MC_DESC
29753f127fSDimitry Andric #define ENABLE_INSTR_PREDICATE_VERIFIER
300b57cec5SDimitry Andric #include "ARCGenInstrInfo.inc"
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric #define GET_SUBTARGETINFO_MC_DESC
330b57cec5SDimitry Andric #include "ARCGenSubtargetInfo.inc"
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric #define GET_REGINFO_MC_DESC
360b57cec5SDimitry Andric #include "ARCGenRegisterInfo.inc"
370b57cec5SDimitry Andric 
createARCMCInstrInfo()380b57cec5SDimitry Andric static MCInstrInfo *createARCMCInstrInfo() {
390b57cec5SDimitry Andric   auto *X = new MCInstrInfo();
400b57cec5SDimitry Andric   InitARCMCInstrInfo(X);
410b57cec5SDimitry Andric   return X;
420b57cec5SDimitry Andric }
430b57cec5SDimitry Andric 
createARCMCRegisterInfo(const Triple & TT)440b57cec5SDimitry Andric static MCRegisterInfo *createARCMCRegisterInfo(const Triple &TT) {
450b57cec5SDimitry Andric   auto *X = new MCRegisterInfo();
460b57cec5SDimitry Andric   InitARCMCRegisterInfo(X, ARC::BLINK);
470b57cec5SDimitry Andric   return X;
480b57cec5SDimitry Andric }
490b57cec5SDimitry Andric 
createARCMCSubtargetInfo(const Triple & TT,StringRef CPU,StringRef FS)500b57cec5SDimitry Andric static MCSubtargetInfo *createARCMCSubtargetInfo(const Triple &TT,
510b57cec5SDimitry Andric                                                  StringRef CPU, StringRef FS) {
52e8d8bef9SDimitry Andric   return createARCMCSubtargetInfoImpl(TT, CPU, /*TuneCPU=*/CPU, FS);
530b57cec5SDimitry Andric }
540b57cec5SDimitry Andric 
createARCMCAsmInfo(const MCRegisterInfo & MRI,const Triple & TT,const MCTargetOptions & Options)550b57cec5SDimitry Andric static MCAsmInfo *createARCMCAsmInfo(const MCRegisterInfo &MRI,
56480093f4SDimitry Andric                                      const Triple &TT,
57480093f4SDimitry Andric                                      const MCTargetOptions &Options) {
580b57cec5SDimitry Andric   MCAsmInfo *MAI = new ARCMCAsmInfo(TT);
590b57cec5SDimitry Andric 
600b57cec5SDimitry Andric   // Initial state of the frame pointer is SP.
615ffd83dbSDimitry Andric   MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, ARC::SP, 0);
620b57cec5SDimitry Andric   MAI->addInitialFrameState(Inst);
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric   return MAI;
650b57cec5SDimitry Andric }
660b57cec5SDimitry Andric 
createARCMCInstPrinter(const Triple & T,unsigned SyntaxVariant,const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)670b57cec5SDimitry Andric static MCInstPrinter *createARCMCInstPrinter(const Triple &T,
680b57cec5SDimitry Andric                                              unsigned SyntaxVariant,
690b57cec5SDimitry Andric                                              const MCAsmInfo &MAI,
700b57cec5SDimitry Andric                                              const MCInstrInfo &MII,
710b57cec5SDimitry Andric                                              const MCRegisterInfo &MRI) {
720b57cec5SDimitry Andric   return new ARCInstPrinter(MAI, MII, MRI);
730b57cec5SDimitry Andric }
740b57cec5SDimitry Andric 
ARCTargetStreamer(MCStreamer & S)750b57cec5SDimitry Andric ARCTargetStreamer::ARCTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
760b57cec5SDimitry Andric ARCTargetStreamer::~ARCTargetStreamer() = default;
770b57cec5SDimitry Andric 
createTargetAsmStreamer(MCStreamer & S,formatted_raw_ostream & OS,MCInstPrinter * InstPrint)780b57cec5SDimitry Andric static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
790b57cec5SDimitry Andric                                                  formatted_raw_ostream &OS,
80*0fca6ea1SDimitry Andric                                                  MCInstPrinter *InstPrint) {
810b57cec5SDimitry Andric   return new ARCTargetStreamer(S);
820b57cec5SDimitry Andric }
830b57cec5SDimitry Andric 
840b57cec5SDimitry Andric // Force static initialization.
LLVMInitializeARCTargetMC()85480093f4SDimitry Andric extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTargetMC() {
860b57cec5SDimitry Andric   // Register the MC asm info.
870b57cec5SDimitry Andric   Target &TheARCTarget = getTheARCTarget();
880b57cec5SDimitry Andric   RegisterMCAsmInfoFn X(TheARCTarget, createARCMCAsmInfo);
890b57cec5SDimitry Andric 
900b57cec5SDimitry Andric   // Register the MC instruction info.
910b57cec5SDimitry Andric   TargetRegistry::RegisterMCInstrInfo(TheARCTarget, createARCMCInstrInfo);
920b57cec5SDimitry Andric 
930b57cec5SDimitry Andric   // Register the MC register info.
940b57cec5SDimitry Andric   TargetRegistry::RegisterMCRegInfo(TheARCTarget, createARCMCRegisterInfo);
950b57cec5SDimitry Andric 
960b57cec5SDimitry Andric   // Register the MC subtarget info.
970b57cec5SDimitry Andric   TargetRegistry::RegisterMCSubtargetInfo(TheARCTarget,
980b57cec5SDimitry Andric                                           createARCMCSubtargetInfo);
990b57cec5SDimitry Andric 
1000b57cec5SDimitry Andric   // Register the MCInstPrinter
1010b57cec5SDimitry Andric   TargetRegistry::RegisterMCInstPrinter(TheARCTarget, createARCMCInstPrinter);
1020b57cec5SDimitry Andric 
1030b57cec5SDimitry Andric   TargetRegistry::RegisterAsmTargetStreamer(TheARCTarget,
1040b57cec5SDimitry Andric                                             createTargetAsmStreamer);
1050b57cec5SDimitry Andric }
106