LLVM 24.0.0git
AVR.h
Go to the documentation of this file.
1//===-- AVR.h - Top-level interface for AVR representation ------*- C++ -*-===//
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 contains the entry points for global functions defined in the LLVM
10// AVR back-end.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_AVR_H
15#define LLVM_AVR_H
16
19#include "llvm/IR/Analysis.h"
20#include "llvm/IR/PassManager.h"
21#include "llvm/Pass.h"
22#include "llvm/PassRegistry.h"
25
26namespace llvm {
27
29class FunctionPass;
30class PassRegistry;
31
32class AVRShiftExpandPass : public RequiredPassInfoMixin<AVRShiftExpandPass> {
33public:
35};
36
38
43
45 CodeGenOptLevel OptLevel);
48
53
54/// Contains the AVR backend.
55namespace AVR {
56
57/// An integer that identifies all of the supported AVR address spaces.
68
69/// Checks if a given type is a pointer to program memory.
70template <typename T> bool isProgramMemoryAddress(T *V) {
71 auto *PT = cast<PointerType>(V->getType());
72 assert(PT != nullptr && "unexpected MemSDNode");
73 return PT->getAddressSpace() == ProgramMemory ||
74 PT->getAddressSpace() == ProgramMemory1 ||
75 PT->getAddressSpace() == ProgramMemory2 ||
76 PT->getAddressSpace() == ProgramMemory3 ||
77 PT->getAddressSpace() == ProgramMemory4 ||
78 PT->getAddressSpace() == ProgramMemory5;
79}
80
81template <typename T> AddressSpace getAddressSpace(T *V) {
82 auto *PT = cast<PointerType>(V->getType());
83 assert(PT != nullptr && "unexpected MemSDNode");
84 unsigned AS = PT->getAddressSpace();
85 if (AS < NumAddrSpaces)
86 return static_cast<AddressSpace>(AS);
87 return NumAddrSpaces;
88}
89
90inline bool isProgramMemoryAccess(MemSDNode const *N) {
91 auto *V = N->getMemOperand()->getValue();
92 if (V != nullptr && isProgramMemoryAddress(V))
93 return true;
94 return false;
95}
96
97// Get the index of the program memory bank.
98// -1: not program memory
99// 0: ordinary program memory
100// 1~5: extended program memory
101inline int getProgramMemoryBank(MemSDNode const *N) {
102 auto *V = N->getMemOperand()->getValue();
103 if (V == nullptr || !isProgramMemoryAddress(V))
104 return -1;
106 assert(ProgramMemory <= AS && AS <= ProgramMemory5);
107 return static_cast<int>(AS - ProgramMemory);
108}
109
110} // end of namespace AVR
111
112} // end namespace llvm
113
114#endif // LLVM_AVR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
#define T
FunctionAnalysisManager FAM
AVRISelDAGToDAGPass(AVRTargetMachine &TM, CodeGenOptLevel OptLevel)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
A generic AVR implementation.
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
This is an abstract virtual class for memory operations.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Pass interface - Implemented by all 'passes'.
Definition Pass.h:97
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
SelectionDAGISelPass(std::unique_ptr< SelectionDAGISel > Selector)
Pass manager infrastructure for declaring and invalidating analyses.
Contains the AVR backend.
bool isProgramMemoryAccess(MemSDNode const *N)
Definition AVR.h:90
AddressSpace getAddressSpace(T *V)
Definition AVR.h:81
int getProgramMemoryBank(MemSDNode const *N)
Definition AVR.h:101
bool isProgramMemoryAddress(T *V)
Checks if a given type is a pointer to program memory.
Definition AVR.h:70
AddressSpace
An integer that identifies all of the supported AVR address spaces.
Definition AVR.h:58
@ DataMemory
Definition AVR.h:59
@ NumAddrSpaces
Definition AVR.h:66
@ ProgramMemory
Definition AVR.h:60
@ ProgramMemory2
Definition AVR.h:62
@ ProgramMemory4
Definition AVR.h:64
@ ProgramMemory1
Definition AVR.h:61
@ ProgramMemory5
Definition AVR.h:65
@ ProgramMemory3
Definition AVR.h:63
This is an optimization pass for GlobalISel generic memory operations.
void initializeAVRExpandPseudoPass(PassRegistry &)
FunctionPass * createAVRISelDagLegacyPass(AVRTargetMachine &TM, CodeGenOptLevel OptLevel)
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
Pass * createAVRShiftExpandLegacyPass()
FunctionPass * createAVRExpandPseudoPass()
void initializeAVRDAGToDAGISelLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
void initializeAVRShiftExpandLegacyPass(PassRegistry &)
void initializeAVRAsmPrinterPass(PassRegistry &)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
#define N
A CRTP mix-in for passes that should not be skipped.