Added list of scratch & reserved registers to calling convention. The
[jitcs.git] / src / jitcs_int_callingconvention_impl.h
blobe9236f90567016ee33b825825e14e1d2764c1bdd
1 //===-- jitcs_callconv.h - --------------------------------------*- C++ -*-===//
2 //
3 //
4 //===----------------------------------------------------------------------===//
6 #ifndef _JITCS_INT_CALLINGCONVENTION_IMPL_H_
7 #define _JITCS_INT_CALLINGCONVENTION_IMPL_H_
9 #include "jitcs_callingconvention.h"
10 #include <vector>
11 #include <memory>
13 namespace jitcs {
14 class CallingConventionImpl : public CallingConvention {
15 public:
16 struct IOParamInfo {
17 RefOrNull<const VirtualRegister> reg;
18 SpillSlotInfo save;
21 public:
22 CallingConventionImpl(const RefCounter<IMachineInfo>& m);
23 virtual ~CallingConventionImpl() = default;
25 public:
26 virtual RefCounter<IMachineInfo> getMachineInfo() const { return _machine; }
27 virtual size_t getResultCount() const { return _results.size(); }
28 virtual size_t getParamCount() const { return _params.size(); }
29 virtual size_t getParamAreaSize() const { return _paramArea; }
30 virtual SpillSlotInfo getResultSpillSlotInfo(size_t r) const { return _results[r].save; }
31 virtual RefOrNull<const VirtualRegister> getResultRegister(size_t r) const { return _results[r].reg; }
32 virtual SpillSlotInfo getParamSpillSlotInfo(size_t p) const { return _params[p].save; }
33 virtual RefOrNull<const VirtualRegister> getParamRegister(size_t p) const { return _params[p].reg; }
34 virtual size_t getRequiredStackAlignment() const { return _alignment; }
35 virtual size_t getRequiredStackAlignmentOffset() const { return _alignmentOffset; }
36 virtual CallerCalleeStrategyId getStackCleaningStrategy() const { return _stackCleaning; }
38 virtual FTSubType getSubType() const { return _subtype; }
39 virtual FTTypeId getResultType(size_t r) const { return _outtypes[r]; }
40 virtual FTTypeId getParamType(size_t p) const { return _intypes[p]; }
42 virtual u32 getScratchResources(ResClassId) const;
43 virtual u32 getReservedResources(ResClassId) const;
45 public:
46 virtual void setTypeInfo(FTSubType,Slice<FTTypeId> res,Slice<FTTypeId> par);
47 virtual void addResult(const VirtualRegister*, SpillSlotInfo);
48 virtual void addParam(const VirtualRegister*, SpillSlotInfo);
49 virtual void setStackAlignment(size_t align, size_t ofs);
50 virtual void setParamAreaSize(size_t);
51 virtual void setCleanStack(CallerCalleeStrategyId);
52 virtual void setResClassCount(size_t resNo);
53 virtual void setScratchResources(ResClassId, u32);
54 virtual void setReservedResources(ResClassId, u32);
56 private:
57 RefCounter<IMachineInfo> _machine;
58 std::vector<IOParamInfo> _results, _params;
59 //ConstBitmapRef _callerSave, _calleeSave;
60 //std::vector< std::vector<u32> > _callerSaveList, _calleeSaveList;
61 //u8* _resourceData;
62 size_t _alignment, _alignmentOffset, _paramArea;
63 CallerCalleeStrategyId _stackCleaning;
64 FTSubType _subtype;
65 std::vector<FTTypeId> _outtypes, _intypes;
66 std::vector<u32> _scratchResources;
67 std::vector<u32> _reservedResources;
70 } // end of namespace jitcs
72 #endif
73 // _JITCS_INT_CALLINGCONVENTION_IMPL_H_