blob: f0746d73c95f477f92433a14d1e88bbb848e212c [file] [log] [blame]
Dylan McKay5c96de32016-01-07 10:53:15 +00001//===-- AVR.h - Top-level interface for AVR representation ------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dylan McKay5c96de32016-01-07 10:53:15 +00006//
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
Dylan McKay5c96de32016-01-07 10:53:15 +000017#include "llvm/CodeGen/SelectionDAGNodes.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000018#include "llvm/Target/TargetMachine.h"
Dylan McKay5c96de32016-01-07 10:53:15 +000019
20namespace llvm {
21
22class AVRTargetMachine;
23class FunctionPass;
24
25FunctionPass *createAVRISelDag(AVRTargetMachine &TM,
26 CodeGenOpt::Level OptLevel);
27FunctionPass *createAVRExpandPseudoPass();
28FunctionPass *createAVRFrameAnalyzerPass();
Dylan McKay1e57fa42016-12-13 05:53:14 +000029FunctionPass *createAVRRelaxMemPass();
Dylan McKay5c96de32016-01-07 10:53:15 +000030FunctionPass *createAVRDynAllocaSRPass();
31FunctionPass *createAVRBranchSelectionPass();
32
Dylan McKay8cec7eb2016-12-07 11:08:56 +000033void initializeAVRExpandPseudoPass(PassRegistry&);
Dylan McKay1e57fa42016-12-13 05:53:14 +000034void initializeAVRRelaxMemPass(PassRegistry&);
Dylan McKay8cec7eb2016-12-07 11:08:56 +000035
Dylan McKayd56676e2016-05-18 09:43:01 +000036/// Contains the AVR backend.
Dylan McKay5c96de32016-01-07 10:53:15 +000037namespace AVR {
38
Dylan McKay0603bae2018-07-15 07:24:27 +000039/// An integer that identifies all of the supported AVR address spaces.
Dylan McKay5c96de32016-01-07 10:53:15 +000040enum AddressSpace { DataMemory, ProgramMemory };
41
Dylan McKay0603bae2018-07-15 07:24:27 +000042/// Checks if a given type is a pointer to program memory.
Dylan McKay5c96de32016-01-07 10:53:15 +000043template <typename T> bool isProgramMemoryAddress(T *V) {
44 return cast<PointerType>(V->getType())->getAddressSpace() == ProgramMemory;
45}
46
47inline bool isProgramMemoryAccess(MemSDNode const *N) {
48 auto V = N->getMemOperand()->getValue();
49
50 return (V != nullptr) ? isProgramMemoryAddress(V) : false;
51}
52
53} // end of namespace AVR
54
55} // end namespace llvm
56
57#endif // LLVM_AVR_H