]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/lib/Target/SystemZ/README.txt
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / lib / Target / SystemZ / README.txt
1 //===---------------------------------------------------------------------===//
2 // Random notes about and ideas for the SystemZ backend.
3 //===---------------------------------------------------------------------===//
4
5 The initial backend is deliberately restricted to z10.  We should add support
6 for later architectures at some point.
7
8 --
9
10 SystemZDAGToDAGISel::SelectInlineAsmMemoryOperand() is passed "m" for all
11 inline asm memory constraints; it doesn't get to see the original constraint.
12 This means that it must conservatively treat all inline asm constraints
13 as the most restricted type, "R".
14
15 --
16
17 If an inline asm ties an i32 "r" result to an i64 input, the input
18 will be treated as an i32, leaving the upper bits uninitialised.
19 For example:
20
21 define void @f4(i32 *%dst) {
22   %val = call i32 asm "blah $0", "=r,0" (i64 103)
23   store i32 %val, i32 *%dst
24   ret void
25 }
26
27 from CodeGen/SystemZ/asm-09.ll will use LHI rather than LGHI.
28 to load 103.  This seems to be a general target-independent problem.
29
30 --
31
32 The tuning of the choice between Load Address (LA) and addition in
33 SystemZISelDAGToDAG.cpp is suspect.  It should be tweaked based on
34 performance measurements.
35
36 --
37
38 There is no scheduling support.
39
40 --
41
42 We don't use the Branch on Count or Branch on Index families of instruction.
43
44 --
45
46 We don't use the condition code results of anything except comparisons.
47
48 Implementing this may need something more finely grained than the z_cmp
49 and z_ucmp that we have now.  It might (or might not) also be useful to
50 have a mask of "don't care" values in conditional branches.  For example,
51 integer comparisons never set CC to 3, so the bottom bit of the CC mask
52 isn't particularly relevant.  JNLH and JE are equally good for testing
53 equality after an integer comparison, etc.
54
55 --
56
57 We don't optimize string and block memory operations.
58
59 --
60
61 We don't take full advantage of builtins like fabsl because the calling
62 conventions require f128s to be returned by invisible reference.
63
64 --
65
66 DAGCombiner can detect integer absolute, but there's not yet an associated
67 ISD opcode.  We could add one and implement it using Load Positive.
68 Negated absolutes could use Load Negative.
69
70 --
71
72 DAGCombiner doesn't yet fold truncations of extended loads.  Functions like:
73
74     unsigned long f (unsigned long x, unsigned short *y)
75     {
76       return (x << 32) | *y;
77     }
78
79 therefore end up as:
80
81         sllg    %r2, %r2, 32
82         llgh    %r0, 0(%r3)
83         lr      %r2, %r0
84         br      %r14
85
86 but truncating the load would give:
87
88         sllg    %r2, %r2, 32
89         lh      %r2, 0(%r3)
90         br      %r14
91
92 --
93
94 Functions like:
95
96 define i64 @f1(i64 %a) {
97   %and = and i64 %a, 1
98   ret i64 %and
99 }
100
101 ought to be implemented as:
102
103         lhi     %r0, 1
104         ngr     %r2, %r0
105         br      %r14
106
107 but two-address optimisations reverse the order of the AND and force:
108
109         lhi     %r0, 1
110         ngr     %r0, %r2
111         lgr     %r2, %r0
112         br      %r14
113
114 CodeGen/SystemZ/and-04.ll has several examples of this.
115
116 --
117
118 Out-of-range displacements are usually handled by loading the full
119 address into a register.  In many cases it would be better to create
120 an anchor point instead.  E.g. for:
121
122 define void @f4a(i128 *%aptr, i64 %base) {
123   %addr = add i64 %base, 524288
124   %bptr = inttoptr i64 %addr to i128 *
125   %a = load volatile i128 *%aptr
126   %b = load i128 *%bptr
127   %add = add i128 %a, %b
128   store i128 %add, i128 *%aptr
129   ret void
130 }
131
132 (from CodeGen/SystemZ/int-add-08.ll) we load %base+524288 and %base+524296
133 into separate registers, rather than using %base+524288 as a base for both.
134
135 --
136
137 Dynamic stack allocations round the size to 8 bytes and then allocate
138 that rounded amount.  It would be simpler to subtract the unrounded
139 size from the copy of the stack pointer and then align the result.
140 See CodeGen/SystemZ/alloca-01.ll for an example.
141
142 --
143
144 Atomic loads and stores use the default compare-and-swap based implementation.
145 This is probably much too conservative in practice, and the overhead is
146 especially bad for 8- and 16-bit accesses.