1 //===-- src/jitcs_int_callingconvention_impl.h ------------------*- C++ -*-===//
2 // Implementation class to handle calling convention object setup.
4 // Copyright (C) 2013-2014 Dirk Steinke.
5 // See copyright and license notice in COPYRIGHT or include/jitcs.h
6 //===----------------------------------------------------------------------===//
8 #ifndef _JITCS_INT_CALLINGCONVENTION_IMPL_H_
9 #define _JITCS_INT_CALLINGCONVENTION_IMPL_H_
11 #include "jitcs_callingconvention.h"
16 class CallingConventionImpl
: public CallingConvention
{
19 RefOrNull
<const VirtualRegister
> reg
;
24 CallingConventionImpl(const RefCounter
<IMachineInfo
>& m
);
25 virtual ~CallingConventionImpl() = default;
28 virtual RefCounter
<IMachineInfo
> getMachineInfo() const { return _machine
; }
29 virtual size_t getResultCount() const { return _results
.size(); }
30 virtual size_t getParamCount() const { return _params
.size(); }
31 virtual size_t getParamAreaSize() const { return _paramArea
; }
32 virtual SpillSlotInfo
getResultSpillSlotInfo(size_t r
) const { return _results
[r
].save
; }
33 virtual RefOrNull
<const VirtualRegister
> getResultRegister(size_t r
) const { return _results
[r
].reg
; }
34 virtual SpillSlotInfo
getParamSpillSlotInfo(size_t p
) const { return _params
[p
].save
; }
35 virtual RefOrNull
<const VirtualRegister
> getParamRegister(size_t p
) const { return _params
[p
].reg
; }
36 virtual size_t getRequiredStackAlignment() const { return _alignment
; }
37 virtual size_t getRequiredStackAlignmentOffset() const { return _alignmentOffset
; }
38 virtual CallerCalleeStrategyId
getStackCleaningStrategy() const { return _stackCleaning
; }
40 virtual FTSubType
getSubType() const { return _subtype
; }
41 virtual FTTypeId
getResultType(size_t r
) const { return _outtypes
[r
]; }
42 virtual FTTypeId
getParamType(size_t p
) const { return _intypes
[p
]; }
44 virtual u32
getScratchResources(ResClassId
) const;
45 virtual u32
getReservedResources(ResClassId
) const;
48 virtual void setTypeInfo(FTSubType
,Slice
<FTTypeId
> res
,Slice
<FTTypeId
> par
);
49 virtual void addResult(const VirtualRegister
*, SpillSlotInfo
);
50 virtual void addParam(const VirtualRegister
*, SpillSlotInfo
);
51 virtual void setStackAlignment(size_t align
, size_t ofs
);
52 virtual void setParamAreaSize(size_t);
53 virtual void setCleanStack(CallerCalleeStrategyId
);
54 virtual void setResClassCount(size_t resNo
);
55 virtual void setScratchResources(ResClassId
, u32
);
56 virtual void setReservedResources(ResClassId
, u32
);
59 RefCounter
<IMachineInfo
> _machine
;
60 std::vector
<IOParamInfo
> _results
, _params
;
61 //ConstBitmapRef _callerSave, _calleeSave;
62 //std::vector< std::vector<u32> > _callerSaveList, _calleeSaveList;
64 size_t _alignment
, _alignmentOffset
, _paramArea
;
65 CallerCalleeStrategyId _stackCleaning
;
67 std::vector
<FTTypeId
> _outtypes
, _intypes
;
68 std::vector
<u32
> _scratchResources
;
69 std::vector
<u32
> _reservedResources
;
72 } // end of namespace jitcs
75 // _JITCS_INT_CALLINGCONVENTION_IMPL_H_