aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r--include/asm-powerpc/ppc_asm.h76
1 files changed, 40 insertions, 36 deletions
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
index 0dc798d46ea4..ab8688d39024 100644
--- a/include/asm-powerpc/ppc_asm.h
+++ b/include/asm-powerpc/ppc_asm.h
@@ -156,52 +156,56 @@ n:
156#endif 156#endif
157 157
158/* 158/*
159 * LOADADDR( rn, name ) 159 * LOAD_REG_IMMEDIATE(rn, expr)
160 * loads the address of 'name' into 'rn' 160 * Loads the value of the constant expression 'expr' into register 'rn'
161 * using immediate instructions only. Use this when it's important not
162 * to reference other data (i.e. on ppc64 when the TOC pointer is not
163 * valid).
161 * 164 *
162 * LOADBASE( rn, name ) 165 * LOAD_REG_ADDR(rn, name)
163 * loads the address (possibly without the low 16 bits) of 'name' into 'rn' 166 * Loads the address of label 'name' into register 'rn'. Use this when
164 * suitable for base+disp addressing 167 * you don't particularly need immediate instructions only, but you need
168 * the whole address in one register (e.g. it's a structure address and
169 * you want to access various offsets within it). On ppc32 this is
170 * identical to LOAD_REG_IMMEDIATE.
171 *
172 * LOAD_REG_ADDRBASE(rn, name)
173 * ADDROFF(name)
174 * LOAD_REG_ADDRBASE loads part of the address of label 'name' into
175 * register 'rn'. ADDROFF(name) returns the remainder of the address as
176 * a constant expression. ADDROFF(name) is a signed expression < 16 bits
177 * in size, so is suitable for use directly as an offset in load and store
178 * instructions. Use this when loading/storing a single word or less as:
179 * LOAD_REG_ADDRBASE(rX, name)
180 * ld rY,ADDROFF(name)(rX)
165 */ 181 */
166#ifdef __powerpc64__ 182#ifdef __powerpc64__
167#define LOADADDR(rn,name) \ 183#define LOAD_REG_IMMEDIATE(reg,expr) \
168 lis rn,name##@highest; \ 184 lis (reg),(expr)@highest; \
169 ori rn,rn,name##@higher; \ 185 ori (reg),(reg),(expr)@higher; \
170 rldicr rn,rn,32,31; \ 186 rldicr (reg),(reg),32,31; \
171 oris rn,rn,name##@h; \ 187 oris (reg),(reg),(expr)@h; \
172 ori rn,rn,name##@l 188 ori (reg),(reg),(expr)@l;
173 189
174#define LOADBASE(rn,name) \ 190#define LOAD_REG_ADDR(reg,name) \
175 ld rn,name@got(r2) 191 ld (reg),name@got(r2)
176 192
177#define OFF(name) 0 193#define LOAD_REG_ADDRBASE(reg,name) LOAD_REG_ADDR(reg,name)
178 194#define ADDROFF(name) 0
179#define SET_REG_TO_CONST(reg, value) \
180 lis reg,(((value)>>48)&0xFFFF); \
181 ori reg,reg,(((value)>>32)&0xFFFF); \
182 rldicr reg,reg,32,31; \
183 oris reg,reg,(((value)>>16)&0xFFFF); \
184 ori reg,reg,((value)&0xFFFF);
185
186#define SET_REG_TO_LABEL(reg, label) \
187 lis reg,(label)@highest; \
188 ori reg,reg,(label)@higher; \
189 rldicr reg,reg,32,31; \
190 oris reg,reg,(label)@h; \
191 ori reg,reg,(label)@l;
192 195
193/* offsets for stack frame layout */ 196/* offsets for stack frame layout */
194#define LRSAVE 16 197#define LRSAVE 16
195 198
196#else /* 32-bit */ 199#else /* 32-bit */
197#define LOADADDR(rn,name) \
198 lis rn,name@ha; \
199 addi rn,rn,name@l
200 200
201#define LOADBASE(rn,name) \ 201#define LOAD_REG_IMMEDIATE(reg,expr) \
202 lis rn,name@ha 202 lis (reg),(expr)@ha; \
203 addi (reg),(reg),(expr)@l;
204
205#define LOAD_REG_ADDR(reg,name) LOAD_REG_IMMEDIATE(reg, name)
203 206
204#define OFF(name) name@l 207#define LOAD_REG_ADDRBASE(reg, name) lis (reg),name@ha
208#define ADDROFF(name) name@l
205 209
206/* offsets for stack frame layout */ 210/* offsets for stack frame layout */
207#define LRSAVE 4 211#define LRSAVE 4