Skip to content

Commit

Permalink
Support parameters with local symbols to fix #3
Browse files Browse the repository at this point in the history
Works with Apple clang version 13.1.6 (clang-1316.0.21.2)
  • Loading branch information
praeclarum committed Sep 1, 2022
1 parent 595a07d commit 4ebf028
Show file tree
Hide file tree
Showing 5 changed files with 1,983 additions and 1,958 deletions.
4 changes: 2 additions & 2 deletions Iril/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2213,10 +2213,10 @@ public void WriteAssembly (string path)
if (hasEntryPoint) {
var text = @"{
""runtimeOptions"": {
""tfm"": ""netcoreapp2.1"",
""tfm"": ""net6.0"",
""framework"": {
""name"": ""Microsoft.NETCore.App"",
""version"": ""2.1.0""
""version"": ""6.0.0""
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Iril/IR/FunctionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public enum ParameterAttributes
NoAlias = 1 << 10,
Align8 = 1 << 11,
Byval = 1 << 12,
NoUndef = 1 << 13,
}

public class FunctionDeclaration
Expand Down
10 changes: 10 additions & 0 deletions Iril/IR/IR.jay
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Iril.IR
%token FCMP OEQ OGT OGE OLT OLE ONE ORD UEQ UNE UNO
%token PHI SELECT CALL TAIL VA_ARG ASM SIDEEFFECT
%token LANDINGPAD CATCH CATCHPAD CLEANUPPAD
%token NOUNDEF

%start module

Expand Down Expand Up @@ -532,10 +533,18 @@ parameter
{
$$ = new Parameter (LocalSymbol.None, (LType)$1);
}
| type LOCAL_SYMBOL
{
$$ = new Parameter ((LocalSymbol)$2, (LType)$1);
}
| type parameter_attributes
{
$$ = new Parameter (LocalSymbol.None, (LType)$1);
}
| type parameter_attributes LOCAL_SYMBOL
{
$$ = new Parameter ((LocalSymbol)$3, (LType)$1);
}
| METADATA
{
$$ = new Parameter (LocalSymbol.None, IntegerType.I32);
Expand All @@ -557,6 +566,7 @@ parameter_attributes
parameter_attribute
: NONNULL { $$ = ParameterAttributes.NonNull; }
| NOCAPTURE { $$ = ParameterAttributes.NoCapture; }
| NOUNDEF { $$ = ParameterAttributes.NoUndef; }
| READONLY { $$ = ParameterAttributes.ReadOnly; }
| WRITEONLY { $$ = ParameterAttributes.WriteOnly; }
| READNONE { $$ = ParameterAttributes.ReadNone; }
Expand Down
1 change: 1 addition & 0 deletions Iril/IR/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class MultiCharToken
{ Symbol.Intern ("phi"), Token.PHI },
{ Symbol.Intern ("ret"), Token.RET },
{ Symbol.Intern ("nocapture"), Token.NOCAPTURE },
{ Symbol.Intern ("noundef"), Token.NOUNDEF },
{ Symbol.Intern ("writeonly"), Token.WRITEONLY },
{ Symbol.Intern ("readonly"), Token.READONLY },
{ Symbol.Intern ("attributes"), Token.ATTRIBUTES },
Expand Down
Loading

0 comments on commit 4ebf028

Please sign in to comment.