xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AVR/AVR.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric //===-- AVR.h - Top-level interface for AVR representation ------*- 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 contains the entry points for global functions defined in the LLVM
100b57cec5SDimitry Andric // AVR back-end.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LLVM_AVR_H
150b57cec5SDimitry Andric #define LLVM_AVR_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAGNodes.h"
180b57cec5SDimitry Andric #include "llvm/Target/TargetMachine.h"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric namespace llvm {
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric class AVRTargetMachine;
230b57cec5SDimitry Andric class FunctionPass;
240b57cec5SDimitry Andric 
25*fe6060f1SDimitry Andric Pass *createAVRShiftExpandPass();
260b57cec5SDimitry Andric FunctionPass *createAVRISelDag(AVRTargetMachine &TM,
270b57cec5SDimitry Andric                                CodeGenOpt::Level OptLevel);
280b57cec5SDimitry Andric FunctionPass *createAVRExpandPseudoPass();
290b57cec5SDimitry Andric FunctionPass *createAVRFrameAnalyzerPass();
300b57cec5SDimitry Andric FunctionPass *createAVRRelaxMemPass();
310b57cec5SDimitry Andric FunctionPass *createAVRDynAllocaSRPass();
320b57cec5SDimitry Andric FunctionPass *createAVRBranchSelectionPass();
330b57cec5SDimitry Andric 
34*fe6060f1SDimitry Andric void initializeAVRShiftExpandPass(PassRegistry &);
350b57cec5SDimitry Andric void initializeAVRExpandPseudoPass(PassRegistry&);
360b57cec5SDimitry Andric void initializeAVRRelaxMemPass(PassRegistry&);
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric /// Contains the AVR backend.
390b57cec5SDimitry Andric namespace AVR {
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric /// An integer that identifies all of the supported AVR address spaces.
420b57cec5SDimitry Andric enum AddressSpace { DataMemory, ProgramMemory };
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric /// Checks if a given type is a pointer to program memory.
450b57cec5SDimitry Andric template <typename T> bool isProgramMemoryAddress(T *V) {
460b57cec5SDimitry Andric   return cast<PointerType>(V->getType())->getAddressSpace() == ProgramMemory;
470b57cec5SDimitry Andric }
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric inline bool isProgramMemoryAccess(MemSDNode const *N) {
500b57cec5SDimitry Andric   auto V = N->getMemOperand()->getValue();
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric   return (V != nullptr) ? isProgramMemoryAddress(V) : false;
530b57cec5SDimitry Andric }
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric } // end of namespace AVR
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric } // end namespace llvm
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric #endif // LLVM_AVR_H
60