-
Notifications
You must be signed in to change notification settings - Fork 0
/
codes.h
112 lines (91 loc) · 2.5 KB
/
codes.h
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
/*
codes.h (Register Stacks)
Cody Fagley
Authored on March 14, 2019
Last Modified March 14, 2019
*/
/*
Contains Register Codes for AArch64 Architecture
Table of Contents
=================
1.) Get Register -- a32i
2.) Get Register -- a32f
3.) Get Register (Flexible)
*/
#ifndef REGSTACK_CODES_H
#define REGSTACK_CODES_H
/* Get Register -- a32i
*/
char* get_reg_a32i(ADR i, unsigned char bits)
{
char* str = (char*) malloc(10);
/*
TODO:
* Reconnect 'bits' functionality to size registers to best fit
*/
switch(bits)
{
case (8):
if (i < 14) sprintf(str, "b%u", i-1); else
if (i < 28) sprintf(str, "b%u", i+3); else
sprintf(str, "v%u.s[%d]", (i-24)/4, (i-24)%4);
break;
case (16):
if (i < 14) sprintf(str, "s%u", i-1); else
if (i < 28) sprintf(str, "s%u", i+3); else
sprintf(str, "v%u.s[%d]", (i-24)/4, (i-24)%4);
break;
case (32):
if (i < 14) sprintf(str, "w%u", i-1); else
if (i < 28) sprintf(str, "w%u", i+3); else
sprintf(str, "v%u.s[%d]", (i-24)/4, (i-24)%4);
break;
case (64):
if (i < 14) sprintf(str, "x%u", i-1); else
if (i < 28) sprintf(str, "x%u", i+3); else
sprintf(str, "v%u.s[%d]", (i-24)/4, (i-24)%4);
break;
}
return str;
}
/* Get Register -- a32f
*/
char* get_reg_a32f(ADR i, unsigned char bits)
{
char* str = (char*) malloc(10);
return str;
}
/* 1.) Get Register (Flexible)
*/
char* get_reg(ADR i, unsigned char bits)
{
/* TODO: Replace optimization if conditions with #IFDEF and #DEFINE statements */
// Route a32i Register Name Request
if (get_optimization() == a32i) return get_reg_a32i(i, bits);
char* str = (char*) malloc(10);
switch(bits)
{
case (8):
if (i < 29) sprintf(str, "b%u", i); else
if (i < 41) sprintf(str, "v%u.s[0]", i-28); else
sprintf(str, "v%u.s[0]", i-24);
break;
case (16):
if (i < 29) sprintf(str, "s%u", i); else
if (i < 41) sprintf(str, "v%u.s[0]", i-28); else
sprintf(str, "v%u.s[0]", i-24);
break;
case (32):
if (i < 29) sprintf(str, "w%u", i); else
if (i < 41) sprintf(str, "v%u.s[0]", i-28); else
sprintf(str, "v%u.s[0]", i-24);
break;
case (64):
if (i < 29) sprintf(str, "x%u", i); else
if (i < 41) sprintf(str, "v%u.s[0]", i-28); else
sprintf(str, "v%u.s[0]", i-24);
break;
}
return str;
}
#endif