summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/InlineAsmRegisters.c
blob: 251c345af484038e9b0794c86bcd091d6818d095 (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
#include "compiler/InlineAsmRegisters.h"
#include "compiler/CompilerTools.h"

#ifdef __MWERKS__
#pragma options align=mac68k
#endif
typedef struct HashedRegister {
    struct HashedRegister *next;
    IARegister reg;
} HashedRegister;
#ifdef __MWERKS__
#pragma options align=reset
#endif

static HashedRegister *hashedregisters[64];

void InlineAsm_InitializeRegisters(void) {
    SInt32 i;

    for (i = 0; i < 64; i++)
        hashedregisters[i] = NULL;
}

void InlineAsm_InsertRegister(char *name, RegClass rclass, short num, Object *object) {
    HashedRegister **ptr;
    HashedRegister *hr;

    ptr = hashedregisters + (CHash(name) & 63);
    hr = lalloc(sizeof(HashedRegister));
    hr->reg.name = name;
    hr->reg.rclass = rclass;
    hr->reg.num = num;
    hr->reg.object = object;

    hr->next = *ptr;
    *ptr = hr;
}

IARegister *InlineAsm_LookupRegister(char *name) {
    HashedRegister *scan;
    IARegister *reg;

    for (scan = hashedregisters[CHash(name) & 63]; scan; scan = scan->next) {
        reg = &scan->reg;
        if (!strcmp(scan->reg.name, name))
            return reg;
    }

    return NULL;
}