Mercurial > projects > ldc
comparison gen/asm-x86-64.h @ 1109:97d80437cb80
Fix field access from inline asm. See tests/mini/asm10.d
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Thu, 12 Mar 2009 23:48:43 +0100 |
parents | d03814546977 |
children | ea7b8b6c96c0 |
comparison
equal
deleted
inserted
replaced
1108:d03814546977 | 1109:97d80437cb80 |
---|---|
1570 | 1570 |
1571 void setAsmCode() | 1571 void setAsmCode() |
1572 { | 1572 { |
1573 AsmCode * asmcode = new AsmCode ( N_Regs ); | 1573 AsmCode * asmcode = new AsmCode ( N_Regs ); |
1574 asmcode->insnTemplate = insnTemplate.str(); | 1574 asmcode->insnTemplate = insnTemplate.str(); |
1575 Logger::cout() << "insnTemplate = " << asmcode->insnTemplate << '\n'; | |
1575 stmt->asmcode = ( code* ) asmcode; | 1576 stmt->asmcode = ( code* ) asmcode; |
1576 } | 1577 } |
1577 | 1578 |
1578 // note: doesn't update AsmOp op | 1579 // note: doesn't update AsmOp op |
1579 bool matchOperands ( unsigned nOperands ) | 1580 bool matchOperands ( unsigned nOperands ) |
2168 mode = Mode_Input; | 2169 mode = Mode_Input; |
2169 } | 2170 } |
2170 | 2171 |
2171 use_star = opTakesLabel();//opInfo->takesLabel(); | 2172 use_star = opTakesLabel();//opInfo->takesLabel(); |
2172 | 2173 |
2173 if ( operand->segmentPrefix != Reg_Invalid || operand->constDisplacement ) | 2174 if (Logger::enabled()) { |
2174 { | 2175 Logger::cout() << "Opr_Mem\n"; |
2175 if ( operand->symbolDisplacement.dim ) | 2176 LOG_SCOPE |
2176 { | 2177 Logger::cout() << "baseReg: " << operand->baseReg << '\n'; |
2177 insnTemplate << operand->constDisplacement << '+'; | 2178 Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n'; |
2179 Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n'; | |
2180 for (int i = 0; i < operand->symbolDisplacement.dim; i++) { | |
2181 Expression* expr = (Expression*) operand->symbolDisplacement.data[i]; | |
2182 Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n'; | |
2178 } | 2183 } |
2179 //addOperand(fmt, Arg_Integer, newIntExp(operand->constDisplacement), asmcode); | |
2180 if ( opInfo->operands[i] & Opr_Dest ) | |
2181 asmcode->clobbersMemory = 1; | |
2182 } | 2184 } |
2183 | |
2184 if ( operand->segmentPrefix != Reg_Invalid ) | 2185 if ( operand->segmentPrefix != Reg_Invalid ) |
2185 { | 2186 { |
2186 writeReg ( operand->segmentPrefix ); | 2187 writeReg ( operand->segmentPrefix ); |
2187 insnTemplate << ':'; | 2188 insnTemplate << ':'; |
2189 } | |
2190 if ( (operand->segmentPrefix != Reg_Invalid && operand->symbolDisplacement.dim == 0) | |
2191 || operand->constDisplacement ) | |
2192 { | |
2193 insnTemplate << operand->constDisplacement; | |
2194 if ( operand->symbolDisplacement.dim ) | |
2195 { | |
2196 insnTemplate << '+'; | |
2197 } | |
2198 operand->constDisplacement = 0; | |
2199 //addOperand(fmt, Arg_Integer, newIntExp(operand->constDisplacement), asmcode); | |
2200 if ( opInfo->operands[i] & Opr_Dest ) | |
2201 asmcode->clobbersMemory = 1; | |
2188 } | 2202 } |
2189 if ( operand->symbolDisplacement.dim ) | 2203 if ( operand->symbolDisplacement.dim ) |
2190 { | 2204 { |
2191 Expression * e = ( Expression * ) operand->symbolDisplacement.data[0]; | 2205 Expression * e = ( Expression * ) operand->symbolDisplacement.data[0]; |
2192 Declaration * decl = 0; | 2206 Declaration * decl = 0; |
2298 } | 2312 } |
2299 } | 2313 } |
2300 } | 2314 } |
2301 if ( use_star ) | 2315 if ( use_star ) |
2302 insnTemplate << '*'; | 2316 insnTemplate << '*'; |
2303 if ( operand->segmentPrefix != Reg_Invalid && !(operand->constDisplacement)) | |
2304 { | |
2305 insnTemplate << operand->constDisplacement; | |
2306 if ( opInfo->operands[i] & Opr_Dest ) | |
2307 asmcode->clobbersMemory = 1; | |
2308 } | |
2309 if ( operand->baseReg != Reg_Invalid || operand->indexReg != Reg_Invalid ) | 2317 if ( operand->baseReg != Reg_Invalid || operand->indexReg != Reg_Invalid ) |
2310 { | 2318 { |
2311 insnTemplate << '('; | 2319 insnTemplate << '('; |
2312 if ( operand->baseReg != Reg_Invalid ) | 2320 if ( operand->baseReg != Reg_Invalid ) |
2313 writeReg ( operand->baseReg ); | 2321 writeReg ( operand->baseReg ); |
2329 return false; | 2337 return false; |
2330 } | 2338 } |
2331 } | 2339 } |
2332 | 2340 |
2333 asmcode->insnTemplate = insnTemplate.str(); | 2341 asmcode->insnTemplate = insnTemplate.str(); |
2342 Logger::cout() << "insnTemplate = " << asmcode->insnTemplate << '\n'; | |
2334 return true; | 2343 return true; |
2335 } | 2344 } |
2336 | 2345 |
2337 bool isIntExp ( Expression * exp ) | 2346 bool isIntExp ( Expression * exp ) |
2338 { | 2347 { |