File: Arena.h

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (128 lines) | stat: -rw-r--r-- 3,068 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#pragma once
#include "../Arena.h"
#include "WindowsParams.h"
#include "PosixParams.h"

namespace code {
	namespace x64 {
		STORM_PKG(core.asm.x64);

		class Layout;

		/**
		 * Arena for X86-64. Use WindowsArena or PosixArena for different flavours of the 64-bit
		 * arena. The main difference between the two systems is the calling convention.
		 */
		class Arena : public code::Arena {
			STORM_ABSTRACT_CLASS;
		public:
			// Create.
			STORM_CTOR Arena();

			/**
			 * Transform.
			 */

			virtual code::Arena::TransformInfo STORM_FN transformInfo(Listing *src) const;
			virtual void STORM_FN output(Listing *src, Output *to) const;

			/**
			 * Outputs.
			 */

			virtual LabelOutput *STORM_FN labelOutput() const;

			/**
			 * Registers.
			 */

			virtual void STORM_FN removeFnRegs(RegSet *from) const;
			virtual RegSet *STORM_FN fnResultRegs() const;

			/**
			 * Misc.
			 */

			virtual Listing *STORM_FN redirect(Bool member, TypeDesc *result, Array<TypeDesc *> *params, Ref fn, Operand param);
			virtual Listing *STORM_FN engineRedirect(TypeDesc *result, Array<TypeDesc *> *params, Ref fn, Operand engine);
			virtual Reg STORM_FN functionDispatchReg();

			virtual void STORM_FN resizeStackFrame(Listing *out, Reg tmpReg, Binary *newSz);


			/**
			 * Parameter layout (new interface here):
			 */

			// Create parameter layout.
			virtual code::Params *STORM_FN createParams(Bool member) const ABSTRACT;

			// Layout parameters.
			code::Params *layoutParams(Bool member, TypeDesc *result, Array<TypeDesc *> *params);

			// Create the layout transform.
			virtual Layout *STORM_FN layoutTfm() const ABSTRACT;

			// Registers that are not preserved across function calls. Initialized by subclasses.
			RegSet *dirtyRegs;
		};


		class WindowsArena : public Arena {
			STORM_CLASS;
		public:
			// Create.
			STORM_CTOR WindowsArena();

			/**
			 * Output.
			 */
			virtual LabelOutput *STORM_FN labelOutput() const;
			virtual CodeOutput *STORM_FN codeOutput(Binary *owner, LabelOutput *size) const;

			/**
			 * Parameters.
			 */
			virtual Nat STORM_FN firstParamId(MAYBE(TypeDesc *) desc);
			virtual Operand STORM_FN firstParamLoc(Nat id);
			virtual code::Params *STORM_FN createParams(Bool member) const;
			virtual Layout *STORM_FN layoutTfm() const;

			/**
			 * Replacing functions.
			 */

			virtual code::Arena::Skeleton *STORM_FN compatibleFrameSkeleton(Binary *binary, Nat offset);

		};


		class PosixArena : public Arena {
			STORM_CLASS;
		public:
			// Create.
			STORM_CTOR PosixArena();

			/**
			 * Output.
			 */
			virtual CodeOutput *STORM_FN codeOutput(Binary *owner, LabelOutput *size) const;

			/**
			 * Parameters.
			 */
			virtual Nat STORM_FN firstParamId(MAYBE(TypeDesc *) desc);
			virtual Operand STORM_FN firstParamLoc(Nat id);
			virtual code::Params *STORM_FN createParams(Bool member) const;
			virtual Layout *STORM_FN layoutTfm() const;

			/**
			 * Replacing functions.
			 */

			virtual code::Arena::Skeleton *STORM_FN compatibleFrameSkeleton(Binary *binary, Nat offset);

		};

	}
}