Skip to content

Commit

Permalink
add back multiplication to make the fiat-crypto backend possible
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgruetter committed Feb 13, 2020
1 parent 62d7f75 commit b28c1dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bedrock2/src/bedrock2/BasicCSyntax.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Definition to_c_parameters : ToCString.parameters := {|
match op with
| add => e1++"+"++e2
| sub => e1++"-"++e2
| mul => e1++"*"++e2
| mulhuu => "sizeof(intptr_t) == 4 ? ((uint64_t)"++e1++"*"++e2++")>>32 : ((__uint128_t)"++e1++"*"++e2++")>>64 /* TODO this has not been tested */"
| divu => e1++"/"++e2
| remu => e1++"%"++e2
| and => e1++"&"++e2
| or => e1++"|"++e2
| xor => e1++"^"++e2
Expand Down
4 changes: 4 additions & 0 deletions bedrock2/src/bedrock2/Semantics.v
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Section binops.
match bop with
| bopname.add => word.add
| bopname.sub => word.sub
| bopname.mul => word.mul
| bopname.mulhuu => word.mulhuu
| bopname.divu => word.divu
| bopname.remu => word.modu
| bopname.and => word.and
| bopname.or => word.or
| bopname.xor => word.xor
Expand Down
2 changes: 1 addition & 1 deletion bedrock2/src/bedrock2/Syntax.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Require Coq.Strings.String.
Require Import Coq.Numbers.BinNums.

Module Import bopname.
Inductive bopname := add | sub | and | or | xor | sru | slu | srs | lts | ltu | eq.
Inductive bopname := add | sub | mul | mulhuu | divu | remu | and | or | xor | sru | slu | srs | lts | ltu | eq.
End bopname.
Notation bopname := bopname.bopname.

Expand Down
4 changes: 4 additions & 0 deletions compiler/src/compiler/FlatToRiscvDef.v
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ Section FlatToRiscv1.
match op with
| Syntax.bopname.add => [[Add rd rs1 rs2]]
| Syntax.bopname.sub => [[Sub rd rs1 rs2]]
| Syntax.bopname.mul => [[Mul rd rs1 rs2]]
| Syntax.bopname.mulhuu => [[Mulhu rd rs1 rs2]]
| Syntax.bopname.divu => [[Divu rd rs1 rs2]]
| Syntax.bopname.remu => [[Remu rd rs1 rs2]]
| Syntax.bopname.and => [[And rd rs1 rs2]]
| Syntax.bopname.or => [[Or rd rs1 rs2]]
| Syntax.bopname.xor => [[Xor rd rs1 rs2]]
Expand Down

0 comments on commit b28c1dc

Please sign in to comment.