Repository navigation
Expand file tree
/
Copy pathreg.h
More file actions
58 lines (53 loc) · 1.48 KB
/
Copy pathreg.h
File metadata and controls
58 lines (53 loc) · 1.48 KB
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
#ifndef REG_C
#define REG_C
#include "3ac.h"
#include "joecc_assert.h"
/**
* Represents the registers in x86_64 as bits
**/
enum reguse {
DI = 0,
SI = 1,
DX = 2,
CX = 3,
R8 = 4,
R9 = 5,
AX = 6,
R10 = 7,
R11 = 8,
R12 = 9,
R13 = 10,
R14 = 11,
R15 = 12,
BX = 13,
//missing BP and SP
//This is because we don't allow them to be used in that way
};
#define REGBIT(b) (1 << (b))
#define callermask BX | R12 | R13 | R14 | R15
/**
* Stores the string names of the registers for assembly output.
* Indexed by the location of the set bit in reguse.
**/
extern const char* ireg64[];
extern const char* ireg32[];
extern const char* ireg16[];
extern const char* ireg8[];
//Separate case for floating point numbers, indexing scheme really does not need explaining for anyone with any familiarity with SSE/AVX
extern const char* freg256[];
extern const char* freg128[];
//Separate things for floats, ints
void liveness(PROGRAM* prog);
void printadjmatrix(int dim, BITFIELD adjmatrix);
/**
* Represents the information for a regnum from the 3ac for our graph coloring algorithm to make use of.
* The colors in this algorithm correspond to the registers in reguse, and we spill until we can color.
**/
typedef struct {
DYNARR* neighbors; //array of REGINF pointers
short banneighbors; //clobbers, inputs, output to go elsewhere
short color; //which register
} REGINF;
void regalloc(PROGRAM* prog, BITFIELD adjmatrix);
BITFIELD liveadjmatrix(PROGRAM* prog, DYNARR** usedefs);
#endif