나는 인텔의 정적 코드 분석기 IACA으로 놀아왔다.
같이, 나는 매직 수동으로 바이트를 입력 할 수 있습니다 조립 조각으로 테스트 할 때 그것은 잘 작동 :IACA를 비 어셈블리 루틴과 함께 사용
procedure TSlice.BitSwap(a, b: integer);
asm
//RCX = self
//edx = a
//r8d = b
mov ebx, 111 // Start IACA marker bytes
db $64, $67, $90 // Start IACA marker bytes
xor eax, eax
xor r10d, r10d
mov r9d, [rcx] // read the value
mov ecx,edx // need a in cl for the shift
btr r9d, edx // read and clear the a bit
setc al // convert cf to bit
shl eax, cl // shift bit to ecx position
btr r9d, r8d // read and clear the b bit
mov ecx, r8d // need b in ecx for shift
setc r10b // convert cf to bit
shl r10d, cl // shift bit to edx position
or r9d, eax // copy in old edx bit
or r9d, r10d // copy in old ecx bit
mov [r8], r9d // store result
ret
mov ebx, 222 // End IACA marker bytes
db $64, $67, $90 // End IACA marker bytes
end;
필요한 매직 마커/접미사 비 어셈블리 코드를 앞에 할 수있는 방법이 있나요 나는 할 수 있도록 컴파일러가 생성 한 코드를 분석 하시겠습니까?
나는 내가 CPU 뷰에서 생성 된 어셈블리를 복사 - 붙여 넣기하고를 사용하여 루틴을 만들 수 있습니다 알고 있지만, 나는
편집
내가 찾고 쉬운 워크 플로우가 기대했다 64 비트 컴파일러에서 작동하는 솔루션 어셈블리와 일반 코드를 32 비트 컴파일러에서 혼합 할 수 있다는 것을 알고 있습니다.
업데이트
@ Dsm의 제안이 작동합니다. @ Rudy의 속임수가 아닙니다.
다음 더미 코드는 작동 :
Throughput Analysis Report
--------------------------
Block Throughput: 13.33 Cycles Throughput Bottleneck: Dependency chains (possibly between iterations)
Port Binding In Cycles Per Iteration:
---------------------------------------------------------------------------------------
| Port | 0 - DV | 1 | 2 - D | 3 - D | 4 | 5 | 6 | 7 |
---------------------------------------------------------------------------------------
| Cycles | 1.3 0.0 | 1.4 | 1.0 1.0 | 1.0 1.0 | 0.0 | 1.4 | 2.0 | 0.0 |
---------------------------------------------------------------------------------------
N - port number or number of cycles resource conflict caused delay, DV - Divider pipe (on port 0)
D - Data fetch pipe (on ports 2 and 3), CP - on a critical path
F - Macro Fusion with the previous instruction occurred
* - instruction micro-ops not bound to a port
^ - Micro Fusion happened
# - ESP Tracking sync uop was issued
@ - SSE instruction followed an AVX256/AVX512 instruction, dozens of cycles penalty is expected
X - instruction not supported, was not accounted in Analysis
| Num Of | Ports pressure in cycles | |
| Uops | 0 - DV | 1 | 2 - D | 3 - D | 4 | 5 | 6 | 7 | |
---------------------------------------------------------------------------------
| 3^ | 0.3 | 0.3 | 1.0 1.0 | | | 0.3 | 1.0 | | CP | ret
| X | | | | | | | | | | int3
[... more int3's]
| X | | | | | | | | | | int3
| 1 | 1.0 | | | | | | | | | shl eax, 0x10
| 1 | | 0.6 | | | | 0.3 | | | | cmp eax, 0x64
| 3^ | | 0.3 | | 1.0 1.0 | | 0.6 | 1.0 | | CP | ret
| X | | | | | | | | | | int3
| X | | | | | | | | | | int3
[...]
Total Num Of Uops: 8
업데이트 2
이 IACA은 폭탄 것하고 코드를 분석 할 수 없습니다에 호출 문이있는 경우. 불법적 인 지시에 대해 불평 함. 그러나 기본적인 아이디어가 작동합니다. 분명히 초기 ret
및 관련 비용을 뺄 필요가 있습니다.
두 시퀀스 모두 정확히 8 바이트입니다. Can not :'X : = $ 906764000000F6BB' 그리고 루틴 끝에서'X : = $ 906764000000DEBB','X'는'UInt64'입니까? –
기계 코드를 변경할 수 없다면 정적 해석은 무엇입니까? –
@RudyVelthuis, 비교를위한 기준선으로 사용. 비 어셈블리 코드는 인라인 될 수 있지만 어셈블리 코드는 인라인 될 수 없습니다. – Johan