Skip to content
Snippets Groups Projects
SMPDataFlowAnalysis.cpp 390 KiB
Newer Older
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577
		case NN_blendps:              // Blend Packed Single Precision Floating-Point Values
		case NN_blendvpd:             // Variable Blend Packed Double Precision Floating-Point Values
		case NN_blendvps:             // Variable Blend Packed Single Precision Floating-Point Values
		case NN_dppd:                 // Dot Product of Packed Double Precision Floating-Point Values
		case NN_dpps:                 // Dot Product of Packed Single Precision Floating-Point Values
		case NN_extractps:            // Extract Packed Single Precision Floating-Point Value
		case NN_insertps:             // Insert Packed Single Precision Floating-Point Value
		case NN_movntdqa:             // Load Double Quadword Non-Temporal Aligned Hint
		case NN_mpsadbw:              // Compute Multiple Packed Sums of Absolute Difference
		case NN_packusdw:             // Pack with Unsigned Saturation
		case NN_pblendvb:             // Variable Blend Packed Bytes
		case NN_pblendw:              // Blend Packed Words
		case NN_pcmpeqq:              // Compare Packed Qword Data for Equal
		case NN_pextrb:               // Extract Byte
		case NN_pextrd:               // Extract Dword
		case NN_pextrq:               // Extract Qword
		case NN_phminposuw:           // Packed Horizontal Word Minimum
		case NN_pinsrb:               // Insert Byte
		case NN_pinsrd:               // Insert Dword
		case NN_pinsrq:               // Insert Qword
		case NN_pmaxsb:               // Maximum of Packed Signed Byte Integers
		case NN_pmaxsd:               // Maximum of Packed Signed Dword Integers
		case NN_pmaxud:               // Maximum of Packed Unsigned Dword Integers
		case NN_pmaxuw:               // Maximum of Packed Word Integers
		case NN_pminsb:               // Minimum of Packed Signed Byte Integers
		case NN_pminsd:               // Minimum of Packed Signed Dword Integers
		case NN_pminud:               // Minimum of Packed Unsigned Dword Integers
		case NN_pminuw:               // Minimum of Packed Word Integers
		case NN_pmovsxbw:             // Packed Move with Sign Extend
		case NN_pmovsxbd:             // Packed Move with Sign Extend
		case NN_pmovsxbq:             // Packed Move with Sign Extend
		case NN_pmovsxwd:             // Packed Move with Sign Extend
		case NN_pmovsxwq:             // Packed Move with Sign Extend
		case NN_pmovsxdq:             // Packed Move with Sign Extend
		case NN_pmovzxbw:             // Packed Move with Zero Extend
		case NN_pmovzxbd:             // Packed Move with Zero Extend
		case NN_pmovzxbq:             // Packed Move with Zero Extend
		case NN_pmovzxwd:             // Packed Move with Zero Extend
		case NN_pmovzxwq:             // Packed Move with Zero Extend
		case NN_pmovzxdq:             // Packed Move with Zero Extend
		case NN_pmuldq:               // Multiply Packed Signed Dword Integers
		case NN_pmulld:               // Multiply Packed Signed Dword Integers and Store Low Result
		case NN_ptest:                // Logical Compare
		case NN_roundpd:              // Round Packed Double Precision Floating-Point Values
		case NN_roundps:              // Round Packed Single Precision Floating-Point Values
		case NN_roundsd:              // Round Scalar Double Precision Floating-Point Values
		case NN_roundss:              // Round Scalar Single Precision Floating-Point Values
			SMP_fprintf(OutFile, "ERROR");
			break;

// SSSE4.2 instructions

		case NN_crc32:                // Accumulate CRC32 Value
		case NN_pcmpestri:            // Packed Compare Explicit Length Strings: Return Index
		case NN_pcmpestrm:            // Packed Compare Explicit Length Strings: Return Mask
		case NN_pcmpistri:            // Packed Compare Implicit Length Strings: Return Index
		case NN_pcmpistrm:            // Packed Compare Implicit Length Strings: Return Mask
		case NN_pcmpgtq:              // Compare Packed Data for Greater Than
		case NN_popcnt:               // Return the Count of Number of Bits Set to 1
			SMP_fprintf(OutFile, "ERROR");
			break;

// AMD SSE4a instructions

		case NN_extrq:                // Extract Field From Register
		case NN_insertq:              // Insert Field
		case NN_movntsd:              // Move Non-Temporal Scalar Double-Precision Floating-Point
		case NN_movntss:              // Move Non-Temporal Scalar Single-Precision Floating-Point
		case NN_lzcnt:                // Leading Zero Count
			SMP_fprintf(OutFile, "ERROR");
			break;

// xsave/xrstor instructions

		case NN_xgetbv:               // Get Value of Extended Control Register
		case NN_xrstor:               // Restore Processor Extended States
		case NN_xsave:                // Save Processor Extended States
		case NN_xsetbv:               // Set Value of Extended Control Register
			SMP_fprintf(OutFile, "ERROR");
			break;

// Intel Safer Mode Extensions (SMX)

		case NN_getsec:               // Safer Mode Extensions (SMX) Instruction
			SMP_fprintf(OutFile, "ERROR");
			break;

// AMD-V Virtualization ISA Extension

		case NN_clgi:                 // Clear Global Interrupt Flag
		case NN_invlpga:              // Invalidate TLB Entry in a Specified ASID
		case NN_skinit:               // Secure Init and Jump with Attestation
		case NN_stgi:                 // Set Global Interrupt Flag
		case NN_vmexit:               // Stop Executing Guest: Begin Executing Host
		case NN_vmload:               // Load State from VMCB
		case NN_vmmcall:              // Call VMM
		case NN_vmrun:                // Run Virtual Machine
		case NN_vmsave:               // Save State to VMCB
			SMP_fprintf(OutFile, "ERROR");
			break;

// VMX+ instructions

		case NN_invept:               // Invalidate Translations Derived from EPT
		case NN_invvpid:              // Invalidate Translations Based on VPID
			SMP_fprintf(OutFile, "ERROR");
			break;

// Intel Atom instructions

		case NN_movbe:                // Move Data After Swapping Bytes
			SMP_fprintf(OutFile, "ERROR");
			break;

// Intel AES instructions

		case NN_aesenc:                // Perform One Round of an AES Encryption Flow
		case NN_aesenclast:            // Perform the Last Round of an AES Encryption Flow
		case NN_aesdec:                // Perform One Round of an AES Decryption Flow
		case NN_aesdeclast:            // Perform the Last Round of an AES Decryption Flow
		case NN_aesimc:                // Perform the AES InvMixColumn Transformation
		case NN_aeskeygenassist:       // AES Round Key Generation Assist
			SMP_fprintf(OutFile, "ERROR");
			break;

// Carryless multiplication

		case NN_pclmulqdq:            // Carry-Less Multiplication Quadword
			SMP_fprintf(OutFile, "ERROR");
			break;

// Returns modifies by operand size prefixes

		case NN_retnw:               // Return Near from Procedure (use16)
		case NN_retnd:               // Return Near from Procedure (use32)
		case NN_retnq:               // Return Near from Procedure (use64)
		case NN_retfw:               // Return Far from Procedure (use16)
		case NN_retfd:               // Return Far from Procedure (use32)
		case NN_retfq:               // Return Far from Procedure (use64)
			SMP_fprintf(OutFile, "return");
			break;

// RDRAND support

		case NN_rdrand:              // Read Random Number
			SMP_fprintf(OutFile, "ERROR");
			break;

// new GPR instructions

		case NN_adcx:                 // Unsigned Integer Addition of Two Operands with Carry Flag
		case NN_adox:                 // Unsigned Integer Addition of Two Operands with Overflow Flag
		case NN_andn:                 // Logical AND NOT
		case NN_bextr:                // Bit Field Extract
		case NN_blsi:                 // Extract Lowest Set Isolated Bit
		case NN_blsmsk:               // Get Mask Up to Lowest Set Bit
		case NN_blsr:                 // Reset Lowest Set Bit
		case NN_bzhi:                 // Zero High Bits Starting with Specified Bit Position
		case NN_clac:                 // Clear AC Flag in EFLAGS Register
		case NN_mulx:                 // Unsigned Multiply Without Affecting Flags
		case NN_pdep:                 // Parallel Bits Deposit
		case NN_pext:                 // Parallel Bits Extract
		case NN_rorx:                 // Rotate Right Logical Without Affecting Flags
		case NN_sarx:                 // Shift Arithmetically Right Without Affecting Flags
		case NN_shlx:                 // Shift Logically Left Without Affecting Flags
		case NN_shrx:                 // Shift Logically Right Without Affecting Flags
		case NN_stac:                 // Set AC Flag in EFLAGS Register
		case NN_tzcnt:                // Count the Number of Trailing Zero Bits
		case NN_xsaveopt:             // Save Processor Extended States Optimized
		case NN_invpcid:              // Invalidate Processor Context ID
		case NN_rdseed:               // Read Random Seed
		case NN_rdfsbase:             // Read FS Segment Base
		case NN_rdgsbase:             // Read GS Segment Base
		case NN_wrfsbase:             // Write FS Segment Base
		case NN_wrgsbase:             // Write GS Segment Base
			SMP_fprintf(OutFile, "ERROR");
			break;

// new AVX instructions
		case NN_vaddpd:               // Add Packed Double-Precision Floating-Point Values
		case NN_vaddps:               // Packed Single-FP Add
		case NN_vaddsd:               // Add Scalar Double-Precision Floating-Point Values
		case NN_vaddss:               // Scalar Single-FP Add
		case NN_vaddsubpd:            // Add /Sub packed DP FP numbers
		case NN_vaddsubps:            // Add /Sub packed SP FP numbers
		case NN_vaesdec:              // Perform One Round of an AES Decryption Flow
		case NN_vaesdeclast:          // Perform the Last Round of an AES Decryption Flow
		case NN_vaesenc:              // Perform One Round of an AES Encryption Flow
		case NN_vaesenclast:          // Perform the Last Round of an AES Encryption Flow
		case NN_vaesimc:              // Perform the AES InvMixColumn Transformation
		case NN_vaeskeygenassist:     // AES Round Key Generation Assist
		case NN_vandnpd:              // Bitwise Logical AND NOT of Packed Double-Precision Floating-Point Values
		case NN_vandnps:              // Bitwise Logical And Not for Single-FP
		case NN_vandpd:               // Bitwise Logical AND of Packed Double-Precision Floating-Point Values
		case NN_vandps:               // Bitwise Logical And for Single-FP
		case NN_vblendpd:             // Blend Packed Double Precision Floating-Point Values
		case NN_vblendps:             // Blend Packed Single Precision Floating-Point Values
		case NN_vblendvpd:            // Variable Blend Packed Double Precision Floating-Point Values
		case NN_vblendvps:            // Variable Blend Packed Single Precision Floating-Point Values
		case NN_vbroadcastf128:       // Broadcast 128 Bits of Floating-Point Data
		case NN_vbroadcasti128:       // Broadcast 128 Bits of Integer Data
		case NN_vbroadcastsd:         // Broadcast Double-Precision Floating-Point Element
		case NN_vbroadcastss:         // Broadcast Single-Precision Floating-Point Element
		case NN_vcmppd:               // Compare Packed Double-Precision Floating-Point Values
		case NN_vcmpps:               // Packed Single-FP Compare
		case NN_vcmpsd:               // Compare Scalar Double-Precision Floating-Point Values
		case NN_vcmpss:               // Scalar Single-FP Compare
		case NN_vcomisd:              // Compare Scalar Ordered Double-Precision Floating-Point Values and Set EFLAGS
		case NN_vcomiss:              // Scalar Ordered Single-FP Compare and Set EFLAGS
		case NN_vcvtdq2pd:            // Convert Packed Doubleword Integers to Packed Single-Precision Floating-Point Values
		case NN_vcvtdq2ps:            // Convert Packed Doubleword Integers to Packed Double-Precision Floating-Point Values
		case NN_vcvtpd2dq:            // Convert Packed Double-Precision Floating-Point Values to Packed Doubleword Integers
		case NN_vcvtpd2ps:            // Convert Packed Double-Precision Floating-Point Values to Packed Single-Precision Floating-Point Values
		case NN_vcvtph2ps:            // Convert 16-bit FP Values to Single-Precision FP Values
		case NN_vcvtps2dq:            // Convert Packed Single-Precision Floating-Point Values to Packed Doubleword Integers
		case NN_vcvtps2pd:            // Convert Packed Single-Precision Floating-Point Values to Packed Double-Precision Floating-Point Values
		case NN_vcvtps2ph:            // Convert Single-Precision FP value to 16-bit FP value
		case NN_vcvtsd2si:            // Convert Scalar Double-Precision Floating-Point Value to Doubleword Integer
		case NN_vcvtsd2ss:            // Convert Scalar Double-Precision Floating-Point Value to Scalar Single-Precision Floating-Point Value
		case NN_vcvtsi2sd:            // Convert Doubleword Integer to Scalar Double-Precision Floating-Point Value
		case NN_vcvtsi2ss:            // Scalar signed INT32 to Single-FP conversion
		case NN_vcvtss2sd:            // Convert Scalar Single-Precision Floating-Point Value to Scalar Double-Precision Floating-Point Value
		case NN_vcvtss2si:            // Scalar Single-FP to signed INT32 conversion
		case NN_vcvttpd2dq:           // Convert With Truncation Packed Double-Precision Floating-Point Values to Packed Doubleword Integers
		case NN_vcvttps2dq:           // Convert With Truncation Packed Single-Precision Floating-Point Values to Packed Doubleword Integers
		case NN_vcvttsd2si:           // Convert with Truncation Scalar Double-Precision Floating-Point Value to Doubleword Integer
		case NN_vcvttss2si:           // Scalar Single-FP to signed INT32 conversion (truncate)
		case NN_vdivpd:               // Divide Packed Double-Precision Floating-Point Values
		case NN_vdivps:               // Packed Single-FP Divide
		case NN_vdivsd:               // Divide Scalar Double-Precision Floating-Point Values
		case NN_vdivss:               // Scalar Single-FP Divide
		case NN_vdppd:                // Dot Product of Packed Double Precision Floating-Point Values
		case NN_vdpps:                // Dot Product of Packed Single Precision Floating-Point Values
		case NN_vextractf128:         // Extract Packed Floating-Point Values
		case NN_vextracti128:         // Extract Packed Integer Values
		case NN_vextractps:           // Extract Packed Floating-Point Values
		case NN_vfmadd132pd:          // Fused Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfmadd132ps:          // Fused Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfmadd132sd:          // Fused Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfmadd132ss:          // Fused Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfmadd213pd:          // Fused Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfmadd213ps:          // Fused Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfmadd213sd:          // Fused Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfmadd213ss:          // Fused Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfmadd231pd:          // Fused Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfmadd231ps:          // Fused Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfmadd231sd:          // Fused Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfmadd231ss:          // Fused Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfmaddsub132pd:       // Fused Multiply-Alternating Add/Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmaddsub132ps:       // Fused Multiply-Alternating Add/Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmaddsub213pd:       // Fused Multiply-Alternating Add/Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmaddsub213ps:       // Fused Multiply-Alternating Add/Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmaddsub231pd:       // Fused Multiply-Alternating Add/Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmaddsub231ps:       // Fused Multiply-Alternating Add/Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmsub132pd:          // Fused Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmsub132ps:          // Fused Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmsub132sd:          // Fused Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfmsub132ss:          // Fused Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vfmsub213pd:          // Fused Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmsub213ps:          // Fused Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmsub213sd:          // Fused Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfmsub213ss:          // Fused Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vfmsub231pd:          // Fused Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfmsub231ps:          // Fused Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfmsub231sd:          // Fused Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfmsub231ss:          // Fused Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vfmsubadd132pd:       // Fused Multiply-Alternating Subtract/Add of Packed Double-Precision Floating-Point Values
		case NN_vfmsubadd132ps:       // Fused Multiply-Alternating Subtract/Add of Packed Single-Precision Floating-Point Values
		case NN_vfmsubadd213pd:       // Fused Multiply-Alternating Subtract/Add of Packed Double-Precision Floating-Point Values
		case NN_vfmsubadd213ps:       // Fused Multiply-Alternating Subtract/Add of Packed Single-Precision Floating-Point Values
		case NN_vfmsubadd231pd:       // Fused Multiply-Alternating Subtract/Add of Packed Double-Precision Floating-Point Values
		case NN_vfmsubadd231ps:       // Fused Multiply-Alternating Subtract/Add of Packed Single-Precision Floating-Point Values
		case NN_vfnmadd132pd:         // Fused Negative Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfnmadd132ps:         // Fused Negative Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfnmadd132sd:         // Fused Negative Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfnmadd132ss:         // Fused Negative Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfnmadd213pd:         // Fused Negative Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfnmadd213ps:         // Fused Negative Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfnmadd213sd:         // Fused Negative Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfnmadd213ss:         // Fused Negative Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfnmadd231pd:         // Fused Negative Multiply-Add of Packed Double-Precision Floating-Point Values
		case NN_vfnmadd231ps:         // Fused Negative Multiply-Add of Packed Single-Precision Floating-Point Values
		case NN_vfnmadd231sd:         // Fused Negative Multiply-Add of Scalar Double-Precision Floating-Point Values
		case NN_vfnmadd231ss:         // Fused Negative Multiply-Add of Scalar Single-Precision Floating-Point Values
		case NN_vfnmsub132pd:         // Fused Negative Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfnmsub132ps:         // Fused Negative Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfnmsub132sd:         // Fused Negative Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfnmsub132ss:         // Fused Negative Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vfnmsub213pd:         // Fused Negative Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfnmsub213ps:         // Fused Negative Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfnmsub213sd:         // Fused Negative Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfnmsub213ss:         // Fused Negative Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vfnmsub231pd:         // Fused Negative Multiply-Subtract of Packed Double-Precision Floating-Point Values
		case NN_vfnmsub231ps:         // Fused Negative Multiply-Subtract of Packed Single-Precision Floating-Point Values
		case NN_vfnmsub231sd:         // Fused Negative Multiply-Subtract of Scalar Double-Precision Floating-Point Values
		case NN_vfnmsub231ss:         // Fused Negative Multiply-Subtract of Scalar Single-Precision Floating-Point Values
		case NN_vgatherdps:           // Gather Packed SP FP Values Using Signed Dword Indices
		case NN_vgatherdpd:           // Gather Packed DP FP Values Using Signed Dword Indices
		case NN_vgatherqps:           // Gather Packed SP FP Values Using Signed Qword Indices
		case NN_vgatherqpd:           // Gather Packed DP FP Values Using Signed Qword Indices
		case NN_vhaddpd:              // Add horizontally packed DP FP numbers
		case NN_vhaddps:              // Add horizontally packed SP FP numbers
		case NN_vhsubpd:              // Sub horizontally packed DP FP numbers
		case NN_vhsubps:              // Sub horizontally packed SP FP numbers
		case NN_vinsertf128:          // Insert Packed Floating-Point Values
		case NN_vinserti128:          // Insert Packed Integer Values
		case NN_vinsertps:            // Insert Packed Single Precision Floating-Point Value
		case NN_vlddqu:               // Load Unaligned Packed Integer Values
		case NN_vldmxcsr:             // Load Streaming SIMD Extensions Technology Control/Status Register
		case NN_vmaskmovdqu:          // Store Selected Bytes of Double Quadword with NT Hint
		case NN_vmaskmovpd:           // Conditionally Load Packed Double-Precision Floating-Point Values
		case NN_vmaskmovps:           // Conditionally Load Packed Single-Precision Floating-Point Values
		case NN_vmaxpd:               // Return Maximum Packed Double-Precision Floating-Point Values
		case NN_vmaxps:               // Packed Single-FP Maximum
		case NN_vmaxsd:               // Return Maximum Scalar Double-Precision Floating-Point Value
		case NN_vmaxss:               // Scalar Single-FP Maximum
		case NN_vminpd:               // Return Minimum Packed Double-Precision Floating-Point Values
		case NN_vminps:               // Packed Single-FP Minimum
		case NN_vminsd:               // Return Minimum Scalar Double-Precision Floating-Point Value
		case NN_vminss:               // Scalar Single-FP Minimum
		case NN_vmovapd:              // Move Aligned Packed Double-Precision Floating-Point Values
		case NN_vmovaps:              // Move Aligned Four Packed Single-FP
		case NN_vmovd:                // Move 32 bits
		case NN_vmovddup:             // Move One Double-FP and Duplicate
		case NN_vmovdqa:              // Move Aligned Double Quadword
		case NN_vmovdqu:              // Move Unaligned Double Quadword
		case NN_vmovhlps:             // Move High to Low Packed Single-FP
		case NN_vmovhpd:              // Move High Packed Double-Precision Floating-Point Values
		case NN_vmovhps:              // Move High Packed Single-FP
		case NN_vmovlhps:             // Move Low to High Packed Single-FP
		case NN_vmovlpd:              // Move Low Packed Double-Precision Floating-Point Values
		case NN_vmovlps:              // Move Low Packed Single-FP
		case NN_vmovmskpd:            // Extract Packed Double-Precision Floating-Point Sign Mask
		case NN_vmovmskps:            // Move Mask to Register
		case NN_vmovntdq:             // Store Double Quadword Using Non-Temporal Hint
		case NN_vmovntdqa:            // Load Double Quadword Non-Temporal Aligned Hint
		case NN_vmovntpd:             // Store Packed Double-Precision Floating-Point Values Using Non-Temporal Hint
		case NN_vmovntps:             // Move Aligned Four Packed Single-FP Non Temporal
		case NN_vmovntsd:             // Move Non-Temporal Scalar Double-Precision Floating-Point
		case NN_vmovntss:             // Move Non-Temporal Scalar Single-Precision Floating-Point
		case NN_vmovq:                // Move 64 bits
		case NN_vmovsd:               // Move Scalar Double-Precision Floating-Point Values
		case NN_vmovshdup:            // Move Packed Single-FP High and Duplicate
		case NN_vmovsldup:            // Move Packed Single-FP Low and Duplicate
		case NN_vmovss:               // Move Scalar Single-FP
		case NN_vmovupd:              // Move Unaligned Packed Double-Precision Floating-Point Values
		case NN_vmovups:              // Move Unaligned Four Packed Single-FP
		case NN_vmpsadbw:             // Compute Multiple Packed Sums of Absolute Difference
		case NN_vmulpd:               // Multiply Packed Double-Precision Floating-Point Values
		case NN_vmulps:               // Packed Single-FP Multiply
		case NN_vmulsd:               // Multiply Scalar Double-Precision Floating-Point Values
		case NN_vmulss:               // Scalar Single-FP Multiply
		case NN_vorpd:                // Bitwise Logical OR of Double-Precision Floating-Point Values
		case NN_vorps:                // Bitwise Logical OR for Single-FP Data
		case NN_vpabsb:               // Packed Absolute Value Byte
		case NN_vpabsd:               // Packed Absolute Value Doubleword
		case NN_vpabsw:               // Packed Absolute Value Word
		case NN_vpackssdw:            // Pack with Signed Saturation (Dword->Word)
		case NN_vpacksswb:            // Pack with Signed Saturation (Word->Byte)
		case NN_vpackusdw:            // Pack with Unsigned Saturation
		case NN_vpackuswb:            // Pack with Unsigned Saturation (Word->Byte)
		case NN_vpaddb:               // Packed Add Byte
		case NN_vpaddd:               // Packed Add Dword
		case NN_vpaddq:               // Add Packed Quadword Integers
		case NN_vpaddsb:              // Packed Add with Saturation (Byte)
		case NN_vpaddsw:              // Packed Add with Saturation (Word)
		case NN_vpaddusb:             // Packed Add Unsigned with Saturation (Byte)
		case NN_vpaddusw:             // Packed Add Unsigned with Saturation (Word)
		case NN_vpaddw:               // Packed Add Word
		case NN_vpalignr:             // Packed Align Right
		case NN_vpand:                // Bitwise Logical And
		case NN_vpandn:               // Bitwise Logical And Not
		case NN_vpavgb:               // Packed Average (Byte)
		case NN_vpavgw:               // Packed Average (Word)
		case NN_vpblendd:             // Blend Packed Dwords
		case NN_vpblendvb:            // Variable Blend Packed Bytes
		case NN_vpblendw:             // Blend Packed Words
		case NN_vpbroadcastb:         // Broadcast a Byte Integer
		case NN_vpbroadcastd:         // Broadcast a Dword Integer
		case NN_vpbroadcastq:         // Broadcast a Qword Integer
		case NN_vpbroadcastw:         // Broadcast a Word Integer
		case NN_vpclmulqdq:           // Carry-Less Multiplication Quadword
		case NN_vpcmpeqb:             // Packed Compare for Equal (Byte)
		case NN_vpcmpeqd:             // Packed Compare for Equal (Dword)
		case NN_vpcmpeqq:             // Compare Packed Qword Data for Equal
		case NN_vpcmpeqw:             // Packed Compare for Equal (Word)
		case NN_vpcmpestri:           // Packed Compare Explicit Length Strings: Return Index
		case NN_vpcmpestrm:           // Packed Compare Explicit Length Strings: Return Mask
		case NN_vpcmpgtb:             // Packed Compare for Greater Than (Byte)
		case NN_vpcmpgtd:             // Packed Compare for Greater Than (Dword)
		case NN_vpcmpgtq:             // Compare Packed Data for Greater Than
		case NN_vpcmpgtw:             // Packed Compare for Greater Than (Word)
		case NN_vpcmpistri:           // Packed Compare Implicit Length Strings: Return Index
		case NN_vpcmpistrm:           // Packed Compare Implicit Length Strings: Return Mask
		case NN_vperm2f128:           // Permute Floating-Point Values
		case NN_vperm2i128:           // Permute Integer Values
		case NN_vpermd:               // Full Doublewords Element Permutation
		case NN_vpermilpd:            // Permute Double-Precision Floating-Point Values
		case NN_vpermilps:            // Permute Single-Precision Floating-Point Values
		case NN_vpermpd:              // Permute Double-Precision Floating-Point Elements
		case NN_vpermps:              // Permute Single-Precision Floating-Point Elements
		case NN_vpermq:               // Qwords Element Permutation
		case NN_vpextrb:              // Extract Byte
		case NN_vpextrd:              // Extract Dword
		case NN_vpextrq:              // Extract Qword
		case NN_vpextrw:              // Extract Word
		case NN_vpgatherdd:           // Gather Packed Dword Values Using Signed Dword Indices
		case NN_vpgatherdq:           // Gather Packed Qword Values Using Signed Dword Indices
		case NN_vpgatherqd:           // Gather Packed Dword Values Using Signed Qword Indices
		case NN_vpgatherqq:           // Gather Packed Qword Values Using Signed Qword Indices
		case NN_vphaddd:              // Packed Horizontal Add Doubleword
		case NN_vphaddsw:             // Packed Horizontal Add and Saturate
		case NN_vphaddw:              // Packed Horizontal Add Word
		case NN_vphminposuw:          // Packed Horizontal Word Minimum
		case NN_vphsubd:              // Packed Horizontal Subtract Doubleword
		case NN_vphsubsw:             // Packed Horizontal Subtract and Saturate
		case NN_vphsubw:              // Packed Horizontal Subtract Word
		case NN_vpinsrb:              // Insert Byte
		case NN_vpinsrd:              // Insert Dword
		case NN_vpinsrq:              // Insert Qword
		case NN_vpinsrw:              // Insert Word
		case NN_vpmaddubsw:           // Multiply and Add Packed Signed and Unsigned Bytes
		case NN_vpmaddwd:             // Packed Multiply and Add
		case NN_vpmaskmovd:           // Conditionally Store Dword Values Using Mask
		case NN_vpmaskmovq:           // Conditionally Store Qword Values Using Mask
		case NN_vpmaxsb:              // Maximum of Packed Signed Byte Integers
		case NN_vpmaxsd:              // Maximum of Packed Signed Dword Integers
		case NN_vpmaxsw:              // Packed Signed Integer Word Maximum
		case NN_vpmaxub:              // Packed Unsigned Integer Byte Maximum
		case NN_vpmaxud:              // Maximum of Packed Unsigned Dword Integers
		case NN_vpmaxuw:              // Maximum of Packed Word Integers
		case NN_vpminsb:              // Minimum of Packed Signed Byte Integers
		case NN_vpminsd:              // Minimum of Packed Signed Dword Integers
		case NN_vpminsw:              // Packed Signed Integer Word Minimum
		case NN_vpminub:              // Packed Unsigned Integer Byte Minimum
		case NN_vpminud:              // Minimum of Packed Unsigned Dword Integers
		case NN_vpminuw:              // Minimum of Packed Word Integers
		case NN_vpmovmskb:            // Move Byte Mask to Integer
		case NN_vpmovsxbd:            // Packed Move with Sign Extend
		case NN_vpmovsxbq:            // Packed Move with Sign Extend
		case NN_vpmovsxbw:            // Packed Move with Sign Extend
		case NN_vpmovsxdq:            // Packed Move with Sign Extend
		case NN_vpmovsxwd:            // Packed Move with Sign Extend
		case NN_vpmovsxwq:            // Packed Move with Sign Extend
		case NN_vpmovzxbd:            // Packed Move with Zero Extend
		case NN_vpmovzxbq:            // Packed Move with Zero Extend
		case NN_vpmovzxbw:            // Packed Move with Zero Extend
		case NN_vpmovzxdq:            // Packed Move with Zero Extend
		case NN_vpmovzxwd:            // Packed Move with Zero Extend
		case NN_vpmovzxwq:            // Packed Move with Zero Extend
		case NN_vpmuldq:              // Multiply Packed Signed Dword Integers
		case NN_vpmulhrsw:            // Packed Multiply High with Round and Scale
		case NN_vpmulhuw:             // Packed Multiply High Unsigned
		case NN_vpmulhw:              // Packed Multiply High
		case NN_vpmulld:              // Multiply Packed Signed Dword Integers and Store Low Result
		case NN_vpmullw:              // Packed Multiply Low
		case NN_vpmuludq:             // Multiply Packed Unsigned Doubleword Integers
		case NN_vpor:                 // Bitwise Logical Or
		case NN_vpsadbw:              // Packed Sum of Absolute Differences
		case NN_vpshufb:              // Packed Shuffle Bytes
		case NN_vpshufd:              // Shuffle Packed Doublewords
		case NN_vpshufhw:             // Shuffle Packed High Words
		case NN_vpshuflw:             // Shuffle Packed Low Words
		case NN_vpsignb:              // Packed SIGN Byte
		case NN_vpsignd:              // Packed SIGN Doubleword
		case NN_vpsignw:              // Packed SIGN Word
		case NN_vpslld:               // Packed Shift Left Logical (Dword)
		case NN_vpslldq:              // Shift Double Quadword Left Logical
		case NN_vpsllq:               // Packed Shift Left Logical (Qword)
		case NN_vpsllvd:              // Variable Bit Shift Left Logical (Dword)
		case NN_vpsllvq:              // Variable Bit Shift Left Logical (Qword)
		case NN_vpsllw:               // Packed Shift Left Logical (Word)
		case NN_vpsrad:               // Packed Shift Right Arithmetic (Dword)
		case NN_vpsravd:              // Variable Bit Shift Right Arithmetic
		case NN_vpsraw:               // Packed Shift Right Arithmetic (Word)
		case NN_vpsrld:               // Packed Shift Right Logical (Dword)
		case NN_vpsrldq:              // Shift Double Quadword Right Logical (Qword)
		case NN_vpsrlq:               // Packed Shift Right Logical (Qword)
		case NN_vpsrlvd:              // Variable Bit Shift Right Logical (Dword)
		case NN_vpsrlvq:              // Variable Bit Shift Right Logical (Qword)
		case NN_vpsrlw:               // Packed Shift Right Logical (Word)
		case NN_vpsubb:               // Packed Subtract Byte
		case NN_vpsubd:               // Packed Subtract Dword
		case NN_vpsubq:               // Subtract Packed Quadword Integers
		case NN_vpsubsb:              // Packed Subtract with Saturation (Byte)
		case NN_vpsubsw:              // Packed Subtract with Saturation (Word)
		case NN_vpsubusb:             // Packed Subtract Unsigned with Saturation (Byte)
		case NN_vpsubusw:             // Packed Subtract Unsigned with Saturation (Word)
		case NN_vpsubw:               // Packed Subtract Word
		case NN_vptest:               // Logical Compare
		case NN_vpunpckhbw:           // Unpack High Packed Data (Byte->Word)
		case NN_vpunpckhdq:           // Unpack High Packed Data (Dword->Qword)
		case NN_vpunpckhqdq:          // Unpack High Packed Data (Qword->Xmmword)
		case NN_vpunpckhwd:           // Unpack High Packed Data (Word->Dword)
		case NN_vpunpcklbw:           // Unpack Low Packed Data (Byte->Word)
		case NN_vpunpckldq:           // Unpack Low Packed Data (Dword->Qword)
		case NN_vpunpcklqdq:          // Unpack Low Packed Data (Qword->Xmmword)
		case NN_vpunpcklwd:           // Unpack Low Packed Data (Word->Dword)
		case NN_vpxor:                // Bitwise Logical Exclusive Or
		case NN_vrcpps:               // Packed Single-FP Reciprocal
		case NN_vrcpss:               // Scalar Single-FP Reciprocal
		case NN_vroundpd:             // Round Packed Double Precision Floating-Point Values
		case NN_vroundps:             // Round Packed Single Precision Floating-Point Values
		case NN_vroundsd:             // Round Scalar Double Precision Floating-Point Values
		case NN_vroundss:             // Round Scalar Single Precision Floating-Point Values
		case NN_vrsqrtps:             // Packed Single-FP Square Root Reciprocal
		case NN_vrsqrtss:             // Scalar Single-FP Square Root Reciprocal
		case NN_vshufpd:              // Shuffle Packed Double-Precision Floating-Point Values
		case NN_vshufps:              // Shuffle Single-FP
		case NN_vsqrtpd:              // Compute Square Roots of Packed Double-Precision Floating-Point Values
		case NN_vsqrtps:              // Packed Single-FP Square Root
		case NN_vsqrtsd:              // Compute Square Rootof Scalar Double-Precision Floating-Point Value
		case NN_vsqrtss:              // Scalar Single-FP Square Root
		case NN_vstmxcsr:             // Store Streaming SIMD Extensions Technology Control/Status Register
		case NN_vsubpd:               // Subtract Packed Double-Precision Floating-Point Values
		case NN_vsubps:               // Packed Single-FP Subtract
		case NN_vsubsd:               // Subtract Scalar Double-Precision Floating-Point Values
		case NN_vsubss:               // Scalar Single-FP Subtract
		case NN_vtestpd:              // Packed Double-Precision Floating-Point Bit Test
		case NN_vtestps:              // Packed Single-Precision Floating-Point Bit Test
		case NN_vucomisd:             // Unordered Compare Scalar Ordered Double-Precision Floating-Point Values and Set EFLAGS
		case NN_vucomiss:             // Scalar Unordered Single-FP Compare and Set EFLAGS
		case NN_vunpckhpd:            // Unpack and Interleave High Packed Double-Precision Floating-Point Values
		case NN_vunpckhps:            // Unpack High Packed Single-FP Data
		case NN_vunpcklpd:            // Unpack and Interleave Low Packed Double-Precision Floating-Point Values
		case NN_vunpcklps:            // Unpack Low Packed Single-FP Data
		case NN_vxorpd:               // Bitwise Logical OR of Double-Precision Floating-Point Values
		case NN_vxorps:               // Bitwise Logical XOR for Single-FP Data
		case NN_vzeroall:             // Zero All YMM Registers
		case NN_vzeroupper:           // Zero Upper Bits of YMM Registers
			SMP_fprintf(OutFile, "ERROR");
			break;

// Transactional Synchronization Extensions

		case NN_xabort:               // Transaction Abort
		case NN_xbegin:               // Transaction Begin
		case NN_xend:                 // Transaction End
		case NN_xtest:                // Test If In Transactional Execution
			SMP_fprintf(OutFile, "ERROR");
			break;

// Virtual PC synthetic instructions

		case NN_vmgetinfo:            // Virtual PC - Get VM Information
		case NN_vmsetinfo:            // Virtual PC - Set VM Information
		case NN_vmdxdsbl:             // Virtual PC - Disable Direct Execution
		case NN_vmdxenbl:             // Virtual PC - Enable Direct Execution
		case NN_vmcpuid:              // Virtual PC - Virtualized CPU Information
		case NN_vmhlt:                // Virtual PC - Halt
		case NN_vmsplaf:              // Virtual PC - Spin Lock Acquisition Failed
		case NN_vmpushfd:             // Virtual PC - Push virtualized flags register
		case NN_vmpopfd:              // Virtual PC - Pop virtualized flags register
		case NN_vmcli:                // Virtual PC - Clear Interrupt Flag
		case NN_vmsti:                // Virtual PC - Set Interrupt Flag
		case NN_vmiretd:              // Virtual PC - Return From Interrupt
		case NN_vmsgdt:               // Virtual PC - Store Global Descriptor Table
		case NN_vmsidt:               // Virtual PC - Store Interrupt Descriptor Table
		case NN_vmsldt:               // Virtual PC - Store Local Descriptor Table
		case NN_vmstr:                // Virtual PC - Store Task Register
		case NN_vmsdte:               // Virtual PC - Store to Descriptor Table Entry
		case NN_vpcext:               // Virtual PC - ISA extension
			SMP_fprintf(OutFile, "ERROR");
			break;

		case NN_last:	
			SMP_fprintf(OutFile, "ERROR");
			break;

		default:
			SMP_fprintf(OutFile, "ERROR");
			break;
	}

	return;
} // end of PrintOpcode()

// MACHINE DEPENDENT: Is operand type a known type that we want to analyze?
bool MDKnownOperandType(STARSOpndType TempOp) {
	bool GoodOpType = ((TempOp.type >= o_reg) && (TempOp.type <= o_xmmreg));
#if SMP_DEBUG_OPERAND_TYPES
	if (!GoodOpType && (o_void != TempOp.type)) {
		SMP_msg("WARNING: Operand type %d \n", TempOp.type);
	}
#endif 
	return GoodOpType;
clc5q's avatar
clc5q committed
// Meet function over any two types in the type lattice.
SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2) {
	SMPOperandType MeetType = UNKNOWN;
	bool ProfDerived = IsProfDerived(Type1) || IsProfDerived(Type2);
	if (IsEqType(UNINIT, Type1))
		MeetType = Type2;
	else if (IsEqType(UNINIT, Type2) || IsEqType(Type1, Type2)
		|| IsUnknown(Type1))
		MeetType = Type1;
	else if (IsNumeric(Type1)) {
		if (IsNumeric(Type2))  // one is NUMERIC, one is CODEPTR
			MeetType = NUMERIC;
		else if (IsDataPtr(Type2) || IsUnknown(Type2))
			MeetType = UNKNOWN;
clc5q's avatar
clc5q committed
	}
	else if (IsDataPtr(Type1)) {
		if (IsDataPtr(Type2))  // two different POINTER subtypes
			MeetType = POINTER;
		else if (IsNumeric(Type2) || IsUnknown(Type2))
			MeetType = UNKNOWN;
clc5q's avatar
clc5q committed
	}
	if (ProfDerived && IsNotEqType(UNINIT, MeetType))
		MeetType = MakeProfDerived(MeetType);
clc5q's avatar
clc5q committed
	return MeetType;
} // end of SMPTypeMeet()

// Meet function for SCCP constant propagation; updates NewConstStruct
void STARSConstantTypeMeet(struct STARS_SCCP_Const_Struct OldConstStruct, struct STARS_SCCP_Const_Struct &NewConstStruct) {
	if ((OldConstStruct.ConstType != STARS_CONST_BOTTOM) && (NewConstStruct.ConstType != STARS_CONST_TOP)) {
		// We have four possibilities. Three of them have NewConstStruct lower in the type lattice, which means the final
		//  result is simply the NewConstStruct (i.e. if Old == TOP, New == CONST or BOTTOM; or Old == CONST, New == BOTTOM).
		// The fourth possibility is that Old == CONST, New == CONST, and we have to check the const values for consistency,
		//  lowering NewConstStruct to BOTTOM if they are inconsistent.
		if ((OldConstStruct.ConstType == STARS_CONST_HAS_VALUE) && (NewConstStruct.ConstType == STARS_CONST_HAS_VALUE)) {
			if (OldConstStruct.ConstValue != NewConstStruct.ConstValue) { // inconsistent const values
				NewConstStruct.ConstType = STARS_CONST_BOTTOM;
			}
		}
	}
	else {
		NewConstStruct = OldConstStruct;
	}
	return;
} // end of STARSConstantTypeMeet()
// *****************************************************************
// Class DisAsmString
// *****************************************************************
DisAsmString::DisAsmString(void) {
	this->CurrAddr = BADADDR;
	this->StringLen = 0;
	this->CachedDisAsm[0] = '\0';
	return;
}

char *DisAsmString::GetDisAsm(ea_t InstAddr, bool MarkerInst) {
	if (InstAddr != this->CurrAddr) {
		this->CurrAddr = InstAddr;
		if (MarkerInst) {
			this->SetMarkerInstText(InstAddr);
			bool IDAsuccess = SMP_generate_disasm_line(InstAddr, this->CachedDisAsm, sizeof(this->CachedDisAsm) - 1);
			if (IDAsuccess) {
				// Remove interactive color-coding tags.
				this->StringLen = SMP_tag_remove(this->CachedDisAsm, this->CachedDisAsm, 0);
				if (-1 >= StringLen) {
					SMP_msg("ERROR: tag_remove failed at addr %lx \n", (unsigned long) InstAddr);
					this->CachedDisAsm[0] = '\0';
				}
			}
			else {
				SMP_msg("ERROR: generate_disasm_line failed at addr %lx \n", (unsigned long) InstAddr);
				this->CachedDisAsm[0] = '\0';
			}
		}
	}
	return (char *) this->CachedDisAsm;
} // end of DisAsmString::GetDisasm()

// Set the disasm text for the SSA marker instructions, which have no IDA Pro disasm because
//  they are pseudo-instructions that we add at the top of each function to hold LiveIn name info.
void DisAsmString::SetMarkerInstText(ea_t InstAddr) {
	if (InstAddr != this->CurrAddr) {
		this->CurrAddr = InstAddr;
		SMP_strncpy(this->CachedDisAsm, "\tfnop\t; Top of function SSA marker for SMP", 
			sizeof(this->CachedDisAsm) - 1);
		this->StringLen = (ssize_t) strlen(this->CachedDisAsm);
	}
	return;
} // end of DisAsmString::SetMarkerInstText()

clc5q's avatar
clc5q committed
// *****************************************************************
// Class DefOrUse
// *****************************************************************

// Default constructor to make the compilers happy.
DefOrUse::DefOrUse(void) {
	this->Operand.type = o_void;
	this->SSANumber = -2;
	this->NonSpeculativeOpType = UNINIT;
	this->MetadataStatus = DEF_METADATA_UNANALYZED;
	this->booleans1 = 0;
clc5q's avatar
clc5q committed
// Constructor.
DefOrUse::DefOrUse(STARSOpndType Ref, SMPOperandType Type, int SSASub) {
	if (o_reg == Ref.type) {
		// We want to map AH, AL, and AX to EAX, etc. throughout our data flow analysis
		//  and type inference systems.
clc5q's avatar
clc5q committed
	this->Operand = Ref;
	this->SSANumber = SSASub;
clc5q's avatar
clc5q committed
	this->OpType = Type;

	assert(!IsProfDerived(Type));
	this->NonSpeculativeOpType = Type;
	this->MetadataStatus = DEF_METADATA_UNANALYZED;
	this->booleans1 = 0;
// Copy constructor.
DefOrUse::DefOrUse(const DefOrUse &CopyIn) {
	*this = CopyIn;
	return;
}

// Assignment operator for copy constructor use.
DefOrUse &DefOrUse::operator=(const DefOrUse &rhs) {
	this->Operand = rhs.Operand;
	this->OpType = rhs.OpType;
	this->NonSpeculativeOpType = rhs.NonSpeculativeOpType;
	this->SSANumber = rhs.SSANumber;
	this->MetadataStatus = rhs.MetadataStatus;
	this->booleans1 = rhs.booleans1;
// Set the operand type for this DEF or USE - don't forget to take
//  into account the speculative (profiler) status.
void DefOrUse::SetType(SMPOperandType Type, const SMPInstr *Instr) {
	SMPOperandType OldType = this->OpType;
	SMPOperandType NewType = Type;
	if (Instr->GetBlock()->GetFunc()->GetIsSpeculative()) {
		NewType = (SMPOperandType)(((int)NewType) | PROF_BASE);
		if (!IsProfDerived(OldType))
			this->NonSpeculativeOpType = OldType;
	this->OpType = NewType;
void DefOrUse::SetMetadataStatus(SMPMetadataType NewStatus) {
	// See if we are just updating explanation codes.
	bool OldUsed = ((this->MetadataStatus >= DEF_METADATA_USED) && (this->MetadataStatus < DEF_METADATA_REDUNDANT));
	if (OldUsed) {
		bool NewUsed = ((NewStatus >= DEF_METADATA_USED) && (NewStatus < DEF_METADATA_REDUNDANT));
		if (NewUsed) { 
			// Union the explanation codes.
			int TempInt = (int) this->GetMetadataStatus();
			TempInt |= (int) NewStatus; 
			this->MetadataStatus = (SMPMetadataType) TempInt; 
			return;
		}
	}
	this->MetadataStatus = NewStatus;
	return;
}

// Debug printing.
void DefOrUse::Dump(void) const {
	PrintListOperand(this->Operand, this->SSANumber);
	if (IsEqType(this->OpType , NUMERIC))
	else if (IsEqType(this->OpType , CODEPTR))
	else if (IsEqType(this->OpType , POINTER))
	else if (IsEqType(this->OpType , STACKPTR))
	else if (IsEqType(this->OpType , GLOBALPTR))
	else if (IsEqType(this->OpType , HEAPPTR))
	else if (IsEqType(this->OpType , PTROFFSET))
	else if (IsEqType(this->OpType , UNKNOWN))
	if (IsProfDerived(this->OpType))
	// Don't write anything for UNINIT OpType

	// Emit the metadata status.
	if (DEF_METADATA_UNUSED == this->MetadataStatus)
	else if (DEF_METADATA_USED == this->MetadataStatus)
	else if (DEF_METADATA_REDUNDANT == this->MetadataStatus)
	// Is the DEF possibly aliased because of an indirect write in
	//  the DEF-USE chain?
	if (this->HasIndirectWrite())
	return;
} // end of DefOrUse::Dump()

// *****************************************************************
// Class DefOrUseSet
// *****************************************************************

// Default constructor.
DefOrUseSet::DefOrUseSet(void) {
// Destructor.
DefOrUseSet::~DefOrUseSet() {
// Find the reference for a given operand type.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::FindRef(STARSOpndType SearchOp) {
	set<DefOrUse, LessDefUse>::iterator CurrRef;
	DefOrUse DummyRef(SearchOp);
	CurrRef = this->Refs.find(DummyRef);
	return CurrRef;
}

// Insert a new DEF or USE; must be new, insert must succeed else we assert.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::InsertRef(DefOrUse Ref) {
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(Ref);
	assert(InsertResult.second);
	return InsertResult.first;
}

// Set a Def or Use into the list, along with its type.
void DefOrUseSet::SetRef(STARSOpndType Ref, SMPOperandType Type, int SSASub) {
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	DefOrUse CurrRef(Ref, Type, SSASub);
	InsertResult = this->Refs.insert(CurrRef);
	if ((!(InsertResult.second)) && (o_reg != Ref.type)) {
		SMP_msg("ERROR: Inserted duplicate DEF or USE.\n");
	}
// Change the indirect write status for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetOp(set<DefOrUse, LessDefUse>::iterator CurrRef, STARSOpndType NewOp) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	assert(CurrRef != this->Refs.end());
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetOp(NewOp);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	return InsertResult.first;
} // end of DefOrUseSet::SetOp()

// Change the SSA subscript for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetSSANum(STARSOpndType CurrOp, int NewSSASub) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
	set<DefOrUse, LessDefUse>::iterator NextRef = CurrRef;
	++NextRef;
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetSSANum(NewSSASub);
	this->Refs.erase(CurrRef);
	CurrRef = this->Refs.insert(NextRef, NewCopy);
	return CurrRef;
} // end of DefOrUseSet::SetSSANum()

// Change the operand type for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetType(STARSOpndType CurrOp, SMPOperandType Type, const SMPInstr* Instr) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
#if 1
	if (o_imm == CurrOp.type) {
		if (UNINIT != CurrRef->GetType() && Type != CurrRef->GetType()) {
			SMP_msg("ERROR: Changing type of immediate from %d to %d at %lx: ", CurrRef->GetType(), Type, (unsigned long) Instr->GetAddr());
			SMPInstr InstCopy = (*Instr);
			InstCopy.Dump();
	DefOrUse NewCopy = (*CurrRef);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	CurrRef = InsertResult.first;
} // end of DefOrUseSet::SetType()

// Change the Metadata type for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetMetadata(STARSOpndType CurrOp, SMPMetadataType Status) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetMetadataStatus(Status);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	CurrRef = InsertResult.first;
	return CurrRef;
} // end of DefOrUseSet::SetMetadata()
// Change the indirect write status for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetIndWrite(STARSOpndType CurrOp, bool IndWriteFlag) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetIndWrite(IndWriteFlag);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	CurrRef = InsertResult.first;
	return CurrRef;
} // end of DefOrUseSet::SetIndWrite()

// Change the ignore apparent truncation flag for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetNoTruncation(STARSOpndType CurrOp, bool NoTruncFlag) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetNoTruncation(NoTruncFlag);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	CurrRef = InsertResult.first;
	return CurrRef;
} // end of DefOrUseSet::SetNoTruncation()

// Change the ignore apparent overflow flag for a reference.
set<DefOrUse, LessDefUse>::iterator DefOrUseSet::SetNoOverflow(STARSOpndType CurrOp, bool NoOverflowFlag) {
	// To change a field within a set, we must grab a copy, change the copy,
	//  delete the old set member, and insert the updated copy as a new member.
	set<DefOrUse, LessDefUse>::iterator CurrRef = this->FindRef(CurrOp);
	assert(CurrRef != this->Refs.end());
	DefOrUse NewCopy = (*CurrRef);
	NewCopy.SetNoOverflow(NoOverflowFlag);
	this->Refs.erase(CurrRef);
	pair<set<DefOrUse, LessDefUse>::iterator, bool> InsertResult;
	InsertResult = this->Refs.insert(NewCopy);
	assert(InsertResult.second);
	CurrRef = InsertResult.first;
	return CurrRef;
} // end of DefOrUseSet::SetNoOverflow()

// Debug printing.
	set<DefOrUse, LessDefUse>::iterator CurrRef;
	for (CurrRef = this->Refs.begin(); CurrRef != this->Refs.end(); ++CurrRef) {
		CurrRef->Dump();
	}
clc5q's avatar
clc5q committed
// Do all types agree, ignoring any flags registers in the set? This is used
//  for conditional move instructions; if all types agree, it does not matter
//  whether the move happens or not.
bool DefOrUseSet::TypesAgreeNoFlags(void) {
	bool FoundFirstUse = false;
	set<DefOrUse, LessDefUse>::iterator CurrUse;
	SMPOperandType UseType = UNINIT;
	for (CurrUse = this->Refs.begin(); CurrUse != this->Refs.end(); ++CurrUse) {
		if (!(CurrUse->GetOp().is_reg(X86_FLAGS_REG))) { // ignore flags
			if (!FoundFirstUse) {
				FoundFirstUse = true;
				UseType = CurrUse->GetType();
			}
			else {
				if (IsNotEqType(CurrUse->GetType(), UseType)) {