13
13
//
14
14
//===----------------------------------------------------------------------===//
15
15
16
+ let Namespace = "Z80" in {
16
17
class Z80Reg<string n, bits<16> Enc = -1> : Register<n> {
17
- let Namespace = "Z80";
18
18
let HWEncoding = Enc;
19
19
}
20
+
21
+ // Subregister indices.
22
+ def sub_low : SubRegIndex<8>;
23
+ def sub_high : SubRegIndex<8, 8>;
24
+ def sub_short : SubRegIndex<16>;
25
+
20
26
class Z80RegWithSubRegs<string n, list<Register> sub = [], bits<16> enc = -1>
21
27
: Z80Reg<n, enc> {
22
28
let SubRegs = sub;
29
+ let SubRegIndices = [sub_high, sub_low];
30
+ let CoveredBySubRegs = 1;
23
31
}
24
32
25
- // Subregister indices.
26
- let Namespace = "Z80" in {
27
- def sub_low : SubRegIndex<8>;
28
- def sub_high : SubRegIndex<8, 8>;
29
- def sub_short : SubRegIndex<16>;
33
+ class EZ80RegPair<Z80Reg subreg>
34
+ : Register<""> {
35
+ let HWEncoding{1-0} = subreg.HWEncoding{1-0};
36
+ let SubRegs = [subreg];
37
+ let SubRegIndices = [sub_short];
38
+ let AsmName = subreg.AsmName;
39
+ //let AltNames = subreg.AltNames;
40
+ }
30
41
}
31
-
32
42
//===----------------------------------------------------------------------===//
33
43
// Register definitions...
34
44
//
@@ -51,33 +61,37 @@ def IYH : Z80Reg<"iyh", 4>;
51
61
def IYL : Z80Reg<"iyl", 5>;
52
62
}
53
63
54
- let SubRegIndices = [sub_high, sub_low], CoveredBySubRegs = 1 in {
55
64
// 16-bit registers
56
65
def AF : Z80RegWithSubRegs<"af", [A,F], 3>, DwarfRegNum<[3]>;
57
66
def BC : Z80RegWithSubRegs<"bc", [B,C], 0>, DwarfRegNum<[0]>;
58
67
def DE : Z80RegWithSubRegs<"de", [D,E], 1>, DwarfRegNum<[1]>;
59
68
def HL : Z80RegWithSubRegs<"hl", [H,L], 2>, DwarfRegNum<[2]>;
60
69
// 16-bit index registers
61
- let CostPerUse = [1] in {
62
- def IX : Z80RegWithSubRegs<"ix", [IXH,IXL], 2>, DwarfRegNum<[4]>;
63
- def IY : Z80RegWithSubRegs<"iy", [IYH,IYL], 2>, DwarfRegNum<[5]>;
64
- }
70
+ let CostPerUse = 1 in {
71
+ def IX : Z80RegWithSubRegs<"ix", [IXH,IXL], 2>;
72
+ def IY : Z80RegWithSubRegs<"iy", [IYH,IYL], 2>;
65
73
}
66
- def SPS : Z80Reg<"sp", 3>, DwarfRegNum<[6]>;
67
74
68
- let SubRegIndices = [sub_short] in {
75
+ def SPS : Z80Reg<"sp", 3>;
76
+
69
77
// 24-bit registers
70
- def UBC : Z80RegWithSubRegs<"bc", [BC], 0>, DwarfRegAlias <BC>;
71
- def UDE : Z80RegWithSubRegs<"de", [DE], 1>, DwarfRegAlias <DE>;
72
- def UHL : Z80RegWithSubRegs<"hl", [HL], 2>, DwarfRegAlias <HL>;
78
+ def UBC : EZ80RegPair <BC>;
79
+ def UDE : EZ80RegPair <DE>;
80
+ def UHL : EZ80RegPair <HL>;
73
81
// 24-bit index registers
74
- let CostPerUse = [1] in {
75
- def UIX : Z80RegWithSubRegs<"ix", [IX], 2>, DwarfRegAlias <IX>;
76
- def UIY : Z80RegWithSubRegs<"iy", [IY], 2>, DwarfRegAlias <IY>;
82
+ let CostPerUse = 1 in {
83
+ def UIX : EZ80RegPair <IX>;
84
+ def UIY : EZ80RegPair <IY>;
77
85
}
78
- }
79
- def SPL : Z80Reg<"sp", 3>, DwarfRegNum<[7]>;
80
- def PC : Z80Reg<"pc">, DwarfRegNum<[8]>;
86
+
87
+ //definition of SPL register for EZ80 ADL mode.
88
+ //It havn't common part with SPS register, so this definition is not 100%
89
+ //correct, but SPS and SPL cannot be used within one function. Moreover, ADL=1
90
+ //and ADL=0 instructions cannot be mixed within one ELF section, because no one
91
+ //disassembler which may correctly disassemble result code.
92
+ def SPL : EZ80RegPair<SPS>;
93
+
94
+ def PC : Z80Reg<"pc">;
81
95
82
96
//===----------------------------------------------------------------------===//
83
97
// Register Class Definitions...
0 commit comments