Skip to content

Commit

Permalink
Fix several bugs; Add [data_layout] and [triple] command-line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
MatwayBurkow committed Aug 17, 2020
1 parent dad5182 commit 4cb33b9
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 198 deletions.
12 changes: 6 additions & 6 deletions Var.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ isPlain: [

isTinyArg: [
refToVar: processor: ;;
#refToVar isPlain [
# var: refToVar getVar;
# var.data.getTag VarRef =
#] ||

refToVar isUnallocable ~
[refToVar @processor getStorageSize processor.options.pointerSize 8nx / 2nx * > ~] &&
[
refToVar isPlain
[
refToVar @processor getStorageSize processor.options.pointerSize 8nx / > ~
] ||
] &&
];

isUnallocable: [
Expand Down
2 changes: 1 addition & 1 deletion build/compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

FOR /F "tokens=*" %%v IN ('git log --date^=format:%%y%%m%%d --format^=%%cd -1') DO SET SOURCE_VERSION=%%v

mplc.exe -D COMPILER_SOURCE_VERSION=%SOURCE_VERSION% -D DEBUG=FALSE -D DEBUG_MEMORY=TRUE -I ../sl -call_trace 0 -debug_memory -ndebug -o mplc.ll ../main.mpl
mplc.exe -D COMPILER_SOURCE_VERSION=%SOURCE_VERSION% -D DEBUG=TRUE -D DEBUG_MEMORY=TRUE -I ../sl -call_trace 0 -debug_memory -ndebug -o mplc.ll ../main.mpl
37 changes: 9 additions & 28 deletions codeNode.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ updateInputCountInMatchingInfo: [
updateInputCount: [
delta: block:;;


delta @block.@buildingMatchingInfo updateInputCountInMatchingInfo
block.state NodeStateNew = [
delta @block.@matchingInfo updateInputCountInMatchingInfo
Expand Down Expand Up @@ -319,29 +320,6 @@ setTopologyIndex: [
] when
];

getStackEntryForPreInput: [
copy depth:;
depth @processor block getStackDepth < [
entry: depth @processor block getStackEntry;
[entry getVar.host block is ~] "Pre input is just in inputs!" assert
shadowBegin: RefToVar;
shadowEnd: RefToVar;
entry @shadowBegin @shadowEnd ShadowReasonInput @processor @block makeShadows

newEvent: ShadowEvent;
ShadowReasonInput @newEvent.setTag
branch: ShadowReasonInput @newEvent.get;
shadowBegin @branch.@refToVar set
ArgMeta @branch.@argCase set
@block @shadowBegin setTopologyIndex
@newEvent @block addShadowEvent

shadowEnd
] [
RefToVar
] if
];

makeVarCode: [VarCode @processor @block createVariable];
makeVarInt8: [VarInt8 @processor @block checkValue makeValuePair VarInt8 @processor @block createVariable @processor @block createPlainIR];
makeVarInt16: [VarInt16 @processor @block checkValue makeValuePair VarInt16 @processor @block createVariable @processor @block createPlainIR];
Expand Down Expand Up @@ -1725,7 +1703,7 @@ callCallable: [
var.data.getTag VarStruct = [
@predicate call
] [
[FALSE] "Wrong type to call!" assert
"not callable" @processor @block compilerError
] if
] if
] if
Expand Down Expand Up @@ -2957,7 +2935,7 @@ addMatchingNode: [

astArrayIndex @block.@astArrayIndex set

astArrayIndex processor.matchingNodes.size < [astArrayIndex processor.matchingNodes.at.assigned] && [
astArrayIndex processor.matchingNodes.size < [astArrayIndex processor.matchingNodes.at.valid?] && [
#it exists
] [
tableValue: MatchingNode;
Expand Down Expand Up @@ -3511,6 +3489,9 @@ makeCompilerPosition: [

hasForcedSignature [
forcedSignature @block.@csignature set
validInputCount forcedSignature.inputs.getSize = ~ [
inputCountMismatch
] when
] when

addRefOrCopyArg: [
Expand Down Expand Up @@ -3620,13 +3601,13 @@ makeCompilerPosition: [
] loop
] when

invalidOutputCount: block.matchingInfo.inputs.getSize block.matchingInfo.maxInputCount -;

block.parent 0 =
[block.stack.size 0 >] && [
[block.stack.size invalidOutputCount >] && [
"module can not have inputs or outputs" @processor block compilerError
] when

invalidOutputCount: block.matchingInfo.inputs.getSize block.matchingInfo.maxInputCount -;

@block.@outputs.clear
i: invalidOutputCount copy dynamic;
[
Expand Down
23 changes: 20 additions & 3 deletions defaultImpl.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FailProcForProcessor: [{
trace storageAddress 0nx = [
FALSE
] [
(trace.name trace.line copy trace.column copy) " in %s at %i:%i\n\00" printf
(trace.name trace.line copy trace.column copy) " in %s at %i:%i\n\00" printf drop
trace.prev trace addressToReference !trace
TRUE
] if
Expand Down Expand Up @@ -193,6 +193,10 @@ getStackEntryWith: [
] [
depth currentBlock.stack.size < [
currentBlock.stack.size 1 - depth - @currentBlock.@stack.at !result
check [result getVar.data.getTag VarInvalid =] && [
"stack underflow" @processor block compilerError
] when

FALSE
] [
depth currentBlock.stack.size - currentBlock.buildingMatchingInfo.inputs.size + @depth set
Expand Down Expand Up @@ -231,9 +235,22 @@ getStackDepth: [
processor: Processor Cref;
} () {} [
processor: block:;;

("stack:" LF "depth=" processor block getStackDepth LF) printList
hasInvalid: FALSE dynamic;
depth: 0 dynamic;
@processor @block getStackDepth [
hasInvalid ~ [
entry: i @processor block getStackEntryUnchecked;
entry getVar.data.getTag VarInvalid = [
TRUE !hasInvalid
] [
depth 1 + !depth
] if
] when
] times

("stack:" LF "depth=" depth LF) printList

depth [
entry: i @processor block getStackEntryUnchecked;
(entry @processor block getMplType entry.mutable ["R"] ["C"] if entry getVar.temporary ["T"] [""] if
entry isPlain [entry getPlainValueInformation] [String] if LF) printList
Expand Down
Loading

0 comments on commit 4cb33b9

Please sign in to comment.