11 l = va_arg(fmt->args, Loc);
14 return fmtprint(fmt, "<loc%d>", l.type);
16 return fmtprint(fmt, "0x%lux", l.addr);
18 return fmtprint(fmt, "*0x%lux", l.addr);
20 return fmtprint(fmt, "%ld(%s)", l.offset, l.reg);
22 return fmtprint(fmt, "%s", l.reg);
27 loccmp(Loc *a, Loc *b)
45 i = strcmp(a->reg, b->reg);
48 if(a->offset < b->offset)
50 if(a->offset > b->offset)
54 return strcmp(a->reg, b->reg);
59 lget1(Map *map, Regs *regs, Loc loc, uchar *a, uint n)
61 if(locsimplify(map, regs, loc, &loc) < 0)
64 return get1(map, loc.addr, a, n);
65 /* could do more here - i'm lazy */
66 werrstr("bad location for lget1");
71 lget2(Map *map, Regs *regs, Loc loc, u16int *u)
75 if(locsimplify(map, regs, loc, &loc) < 0)
78 return get2(map, loc.addr, u);
79 if(loc.type == LCONST){
84 if(rget(regs, loc.reg, &ul) < 0)
89 werrstr("bad location for lget2");
94 lget4(Map *map, Regs *regs, Loc loc, u32int *u)
98 if(locsimplify(map, regs, loc, &loc) < 0)
100 if(loc.type == LADDR)
101 return get4(map, loc.addr, u);
102 if(loc.type == LCONST){
106 if(loc.type == LREG){
107 if(rget(regs, loc.reg, &ul) < 0)
112 werrstr("bad location for lget4");
117 lgeta(Map *map, Regs *regs, Loc loc, u64int *u)
121 if(machcpu == &machamd64)
122 return lget8(map, regs, loc, u);
123 if(lget4(map, regs, loc, &v) < 0)
130 lget8(Map *map, Regs *regs, Loc loc, u64int *u)
134 if(locsimplify(map, regs, loc, &loc) < 0)
136 if(loc.type == LADDR)
137 return get8(map, loc.addr, u);
138 if(loc.type == LCONST){
142 if(loc.type == LREG){
143 if(rget(regs, loc.reg, &ul) < 0)
148 werrstr("bad location for lget8");
153 lput1(Map *map, Regs *regs, Loc loc, uchar *a, uint n)
155 if(locsimplify(map, regs, loc, &loc) < 0)
157 if(loc.type == LADDR)
158 return put1(map, loc.addr, a, n);
159 /* could do more here - i'm lazy */
160 werrstr("bad location for lput1");
165 lput2(Map *map, Regs *regs, Loc loc, u16int u)
167 if(locsimplify(map, regs, loc, &loc) < 0)
169 if(loc.type == LADDR)
170 return put2(map, loc.addr, u);
172 return rput(regs, loc.reg, u);
173 werrstr("bad location for lput2");
178 lput4(Map *map, Regs *regs, Loc loc, u32int u)
180 if(locsimplify(map, regs, loc, &loc) < 0)
182 if(loc.type == LADDR)
183 return put4(map, loc.addr, u);
185 return rput(regs, loc.reg, u);
186 werrstr("bad location for lput4");
191 lput8(Map *map, Regs *regs, Loc loc, u64int u)
193 if(locsimplify(map, regs, loc, &loc) < 0)
195 if(loc.type == LADDR)
196 return put8(map, loc.addr, u);
198 return rput(regs, loc.reg, u);
199 werrstr("bad location for lput8");
217 locindir(char *reg, long offset)
225 l.addr = 0; /* SHUT UP GCC 4.0 */
262 locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc)
266 if(loc.type == LOFFSET){
267 if(rget(regs, loc.reg, &u) < 0)
269 *newloc = locaddr(u + loc.offset);