Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for RISC-V 32 I M #781

Open
wants to merge 121 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
0be66c6
Add dependencies to build vscoq-language-server (temp fix).
rtetley Jan 24, 2024
edd3b75
Provides RISCV initial architecture description and first instruction…
clebreto Feb 1, 2024
bfafb60
Adds SUB, AND, MV
eponier Feb 23, 2024
881bfc8
Adds LOAD and STORE
eponier Feb 23, 2024
121aad6
Refactor cond
eponier Feb 21, 2024
65371a0
Add XOR and OR to compiler/riscv_instr_decl.v (#747)
zeri42 Mar 8, 2024
35faf94
Adds the very minimal bits for dummy compilation.
clebreto Mar 4, 2024
602bee6
WIP : bug-499.
clebreto Mar 11, 2024
8055c6d
Adds li to implement more functionalities.
clebreto Mar 11, 2024
254fd06
Merge pull request #754 from jasmin-lang/riscv-compiler-skeleton
eponier Mar 19, 2024
218dc38
Merge branch 'main' into risc-v
eponier Mar 19, 2024
b0b4453
Adds XOR lowering.
clebreto Mar 27, 2024
3a80c10
Fix adressing assembly syntax.
clebreto Mar 28, 2024
f9fc5db
Intrepret "subi" as ADDI.
clebreto Mar 28, 2024
9778be6
Factorize instructions by encodings.
clebreto Mar 28, 2024
7a00b90
Adds swap and subi as extra ops.
clebreto Mar 28, 2024
84b5d1b
Condition lowering implementation.
clebreto Apr 8, 2024
12e88bc
Provides JAL instruction to match calling convention
clebreto Apr 8, 2024
9309743
Provides tests for branching conditions.
clebreto Apr 9, 2024
2f9c8c8
Hack to compare with imm.
clebreto Apr 9, 2024
ff7977e
X1 -> X2
eponier Apr 9, 2024
33f5b14
X1 -> X2 again
eponier Apr 9, 2024
50e48b8
Push and pop ok
eponier Apr 9, 2024
6f1cc0e
assemble_cond: correctly detects 0
eponier Apr 9, 2024
6d84586
Fixes program crash
eponier Apr 9, 2024
8e2aa91
Allows to execute at least once each test.
clebreto Apr 9, 2024
922c98c
Merge branch 'main' into risc-v
eponier Apr 10, 2024
ff82fa2
Check execution of tests.
clebreto Apr 10, 2024
7de90ac
Adds MUL MULH instructions declaration.
clebreto Apr 10, 2024
51d9f0b
Fix typo.
clebreto Apr 10, 2024
1ccb0de
Continues to add multiplication ops.
clebreto Apr 10, 2024
dd28d82
Lower multiplication.
clebreto Apr 10, 2024
4e65069
Polishing
eponier Apr 10, 2024
9d82cc5
The cheatsheet is lying!
eponier Apr 10, 2024
542c92c
Proofs skeleton with Admitted.
rtetley Apr 11, 2024
e39523e
Change condt_not signature for proofs.
clebreto Apr 11, 2024
5fd0df7
Finalize previous commit.
clebreto Apr 11, 2024
263e6ce
WIP on params_proof
rtetley Apr 11, 2024
16fed13
Correctly zeroing the 2 lest significant bits.
clebreto Apr 12, 2024
b23ec40
Adapt printing of functions enclosed in namespaces.
clebreto Apr 12, 2024
19104e8
Merge branch 'main' into risc-v
eponier Apr 12, 2024
d53c71c
Escape globals and push (really needed ?).
clebreto Apr 12, 2024
fdeadb3
WIP params_proof
rtetley Apr 12, 2024
e5702f8
WIP riscv_params_proof
rtetley Apr 12, 2024
548ebde
Provides SLL and SLI.
clebreto Apr 12, 2024
3b5d937
Prove assemble_extra_op.
rtetley Apr 15, 2024
aff3b23
Adds NOT and NEG pseudo ops.
clebreto Apr 15, 2024
14428bb
Proove params_core_proof
rtetley Apr 15, 2024
37df6af
Proove params common proof
rtetley Apr 15, 2024
7f1799d
Adds support for signed / unsigned load.
clebreto Apr 15, 2024
5763849
Add srl, srli, and a first compiling risc-v version of gimli
sopmacF Apr 16, 2024
4f07a3d
WIP lowering proofs.
clebreto Apr 16, 2024
2ed57bc
WIP Proof lowering.
rtetley Apr 16, 2024
ec1f95d
Renames commonly used registers.
clebreto Apr 17, 2024
54ccb4f
Provides stack zeroization.
clebreto Apr 17, 2024
86f3f92
Advance on stackzero proof.
clebreto Apr 17, 2024
7f75d53
Advance again on stackzero.
clebreto Apr 17, 2024
a8d17b5
WIP proof lowering
rtetley Apr 18, 2024
729e5a7
Don't use callee saved register.
clebreto Apr 18, 2024
6b6561d
Admit remaining stack zero proofs.
clebreto Apr 18, 2024
ed2bf10
Fix shift declaration and proof.
clebreto Apr 18, 2024
fabe78d
Lowering proof done.
rtetley Apr 19, 2024
b5de339
Stack zeroization proof.
rtetley Apr 19, 2024
a06b9d9
Cleaning
eponier Apr 19, 2024
e249081
Gimli: fix and move to examples
eponier Apr 19, 2024
505b4c2
Lowering: factorize reasoning on op2
eponier Apr 24, 2024
538c494
Lowering: accept more left shifts
eponier Apr 25, 2024
846b1a5
assemble_cond: cleaning & more compact proof
eponier Apr 25, 2024
b466cd5
Merge branch 'main' into risc-v
eponier May 17, 2024
9464d24
Merge remote-tracking branch 'upstream/main' into risc-v
eponier Jun 3, 2024
8df3761
Merge remote-tracking branch 'upstream/main' into risc-v
eponier Jun 7, 2024
3371cb3
Merge remote-tracking branch 'upstream/main' into risc-v
eponier Jun 18, 2024
59b3b1d
Merge branch 'main' into risc-v
clebreto Jul 2, 2024
c11b63d
doit hack
clebreto Jul 2, 2024
7ecbdeb
Merge branch 'main' into risc-v
eponier Jul 29, 2024
79879e7
Merge branch 'main' into risc-v
eponier Sep 16, 2024
5017d5f
Proper asm "call" for syscalls
eponier Sep 16, 2024
3a85822
Adds some tests.
clebreto May 24, 2024
082668b
Fix sub test ...
clebreto May 24, 2024
427a733
Prove decide_op_reg_imm.
clebreto May 27, 2024
6dbfd66
Use is_arith_small_neg for sub
clebreto May 27, 2024
8e87601
Fixing and polishing
eponier May 30, 2024
28da830
Removes unused variable.
clebreto May 30, 2024
44640b4
Adds some Omul and lower_mulu tests.
clebreto May 30, 2024
e2b99d0
Fix load printing.
clebreto May 31, 2024
eee54f8
Better error message
clebreto Jun 3, 2024
df758a9
WIP large stack
clebreto Jun 3, 2024
02174a6
printing
eponier Jun 3, 2024
cca80c3
multiple fixes
eponier Jun 3, 2024
f0667d0
Adds load and fix test.
clebreto Jun 4, 2024
6313772
Adds sra instruction and associated proof.
clebreto Jul 18, 2024
c20b1a9
FIX typo.
clebreto Jul 18, 2024
4545b4a
Adds shift basic tests.
clebreto Jul 18, 2024
914d965
Template test files must be .jinc (again)
eponier Jul 29, 2024
7ce49f6
Use an env var for assembly checker on risc-v
eponier Jul 29, 2024
26fe70b
Prove riscv_lower_addressing
eponier Jun 17, 2024
03dab30
Fix macos / linux assembly checker option handling
clebreto Aug 4, 2024
11d9268
Use jasmin shift semantic properly.
clebreto Sep 3, 2024
013919d
Introduce smart_addi to stack alloc as done
clebreto Sep 3, 2024
a2473d9
Moves subi from ext op to lowering.
clebreto Sep 16, 2024
df36861
End of the proofs
eponier Sep 16, 2024
31cd7b2
Merge pull request #868 from jasmin-lang/789-risc-v-test-every-instru…
clebreto Sep 16, 2024
72d4742
Clear out unused Lemma.
clebreto Sep 30, 2024
7212a26
FIXME -> TODO.
clebreto Sep 30, 2024
1b6f96f
x28 x29 are FP temporaries -> OK
clebreto Sep 30, 2024
2296f15
FIXME -> Comment
clebreto Sep 30, 2024
9ddd343
Fix typo.
clebreto Sep 30, 2024
9008aad
Remove comment
clebreto Sep 30, 2024
eba00c4
move write_lval_eq to psem_facts.
clebreto Sep 30, 2024
582b3ca
Call pass LowerAddressing also in OCaml
eponier Oct 1, 2024
7a14e76
Add RA to the list of callee_saved registers.
clebreto Oct 8, 2024
b74ebeb
Merge branch 'main' into risc-v
bgregoir Oct 17, 2024
f286134
adapte 4fc6626e82abf81afe315e1f7344889678f48a00 to risc-v
bgregoir Oct 17, 2024
c1036d6
Merge branch 'main' into risc-v
eponier Oct 24, 2024
3a2c8bc
Risc v constants if while (#934)
bgregoir Nov 5, 2024
fd5e550
Revert "Add RA to the list of callee_saved registers."
eponier Nov 5, 2024
d03e378
RISC-V: proper management of the return address
eponier Oct 22, 2024
14e0e9a
Provides SLT, SLTI, SLTU, SLTIU for RISC-V.
clebreto Nov 15, 2024
3af7bbd
Provides extraction to EC.
clebreto Nov 16, 2024
f668724
Merge branch 'main' into risc-v
bgregoir Nov 16, 2024
984590c
Merge branch 'risc-v' of github.com:jasmin-lang/jasmin into risc-v
bgregoir Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
([PR #948](https://github.com/jasmin-lang/jasmin/pull/948);
fixes [#931](https://github.com/jasmin-lang/jasmin/issues/931)).

- Correcting shift in location produced by multiline string annotations
- Correcting shift in location produced by multiline string annotations
([PR #959](https://github.com/jasmin-lang/jasmin/pull/959);
fixes [#943](https://github.com/jasmin-lang/jasmin/issues/943)).

Expand Down
3 changes: 2 additions & 1 deletion compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ CHECKCATS ?= \
x86-64-stack-zero-loop \
x86-64-stack-zero-unrolled \
arm-m4-stack-zero-loop \
arm-m4-stack-zero-unrolled
arm-m4-stack-zero-unrolled \
risc-v

# --------------------------------------------------------------------
DESTDIR ?=
Expand Down
6 changes: 6 additions & 0 deletions compiler/config/tests.config
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ args = -stack-zero=unrolled
okdirs = examples/**/arm-m4 tests/success/**/arm-m4
kodirs = tests/fail/**/arm-m4
exclude = tests/success/arm-m4/large_stack

[test-risc-v]
bin = ./scripts/check-risc-v
okdirs = examples/**/risc-v tests/success/**/risc-v tests/success/**/common
kodirs = tests/fail/**/risc-v
exclude = tests/fail/warning
9 changes: 6 additions & 3 deletions compiler/entry/commonCLI.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ open Cmdliner

let get_arch_module arch call_conv : (module Arch_full.Arch) =
(module Arch_full.Arch_from_Core_arch
((val match arch with
(val match arch with
| Utils.X86_64 ->
(module (val CoreArchFactory.core_arch_x86 ~use_lea:false
~use_set0:false call_conv)
: Arch_full.Core_arch)
| Utils.ARM_M4 ->
(module CoreArchFactory.Core_arch_ARM
: Arch_full.Core_arch))))
: Arch_full.Core_arch)
| Utils.RISCV ->
(module CoreArchFactory.Core_arch_RISCV
: Arch_full.Core_arch)))

let arch =
let alts = [ ("x86-64", Utils.X86_64); ("arm-m4", Utils.ARM_M4) ] in
let alts = [ ("x86-64", Utils.X86_64); ("arm-m4", Utils.ARM_M4); ("riscv", Utils.RISCV) ] in
let doc =
Format.asprintf "The target architecture (%s)" (Arg.doc_alts_enum alts)
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/entry/jasmin2ec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let parse_and_extract arch call_conv =
Format.eprintf "%a@." pp_hierror e;
exit 1

let model =
let model =
let alts = [ ("normal", Normal) ; ("CT", ConstantTime) ] in
let doc =
Format.asprintf "Extraction model (determines added annotations (e.g. leakage) (%s)."
Expand Down
83 changes: 83 additions & 0 deletions compiler/examples/gimli/risc-v/gimli.jazz
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
param int N_ROUND = 24;
param int N_COLUMN = 4;
param int ROUND_CONSTANT = 0x9e377900;

inline
fn swap(reg ptr u32[12] state, inline int i, inline int j) -> reg ptr u32[12] {
reg u32 x y;

x = state[i];
y = state[j];
state[i] = y;
state[j] = x;

return state;
}

inline fn ror32(reg u32 in, inline int cnt) -> reg u32 {
reg u32 u l ret;
u = in << cnt;
l = in >> (32 - cnt);
ret = u | l;
return ret;
}

export
fn gimli(reg ptr u32[12] state) -> reg ptr u32[12] {
inline int round, column;
reg u32 x, y, z;
reg u32 a, b;
reg u32 rc;
reg u32 tmp;

rc = ROUND_CONSTANT;

for round = N_ROUND downto 0 {
for column = 0 to N_COLUMN {
x = state[0 + column];
/* x <<r= 24; */
x = ror32(x,24);
y = state[4 + column];
/* y <<r= 9; */
y = ror32(y,9);
z = state[8 + column];

tmp = z << 1;
a = x ^ tmp;
b = y & z;
tmp = b << 2;
a = a ^ tmp;
state[8 + column] = a;

a = y ^ x;
b = x | z;
tmp = b << 1;
a = a ^ tmp;
state[4 + column] = a;

a = z ^ y;
b = x & y;
tmp = b << 3;
a = a ^ tmp;
state[0 + column] = a;
}

if (round % 4 == 0) {
state = swap(state, 0, 1);
state = swap(state, 2, 3);
}

if (round % 4 == 2) {
state = swap(state, 0, 2);
state = swap(state, 1, 3);
}

if (round % 4 == 0) {
a = state[0];
b = rc + round;
a ^= b;
state[0] = a;
}
}
return state;
}
36 changes: 36 additions & 0 deletions compiler/scripts/check-risc-v
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

set -e

DIR=$(mktemp -d jasminXXXXXX)
ASM=${DIR}/jasmin.s
OBJ=${DIR}/jasmin.o

trap "rm -r ${DIR}" EXIT

set -x

$(dirname $0)/../jasminc -g -arch risc-v -o ${ASM} "$@"

# Set default ASSEMBLY_CHECKER
ASSEMBLY_CHECKER=${ASSEMBLY_CHECKER:-llvm-mc}
ASSEMBLY_CHECKER_OPTIONS=${ASSEMBLY_CHECKER_OPTIONS:---triple=riscv32 --mcpu=generic-rv32 -mattr=+m --filetype=obj}
# Detect operating system
UNAME_S=$(uname -s)

# Conditionally set ASSEMBLY_CHECKER for Darwin (macOS)
if [ "$UNAME_S" == "Darwin" ]; then
ASSEMBLY_CHECKER="riscv64-unknown-elf-as"
ASSEMBLY_CHECKER_OPTIONS=""
elif [ "$UNAME_S" == "Linux" ]; then
ASSEMBLY_CHECKER="llvm-mc"
ASSEMBLY_CHECKER_OPTIONS="--triple=riscv32 --mcpu=generic-rv32 -mattr=+m --filetype=obj"
fi

# Check if the assembly checker binary exists and is executable
if ! command -v "$ASSEMBLY_CHECKER" &> /dev/null; then
echo "Error: $ASSEMBLY_CHECKER is not installed or not found in PATH."
exit 1
fi

${ASSEMBLY_CHECKER} ${ASSEMBLY_CHECKER_OPTIONS} -o ${OBJ} ${ASM}
4 changes: 4 additions & 0 deletions compiler/src/CLI_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ let check_options () =
then warning Experimental Location.i_dummy
"support of the ARMv7 architecture is experimental";

if !target_arch = RISCV
then warning Experimental Location.i_dummy
"support of the RISC-V architecture is really experimental";

if !ec_list <> []
|| !ecfile <> ""
|| !ec_array_path <> Filename.current_dir_name
Expand Down
13 changes: 9 additions & 4 deletions compiler/src/arch_full.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ open Arch_extra
open Prog

type 'a callstyle =
| StackDirect (* call instruction push the return address on top of the stack *)
| ByReg of 'a option (* call instruction store the return address on a register,
(Some r) neams that the register is forced to be r *)
| StackDirect
(* call instruction push the return address on top of the stack *)
| ByReg of { call : 'a option; return : bool }
(* call instruction store the return address on a register,
- call: (Some r) means that the register is forced to be r
- return:
+ true means that the register is also used for the return
+ false means that there is no constraint (stack is also ok) *)

(* TODO: check that we cannot use sth already defined on the Coq side *)

Expand Down Expand Up @@ -191,7 +196,7 @@ module Arch_from_Core_arch (A : Core_arch) :
let callstyle =
match A.callstyle with
| StackDirect -> StackDirect
| ByReg o -> ByReg (Option.map var_of_reg o)
| ByReg { call; return } -> ByReg { call = Option.map var_of_reg call; return }

let arch_info = Pretyping.{
pd = reg_size;
Expand Down
12 changes: 9 additions & 3 deletions compiler/src/arch_full.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ open Arch_extra
open Prog

type 'a callstyle =
| StackDirect (* call instruction push the return address on top of the stack *)
| ByReg of 'a option (* call instruction store the return address on a register,
(Some r) neams that the register is forced to be r *)
| StackDirect
(* call instruction push the return address on top of the stack *)
| ByReg of { call : 'a option; return : bool }
(* call instruction store the return address on a register,
- call: (Some r) means that the register is forced to be r
- return:
+ true means that the register is also used for the return
+ false means that there is no constraint (stack is also ok) *)

(* x86 : StackDirect
arm v7 : ByReg (Some ra)
riscV : ByReg (can it be StackDirect too ?)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/arm_arch_full.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ module Arm (Lowering_params : Arm_input) : Arch_full.Core_arch = struct

let pp_asm = Pp_arm_m4.print_prog

let callstyle = Arch_full.ByReg (Some LR)
let callstyle = Arch_full.ByReg { call = Some LR; return = false }
end
4 changes: 4 additions & 0 deletions compiler/src/coreArchFactory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module Core_arch_ARM : Arch_full.Core_arch = Arm_arch_full.Arm (struct
let call_conv = Arm_decl.arm_linux_call_conv
end)

module Core_arch_RISCV : Arch_full.Core_arch = Riscv_arch_full.Riscv (struct
let call_conv = Riscv_decl.riscv_linux_call_conv
end)

let core_arch_x86 ~use_lea ~use_set0 call_conv :
(module Arch_full.Core_arch
with type reg = register
Expand Down
1 change: 1 addition & 0 deletions compiler/src/coreArchFactory.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Core_arch_ARM : Arch_full.Core_arch
module Core_arch_RISCV : Arch_full.Core_arch
open X86_decl

val core_arch_x86 :
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/glob_options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let set_target_arch a =
match a with
| "x86-64" -> X86_64
| "arm-m4" -> ARM_M4
| "risc-v" -> RISCV
| _ -> assert false
in target_arch := a'

Expand Down Expand Up @@ -135,9 +136,11 @@ let print_strings = function
| Compiler.RegArrayExpansion -> "arrexp" , "expansion of register arrays"
| Compiler.RemoveGlobal -> "rmglobals", "remove globals variables"
| Compiler.MakeRefArguments -> "makeref" , "add assignments before and after call to ensure that arguments and results are ref ptr"
| Compiler.LoadConstantsInCond -> "loadconst", "introduce registers for constants appearing in conditions (RISC-V only)"
| Compiler.LowerInstruction -> "lowering" , "lowering of instructions"
| Compiler.PropagateInline -> "propagate", "propagate inline variables"
| Compiler.SLHLowering -> "slhlowering" , "lowering of selective load hardening instructions"
| Compiler.LowerAddressing -> "loweraddr", "lowering of complex addressing modes (RISC-V only)"
| Compiler.StackAllocation -> "stkalloc" , "stack allocation"
| Compiler.RemoveReturn -> "rmreturn" , "remove unused returned values"
| Compiler.RegAllocation -> "ralloc" , "register allocation"
Expand Down Expand Up @@ -207,7 +210,7 @@ let options = [
"-intel", Arg.Unit (set_syntax `Intel), " Use intel syntax (default is AT&T)";
"-ATT", Arg.Unit (set_syntax `ATT), " Use AT&T syntax (default is AT&T)";
"-call-conv", Arg.Symbol (["windows"; "linux"], set_cc), " Select calling convention (default depends on host architecture)";
"-arch", Arg.Symbol (["x86-64"; "arm-m4"], set_target_arch), " Select target arch (default is x86-64)";
"-arch", Arg.Symbol (["x86-64"; "arm-m4"; "risc-v"], set_target_arch), " Select target arch (default is x86-64)";
"-stack-zero",
Arg.Symbol (List.map fst stack_zero_strategies, set_stack_zero_strategy),
" Select stack zeroization strategy for export functions";
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/help.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let show_intrinsics asmOp fmt =
begin match sfx with
| [] -> 0
| PVp _ :: _ -> 1
| PVx _ :: _ -> 2
| (PVs _ | PVx _) :: _ -> 2
| (PVv _ | PVsv _) :: _ -> 3
| PVvv _ :: _ -> 4
end
Expand All @@ -17,7 +17,7 @@ let show_intrinsics asmOp fmt =
let headers = [|
"no size suffix";
"one optional size suffix, e.g., “_64”";
"a zero/sign extend suffix, e.g., “_u32u16”";
"a zero/sign extend suffix, e.g., “_s16” or “_u32u16”";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surprising: does it mean that it is now possible to write MOVSX_s16?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any updates on this issue?

"one vector description suffix, e.g., “_4u64”";
"two vector description suffixes, e.g., “_2u16_2u64”";
"a flag setting suffix (i.e. “S”) and a condition suffix (i.e. “cc”)"
Expand Down
22 changes: 11 additions & 11 deletions compiler/src/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module S = Syntax

let increment_newline s lexbuf =
let newlines = String.count_char s '\n' in
let newlines = String.count_char s '\n' in
for _ = 1 to newlines do
Lexing.new_line lexbuf
done
Expand Down Expand Up @@ -35,8 +35,8 @@

"bool" , T_BOOL ;
"int" , T_INT ;
"const" , CONSTANT;

"const" , CONSTANT;
"downto", DOWNTO ;
"else" , ELSE ;
"exec" , EXEC ;
Expand Down Expand Up @@ -74,7 +74,7 @@
let mk_sign : char option -> S.sign =
function
| Some c -> sign_of_char c
| None -> `Unsigned
| None -> `Unsigned

let size_of_string =
function
Expand All @@ -89,7 +89,7 @@
let mksizesign sw s = size_of_string sw, sign_of_char s

let mk_gensize = function
| "1" -> `W1
| "1" -> `W1
| "2" -> `W2
| "4" -> `W4
| "8" -> `W8
Expand All @@ -101,13 +101,13 @@


let mk_vsize = function
| "2" -> `V2
| "2" -> `V2
| "4" -> `V4
| "8" -> `V8
| "16" -> `V16
| "16" -> `V16
| "32" -> `V32
| _ -> assert false
| _ -> assert false

let mkvsizesign r s g = mk_vsize r, sign_of_char s, mk_gensize g

}
Expand All @@ -127,8 +127,8 @@ let ident = idletter (idletter | digit)*

let size = "8" | "16" | "32" | "64" | "128" | "256"
let signletter = ['s' 'u']
let gensize = "1" | "2" | "4" | "8" | "16" | "32" | "64" | "128"
let vsize = "2" | "4" | "8" | "16" | "32"
let gensize = "1" | "2" | "4" | "8" | "16" | "32" | "64" | "128"
let vsize = "2" | "4" | "8" | "16" | "32"


(* -------------------------------------------------------------------- *)
Expand Down
5 changes: 5 additions & 0 deletions compiler/src/main_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ let main () =
module C = CoreArchFactory.Core_arch_ARM
let analyze _ _ _ _ _ = failwith "TODO_ARM: analyze"
end)
| RISCV ->
(module struct
module C = CoreArchFactory.Core_arch_RISCV
let analyze _ _ _ _ _ = failwith "TODO_RISCV: analyze"
end)
in
let module Arch = Arch_full.Arch_from_Core_arch (P.C) in

Expand Down
Loading