xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AVR/AVRMachineFunctionInfo.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric //===-- AVRMachineFuctionInfo.h - AVR machine function info -----*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file declares AVR-specific per-machine-function information.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_AVR_MACHINE_FUNCTION_INFO_H
140b57cec5SDimitry Andric #define LLVM_AVR_MACHINE_FUNCTION_INFO_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric namespace llvm {
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric /// Contains AVR-specific information for each MachineFunction.
210b57cec5SDimitry Andric class AVRMachineFunctionInfo : public MachineFunctionInfo {
220b57cec5SDimitry Andric   /// Indicates if a register has been spilled by the register
230b57cec5SDimitry Andric   /// allocator.
240b57cec5SDimitry Andric   bool HasSpills;
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric   /// Indicates if there are any fixed size allocas present.
270b57cec5SDimitry Andric   /// Note that if there are only variable sized allocas this is set to false.
280b57cec5SDimitry Andric   bool HasAllocas;
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric   /// Indicates if arguments passed using the stack are being
310b57cec5SDimitry Andric   /// used inside the function.
320b57cec5SDimitry Andric   bool HasStackArgs;
330b57cec5SDimitry Andric 
345ffd83dbSDimitry Andric   /// Whether or not the function is an interrupt handler.
355ffd83dbSDimitry Andric   bool IsInterruptHandler;
365ffd83dbSDimitry Andric 
375ffd83dbSDimitry Andric   /// Whether or not the function is an non-blocking interrupt handler.
385ffd83dbSDimitry Andric   bool IsSignalHandler;
395ffd83dbSDimitry Andric 
400b57cec5SDimitry Andric   /// Size of the callee-saved register portion of the
410b57cec5SDimitry Andric   /// stack frame in bytes.
420b57cec5SDimitry Andric   unsigned CalleeSavedFrameSize;
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric   /// FrameIndex for start of varargs area.
450b57cec5SDimitry Andric   int VarArgsFrameIndex;
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric public:
AVRMachineFunctionInfo(const Function & F,const TargetSubtargetInfo * STI)48*bdd1243dSDimitry Andric   AVRMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
490b57cec5SDimitry Andric       : HasSpills(false), HasAllocas(false), HasStackArgs(false),
505ffd83dbSDimitry Andric         CalleeSavedFrameSize(0), VarArgsFrameIndex(0) {
51*bdd1243dSDimitry Andric     CallingConv::ID CallConv = F.getCallingConv();
525ffd83dbSDimitry Andric 
53*bdd1243dSDimitry Andric     this->IsInterruptHandler =
54*bdd1243dSDimitry Andric         CallConv == CallingConv::AVR_INTR || F.hasFnAttribute("interrupt");
55*bdd1243dSDimitry Andric     this->IsSignalHandler =
56*bdd1243dSDimitry Andric         CallConv == CallingConv::AVR_SIGNAL || F.hasFnAttribute("signal");
575ffd83dbSDimitry Andric   }
580b57cec5SDimitry Andric 
5981ad6265SDimitry Andric   MachineFunctionInfo *
clone(BumpPtrAllocator & Allocator,MachineFunction & DestMF,const DenseMap<MachineBasicBlock *,MachineBasicBlock * > & Src2DstMBB)6081ad6265SDimitry Andric   clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
6181ad6265SDimitry Andric         const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
6281ad6265SDimitry Andric       const override {
6381ad6265SDimitry Andric     return DestMF.cloneInfo<AVRMachineFunctionInfo>(*this);
6481ad6265SDimitry Andric   }
6581ad6265SDimitry Andric 
getHasSpills()660b57cec5SDimitry Andric   bool getHasSpills() const { return HasSpills; }
setHasSpills(bool B)670b57cec5SDimitry Andric   void setHasSpills(bool B) { HasSpills = B; }
680b57cec5SDimitry Andric 
getHasAllocas()690b57cec5SDimitry Andric   bool getHasAllocas() const { return HasAllocas; }
setHasAllocas(bool B)700b57cec5SDimitry Andric   void setHasAllocas(bool B) { HasAllocas = B; }
710b57cec5SDimitry Andric 
getHasStackArgs()720b57cec5SDimitry Andric   bool getHasStackArgs() const { return HasStackArgs; }
setHasStackArgs(bool B)730b57cec5SDimitry Andric   void setHasStackArgs(bool B) { HasStackArgs = B; }
740b57cec5SDimitry Andric 
755ffd83dbSDimitry Andric   /// Checks if the function is some form of interrupt service routine.
isInterruptOrSignalHandler()76349cc55cSDimitry Andric   bool isInterruptOrSignalHandler() const {
77349cc55cSDimitry Andric     return isInterruptHandler() || isSignalHandler();
78349cc55cSDimitry Andric   }
795ffd83dbSDimitry Andric 
isInterruptHandler()805ffd83dbSDimitry Andric   bool isInterruptHandler() const { return IsInterruptHandler; }
isSignalHandler()815ffd83dbSDimitry Andric   bool isSignalHandler() const { return IsSignalHandler; }
825ffd83dbSDimitry Andric 
getCalleeSavedFrameSize()830b57cec5SDimitry Andric   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
setCalleeSavedFrameSize(unsigned Bytes)840b57cec5SDimitry Andric   void setCalleeSavedFrameSize(unsigned Bytes) { CalleeSavedFrameSize = Bytes; }
850b57cec5SDimitry Andric 
getVarArgsFrameIndex()860b57cec5SDimitry Andric   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(int Idx)870b57cec5SDimitry Andric   void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; }
880b57cec5SDimitry Andric };
890b57cec5SDimitry Andric 
90349cc55cSDimitry Andric } // namespace llvm
910b57cec5SDimitry Andric 
920b57cec5SDimitry Andric #endif // LLVM_AVR_MACHINE_FUNCTION_INFO_H
93