LLVM 17.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
30 CodeGenOpt::Level OptLevel);
34
38
39/// Contains the AVR backend.
40namespace AVR {
41
42/// An integer that identifies all of the supported AVR address spaces.
52};
53
54/// Checks if a given type is a pointer to program memory.
55template <typename T> bool isProgramMemoryAddress(T *V) {
56 auto *PT = cast<PointerType>(V->getType());
57 assert(PT != nullptr && "unexpected MemSDNode");
58 return PT->getAddressSpace() == ProgramMemory ||
59 PT->getAddressSpace() == ProgramMemory1 ||
60 PT->getAddressSpace() == ProgramMemory2 ||
61 PT->getAddressSpace() == ProgramMemory3 ||
62 PT->getAddressSpace() == ProgramMemory4 ||
63 PT->getAddressSpace() == ProgramMemory5;
64}
65
66template <typename T> AddressSpace getAddressSpace(T *V) {
67 auto *PT = cast<PointerType>(V->getType());
68 assert(PT != nullptr && "unexpected MemSDNode");
69 unsigned AS = PT->getAddressSpace();
70 if (AS < NumAddrSpaces)
71 return static_cast<AddressSpace>(AS);
72 return NumAddrSpaces;
73}
74
75inline bool isProgramMemoryAccess(MemSDNode const *N) {
76 auto *V = N->getMemOperand()->getValue();
77 if (V != nullptr && isProgramMemoryAddress(V))
78 return true;
79 return false;
80}
81
82// Get the index of the program memory bank.
83// -1: not program memory
84// 0: ordinary program memory
85// 1~5: extended program memory
86inline int getProgramMemoryBank(MemSDNode const *N) {
87 auto *V = N->getMemOperand()->getValue();
88 if (V == nullptr || !isProgramMemoryAddress(V))
89 return -1;
91 assert(ProgramMemory <= AS && AS <= ProgramMemory5);
92 return static_cast<int>(AS - ProgramMemory);
93}
94
95} // end of namespace AVR
96
97} // end namespace llvm
98
99#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:311
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:75
AddressSpace getAddressSpace(T *V)
Definition: AVR.h:66
int getProgramMemoryBank(MemSDNode const *N)
Definition: AVR.h:86
bool isProgramMemoryAddress(T *V)
Checks if a given type is a pointer to program memory.
Definition: AVR.h:55
AddressSpace
An integer that identifies all of the supported AVR address spaces.
Definition: AVR.h:43
@ DataMemory
Definition: AVR.h:44
@ NumAddrSpaces
Definition: AVR.h:51
@ ProgramMemory
Definition: AVR.h:45
@ ProgramMemory2
Definition: AVR.h:47
@ ProgramMemory4
Definition: AVR.h:49
@ ProgramMemory1
Definition: AVR.h:46
@ ProgramMemory5
Definition: AVR.h:50
@ ProgramMemory3
Definition: AVR.h:48
Level
Code generation optimization level.
Definition: CodeGen.h:57
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeAVRShiftExpandPass(PassRegistry &)
void initializeAVRExpandPseudoPass(PassRegistry &)
FunctionPass * createAVRISelDag(AVRTargetMachine &TM, CodeGenOpt::Level OptLevel)
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
void initializeAVRDAGToDAGISelPass(PassRegistry &)
FunctionPass * createAVRExpandPseudoPass()
Pass * createAVRShiftExpandPass()
FunctionPass * createAVRBranchSelectionPass()
#define N