'pure' is now 'noStackFrame' for procs
This commit is contained in:
parent
ffefb736d9
commit
5cba831c88
6 changed files with 28 additions and 21 deletions
|
|
@ -21,8 +21,9 @@ const
|
||||||
const
|
const
|
||||||
procPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
procPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||||
wMagic, wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader,
|
wMagic, wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader,
|
||||||
wCompilerProc, wPure, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
|
wCompilerProc, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
|
||||||
wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC}
|
wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC,
|
||||||
|
wNoStackFrame}
|
||||||
converterPragmas* = procPragmas
|
converterPragmas* = procPragmas
|
||||||
methodPragmas* = procPragmas
|
methodPragmas* = procPragmas
|
||||||
macroPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
macroPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||||
|
|
@ -38,8 +39,8 @@ const
|
||||||
wCheckpoint, wPassL, wPassC, wDeadCodeElim, wDeprecated, wFloatChecks,
|
wCheckpoint, wPassL, wPassC, wDeadCodeElim, wDeprecated, wFloatChecks,
|
||||||
wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd}
|
wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd}
|
||||||
lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||||
wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader, wPure,
|
wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader,
|
||||||
wDeprecated, wExtern, wThread, wImportcpp, wImportobjc}
|
wDeprecated, wExtern, wThread, wImportcpp, wImportobjc, wNoStackFrame}
|
||||||
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
|
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
|
||||||
wPure, wHeader, wCompilerProc, wFinal, wSize, wExtern, wShallow,
|
wPure, wHeader, wCompilerProc, wFinal, wSize, wExtern, wShallow,
|
||||||
wImportcpp, wImportobjc}
|
wImportcpp, wImportobjc}
|
||||||
|
|
@ -448,7 +449,7 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
of wNodecl:
|
of wNodecl:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
incl(sym.loc.Flags, lfNoDecl)
|
incl(sym.loc.Flags, lfNoDecl)
|
||||||
of wPure:
|
of wPure, wNoStackFrame:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
if sym != nil: incl(sym.flags, sfPure)
|
if sym != nil: incl(sym.flags, sfPure)
|
||||||
of wVolatile:
|
of wVolatile:
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ type
|
||||||
wFieldChecks,
|
wFieldChecks,
|
||||||
wCheckPoint, wSubsChar,
|
wCheckPoint, wSubsChar,
|
||||||
wAcyclic, wShallow, wUnroll, wLinearScanEnd,
|
wAcyclic, wShallow, wUnroll, wLinearScanEnd,
|
||||||
wWrite, wPutEnv, wPrependEnv, wAppendEnv, wThreadVar, wEmit
|
wWrite, wPutEnv, wPrependEnv, wAppendEnv, wThreadVar, wEmit, wNoStackFrame
|
||||||
|
|
||||||
TSpecialWords* = set[TSpecialWord]
|
TSpecialWords* = set[TSpecialWord]
|
||||||
|
|
||||||
|
|
@ -99,7 +99,8 @@ const
|
||||||
"passc", "passl", "borrow", "fieldchecks",
|
"passc", "passl", "borrow", "fieldchecks",
|
||||||
"checkpoint",
|
"checkpoint",
|
||||||
"subschar", "acyclic", "shallow", "unroll", "linearscanend",
|
"subschar", "acyclic", "shallow", "unroll", "linearscanend",
|
||||||
"write", "putenv", "prependenv", "appendenv", "threadvar", "emit"]
|
"write", "putenv", "prependenv", "appendenv", "threadvar", "emit",
|
||||||
|
"nostackframe"]
|
||||||
|
|
||||||
proc findStr*(a: openarray[string], s: string): int =
|
proc findStr*(a: openarray[string], s: string): int =
|
||||||
for i in countup(low(a), high(a)):
|
for i in countup(low(a), high(a)):
|
||||||
|
|
|
||||||
|
|
@ -1853,7 +1853,7 @@ Nimrod identifiers shall be enclosed in a special character which can be
|
||||||
specified in the statement's pragmas. The default special character is ``'`'``:
|
specified in the statement's pragmas. The default special character is ``'`'``:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
proc addInt(a, b: int): int {.pure.} =
|
proc addInt(a, b: int): int {.noStackFrame.} =
|
||||||
# a in eax, and b in edx
|
# a in eax, and b in edx
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
|
|
@ -2900,12 +2900,17 @@ structure:
|
||||||
|
|
||||||
Pure pragma
|
Pure pragma
|
||||||
-----------
|
-----------
|
||||||
The `pure`:idx: pragma serves two completely different purposes:
|
An object type can be marked with the `pure`:idx: pragma so that its type
|
||||||
1. To mark a procedure that Nimrod should not generate any exit statements like
|
field which is used for runtime type identification is omitted. This is
|
||||||
``return result;`` in the generated code. This is useful for procs that only
|
necessary for binary compatibility with other compiled languages.
|
||||||
consist of an assembler statement.
|
|
||||||
2. To mark an object type so that its type field should be omitted. This is
|
|
||||||
necessary for binary compatibility with other compiled languages.
|
NoStackFrame pragma
|
||||||
|
-------------------
|
||||||
|
A proc can be marked with the `noStackFrame`:idx: pragma to tell the compiler
|
||||||
|
it should not generate a stack frame for the proc. There are also no exit
|
||||||
|
statements like ``return result;`` generated. This is useful for procs that
|
||||||
|
only consist of an assembler statement.
|
||||||
|
|
||||||
|
|
||||||
error pragma
|
error pragma
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ const
|
||||||
when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
# assembler optimized versions for compilers that
|
# assembler optimized versions for compilers that
|
||||||
# have an intel syntax assembler:
|
# have an intel syntax assembler:
|
||||||
proc addInt(a, b: int): int {.compilerProc, pure.} =
|
proc addInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
||||||
# a in eax, and b in edx
|
# a in eax, and b in edx
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
|
|
@ -121,7 +121,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt(a, b: int): int {.compilerProc, pure.} =
|
proc subInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
sub eax, `b`
|
sub eax, `b`
|
||||||
|
|
@ -130,7 +130,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc negInt(a: int): int {.compilerProc, pure.} =
|
proc negInt(a: int): int {.compilerProc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
neg eax
|
neg eax
|
||||||
|
|
@ -139,7 +139,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt(a, b: int): int {.compilerProc, pure.} =
|
proc divInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
@ -150,7 +150,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt(a, b: int): int {.compilerProc, pure.} =
|
proc modInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
@ -162,7 +162,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt(a, b: int): int {.compilerProc, pure.} =
|
proc mulInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -7,7 +7,6 @@ Version 0.8.14
|
||||||
not have an inbox per default
|
not have an inbox per default
|
||||||
- add --deadlock_prevention:on|off switch? timeout for locks?
|
- add --deadlock_prevention:on|off switch? timeout for locks?
|
||||||
- make threadvar efficient again on linux after testing
|
- make threadvar efficient again on linux after testing
|
||||||
- ``pure`` --> ``noStackFrame``, ``noRtti``
|
|
||||||
|
|
||||||
|
|
||||||
version 0.9.0
|
version 0.9.0
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ Changes affecting backwards compatibility
|
||||||
- ``implies`` is no keyword anymore.
|
- ``implies`` is no keyword anymore.
|
||||||
- The ``is`` operator is now the ``of`` operator.
|
- The ``is`` operator is now the ``of`` operator.
|
||||||
- The ``is`` operator is now used to check type equivalence in generic code.
|
- The ``is`` operator is now used to check type equivalence in generic code.
|
||||||
|
- The ``pure`` pragma for procs has been renamed to ``noStackFrame``.
|
||||||
|
|
||||||
|
|
||||||
Language Additions
|
Language Additions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue