Skip to content

Instantly share code, notes, and snippets.

@froggey
Created May 31, 2018 19:49
Show Gist options
  • Select an option

  • Save froggey/939edddf18008decbf96b0ef52334a63 to your computer and use it in GitHub Desktop.

Select an option

Save froggey/939edddf18008decbf96b0ef52334a63 to your computer and use it in GitHub Desktop.
;; Getting the input to perform-target-lap-generation:
(let ((fn (mezzano.compiler.backend.ast-convert:convert
(sys.c::compile-lambda-1 '(lambda ()))))
(target (sys.c::canonicalize-target :x86-64)))
(mezzano.compiler.backend::compile-backend-function-1 fn target)
(mezzano.compiler.backend.register-allocator::allocate-registers fn target)
(mezzano.compiler.backend::print-function fn))
;; =>
#<MEZZANO.COMPILER.BACKEND:BACKEND-FUNCTION {100F707853}>
(:ARGUMENT-SETUP #<MEZZANO.COMPILER.BACKEND:VIRTUAL-REGISTER :FREF :VALUE {100F707F93}> :RBX #<MEZZANO.COMPILER.BACKEND:VIRTUAL-REGISTER :COUNT :VALUE {100F707FF3}> NIL NIL NIL)
(:CONSTANT :R8 NIL)
(:RETURN :R8)
(let ((sys.c::*trace-asm* :full))
(sys.c::compile-lambda '(lambda ())))
;; This is the output from perform-target-lap-generation:
(LAMBDA :IN NIL):
MEZZANO.COMPILER.BACKEND.X86-64::ENTRY-POINT
(:DEBUG NIL)
(:GC :NO-FRAME :INCOMING-ARGUMENTS :RCX :LAYOUT #*0)
(PUSH :RBP)
(:GC :NO-FRAME :INCOMING-ARGUMENTS :RCX :LAYOUT #*00)
(SYS.LAP-X86:MOV64 :RBP :RSP)
(:GC :FRAME :INCOMING-ARGUMENTS :RCX)
(:GC :FRAME :LAYOUT #* :INCOMING-ARGUMENTS :RCX)
(:DEBUG NIL)
(SYS.LAP-X86:TEST32 :ECX :ECX)
(SYS.LAP-X86:JZ #<SYS.LAP:LABEL :ARGS-OK {100F6622F3}>)
(SYS.LAP-X86:LEA64 :RBX
(:RIP (+ (- MEZZANO.COMPILER.BACKEND.X86-64::ENTRY-POINT 16) 9)))
(SYS.LAP-X86:MOV64 :R13
(:FUNCTION SYSTEM.INTERNALS::RAISE-INVALID-ARGUMENT-ERROR))
(SYS.LAP-X86:LEAVE)
(:GC :NO-FRAME :INCOMING-ARGUMENTS :RCX :LAYOUT #*0)
(SYS.LAP-X86:JMP (:OBJECT :R13 2))
#<SYS.LAP:LABEL :ARGS-OK {100F6622F3}>
(:GC :FRAME :LAYOUT #* :INCOMING-ARGUMENTS :RCX)
(:DEBUG NIL)
(:GC :FRAME :LAYOUT #*)
(SYS.LAP-X86:MOV32 :R8D NIL)
(:DEBUG NIL)
(:GC :FRAME :LAYOUT #*)
(SYS.LAP-X86:MOV32 :ECX 2)
(SYS.LAP-X86:LEAVE)
(:GC :NO-FRAME :LAYOUT #*0)
(SYS.LAP-X86:RET)
(:ALIGN 16)
MEZZANO.COMPILER.BACKEND.X86-64::LITERAL-POOL/128
MEZZANO.COMPILER.BACKEND.X86-64::LITERAL-POOL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment