blob: 7dea39bebb21fa79d3a605e51695108a5384535f (
plain)
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
|
/*
Copyright (C) 2008, 2009, 2010 Jiri Olsa <olsajiri@gmail.com>
This file is part of the latrace.
The latrace is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The latrace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the latrace (file COPYING). If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef STACK_H
#define STACK_H
/*
TODO Describe the implementation in more details TODO
Architecture specific data inside lt_arg.
bits 64 32|31 0
--------------------|--------------------
fields flags | offset
offset
- offset or memory or registers
flags
- memory/registers switch
*/
#define LT_STACK_ALIGN(arg) ((arg + 7) & ~7)
#define ARCH_POS_FLAGS 32
#define ARCH_FLAG_MEM 1L
#define ARCH_FLAG_REG_INTEGER 2L
#define ARCH_FLAG_REG_SSE 3L
#define ARCH_FLAG_SVREG 4L
#define ARCH_GET(arg) ((int64_t) ((arg)->arch))
#define ARCH_GET_FLAG(arg) ((int) ((long) arg->arch >> ARCH_POS_FLAGS))
#define ARCH_GET_OFFSET(arg) ((long) ((long) arg->arch & 0xFFFFFFFFL))
#define ARCH_ZERO(arg) \
do {\
arg->arch = NULL; \
} while(0)
#define ARCH_SET(arg, flags, offset) \
do { \
arg->arch = (void*) (offset + \
(flags << ARCH_POS_FLAGS)); \
} while(0)
/* registers index */
#define LT_64_REG_RAX 1
#define LT_64_REG_RCX 2
#define LT_64_REG_RDX 3
#define LT_64_REG_RDI 4
#define LT_64_REG_RSI 5
#define LT_64_REG_R8 6
#define LT_64_REG_R9 7
#define LT_64_REG_RBP 8
#define LT_64_REG_RSP 9
#define LT_64_REG_XMM0 10
#define LT_64_REG_XMM1 11
#define LT_64_REG_XMM2 12
#define LT_64_REG_XMM3 13
#define LT_64_REG_XMM4 14
#define LT_64_REG_XMM5 15
#define LT_64_REG_XMM6 16
#define LT_64_REG_XMM7 17
/* argument classes */
#define LT_CLASS_NONE 1
#define LT_CLASS_INTEGER 2
#define LT_CLASS_SSE 3
#define LT_CLASS_MEMORY 4096
#endif // !STACK_H
|