aboutsummaryrefslogtreecommitdiffstats
path: root/aarch64/OpWeightsAsm.ml
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2020-11-30 11:18:33 +0100
committerLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2020-11-30 11:18:33 +0100
commit019374836c506b0275757d496381d8516dc0213a (patch)
tree3a5d78c77de46dd03e0acf5dcfc4271c7c5a3ac8 /aarch64/OpWeightsAsm.ml
parentf1fb14db44180ef2d74a95f49c42fbed0694e9e8 (diff)
downloadcompcert-kvx-019374836c506b0275757d496381d8516dc0213a.tar.gz
compcert-kvx-019374836c506b0275757d496381d8516dc0213a.zip
Changing weights system at asmblock level instead of asm
Diffstat (limited to 'aarch64/OpWeightsAsm.ml')
-rw-r--r--aarch64/OpWeightsAsm.ml380
1 files changed, 83 insertions, 297 deletions
diff --git a/aarch64/OpWeightsAsm.ml b/aarch64/OpWeightsAsm.ml
index c1d0583a..ca120228 100644
--- a/aarch64/OpWeightsAsm.ml
+++ b/aarch64/OpWeightsAsm.ml
@@ -11,109 +11,17 @@
(* *)
(* *************************************************************)
+open Asmblock
+
(*type called_function = (Registers.reg, AST.ident) Datatypes.sum*)
-type real_instruction =
- | Add
- | Adr
- | Adrp
- | And
- | Asr
- | B
- | Bic
- | Bl
- | Blr
- | Br
- | Cbnz
- | Cbz
- | Cls
- | Clz
- | Cmn
- | Cmp
- | Csel
- | Cset
- | Eon
- | Eor
- | Fabs
- | Fadd
- | Fcmp
- | Fcsel
- | Fcvt
- | Fcvtzs
- | Fcvtzu
- | Fdiv
- | Fmadd
- | Fmov
- | Fmsub
- | Fmul
- | Fnmadd
- | Fnmul
- | Fnmsub
- | Fneg
- | Fsqrt
- | Fsub
- | Ldaxr
- | Ldp
- | Ldr
- | Ldrb
- | Ldrh
- | Ldrsb
- | Ldrsh
- | Ldrsw
- | Lr
- | Lsl
- | Lsr
- | Madd
- | Mov
- | Movk
- | Movn
- | Movz
- | Msub
- | Nop
- | Orn
- | Orr
- | Ret
- | Rev
- | Rev16
- | Ror
- | Sbfiz
- | Sbfx
- | Scvtf
- | Sdiv
- | Smulh
- | Stlxr
- | Stp
- | Str
- | Strb
- | Strh
- | Sub
- | Sxtb
- | Sxth
- | Sxtw
- | Tbnz
- | Tbz
- | Tst
- | Ubfiz
- | Ubfx
- | Ucvtf
- | Udiv
- | Umulh
- | Uxtb
- | Uxth
- | Uxtw
- | Uxtx
- (* Pseudo instr *)
- | Btbl
- | Allocframe
- | Freeframe
- | Builtin
- | Cvtx2w
+type instruction = PBasic of Asmblock.basic | PControl of Asmblock.control
type opweights = {
pipelined_resource_bounds : int array;
nr_non_pipelined_units : int;
- latency_of_op : real_instruction -> int -> int;
- resources_of_op : real_instruction -> int -> int array;
+ latency_of_op : instruction -> int -> int;
+ resources_of_op : instruction -> int -> int array;
(*non_pipelined_resources_of_op : Op.operation -> int -> int array;*)
(*latency_of_load : AST.trapping_mode -> AST.memory_chunk -> Op.addressing -> int -> int;*)
(*resources_of_load : AST.trapping_mode -> AST.memory_chunk -> Op.addressing -> int -> int array;*)
@@ -130,197 +38,86 @@ module Cortex_A53 = struct
(* instr ; ALU ; MAC; LSU *)
let nr_non_pipelined_units = 1
- let latency_of_op (i : real_instruction) (nargs : int) =
+ let latency_of_op (i : instruction) (nargs : int) =
match i with
- | Add -> 1
- | Adr -> 1
- | Adrp -> 1 (* XXX *)
- | And -> 1
- | Asr -> 2
- | B -> 1
- | Bic -> 1
- | Bl -> 1
- | Blr -> 1
- | Br -> 1
- | Cbnz -> 1
- | Cbz -> 1
- | Cls -> 1
- | Clz -> 1
- | Cmn -> 6
- | Cmp -> 6
- | Csel -> 2
- | Cset -> 2
- | Eon -> 1
- | Eor -> 1
- | Fabs -> 6
- | Fadd -> 1
- | Fcmp -> 6
- | Fcsel -> 1
- | Fcvt -> 6
- | Fcvtzs -> 6
- | Fcvtzu -> 6
- | Fdiv -> 50
- | Fmadd -> 1
- | Fmov -> 1
- | Fmsub -> 1
- | Fmul -> 6
- | Fnmadd -> 1
- | Fnmul -> 1
- | Fnmsub -> 1
- | Fneg -> 6
- | Fsqrt -> 1
- | Fsub -> 6
- | Ldaxr -> 3
- | Ldp -> 3
- | Ldr -> 3
- | Ldrb -> 3
- | Ldrh -> 3
- | Ldrsb -> 3
- | Ldrsh -> 3
- | Ldrsw -> 3
- | Lr -> 3
- | Lsl -> 2
- | Lsr -> 2
- | Madd -> 4
- | Mov -> 1 (* XXX *)
- | Movk -> 1
- | Movn -> 1
- | Movz -> 1
- | Msub -> 4
- | Nop -> 1
- | Orn -> 1
- | Orr -> 1
- | Ret -> 1
- | Rev -> 1
- | Rev16 -> 1
- | Ror -> 2
- | Sbfiz -> 2 (* XXX *)
- | Sbfx -> 2
- | Scvtf -> 6
- | Sdiv -> 50
- | Smulh -> 4
- | Stlxr -> 2
- | Stp -> 2
- | Str -> 2
- | Strb -> 2
- | Strh -> 2
- | Sub -> 1
- | Sxtb -> 1
- | Sxth -> 1
- | Sxtw -> 1
- | Tbnz -> 1
- | Tbz -> 1
- | Tst -> 6
- | Ubfiz -> 2 (* XXX *)
- | Ubfx -> 2
- | Ucvtf -> 6
- | Udiv -> 50
- | Umulh -> 4
- | Uxtb -> 1
- | Uxth -> 1
- | Uxtw -> 1
- | Uxtx -> 1
- | Btbl -> 1
- | Allocframe -> 51
- | Freeframe -> 51
- | Builtin -> 51
- | Cvtx2w -> 51
-
- let resources_of_op (i : real_instruction) (nargs : int) =
+ | PBasic (PArith (PArithP (_, _))) -> 1
+ | PBasic (PArith (PArithPP (i', _, _))) -> (
+ match i' with
+ | Psbfiz (_, _, _) | Psbfx (_, _, _) | Pubfiz (_, _, _) | Pubfx (_, _, _)
+ ->
+ 2
+ | Pfcvtds | Pfcvtsd
+ | Pfcvtzs (_, _)
+ | Pfcvtzu (_, _)
+ | Pfabs _ | Pfneg _
+ | Pscvtf (_, _)
+ | Pucvtf (_, _) ->
+ 6
+ | _ -> 1)
+ | PBasic (PArith (PArithPPP (i', _, _, _))) -> (
+ match i' with
+ | Pasrv _ | Plslv _ | Plsrv _ | Prorv _ | Paddext _ | Psubext _ -> 2
+ | Psmulh | Pumulh -> 4
+ | Pfdiv _ | Psdiv _ | Pudiv _ -> 50
+ | _ -> 6)
+ | PBasic (PArith (PArithRR0R (_, _, _, _))) -> 2
+ | PBasic (PArith (PArithRR0 (_, _, _))) -> 1
+ | PBasic (PArith (PArithARRRR0 (_, _, _, _, _))) -> 4
+ | PBasic (PArith (PArithComparisonPP (_, _, _))) -> 6
+ | PBasic (PArith (PArithComparisonR0R (_, _, _))) -> 1
+ | PBasic (PArith (PArithComparisonP (i', _))) -> (
+ match i' with Pfcmp0 _ -> 6 | _ -> 1)
+ | PBasic (PArith (Pcset (_, _))) | PBasic (PArith (Pcsel (_, _, _, _))) -> 6
+ | PBasic (PArith _) -> 1
+ | PBasic (PLoad (_, _, _)) -> 3
+ | PBasic (PStore (_, _, _)) -> 3
+ | PBasic (Pallocframe (_, _)) -> 3
+ | PBasic (Pfreeframe (_, _)) -> 1
+ | PBasic (Ploadsymbol (_, _)) -> 1
+ | PBasic (Pcvtsw2x (_, _)) -> 2
+ | PBasic (Pcvtuw2x (_, _)) -> 2
+ | PBasic (Pcvtx2w _) -> 1
+ | PControl _ -> 6
+
+ let resources_of_op (i : instruction) (nargs : int) =
match i with
- | Add -> [| 1; 1; 0; 0 |]
- | Adr -> [| 1; 1; 0; 0 |]
- | Adrp -> [| 1; 1; 0; 0 |]
- | And -> [| 1; 1; 0; 0 |]
- | Asr -> [| 1; 1; 0; 0 |]
- | B -> [| 1; 1; 0; 0 |]
- | Bic -> [| 1; 1; 0; 0 |]
- | Bl -> [| 1; 1; 0; 0 |]
- | Blr -> [| 1; 1; 0; 0 |]
- | Br -> [| 1; 1; 0; 0 |]
- | Cbnz -> [| 1; 1; 0; 0 |]
- | Cbz -> [| 1; 1; 0; 0 |]
- | Cls -> [| 1; 1; 0; 0 |]
- | Clz -> [| 1; 1; 0; 0 |]
- | Cmn -> [| 1; 1; 1; 0 |]
- | Cmp -> [| 1; 1; 1; 0 |]
- | Csel -> [| 1; 1; 1; 0 |]
- | Cset -> [| 1; 1; 1; 0 |]
- | Eon -> [| 1; 1; 0; 0 |]
- | Eor -> [| 1; 1; 0; 0 |]
- | Fabs -> [| 1; 1; 1; 0 |]
- | Fadd -> [| 1; 1; 1; 0 |]
- | Fcmp -> [| 1; 1; 1; 0 |]
- | Fcsel -> [| 1; 1; 0; 0 |]
- | Fcvt -> [| 1; 1; 1; 0 |]
- | Fcvtzs -> [| 1; 1; 1; 0 |]
- | Fcvtzu -> [| 1; 1; 1; 0 |]
- | Fdiv -> [| 1; 1; 1; 0 |]
- | Fmadd -> [| 1; 1; 0; 0 |]
- | Fmov -> [| 1; 1; 0; 0 |]
- | Fmsub -> [| 1; 1; 0; 0 |]
- | Fmul -> [| 1; 1; 1; 0 |]
- | Fnmadd -> [| 1; 1; 0; 0 |]
- | Fnmul -> [| 1; 1; 0; 0 |]
- | Fnmsub -> [| 1; 1; 0; 0 |]
- | Fneg -> [| 1; 1; 1; 0 |]
- | Fsqrt -> [| 1; 1; 0; 0 |]
- | Fsub -> [| 1; 1; 1; 0 |]
- | Ldaxr -> [| 1; 0; 0; 1 |]
- | Ldp -> [| 1; 0; 0; 1 |]
- | Ldr -> [| 1; 0; 0; 1 |]
- | Ldrb -> [| 1; 0; 0; 1 |]
- | Ldrh -> [| 1; 0; 0; 1 |]
- | Ldrsb -> [| 1; 0; 0; 1 |]
- | Ldrsh -> [| 1; 0; 0; 1 |]
- | Ldrsw -> [| 1; 0; 0; 1 |]
- | Lr -> [| 1; 0; 0; 1 |]
- | Lsl -> [| 1; 1; 0; 0 |]
- | Lsr -> [| 1; 1; 0; 0 |]
- | Madd -> [| 1; 1; 1; 0 |]
- | Mov -> [| 1; 1; 0; 0 |]
- | Movk -> [| 1; 1; 0; 0 |]
- | Movn -> [| 1; 1; 0; 0 |]
- | Movz -> [| 1; 1; 0; 0 |]
- | Msub -> [| 1; 1; 1; 0 |]
- | Nop -> [| 1; 1; 0; 0 |]
- | Orn -> [| 1; 1; 0; 0 |]
- | Orr -> [| 1; 1; 0; 0 |]
- | Ret -> [| 1; 1; 0; 0 |]
- | Rev -> [| 1; 1; 0; 0 |]
- | Rev16 -> [| 1; 1; 0; 0 |]
- | Ror -> [| 1; 1; 0; 0 |]
- | Sbfiz -> [| 1; 1; 0; 0 |]
- | Sbfx -> [| 1; 1; 0; 0 |]
- | Scvtf -> [| 1; 1; 1; 0 |]
- | Sdiv -> [| 1; 0; 0; 0 |]
- | Smulh -> [| 1; 1; 0; 0 |]
- | Stlxr -> [| 1; 0; 0; 1 |]
- | Stp -> [| 1; 0; 0; 1 |]
- | Str -> [| 1; 0; 0; 1 |]
- | Strb -> [| 1; 0; 0; 1 |]
- | Strh -> [| 1; 0; 0; 1 |]
- | Sub -> [| 1; 1; 0; 0 |]
- | Sxtb -> [| 1; 1; 0; 0 |]
- | Sxth -> [| 1; 1; 0; 0 |]
- | Sxtw -> [| 1; 1; 0; 0 |]
- | Tbnz -> [| 1; 1; 0; 0 |]
- | Tbz -> [| 1; 1; 0; 0 |]
- | Tst -> [| 1; 1; 1; 0 |]
- | Ubfiz -> [| 1; 1; 0; 0 |]
- | Ubfx -> [| 1; 1; 0; 0 |]
- | Ucvtf -> [| 1; 1; 1; 0 |]
- | Udiv -> [| 1; 0; 0; 0 |]
- | Umulh -> [| 1; 1; 0; 0 |]
- | Uxtb -> [| 1; 1; 0; 0 |]
- | Uxth -> [| 1; 1; 0; 0 |]
- | Uxtw -> [| 1; 1; 0; 0 |]
- | Uxtx -> [| 1; 1; 0; 0 |]
- | Btbl -> [| 1; 1; 0; 0 |]
- | Allocframe -> [| 1; 1; 1; 1 |]
- | Freeframe -> [| 1; 1; 1; 1 |]
- | Builtin -> [| 1; 1; 1; 1 |]
- | Cvtx2w -> [| 1; 1; 1; 1 |]
+ | PBasic (PArith (PArithP (i', _))) -> (
+ match i' with
+ | Pfmovimmd _ | Pfmovimms _ -> [| 1; 1; 0; 1 |]
+ | _ -> [| 1; 1; 0; 0 |])
+ | PBasic (PArith (PArithPP (i', _, _))) -> (
+ match i' with
+ | Pfcvtds | Pfcvtsd
+ | Pfcvtzs (_, _)
+ | Pfcvtzu (_, _)
+ | Pfabs _ | Pfneg _
+ | Pscvtf (_, _)
+ | Pucvtf (_, _) ->
+ [| 1 ; 1; 1; 0 |]
+ | _ -> [| 1; 1; 0; 0 |])
+ | PBasic (PArith (PArithPPP (i', _, _, _))) -> (
+ match i' with
+ | Pasrv _ | Plslv _ | Plsrv _ | Prorv _ | Paddext _ | Psubext _ -> [| 1; 1; 0; 0 |]
+ | Pfdiv _ | Psdiv _ | Pudiv _ -> [| 1; 0; 0; 0 |]
+ | _ -> [| 1; 1; 1; 0 |])
+ | PBasic (PArith (PArithRR0R (_, _, _, _))) -> [| 1; 1; 0; 0 |]
+ | PBasic (PArith (PArithRR0 (_, _, _))) -> [| 1; 1; 0; 0 |]
+ | PBasic (PArith (PArithARRRR0 (_, _, _, _, _))) -> [| 1; 1; 1; 0 |]
+ | PBasic (PArith (PArithComparisonPP (_, _, _))) -> [| 1; 1; 1; 0 |]
+ | PBasic (PArith (PArithComparisonR0R (_, _, _))) -> [| 1; 1; 0; 0 |]
+ | PBasic (PArith (PArithComparisonP (i', _))) -> (
+ match i' with Pfcmp0 _ -> [| 1; 1; 1; 0 |] | _ -> [| 1; 1; 0; 0 |])
+ | PBasic (PArith (Pcset (_, _))) | PBasic (PArith (Pcsel (_, _, _, _))) -> [| 1; 1; 1; 0 |]
+ | PBasic (PArith _) -> [| 1; 1; 0; 0 |]
+ | PBasic (PLoad (_, _, _)) -> [| 1; 0; 0; 1 |]
+ | PBasic (PStore (_, _, _)) -> [| 1; 0; 0; 1 |]
+ | PBasic (Pallocframe (_, _)) -> [| 1; 0; 0; 1 |]
+ | PBasic (Pfreeframe (_, _)) -> [| 1; 1; 0; 0 |]
+ | PBasic (Ploadsymbol (_, _)) -> [| 1; 1; 0; 0 |]
+ | PBasic (Pcvtsw2x (_, _)) -> [| 1; 1; 0; 0 |]
+ | PBasic (Pcvtuw2x (_, _)) -> [| 1; 1; 0; 0 |]
+ | PBasic (Pcvtx2w _) -> [| 1; 1; 0; 0 |]
+ | PControl _ -> resource_bounds
(*let non_pipelined_resources_of_op (op : operation) (nargs : int) =
match op with
@@ -342,17 +139,6 @@ module Cortex_A53 = struct
[| 1; 1; 1; 0 |]
| _ -> [| 1; 1; 0; 0 |] )*)
- let latency_of_load trap chunk _ _ = 3
-
- let latency_of_call _ _ = 6
-
- let resources_of_load trap chunk addressing nargs = [| 1; 0; 0; 1 |]
-
- let resources_of_store chunk addressing nargs = [| 1; 0; 0; 1 |]
-
- let resources_of_call _ _ = resource_bounds
-
- let resources_of_builtin _ = resource_bounds
end
let get_opweights () : opweights =