Path: blob/main/contrib/llvm-project/llvm/lib/Target/AVR/AVRSubtarget.h
35267 views
//===-- AVRSubtarget.h - Define Subtarget for the AVR -----------*- C++ -*-===//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 declares the AVR specific subclass of TargetSubtargetInfo.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_AVR_SUBTARGET_H13#define LLVM_AVR_SUBTARGET_H1415#include "llvm/CodeGen/TargetSubtargetInfo.h"16#include "llvm/IR/DataLayout.h"17#include "llvm/Target/TargetMachine.h"1819#include "AVRFrameLowering.h"20#include "AVRISelLowering.h"21#include "AVRInstrInfo.h"22#include "AVRSelectionDAGInfo.h"23#include "MCTargetDesc/AVRMCTargetDesc.h"2425#define GET_SUBTARGETINFO_HEADER26#include "AVRGenSubtargetInfo.inc"2728namespace llvm {2930/// A specific AVR target MCU.31class AVRSubtarget : public AVRGenSubtargetInfo {32public:33//! Creates an AVR subtarget.34//! \param TT The target triple.35//! \param CPU The CPU to target.36//! \param FS The feature string.37//! \param TM The target machine.38AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,39const AVRTargetMachine &TM);4041const AVRInstrInfo *getInstrInfo() const override { return &InstrInfo; }42const TargetFrameLowering *getFrameLowering() const override {43return &FrameLowering;44}45const AVRTargetLowering *getTargetLowering() const override {46return &TLInfo;47}48const AVRSelectionDAGInfo *getSelectionDAGInfo() const override {49return &TSInfo;50}51const AVRRegisterInfo *getRegisterInfo() const override {52return &InstrInfo.getRegisterInfo();53}5455/// Parses a subtarget feature string, setting appropriate options.56/// \note Definition of function is auto generated by `tblgen`.57void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);5859AVRSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,60const TargetMachine &TM);6162// Subtarget feature getters.63#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \64bool GETTER() const { return ATTRIBUTE; }65#include "AVRGenSubtargetInfo.inc"6667uint8_t getIORegisterOffset() const { return hasMemMappedGPR() ? 0x20 : 0x0; }6869bool enableSubRegLiveness() const override { return true; }7071/// Gets the ELF architecture for the e_flags field72/// of an ELF object file.73unsigned getELFArch() const {74assert(ELFArch != 0 &&75"every device must have an associate ELF architecture");76return ELFArch;77}7879/// Get I/O register addresses.80int getIORegRAMPZ() const { return hasELPM() ? 0x3b : -1; }81int getIORegEIND() const { return hasEIJMPCALL() ? 0x3c : -1; }82int getIORegSPL() const { return 0x3d; }83int getIORegSPH() const { return hasSmallStack() ? -1 : 0x3e; }84int getIORegSREG() const { return 0x3f; }8586/// Get GPR aliases.87int getRegTmpIndex() const { return hasTinyEncoding() ? 16 : 0; }88int getRegZeroIndex() const { return hasTinyEncoding() ? 17 : 1; }8990Register getTmpRegister() const {91return hasTinyEncoding() ? AVR::R16 : AVR::R0;92}93Register getZeroRegister() const {94return hasTinyEncoding() ? AVR::R17 : AVR::R1;95}9697private:98/// The ELF e_flags architecture.99unsigned ELFArch = 0;100101// Subtarget feature settings102#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \103bool ATTRIBUTE = DEFAULT;104#include "AVRGenSubtargetInfo.inc"105106AVRInstrInfo InstrInfo;107AVRFrameLowering FrameLowering;108AVRTargetLowering TLInfo;109AVRSelectionDAGInfo TSInfo;110};111112} // end namespace llvm113114#endif // LLVM_AVR_SUBTARGET_H115116117