LLVM 20.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
18#include "llvm/Pass.h"
19#include "llvm/PassRegistry.h"
21
22namespace llvm {
23
24class AVRTargetMachine;
25class FunctionPass;
26class PassRegistry;
27
33
37
38/// Contains the AVR backend.
39namespace AVR {
40
41/// An integer that identifies all of the supported AVR address spaces.
51};
52
53/// Checks if a given type is a pointer to program memory.
54template <typename T> bool isProgramMemoryAddress(T *V) {
55 auto *PT = cast<PointerType>(V->getType());
56 assert(PT != nullptr && "unexpected MemSDNode");
57 return PT->getAddressSpace() == ProgramMemory ||
58 PT->getAddressSpace() == ProgramMemory1 ||
59 PT->getAddressSpace() == ProgramMemory2 ||
60 PT->getAddressSpace() == ProgramMemory3 ||
61 PT->getAddressSpace() == ProgramMemory4 ||
62 PT->getAddressSpace() == ProgramMemory5;
63}
64
65template <typename T> AddressSpace getAddressSpace(T *V) {
66 auto *PT = cast<PointerType>(V->getType());
67 assert(PT != nullptr && "unexpected MemSDNode");
68 unsigned AS = PT->getAddressSpace();
69 if (AS < NumAddrSpaces)
70 return static_cast<AddressSpace>(AS);
71 return NumAddrSpaces;
72}
73
74inline bool isProgramMemoryAccess(MemSDNode const *N) {
75 auto *V = N->getMemOperand()->getValue();
76 if (V != nullptr && isProgramMemoryAddress(V))
77 return true;
78 return false;
79}
80
81// Get the index of the program memory bank.
82// -1: not program memory
83// 0: ordinary program memory
84// 1~5: extended program memory
85inline int getProgramMemoryBank(MemSDNode const *N) {
86 auto *V = N->getMemOperand()->getValue();
87 if (V == nullptr || !isProgramMemoryAddress(V))
88 return -1;
90 assert(ProgramMemory <= AS && AS <= ProgramMemory5);
91 return static_cast<int>(AS - ProgramMemory);
92}
93
94} // end of namespace AVR
95
96} // end namespace llvm
97
98#endif // LLVM_AVR_H
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A generic AVR implementation.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
This is an abstract virtual class for memory operations.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:37
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
bool isProgramMemoryAccess(MemSDNode const *N)
Definition: AVR.h:74
AddressSpace getAddressSpace(T *V)
Definition: AVR.h:65
int getProgramMemoryBank(MemSDNode const *N)
Definition: AVR.h:85
bool isProgramMemoryAddress(T *V)
Checks if a given type is a pointer to program memory.
Definition: AVR.h:54
AddressSpace
An integer that identifies all of the supported AVR address spaces.
Definition: AVR.h:42
@ DataMemory
Definition: AVR.h:43
@ NumAddrSpaces
Definition: AVR.h:50
@ ProgramMemory
Definition: AVR.h:44
@ ProgramMemory2
Definition: AVR.h:46
@ ProgramMemory4
Definition: AVR.h:48
@ ProgramMemory1
Definition: AVR.h:45
@ ProgramMemory5
Definition: AVR.h:49
@ ProgramMemory3
Definition: AVR.h:47
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeAVRShiftExpandPass(PassRegistry &)
void initializeAVRExpandPseudoPass(PassRegistry &)
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
FunctionPass * createAVRISelDag(AVRTargetMachine &TM, CodeGenOptLevel OptLevel)
FunctionPass * createAVRExpandPseudoPass()
void initializeAVRDAGToDAGISelLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
Pass * createAVRShiftExpandPass()
FunctionPass * createAVRBranchSelectionPass()
#define N