Skip to content

Instantly share code, notes, and snippets.

@Urgau
Last active December 18, 2021 23:49
Show Gist options
  • Save Urgau/018156b76351329ac9ad11b928af946f to your computer and use it in GitHub Desktop.
Save Urgau/018156b76351329ac9ad11b928af946f to your computer and use it in GitHub Desktop.
Assembly output for core::intrinsics::powf64
#!/usr/bin/env bash
TARGET_LIST=$(rustup target list | cut -d' ' -f1)
mkdir jsons asms
for target in ${TARGET_LIST}
do
curl 'https://godbolt.org/api/compiler/nightly/compile' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Content-Type: application/json' --data-raw '{"source":"#![feature(core_intrinsics)]\n#![no_std]\n\npub fn pow(a: f64, b: f64) -> f64 {\n unsafe { core::intrinsics::powf64(a, b) }\n}\n","compiler":"nightly","options":{"userArguments":"-C opt-level=3 --target='$target'","compilerOptions":{"produceGccDump":{},"produceCfg":false,"produceDevice":false},"filters":{"binary":false,"execute":false,"intel":true,"demangle":true,"labels":true,"directives":true,"commentOnly":true,"trim":false},"tools":[],"libraries":[]},"lang":"rust","files":[],"allowStoreCodeDebug":true}' | jq -r '.asm[].text' > "$target.asm"
done
example::pow:
b _pow
example::pow:
b pow
example::pow:
str x30, [sp, #-16]!
bl pow
ldr x30, [sp], #16
ret
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
push {r11, lr}
bl pow
pop {r11, pc}
example::pow:
local.get 0
local.get 1
call pow
end_function
example::pow:
sub esp, 16
fld qword ptr [esp + 20]
fld qword ptr [esp + 28]
fstp qword ptr [esp + 8]
fstp qword ptr [esp]
call _pow
add esp, 16
ret
example::pow:
push ebx
sub esp, 24
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
fld qword ptr [esp + 32]
fld qword ptr [esp + 40]
fstp qword ptr [esp + 8]
fstp qword ptr [esp]
call pow@PLT
add esp, 24
pop ebx
ret
example::pow:
push ebp
mov ebp, esp
push ebx
sub esp, 20
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
fld qword ptr [ebp + 8]
fld qword ptr [ebp + 16]
fstp qword ptr [esp + 8]
fstp qword ptr [esp]
call pow@PLT
add esp, 20
pop ebx
pop ebp
ret
example::pow:
push ebx
sub esp, 24
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
movsd xmm0, qword ptr [esp + 32]
movsd xmm1, qword ptr [esp + 40]
movsd qword ptr [esp + 8], xmm1
movsd qword ptr [esp], xmm0
call pow@PLT
add esp, 24
pop ebx
ret
example::pow:
push ebp
mov ebp, esp
pop ebp
jmp _pow
example::pow:
jmp _pow
example::pow:
push ebx
sub esp, 16
movsd xmm0, qword ptr [esp + 24]
movsd xmm1, qword ptr [esp + 32]
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
movsd qword ptr [esp + 8], xmm1
movsd qword ptr [esp], xmm0
call pow@PLT
add esp, 16
pop ebx
ret
example::pow:
push ebx
sub esp, 24
movsd xmm0, qword ptr [esp + 32]
movsd xmm1, qword ptr [esp + 40]
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
movsd qword ptr [esp + 8], xmm1
movsd qword ptr [esp], xmm0
call pow@PLT
add esp, 24
pop ebx
ret
example::pow:
push ebp
mov ebp, esp
push ebx
sub esp, 20
movsd xmm0, qword ptr [ebp + 8]
movsd xmm1, qword ptr [ebp + 16]
call .L0$pb
.L0$pb:
pop ebx
.Ltmp0:
add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
movsd qword ptr [esp + 8], xmm1
movsd qword ptr [esp], xmm0
call pow@PLT
add esp, 20
pop ebx
pop ebp
ret
example::pow:
lui $2, %hi(_gp_disp)
addiu $2, $2, %lo(_gp_disp)
addiu $sp, $sp, -24
sw $ra, 20($sp)
addu $gp, $2, $25
lw $25, %call16(pow)($gp)
jalr $25
nop
lw $ra, 20($sp)
jr $ra
addiu $sp, $sp, 24
example::pow:
lui $2, %hi(_gp_disp)
addiu $2, $2, %lo(_gp_disp)
addiu $sp, $sp, -24
sw $ra, 20($sp)
addu $gp, $2, $25
lw $25, %call16(pow)($gp)
jalr $25
nop
lw $ra, 20($sp)
jr $ra
addiu $sp, $sp, 24
example::pow:
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $gp, 0($sp)
lui $1, %hi(%neg(%gp_rel(example::pow)))
daddu $1, $1, $25
daddiu $gp, $1, %lo(%neg(%gp_rel(example::pow)))
ld $25, %call16(pow)($gp)
jalr $25
nop
ld $gp, 0($sp)
ld $ra, 8($sp)
jr $ra
daddiu $sp, $sp, 16
example::pow:
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $gp, 0($sp)
lui $1, %hi(%neg(%gp_rel(example::pow)))
daddu $1, $1, $25
daddiu $gp, $1, %lo(%neg(%gp_rel(example::pow)))
ld $25, %call16(pow)($gp)
jalr $25
nop
ld $gp, 0($sp)
ld $ra, 8($sp)
jr $ra
daddiu $sp, $sp, 16
example::pow:
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $gp, 0($sp)
lui $1, %hi(%neg(%gp_rel(example::pow)))
daddu $1, $1, $25
daddiu $gp, $1, %lo(%neg(%gp_rel(example::pow)))
ld $25, %call16(pow)($gp)
jalr $25
nop
ld $gp, 0($sp)
ld $ra, 8($sp)
jr $ra
daddiu $sp, $sp, 16
example::pow:
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $gp, 0($sp)
lui $1, %hi(%neg(%gp_rel(example::pow)))
daddu $1, $1, $25
daddiu $gp, $1, %lo(%neg(%gp_rel(example::pow)))
ld $25, %call16(pow)($gp)
jalr $25
nop
ld $gp, 0($sp)
ld $ra, 8($sp)
jr $ra
daddiu $sp, $sp, 16
example::pow:
lui $2, %hi(_gp_disp)
addiu $2, $2, %lo(_gp_disp)
addiu $sp, $sp, -24
sw $ra, 20($sp)
addu $gp, $2, $25
lw $25, %call16(pow)($gp)
jalr $25
nop
lw $ra, 20($sp)
jr $ra
addiu $sp, $sp, 24
example::pow:
lui $2, %hi(_gp_disp)
addiu $2, $2, %lo(_gp_disp)
addiu $sp, $sp, -24
sw $ra, 20($sp)
addu $gp, $2, $25
lw $25, %call16(pow)($gp)
jalr $25
nop
lw $ra, 20($sp)
jr $ra
addiu $sp, $sp, 24
<Compilation failed>
example::pow:
mflr 0
stw 0, 4(1)
stwu 1, -16(1)
bl pow@PLT
lwz 0, 20(1)
addi 1, 1, 16
mtlr 0
blr
example::pow:
.quad .Lfunc_begin0
.quad .TOC.@tocbase
.quad 0
.Lfunc_begin0:
mflr 0
std 0, 16(1)
stdu 1, -112(1)
bl pow
nop
addi 1, 1, 112
ld 0, 16(1)
mtlr 0
blr
.long 0
.quad 0
example::pow:
.Lfunc_gep0:
addis 2, 12, .TOC.-.Lfunc_gep0@ha
addi 2, 2, .TOC.-.Lfunc_gep0@l
mflr 0
std 0, 16(1)
stdu 1, -32(1)
bl pow
nop
addi 1, 1, 32
ld 0, 16(1)
mtlr 0
blr
.long 0
.quad 0
example::pow:
addi sp, sp, -16
sw ra, 12(sp)
call pow@plt
lw ra, 12(sp)
addi sp, sp, 16
ret
example::pow:
addi sp, sp, -16
sw ra, 12(sp)
call pow@plt
lw ra, 12(sp)
addi sp, sp, 16
ret
example::pow:
addi sp, sp, -16
sw ra, 12(sp)
call pow@plt
lw ra, 12(sp)
addi sp, sp, 16
ret
example::pow:
addi sp, sp, -16
sd ra, 8(sp)
call pow@plt
ld ra, 8(sp)
addi sp, sp, 16
ret
example::pow:
addi sp, sp, -16
sd ra, 8(sp)
call pow@plt
ld ra, 8(sp)
addi sp, sp, 16
ret
example::pow:
addi sp, sp, -16
sd ra, 8(sp)
call pow@plt
ld ra, 8(sp)
addi sp, sp, 16
ret
example::pow:
stmg %r14, %r15, 112(%r15)
aghi %r15, -160
brasl %r14, pow@PLT
lmg %r14, %r15, 272(%r15)
br %r14
example::pow:
save %sp, -176, %sp
call pow
nop
ret
restore
example::pow:
save %sp, -176, %sp
call pow
nop
ret
restore
example::pow:
push {r7, lr}
add r7, sp, #0
bl pow
pop {r7, pc}
example::pow:
push {r7, lr}
mov r7, sp
bl pow
pop {r7, pc}
example::pow:
push {r7, lr}
mov r7, sp
bl pow
pop {r7, pc}
example::pow:
push {r7, lr}
add r7, sp, #0
bl pow
pop {r7, pc}
example::pow:
push {r7, lr}
mov r7, sp
bl pow
pop {r7, pc}
example::pow:
local.get 0
local.get 1
call pow
end_function
example::pow:
local.get 0
local.get 1
call pow
end_function
example::pow:
local.get 0
local.get 1
call pow
end_function
example::pow:
push rbp
mov rbp, rsp
pop rbp
jmp _pow
example::pow:
push rbp
mov rbp, rsp
pop rbp
jmp _pow
example::pow:
jmp pow@PLT
__llvm_lvi_thunk_r11:
lfence
jmp r11
example::pow:
jmp pow@PLT
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
example::pow:
jmp pow@PLT
example::pow:
jmp pow@PLT
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
example::pow:
push rbp
mov rbp, rsp
pop rbp
jmp pow@PLT
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
example::pow:
jmp qword ptr [rip + pow@GOTPCREL]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment