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: 480b57cec5SDimitry Andric AVRMachineFunctionInfo() 490b57cec5SDimitry Andric : HasSpills(false), HasAllocas(false), HasStackArgs(false), 505ffd83dbSDimitry Andric IsInterruptHandler(false), IsSignalHandler(false), 510b57cec5SDimitry Andric CalleeSavedFrameSize(0), VarArgsFrameIndex(0) {} 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric explicit AVRMachineFunctionInfo(MachineFunction &MF) 540b57cec5SDimitry Andric : HasSpills(false), HasAllocas(false), HasStackArgs(false), 555ffd83dbSDimitry Andric CalleeSavedFrameSize(0), VarArgsFrameIndex(0) { 565ffd83dbSDimitry Andric unsigned CallConv = MF.getFunction().getCallingConv(); 575ffd83dbSDimitry Andric 58349cc55cSDimitry Andric this->IsInterruptHandler = CallConv == CallingConv::AVR_INTR || 59349cc55cSDimitry Andric MF.getFunction().hasFnAttribute("interrupt"); 60349cc55cSDimitry Andric this->IsSignalHandler = CallConv == CallingConv::AVR_SIGNAL || 61349cc55cSDimitry Andric MF.getFunction().hasFnAttribute("signal"); 625ffd83dbSDimitry Andric } 630b57cec5SDimitry Andric 64*81ad6265SDimitry Andric MachineFunctionInfo * 65*81ad6265SDimitry Andric clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, 66*81ad6265SDimitry Andric const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) 67*81ad6265SDimitry Andric const override { 68*81ad6265SDimitry Andric return DestMF.cloneInfo<AVRMachineFunctionInfo>(*this); 69*81ad6265SDimitry Andric } 70*81ad6265SDimitry Andric 710b57cec5SDimitry Andric bool getHasSpills() const { return HasSpills; } 720b57cec5SDimitry Andric void setHasSpills(bool B) { HasSpills = B; } 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric bool getHasAllocas() const { return HasAllocas; } 750b57cec5SDimitry Andric void setHasAllocas(bool B) { HasAllocas = B; } 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric bool getHasStackArgs() const { return HasStackArgs; } 780b57cec5SDimitry Andric void setHasStackArgs(bool B) { HasStackArgs = B; } 790b57cec5SDimitry Andric 805ffd83dbSDimitry Andric /// Checks if the function is some form of interrupt service routine. 81349cc55cSDimitry Andric bool isInterruptOrSignalHandler() const { 82349cc55cSDimitry Andric return isInterruptHandler() || isSignalHandler(); 83349cc55cSDimitry Andric } 845ffd83dbSDimitry Andric 855ffd83dbSDimitry Andric bool isInterruptHandler() const { return IsInterruptHandler; } 865ffd83dbSDimitry Andric bool isSignalHandler() const { return IsSignalHandler; } 875ffd83dbSDimitry Andric 880b57cec5SDimitry Andric unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } 890b57cec5SDimitry Andric void setCalleeSavedFrameSize(unsigned Bytes) { CalleeSavedFrameSize = Bytes; } 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 920b57cec5SDimitry Andric void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; } 930b57cec5SDimitry Andric }; 940b57cec5SDimitry Andric 95349cc55cSDimitry Andric } // namespace llvm 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric #endif // LLVM_AVR_MACHINE_FUNCTION_INFO_H 98