Skip to content

Commit

Permalink
simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
melsman committed Dec 25, 2024
1 parent f496fb3 commit de4afaa
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 195 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
brew tap homebrew/cask
mkdir phantomjs
cd phantomjs
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
wget -q https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
unzip phantomjs-2.1.1-macosx.zip
cp -p phantomjs-2.1.1-macosx/bin/phantomjs /usr/local/bin/
cd ..
Expand All @@ -89,10 +89,10 @@ jobs:
working-directory: ${{ env.RUNHOME }}
run: |
echo "[OS: $OS, HOME: $RUNHOME, THECC: ${{env.THECC}}]"
wget https://github.com/diku-dk/smlpkg/releases/download/v0.1.4/smlpkg-bin-dist-${{env.OS}}.tgz
wget -q https://github.com/diku-dk/smlpkg/releases/download/v0.1.4/smlpkg-bin-dist-${{env.OS}}.tgz
tar xzf smlpkg-bin-dist-${{env.OS}}.tgz
echo "$HOME/smlpkg-bin-dist-${{env.OS}}/bin" >> $GITHUB_PATH
wget https://github.com/melsman/mlkit/releases/download/v4.7.13/mlkit-bin-dist-${{env.OS}}.tgz
wget -q https://github.com/melsman/mlkit/releases/download/v4.7.13/mlkit-bin-dist-${{env.OS}}.tgz
tar xzf mlkit-bin-dist-${{env.OS}}.tgz
echo "$HOME/mlkit-bin-dist-${{env.OS}}/bin" >> $GITHUB_PATH
mkdir -p .mlkit
Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Backend/BACKEND_INFO.sml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,4 @@ signature BACKEND_INFO =
val minCodeInBinSearch : int
val maxDiff : int
val minJumpTabSize : int

val down_growing_stack : bool (* true for x86/x64 code generation *)
end
3 changes: 1 addition & 2 deletions src/Compiler/Backend/BackendInfo.sml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
functor BackendInfo(val down_growing_stack : bool) : BACKEND_INFO =
structure BackendInfo : BACKEND_INFO =
struct
structure PP = PrettyPrint
structure Labels = AddressLabels
Expand Down Expand Up @@ -134,5 +134,4 @@ functor BackendInfo(val down_growing_stack : bool) : BACKEND_INFO =
val maxDiff = 10
val minJumpTabSize = 5

val down_growing_stack = down_growing_stack
end
11 changes: 5 additions & 6 deletions src/Compiler/Backend/CalcOffset.sml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
functor CalcOffset(structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure LineStmt: LINE_STMT
functor CalcOffset(structure LineStmt: LINE_STMT
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type place = Effect.effect
where type label = AddressLabels.label
where type phsize = PhysSizeInf.phsize
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = LineStmt.cc
where type cc = CallConv.cc
structure FetchAndFlush: FETCH_AND_FLUSH
where type lvar = Lvars.lvar
where type label = AddressLabels.label
sharing type FetchAndFlush.Atom = LineStmt.Atom
structure BI : BACKEND_INFO)
sharing type FetchAndFlush.Atom = LineStmt.Atom)
: CALC_OFFSET =
struct

structure BI = BackendInfo
structure PP = PrettyPrint
structure Labels = AddressLabels
val _ = Flags.add_bool_entry
Expand Down
45 changes: 6 additions & 39 deletions src/Compiler/Backend/CallConv.sml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
(* (e.g., resolve_cc, resolve_ccall, handl_arg_phreg, *)
(* handl_return_phreg, resolve_act_cc) *)

functor CallConv(BI : BACKEND_INFO) : CALL_CONV =
structure CallConv : CALL_CONV =
struct

structure BI = BackendInfo
type lvar = Lvars.lvar
type offset = int

Expand Down Expand Up @@ -167,47 +169,12 @@ functor CallConv(BI : BACKEND_INFO) : CALL_CONV =
val ((astys,stys), (ps,regs)) = resolv (stys,(ps,regs))
val ((arstys,rstys), (ps,_)) = resolv (rstys,(ps,regs))
val ((afstys,fstys), (ps,_)) = resolv (fstys,(ps,fregs))
val (astys',arstys',afstys') =
if BI.down_growing_stack then
let val afstys' = map assign_stack (rev fstys)
val arstys' = map assign_stack (rev rstys)
val astys' = map assign_stack (rev stys)
in (astys',arstys',afstys')
end
else
let val astys' = map assign_stack stys
val arstys' = map assign_stack rstys
val afstys' = map assign_stack fstys
in (astys', arstys',afstys')
end
val afstys' = map assign_stack (rev fstys)
val arstys' = map assign_stack (rev rstys)
val astys' = map assign_stack (rev stys)
in (astys@astys', arstys@arstys', afstys@afstys', ps)
end

(*
fun resolve_stys_args ([], [], (acc,ph_regs)) = ([], [], (acc,ph_regs))
| resolve_stys_args (args_stys, reg_args_stys, (acc,[])) = (* no more phregs *)
if BI.down_growing_stack then
let val reg_args = map assign_stack (rev reg_args_stys)
val args = map assign_stack (rev args_stys)
in (args, reg_args, (acc, []))
end
else
let val args = map assign_stack args_stys
val reg_args = map assign_stack reg_args_stys
in (args, reg_args, (acc, []))
end
| resolve_stys_args (asty::astys, rastys, (acc,ph_reg::ph_regs)) =
let val (astys', rastys', (lv_phreg_list,ph_regs')) = resolve_stys_args (astys, rastys, (acc,ph_regs))
val (asty', lv_phreg') = assign_phreg (asty, ph_reg)
in (asty'::astys', rastys', (lv_phreg'::lv_phreg_list,ph_regs'))
end
| resolve_stys_args ([], rasty::rastys, (acc,ph_reg::ph_regs)) =
let val (_,rastys', (lv_phreg_list,ph_regs')) = resolve_stys_args ([], rastys, (acc,ph_regs))
val (rasty', lv_phreg') = assign_phreg (rasty, ph_reg)
in ([], rasty'::rastys', (lv_phreg'::lv_phreg_list,ph_regs'))
end
*)

fun resolve_sty_opt (SOME sty,(ps,[])) = (SOME(assign_stack sty),(ps,[]))
| resolve_sty_opt (SOME sty,(ps,r::rs)) =
let val (sty,p) = assign_phreg(sty,r)
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Backend/ClosConvEnv.sml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

functor ClosConvEnv(BI : BACKEND_INFO where type label = AddressLabels.label) : CLOS_CONV_ENV =
structure ClosConvEnv : CLOS_CONV_ENV =
struct

structure BI = BackendInfo
structure RegvarFinMap = EffVarEnv
structure Labels = AddressLabels
structure PP = PrettyPrint
Expand Down
12 changes: 2 additions & 10 deletions src/Compiler/Backend/ClosExp.sml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
functor ClosExp(structure CallConv: CALL_CONV where type lvar = Lvars.lvar
structure ClosConvEnv: CLOS_CONV_ENV
where type con = Con.con
where type place = AtInf.place
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type label = AddressLabels.label
where type phsize = PhysSizeInf.phsize
where type StringTree = PrettyPrint.StringTree
structure BI : BACKEND_INFO) : CLOS_EXP =
structure ClosExp : CLOS_EXP =
struct
structure BI = BackendInfo
structure PP = PrettyPrint
structure Labels = AddressLabels
structure RE = MulExp.RegionExp
Expand Down
5 changes: 0 additions & 5 deletions src/Compiler/Backend/CodeGenUtil.sml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@ signature INSTS_COMMON = sig
end

functor CodeGenUtil(structure Insts : INSTS_COMMON
structure BackendInfo : BACKEND_INFO
where type label = AddressLabels.label
structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure LineStmt: LINE_STMT
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type label = AddressLabels.label
where type place = Effect.effect
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = LineStmt.cc
structure SubstAndSimplify: SUBST_AND_SIMPLIFY
where type ('a,'b,'c) LinePrg = ('a,'b,'c) LineStmt.LinePrg
where type lvar = Lvars.lvar
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/Backend/FetchAndFlush.sml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
functor FetchAndFlush(structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure LineStmt: LINE_STMT
functor FetchAndFlush(structure LineStmt: LINE_STMT
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type place = Effect.effect
where type label = AddressLabels.label
where type phsize = PhysSizeInf.phsize
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = LineStmt.cc
where type cc = CallConv.cc
structure RegAlloc: REG_ALLOC
where type lvar = Lvars.lvar
where type label = AddressLabels.label
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Backend/JumpTables.sml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
functor JumpTables(BI : BACKEND_INFO) : JUMP_TABLES =
structure JumpTables :> JUMP_TABLES =
struct

structure BI = BackendInfo
(***********)
(* Logging *)
(***********)
Expand Down
16 changes: 3 additions & 13 deletions src/Compiler/Backend/LineStmt.sml
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
functor LineStmt(structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure ClosExp: CLOS_EXP
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type place = Effect.effect
where type label = AddressLabels.label
where type phsize = PhysSizeInf.phsize
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = ClosExp.cc
structure BI : BACKEND_INFO
structure RI : REGISTER_INFO
functor LineStmt(structure RI : REGISTER_INFO
where type lvar = Lvars.lvar)
: LINE_STMT =
struct

structure BI = BackendInfo
structure Labels = AddressLabels
structure PP = PrettyPrint
val _ = Flags.add_bool_entry
Expand Down
38 changes: 9 additions & 29 deletions src/Compiler/Backend/NativeCompile.sml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

signature NATIVE_COMPILE =
sig
structure CallConv : CALL_CONV
structure LineStmt : LINE_STMT
structure ClosExp : CLOS_EXP
structure LineStmt : LINE_STMT where type cc = CallConv.cc
where type lvar = Lvars.lvar
structure SubstAndSimplify : SUBST_AND_SIMPLIFY

type BackendEnv
Expand All @@ -35,7 +34,6 @@ signature NATIVE_COMPILE =
type StoreTypeCO
type Aty


val compile : BackendEnv * ((place*pp)at,place*phsize,unit) LambdaPgm * bool * string(*vcg_file*) ->
BackendEnv * {main_lab:label,
code:(StoreTypeCO,offset,Aty) LinePrg,
Expand All @@ -47,44 +45,26 @@ signature NATIVE_COMPILE =
end


functor NativeCompile (structure BackendInfo : BACKEND_INFO
where type label = AddressLabels.label
structure RegisterInfo : REGISTER_INFO
functor NativeCompile (structure RegisterInfo : REGISTER_INFO
where type lvar = Lvars.lvar
) : NATIVE_COMPILE =
struct
structure RegionExp = MulExp.RegionExp
structure PP = PrettyPrint

structure ClosConvEnv = ClosConvEnv(BackendInfo)

structure CallConv = CallConv(BackendInfo)

structure ClosExp = ClosExp(structure ClosConvEnv = ClosConvEnv
structure BI = BackendInfo
structure CallConv = CallConv)

structure LineStmt = LineStmt(structure CallConv = CallConv
structure ClosExp = ClosExp
structure RI = RegisterInfo
structure BI = BackendInfo)
structure LineStmt = LineStmt(structure RI = RegisterInfo)

structure RegAlloc = RegAlloc(structure CallConv = CallConv
structure LineStmt = LineStmt
structure RegAlloc = RegAlloc(structure LineStmt = LineStmt
structure RI = RegisterInfo)

structure FetchAndFlush = FetchAndFlush(structure CallConv = CallConv
structure LineStmt = LineStmt
structure FetchAndFlush = FetchAndFlush(structure LineStmt = LineStmt
structure RegAlloc = RegAlloc
structure RI = RegisterInfo)

structure CalcOffset = CalcOffset(structure CallConv = CallConv
structure LineStmt = LineStmt
structure FetchAndFlush = FetchAndFlush
structure BI = BackendInfo)
structure CalcOffset = CalcOffset(structure LineStmt = LineStmt
structure FetchAndFlush = FetchAndFlush)

structure SubstAndSimplify = SubstAndSimplify(structure CallConv = CallConv
structure LineStmt = LineStmt
structure SubstAndSimplify = SubstAndSimplify(structure LineStmt = LineStmt
structure CalcOffset = CalcOffset
structure RI = RegisterInfo)

Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/Backend/RegAlloc.sml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
functor RegAlloc(structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure LineStmt: LINE_STMT
functor RegAlloc(structure LineStmt: LINE_STMT
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type place = Effect.effect
where type label = AddressLabels.label
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = LineStmt.cc
where type cc = CallConv.cc
structure RI : REGISTER_INFO
where type lvar = Lvars.lvar)
: REG_ALLOC =
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/Backend/SubstAndSimplify.sml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
functor SubstAndSimplify(structure CallConv: CALL_CONV
where type lvar = Lvars.lvar
structure LineStmt: LINE_STMT
functor SubstAndSimplify(structure LineStmt: LINE_STMT
where type con = Con.con
where type excon = Excon.excon
where type lvar = Lvars.lvar
where type place = Effect.effect
where type label = AddressLabels.label
where type phsize = PhysSizeInf.phsize
where type StringTree = PrettyPrint.StringTree
sharing type CallConv.cc = LineStmt.cc
where type cc = CallConv.cc
structure CalcOffset: CALC_OFFSET
where type lvar = Lvars.lvar
where type place = Effect.place
Expand Down
Loading

0 comments on commit de4afaa

Please sign in to comment.