Skip to content

Commit

Permalink
Merge branch 'master' into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bugdea1er authored Feb 6, 2023
2 parents f5958f5 + 706840b commit 235d26b
Show file tree
Hide file tree
Showing 10 changed files with 4,235 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:

jobs:
windows:
name: Windows Server 2019
runs-on: windows-2019
name: Windows Server 2022
runs-on: windows-2022
steps:
- name: GitHub repository checkout
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/virtual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:

jobs:
windows:
name: Windows Server 2019
runs-on: windows-2019
name: Windows Server 2022
runs-on: windows-2022
steps:
- name: GitHub repository checkout
uses: actions/checkout@v2
Expand Down
29 changes: 29 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ variables:
stages:
- virtual
- llvm
- mips

virtual:
stage: virtual
Expand Down Expand Up @@ -39,6 +40,7 @@ llvm-uemu:
script:
- patch ./scripts/test.sh < ./scripts/llvm-uemu.patch
- ./scripts/test.sh -d
allow_failure: true
tags:
- R2LIN

Expand All @@ -50,5 +52,32 @@ llvm-baikal:
script:
- patch ./scripts/test.sh < ./scripts/llvm-baikal.patch
- ./scripts/test.sh -d
allow_failure: true
tags:
- R2LIN

mips-uemu:
stage: mips
before_script:
- apt-get update
- apt-get install -y build-essential cmake clang-11 gcc-mipsel-linux-gnu git
- rm -rf ../uemu
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.softcom.su/ruc/uemu ../uemu
script:
- patch ./scripts/test.sh < ./scripts/mips-uemu.patch
- ./scripts/test.sh -d
allow_failure: true
tags:
- R2LIN

mips-baikal:
stage: mips
before_script:
- apt-get update
- apt-get install -y build-essential cmake clang-11 gcc-mipsel-linux-gnu sshpass
script:
- patch ./scripts/test.sh < ./scripts/mips-baikal.patch
- ./scripts/test.sh -d
allow_failure: true
tags:
- R2LIN
5 changes: 2 additions & 3 deletions libs/compiler/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#pragma once

#include "syntax.h"
#include "uniio.h"
#include "workspace.h"


Expand All @@ -28,8 +27,8 @@ extern "C" {
/**
* Encode to virtual machine codes
*
* @param ws Compiler workspace
* @param sx Syntax structure
* @param ws Compiler workspace
* @param sx Syntax structure
*
* @return @c 0 on success, @c -1 on failure
*/
Expand Down
38 changes: 38 additions & 0 deletions libs/compiler/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>
#include "codegen.h"
#include "errors.h"
#include "mipsgen.h"
#include "llvmgen.h"
#include "parser.h"
#include "preprocessor.h"
Expand Down Expand Up @@ -168,6 +169,10 @@ status_t compile(workspace *const ws)
{
return compile_to_llvm(ws);
}
else if (strcmp(flag, "-MIPS") == 0)
{
return compile_to_mips(ws);
}
}
}

Expand Down Expand Up @@ -198,6 +203,16 @@ status_t compile_to_llvm(workspace *const ws)
return sts == sts_codegen_error ? sts_llvm_error : sts;
}

int compile_to_mips(workspace *const ws)
{
if (ws_get_output(ws) == NULL)
{
ws_set_output(ws, DEFAULT_MIPS);
}

return compile_from_ws(ws, &encode_to_mips);
}



int auto_compile(const int argc, const char *const *const argv)
Expand All @@ -224,6 +239,14 @@ int auto_compile_to_llvm(const int argc, const char *const *const argv)
return ret;
}

int auto_compile_to_mips(const int argc, const char *const *const argv)
{
workspace ws = ws_parse_args(argc, argv);
const int ret = compile_to_mips(&ws);
ws_clear(&ws);
return ret;
}


int no_macro_compile_to_vm(const char *const path)
{
Expand Down Expand Up @@ -259,3 +282,18 @@ int no_macro_compile_to_llvm(const char *const path)
ws_clear(&ws);
return ret;
}

int no_macro_compile_to_mips(const char *const path)
{
universal_io io = io_create();
in_set_file(&io, path);

workspace ws = ws_create();
ws_add_file(&ws, path);
ws_set_output(&ws, DEFAULT_MIPS);
out_set_file(&io, ws_get_output(&ws));

const int ret = compile_from_io(&ws, &io, &encode_to_mips);
ws_clear(&ws);
return ret;
}
28 changes: 28 additions & 0 deletions libs/compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ EXPORTED status_t compile_to_vm(workspace *const ws);
*/
EXPORTED status_t compile_to_llvm(workspace *const ws);

/**
* Compile MIPS code from workspace
*
* @param ws Compiler workspace
*
* @return Status code
*/
EXPORTED int compile_to_mips(workspace *const ws);


/**
* Compile code from terminal arguments
Expand Down Expand Up @@ -102,6 +111,16 @@ EXPORTED int auto_compile_to_vm(const int argc, const char *const *const argv);
*/
EXPORTED int auto_compile_to_llvm(const int argc, const char *const *const argv);

/**
* Compile MIPS code from terminal arguments
*
* @param argc Number of command line arguments
* @param argv Command line arguments
*
* @return Status code
*/
EXPORTED int auto_compile_to_mips(const int argc, const char *const *const argv);


/**
* Compile RuC virtual machine code with no macro
Expand All @@ -121,6 +140,15 @@ EXPORTED int no_macro_compile_to_vm(const char *const path);
*/
EXPORTED int no_macro_compile_to_llvm(const char *const path);

/**
* Compile MIPS code with no macro
*
* @param path File path
*
* @return Status code
*/
EXPORTED int no_macro_compile_to_mips(const char *const path);

#ifdef __cplusplus
} /* extern "C" */
#endif
Loading

0 comments on commit 235d26b

Please sign in to comment.