Skip to content

Instantly share code, notes, and snippets.

@ScottPJones
Last active February 15, 2018 22:25
Show Gist options
  • Save ScottPJones/8531146104d22a3a46b6777e90968b42 to your computer and use it in GitHub Desktop.
Save ScottPJones/8531146104d22a3a46b6777e90968b42 to your computer and use it in GitHub Desktop.
Code generation of ('0' + q)%UInt8
julia> f(q) = ('0' + q)%UInt8
f (generic function with 1 method)
julia> @code_native f(0x9)
.section __TEXT,__text,regular,pure_instructions
; Function f {
; Location: REPL[9]:1
pushq %rbp
pushq %r14
pushq %rbx
movl %edi, %eax
movabsq $"+", %rcx
movl $805306368, %edi ## imm = 0x30000000
movl %eax, %esi
callq *%rcx
; Function rem; {
; Location: char.jl:75
; Function Type; {
; Location: char.jl:30
testl %eax, %eax
js L37
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
shrl $24, %eax
jmp L265
;}}
; Location: char.jl:31
; Function leading_ones; {
; Location: int.jl:388
; Function ~; {
; Location: int.jl:271
L37:
movl %eax, %ecx
notl %ecx
;}
; Function leading_zeros; {
; Location: int.jl:352
lzcntl %ecx, %r14d
;}}
; Location: char.jl:32
; Function trailing_zeros; {
; Location: int.jl:364
tzcntl %eax, %esi
;}
; Function &; {
; Location: int.jl:287
andl $56, %esi
;}
; Location: char.jl:33
; Function ==; {
; Location: promotion.jl:435
cmpl $1, %r14d
sete %r10b
;}
; Function +; {
; Location: int.jl:53
leaq (%rsi,%r14,8), %rdi
;}
; Function >; {
; Location: operators.jl:250
; Function <; {
; Location: int.jl:49
cmpq $32, %rdi
seta %r8b
;}}
; Function &; {
; Location: int.jl:287
movl %eax, %edi
andl $12632256, %edi ## imm = 0xC0C0C0
;}
; Function xor; {
; Location: int.jl:304
xorl $8421504, %edi ## imm = 0x808080
;}
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
cmpq $31, %rsi
seta %r9b
shrxl %esi, %edi, %edi
;}}
; Function !=; {
; Location: operators.jl:158
; Function ==; {
; Location: int.jl:409
; Function ==; {
; Location: promotion.jl:358
; Function ==; {
; Location: promotion.jl:435
testl %edi, %edi
sete %dl
;}}}}
; Function is_overlong_enc; {
; Location: char.jl:20
; Function ==; {
; Location: promotion.jl:358
; Function ==; {
; Location: promotion.jl:435
movl %eax, %edi
andl $4278190080, %edi ## imm = 0xFF000000
cmpl $3221225472, %edi ## imm = 0xC0000000
sete %r11b
cmpl $3238002688, %edi ## imm = 0xC1000000
sete %cl
movl %eax, %edi
andl $4292870144, %edi ## imm = 0xFFE00000
cmpl $3766484992, %edi ## imm = 0xE0800000
sete %dil
movl %eax, %ebp
andl $4293918720, %ebp ## imm = 0xFFF00000
cmpl $4034920448, %ebp ## imm = 0xF0800000
sete %bl
;}}}
; Function |; {
; Location: bool.jl:37
orb %r9b, %dl
xorb $1, %dl
;}
; Function is_overlong_enc; {
; Location: char.jl:20
; Function |; {
; Location: bool.jl:37
orb %r11b, %cl
orb %r10b, %cl
orb %dil, %bl
orb %cl, %bl
;}}
orb %r8b, %bl
orb %dl, %bl
jne L270
; Location: char.jl:36
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
xorl %ecx, %ecx
cmpl $31, %r14d
movl $4294967295, %edx ## imm = 0xFFFFFFFF
shrxl %r14d, %edx, %edx
cmoval %ecx, %edx
;}}
; Function &; {
; Location: int.jl:287
andl %eax, %edx
cmpq $31, %rsi
;}
; Location: char.jl:37
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
shrxl %esi, %edx, %eax
cmoval %ecx, %eax
;}}
; Location: char.jl:38
; Function &; {
; Location: int.jl:287
movl %eax, %ecx
andl $127, %ecx
;}
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
movl %eax, %edx
shrl $2, %edx
andl $8128, %edx ## imm = 0x1FC0
;}}
; Function |; {
; Location: int.jl:303
orl %ecx, %edx
;}
; Function >>; {
; Location: int.jl:425
; Function >>; {
; Location: int.jl:419
movl %eax, %ecx
shrl $4, %ecx
andl $520192, %ecx ## imm = 0x7F000
shrl $6, %eax
andl $33292288, %eax ## imm = 0x1FC0000
;}}
; Function |; {
; Location: int.jl:303
orl %ecx, %eax
orl %edx, %eax
;}}}
L265:
popq %rbx
popq %r14
popq %rbp
retq
; Function rem; {
; Location: char.jl:75
; Function Type; {
; Location: char.jl:33
L270:
movabsq $invalid_char, %rcx
movl %eax, %edi
callq *%rcx
ud2
nop
;}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment