102 lines · c
1//===- XCoreMachineFunctionInfo.h - XCore machine function info -*- 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-exception6//7//===----------------------------------------------------------------------===//8//9// This file declares XCore-specific per-machine-function information.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H14#define LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H15 16#include "llvm/CodeGen/MachineBasicBlock.h"17#include "llvm/CodeGen/MachineFrameInfo.h"18#include "llvm/CodeGen/MachineFunction.h"19#include <cassert>20#include <utility>21#include <vector>22 23namespace llvm {24 25/// XCoreFunctionInfo - This class is derived from MachineFunction private26/// XCore target-specific information for each MachineFunction.27class XCoreFunctionInfo : public MachineFunctionInfo {28 bool LRSpillSlotSet = false;29 int LRSpillSlot;30 bool FPSpillSlotSet = false;31 int FPSpillSlot;32 bool EHSpillSlotSet = false;33 int EHSpillSlot[2];34 unsigned ReturnStackOffset;35 bool ReturnStackOffsetSet = false;36 int VarArgsFrameIndex = 0;37 mutable int CachedEStackSize = -1;38 std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>>39 SpillLabels;40 41 virtual void anchor();42 43public:44 XCoreFunctionInfo() = default;45 46 explicit XCoreFunctionInfo(const Function &F,47 const TargetSubtargetInfo *STI) {}48 49 MachineFunctionInfo *50 clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,51 const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)52 const override;53 54 ~XCoreFunctionInfo() override = default;55 56 void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; }57 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }58 59 int createLRSpillSlot(MachineFunction &MF);60 bool hasLRSpillSlot() { return LRSpillSlotSet; }61 int getLRSpillSlot() const {62 assert(LRSpillSlotSet && "LR Spill slot not set");63 return LRSpillSlot;64 }65 66 int createFPSpillSlot(MachineFunction &MF);67 bool hasFPSpillSlot() { return FPSpillSlotSet; }68 int getFPSpillSlot() const {69 assert(FPSpillSlotSet && "FP Spill slot not set");70 return FPSpillSlot;71 }72 73 const int* createEHSpillSlot(MachineFunction &MF);74 bool hasEHSpillSlot() { return EHSpillSlotSet; }75 const int* getEHSpillSlot() const {76 assert(EHSpillSlotSet && "EH Spill slot not set");77 return EHSpillSlot;78 }79 80 void setReturnStackOffset(unsigned value) {81 assert(!ReturnStackOffsetSet && "Return stack offset set twice");82 ReturnStackOffset = value;83 ReturnStackOffsetSet = true;84 }85 86 unsigned getReturnStackOffset() const {87 assert(ReturnStackOffsetSet && "Return stack offset not set");88 return ReturnStackOffset;89 }90 91 bool isLargeFrame(const MachineFunction &MF) const;92 93 std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>> &94 getSpillLabels() {95 return SpillLabels;96 }97};98 99} // end namespace llvm100 101#endif // LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H102