Adding copyright notices to most files. Also add readme file, and some
[jitcs.git] / src / jitcs_int_callingconvention_impl.h
blob0343109f3683849473bb41e831811335707439a4
1 //===-- src/jitcs_int_callingconvention_impl.h ------------------*- C++ -*-===//
2 // Implementation class to handle calling convention object setup.
3 //
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"
12 #include <vector>
13 #include <memory>
15 namespace jitcs {
16 class CallingConventionImpl : public CallingConvention {
17 public:
18 struct IOParamInfo {
19 RefOrNull<const VirtualRegister> reg;
20 SpillSlotInfo save;
23 public:
24 CallingConventionImpl(const RefCounter<IMachineInfo>& m);
25 virtual ~CallingConventionImpl() = default;
27 public:
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;
47 public:
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);
58 private:
59 RefCounter<IMachineInfo> _machine;
60 std::vector<IOParamInfo> _results, _params;
61 //ConstBitmapRef _callerSave, _calleeSave;
62 //std::vector< std::vector<u32> > _callerSaveList, _calleeSaveList;
63 //u8* _resourceData;
64 size_t _alignment, _alignmentOffset, _paramArea;
65 CallerCalleeStrategyId _stackCleaning;
66 FTSubType _subtype;
67 std::vector<FTTypeId> _outtypes, _intypes;
68 std::vector<u32> _scratchResources;
69 std::vector<u32> _reservedResources;
72 } // end of namespace jitcs
74 #endif
75 // _JITCS_INT_CALLINGCONVENTION_IMPL_H_