Path: blob/main/contrib/llvm-project/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp
35294 views
//===-- MSP430MCTargetDesc.cpp - MSP430 Target Descriptions ---------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file provides MSP430 specific target descriptions.9//10//===----------------------------------------------------------------------===//1112#include "MSP430MCTargetDesc.h"13#include "MSP430InstPrinter.h"14#include "MSP430MCAsmInfo.h"15#include "TargetInfo/MSP430TargetInfo.h"16#include "llvm/MC/MCDwarf.h"17#include "llvm/MC/MCInstrInfo.h"18#include "llvm/MC/MCRegisterInfo.h"19#include "llvm/MC/MCSubtargetInfo.h"20#include "llvm/MC/TargetRegistry.h"2122using namespace llvm;2324#define GET_INSTRINFO_MC_DESC25#define ENABLE_INSTR_PREDICATE_VERIFIER26#include "MSP430GenInstrInfo.inc"2728#define GET_SUBTARGETINFO_MC_DESC29#include "MSP430GenSubtargetInfo.inc"3031#define GET_REGINFO_MC_DESC32#include "MSP430GenRegisterInfo.inc"3334static MCInstrInfo *createMSP430MCInstrInfo() {35MCInstrInfo *X = new MCInstrInfo();36InitMSP430MCInstrInfo(X);37return X;38}3940static MCRegisterInfo *createMSP430MCRegisterInfo(const Triple &TT) {41MCRegisterInfo *X = new MCRegisterInfo();42InitMSP430MCRegisterInfo(X, MSP430::PC);43return X;44}4546static MCAsmInfo *createMSP430MCAsmInfo(const MCRegisterInfo &MRI,47const Triple &TT,48const MCTargetOptions &Options) {49MCAsmInfo *MAI = new MSP430MCAsmInfo(TT);5051// Initialize initial frame state.52int stackGrowth = -2;5354// Initial state of the frame pointer is sp+ptr_size.55MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(56nullptr, MRI.getDwarfRegNum(MSP430::SP, true), -stackGrowth);57MAI->addInitialFrameState(Inst);5859// Add return address to move list60MCCFIInstruction Inst2 = MCCFIInstruction::createOffset(61nullptr, MRI.getDwarfRegNum(MSP430::PC, true), stackGrowth);62MAI->addInitialFrameState(Inst2);6364return MAI;65}6667static MCSubtargetInfo *68createMSP430MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {69return createMSP430MCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);70}7172static MCInstPrinter *createMSP430MCInstPrinter(const Triple &T,73unsigned SyntaxVariant,74const MCAsmInfo &MAI,75const MCInstrInfo &MII,76const MCRegisterInfo &MRI) {77if (SyntaxVariant == 0)78return new MSP430InstPrinter(MAI, MII, MRI);79return nullptr;80}8182extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetMC() {83Target &T = getTheMSP430Target();8485TargetRegistry::RegisterMCAsmInfo(T, createMSP430MCAsmInfo);86TargetRegistry::RegisterMCInstrInfo(T, createMSP430MCInstrInfo);87TargetRegistry::RegisterMCRegInfo(T, createMSP430MCRegisterInfo);88TargetRegistry::RegisterMCSubtargetInfo(T, createMSP430MCSubtargetInfo);89TargetRegistry::RegisterMCInstPrinter(T, createMSP430MCInstPrinter);90TargetRegistry::RegisterMCCodeEmitter(T, createMSP430MCCodeEmitter);91TargetRegistry::RegisterMCAsmBackend(T, createMSP430MCAsmBackend);92TargetRegistry::RegisterObjectTargetStreamer(93T, createMSP430ObjectTargetStreamer);94}959697