Skip to content

Commit

Permalink
Merge pull request #812 from andrew-johnson-4/eliminate-fragments
Browse files Browse the repository at this point in the history
Eliminate fragments
  • Loading branch information
andrew-johnson-4 authored Oct 12, 2024
2 parents 5f6040f + e597d3b commit 60bc492
Show file tree
Hide file tree
Showing 19 changed files with 30,454 additions and 30,213 deletions.
60,230 changes: 30,326 additions & 29,904 deletions BOOTSTRAP/cli.s

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lambda_mountain"
version = "1.17.2"
version = "1.17.3"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
87 changes: 45 additions & 42 deletions LIB/default-cdecl-return.lm
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@

fragment cdecl::return := λ: DontChain(: l Nil). (: (
(.program(
(.program l)
(.del l)
))
(.frame( (.frame l) ))
cdecl::return := λ: Blob(: l Nil). (: (
(:frame( (:frame l) ))
(:unframe( (:unframe l) ))
(:program( (:program l) (:del l) ))
) Nil);
fragment cdecl::return := λ: DontChain(: l Reg8). (: (
(.program(
(.program l)
\t 'mov \t '% (.expression l) , '%AL \n
\t 'push \s '%RAX \n
(.del l)
\t 'pop \s '%RAX \n
cdecl::return := λ: Blob(: l Reg8). (: (
(:frame( (:frame l) ))
(:unframe( (:unframe l) ))
(:expression( 'AL_s ))
(:program(
(:program l)
'\tmov\t%_s (:expression l) ',%AL\n_s
'\tpush\s%RAX\n_s
(:del l)
'\tpop\s%RAX\n_s
))
(.frame (.frame l))
(.expression 'AL)
) Nil);
fragment cdecl::return := λ: DontChain(: l Reg16). (: (
(.program(
(.program l)
\t 'mov \t '% (.expression l) , '%AX \n
\t 'push \s '%RAX \n
(.del l)
\t 'pop \s '%RAX \n
cdecl::return := λ: Blob(: l Reg16). (: (
(:frame( (:frame l) ))
(:unframe( (:unframe l) ))
(:expression( 'AX_s ))
(:program(
(:program l)
'\tmov\t%_s (:expression l) ',%AX\n_s
'\tpush\s%RAX\n_s
(:del l)
'\tpop\s%RAX\n_s
))
(.frame (.frame l))
(.expression 'AX)
) Nil);
fragment cdecl::return := λ: DontChain(: l Reg32). (: (
(.program(
(.program l)
\t 'mov \t '% (.expression l) , '%EAX \n
\t 'push \s '%RAX \n
(.del l)
\t 'pop \s '%RAX \n
cdecl::return := λ: Blob(: l Reg32). (: (
(:frame (:frame l))
(:unframe( (:unframe l) ))
(:expression 'EAX_s)
(:program(
(:program l)
'\tmov\t%_s (:expression l) ',%EAX\n_s
'\tpush\s%RAX\n_s
(:del l)
'\tpop\s%RAX\n_s
))
(.frame (.frame l))
(.expression 'EAX)
) Nil);
fragment cdecl::return := λ: DontChain(: l Reg64). (: (
(.program(
(.program l)
\t 'mov \t '% (.expression l) , '%RAX \n
\t 'push \s '%RAX \n
(.del l)
\t 'pop \s '%RAX \n
cdecl::return := λ: Blob(: l Reg64). (: (
(:frame (:frame l))
(:unframe( (:unframe l) ))
(:expression 'RAX_s)
(:program(
(:program l)
'\tmov\t%_s (:expression l) ',%RAX\n_s
'\tpush\s%RAX\n_s
(:del l)
'\tpop\s%RAX\n_s
))
(.frame (.frame l))
(.expression 'RAX)
) Nil);

fragment cdecl::return := λ: DontChain(: l Constant+Literal+Sized<1>). (: (
(.program(
(.program l)
Expand Down
32 changes: 0 additions & 32 deletions LIB/default-instruction-macros-64.lm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -21,8 +19,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -35,8 +31,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -49,8 +43,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -63,8 +55,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -76,8 +66,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -90,8 +78,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -104,8 +90,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -119,8 +103,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -133,8 +115,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -148,8 +128,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -163,8 +141,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -178,8 +154,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -192,8 +166,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -207,8 +179,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand All @@ -224,8 +194,6 @@ macro ('declare-simple-instruction-alias-binop-64 (op-alias op-code op-set op-ty
'\t_s op-code '\s%R14,\s%RAX\n_s
op-set
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'RAX_s)
Expand Down
32 changes: 0 additions & 32 deletions LIB/default-instruction-macros-8.lm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s$_s (:expression r) ',\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -18,8 +16,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s_s (:expression r) '\[%RBP\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -31,8 +27,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s0\[%R14B\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -44,8 +38,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s$_s (:expression l) ',\s%AL\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -57,8 +49,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s$_s (:expression r) ',\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -69,8 +59,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s_s (:expression r) '\[%RBP\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -82,8 +70,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s0\[%R14B\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -95,8 +81,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s_s (:expression l) '\[%RBP\],\s%AL\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -109,8 +93,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s$_s (:expression r) ',\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -122,8 +104,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s_s (:expression r) '\[%RBP\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -136,8 +116,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s0\[%R14B\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -150,8 +128,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s0\[%AL\],\s%AL\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -164,8 +140,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s$_s (:expression r) ',\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -177,8 +151,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s_s (:expression r) '\[%RBP\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -191,8 +163,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tmovq\s0\[%R14B\],\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand All @@ -206,8 +176,6 @@ macro ('declare-simple-instruction-alias-binop-8 (op-alias op-code op-type)) (
'\tpopq\s%R14B\n_s
'\t_s op-code '\s%R14B,\s%AL\n_s
))
(:data( (:data l) (:data r) ))
(:text( (:text l) (:text r) ))
(:frame( (:frame l) (:frame r) ))
(:unframe( (:unframe l) (:unframe r) ))
(:expression 'AL_s)
Expand Down
Loading

0 comments on commit 60bc492

Please sign in to comment.