Mercurial > projects > ldc
comparison gen/asm-x86-32.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 | feca4947d1f2 |
children | ea7b8b6c96c0 |
comparison
equal
deleted
inserted
replaced
1108:d03814546977 | 1109:97d80437cb80 |
---|---|
1448 | 1448 |
1449 void setAsmCode() | 1449 void setAsmCode() |
1450 { | 1450 { |
1451 AsmCode * asmcode = new AsmCode ( N_Regs ); | 1451 AsmCode * asmcode = new AsmCode ( N_Regs ); |
1452 asmcode->insnTemplate = insnTemplate.str(); | 1452 asmcode->insnTemplate = insnTemplate.str(); |
1453 Logger::cout() << "insnTemplate = " << asmcode->insnTemplate << '\n'; | |
1453 stmt->asmcode = ( code* ) asmcode; | 1454 stmt->asmcode = ( code* ) asmcode; |
1454 } | 1455 } |
1455 | 1456 |
1456 // note: doesn't update AsmOp op | 1457 // note: doesn't update AsmOp op |
1457 bool matchOperands ( unsigned nOperands ) | 1458 bool matchOperands ( unsigned nOperands ) |
2046 mode = Mode_Input; | 2047 mode = Mode_Input; |
2047 } | 2048 } |
2048 | 2049 |
2049 use_star = opTakesLabel();//opInfo->takesLabel(); | 2050 use_star = opTakesLabel();//opInfo->takesLabel(); |
2050 | 2051 |
2051 if ( operand->segmentPrefix != Reg_Invalid || operand->constDisplacement ) | 2052 if (Logger::enabled()) { |
2052 { | 2053 Logger::cout() << "Opr_Mem\n"; |
2053 if ( operand->symbolDisplacement.dim ) | 2054 LOG_SCOPE |
2054 { | 2055 Logger::cout() << "baseReg: " << operand->baseReg << '\n'; |
2055 insnTemplate << operand->constDisplacement << '+'; | 2056 Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n'; |
2057 Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n'; | |
2058 for (int i = 0; i < operand->symbolDisplacement.dim; i++) { | |
2059 Expression* expr = (Expression*) operand->symbolDisplacement.data[i]; | |
2060 Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n'; | |
2056 } | 2061 } |
2057 //addOperand(fmt, Arg_Integer, newIntExp(operand->constDisplacement), asmcode); | |
2058 if ( opInfo->operands[i] & Opr_Dest ) | |
2059 asmcode->clobbersMemory = 1; | |
2060 } | 2062 } |
2061 | |
2062 if ( operand->segmentPrefix != Reg_Invalid ) | 2063 if ( operand->segmentPrefix != Reg_Invalid ) |
2063 { | 2064 { |
2064 writeReg ( operand->segmentPrefix ); | 2065 writeReg ( operand->segmentPrefix ); |
2065 insnTemplate << ':'; | 2066 insnTemplate << ':'; |
2067 } | |
2068 if ( (operand->segmentPrefix != Reg_Invalid && operand->symbolDisplacement.dim == 0) | |
2069 || operand->constDisplacement ) | |
2070 { | |
2071 insnTemplate << operand->constDisplacement; | |
2072 if ( operand->symbolDisplacement.dim ) | |
2073 { | |
2074 insnTemplate << '+'; | |
2075 } | |
2076 operand->constDisplacement = 0; | |
2077 //addOperand(fmt, Arg_Integer, newIntExp(operand->constDisplacement), asmcode); | |
2078 if ( opInfo->operands[i] & Opr_Dest ) | |
2079 asmcode->clobbersMemory = 1; | |
2066 } | 2080 } |
2067 if ( operand->symbolDisplacement.dim ) | 2081 if ( operand->symbolDisplacement.dim ) |
2068 { | 2082 { |
2069 Expression * e = ( Expression * ) operand->symbolDisplacement.data[0]; | 2083 Expression * e = ( Expression * ) operand->symbolDisplacement.data[0]; |
2070 Declaration * decl = 0; | 2084 Declaration * decl = 0; |
2176 } | 2190 } |
2177 } | 2191 } |
2178 } | 2192 } |
2179 if ( use_star ) | 2193 if ( use_star ) |
2180 insnTemplate << '*'; | 2194 insnTemplate << '*'; |
2181 if ( operand->segmentPrefix != Reg_Invalid && !(operand->constDisplacement) ) | |
2182 { | |
2183 insnTemplate << operand->constDisplacement; | |
2184 if ( opInfo->operands[i] & Opr_Dest ) | |
2185 asmcode->clobbersMemory = 1; | |
2186 } | |
2187 if ( operand->baseReg != Reg_Invalid || operand->indexReg != Reg_Invalid ) | 2195 if ( operand->baseReg != Reg_Invalid || operand->indexReg != Reg_Invalid ) |
2188 { | 2196 { |
2189 insnTemplate << '('; | 2197 insnTemplate << '('; |
2190 if ( operand->baseReg != Reg_Invalid ) | 2198 if ( operand->baseReg != Reg_Invalid ) |
2191 writeReg ( operand->baseReg ); | 2199 writeReg ( operand->baseReg ); |
2207 return false; | 2215 return false; |
2208 } | 2216 } |
2209 } | 2217 } |
2210 | 2218 |
2211 asmcode->insnTemplate = insnTemplate.str(); | 2219 asmcode->insnTemplate = insnTemplate.str(); |
2220 Logger::cout() << "insnTemplate = " << asmcode->insnTemplate << '\n'; | |
2212 return true; | 2221 return true; |
2213 } | 2222 } |
2214 | 2223 |
2215 bool isIntExp ( Expression * exp ) | 2224 bool isIntExp ( Expression * exp ) |
2216 { | 2225 { |