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
20#include "llvm/IR/Analysis.h"
21#include "llvm/IR/PassManager.h"
22#include "llvm/Pass.h"
23#include "llvm/PassRegistry.h"
26
27namespace llvm {
28
30class FunctionPass;
31class PassRegistry;
32
33class AVRShiftExpandPass : public RequiredPassInfoMixin<AVRShiftExpandPass> {
34public:
36};
37
39
44
46 CodeGenOptLevel OptLevel);
47
48class AVRExpandPseudoPass : public RequiredPassInfoMixin<AVRExpandPseudoPass> {
49public:
52};
53
55
57 : public RequiredPassInfoMixin<AVRFrameAnalyzerPass> {
58public:
61};
62
64
69
70/// Contains the AVR backend.
71namespace AVR {
72
73/// An integer that identifies all of the supported AVR address spaces.
84
85/// Checks if a given type is a pointer to program memory.
86template <typename T> bool isProgramMemoryAddress(T *V) {
87 auto *PT = cast<PointerType>(V->getType());
88 assert(PT != nullptr && "unexpected MemSDNode");
89 return PT->getAddressSpace() == ProgramMemory ||
90 PT->getAddressSpace() == ProgramMemory1 ||
91 PT->getAddressSpace() == ProgramMemory2 ||
92 PT->getAddressSpace() == ProgramMemory3 ||
93 PT->getAddressSpace() == ProgramMemory4 ||
94 PT->getAddressSpace() == ProgramMemory5;
95}
96
97template <typename T> AddressSpace getAddressSpace(T *V) {
98 auto *PT = cast<PointerType>(V->getType());
99 assert(PT != nullptr && "unexpected MemSDNode");
100 unsigned AS = PT->getAddressSpace();
101 if (AS < NumAddrSpaces)
102 return static_cast<AddressSpace>(AS);
103 return NumAddrSpaces;
104}
105
106inline bool isProgramMemoryAccess(MemSDNode const *N) {
107 auto *V = N->getMemOperand()->getValue();
108 if (V != nullptr && isProgramMemoryAddress(V))
109 return true;
110 return false;
111}
112
113// Get the index of the program memory bank.
114// -1: not program memory
115// 0: ordinary program memory
116// 1~5: extended program memory
117inline int getProgramMemoryBank(MemSDNode const *N) {
118 auto *V = N->getMemOperand()->getValue();
119 if (V == nullptr || !isProgramMemoryAddress(V))
120 return -1;
122 assert(ProgramMemory <= AS && AS <= ProgramMemory5);
123 return static_cast<int>(AS - ProgramMemory);
124}
125
126} // end of namespace AVR
127
128} // end namespace llvm
129
130#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
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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:106
AddressSpace getAddressSpace(T *V)
Definition AVR.h:97
int getProgramMemoryBank(MemSDNode const *N)
Definition AVR.h:117
bool isProgramMemoryAddress(T *V)
Checks if a given type is a pointer to program memory.
Definition AVR.h:86
AddressSpace
An integer that identifies all of the supported AVR address spaces.
Definition AVR.h:74
@ DataMemory
Definition AVR.h:75
@ NumAddrSpaces
Definition AVR.h:82
@ ProgramMemory
Definition AVR.h:76
@ ProgramMemory2
Definition AVR.h:78
@ ProgramMemory4
Definition AVR.h:80
@ ProgramMemory1
Definition AVR.h:77
@ ProgramMemory5
Definition AVR.h:81
@ ProgramMemory3
Definition AVR.h:79
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createAVRISelDagLegacyPass(AVRTargetMachine &TM, CodeGenOptLevel OptLevel)
FunctionPass * createAVRExpandPseudoLegacyPass()
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
void initializeAVRExpandPseudoLegacyPass(PassRegistry &)
Pass * createAVRShiftExpandLegacyPass()
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.
FunctionPass * createAVRFrameAnalyzerLegacyPass()
Creates instance of the frame analyzer pass.
#define N
A CRTP mix-in for passes that should not be skipped.