Skip to content

Commit

Permalink
rename inlineAsmSyntax to asmSyntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ASVIEST committed Dec 24, 2023
1 parent 6c5c3c9 commit eec8edd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1538,16 +1538,16 @@ proc genAsmStmt(p: BProc, t: PNode) =
genLineDir(p, t)
var s = newRopeAppender()

var inlineAsmSyntax = ""
var asmSyntax = ""
if (let p = t[0]; p.kind == nkPragma):
for i in p:
if whichPragma(i) == wInlineAsmSyntax:
inlineAsmSyntax = i[1].strVal
if whichPragma(i) == wAsmSyntax:
asmSyntax = i[1].strVal

if inlineAsmSyntax != "" and
if asmSyntax != "" and
not (
inlineAsmSyntax == "gcc" and hasGnuAsm in CC[p.config.cCompiler].props or
inlineAsmSyntax == "vcc" and hasGnuAsm notin CC[p.config.cCompiler].props):
asmSyntax == "gcc" and hasGnuAsm in CC[p.config.cCompiler].props or
asmSyntax == "vcc" and hasGnuAsm notin CC[p.config.cCompiler].props):
localError(
p.config, t.info,
"Your compiler does not support the specified inline assembler")
Expand Down
2 changes: 1 addition & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ proc pragmaAsm*(c: PContext, n: PNode): char =
of wSubsChar:
if it[1].kind == nkCharLit: result = chr(int(it[1].intVal))
else: invalidPragma(c, it)
of wInlineAsmSyntax:
of wAsmSyntax:
let s = expectStrLit(c, it)
if s notin ["gcc", "vcc"]: invalidPragma(c, it)
else: invalidPragma(c, it)
Expand Down
2 changes: 1 addition & 1 deletion compiler/wordrecg.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type
wComputedGoto = "computedGoto", wExperimental = "experimental", wDoctype = "doctype",
wWrite = "write", wGensym = "gensym", wInject = "inject", wDirty = "dirty",
wInheritable = "inheritable", wThreadVar = "threadvar", wEmit = "emit",
wAsmNoStackFrame = "asmNoStackFrame", wInlineAsmSyntax = "inlineAsmSyntax", wImplicitStatic = "implicitStatic",
wAsmNoStackFrame = "asmNoStackFrame", wAsmSyntax = "asmSyntax", wImplicitStatic = "implicitStatic",
wGlobal = "global", wCodegenDecl = "codegenDecl", wUnchecked = "unchecked",
wGuard = "guard", wLocks = "locks", wPartial = "partial", wExplain = "explain",
wLiftLocals = "liftlocals", wEnforceNoRaises = "enforceNoRaises", wSystemRaisesDefect = "systemRaisesDefect",
Expand Down
8 changes: 4 additions & 4 deletions doc/manual_experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -2597,18 +2597,18 @@ method foo(x: Base) {.base.} = discard
It gives an error: method `foo` can be defined only in the same module with its type (Base).
inlineAsmSyntax pragma
asmSyntax pragma
======================
`inlineAsmSyntax` pragma allowing specify target inline assembler syntax in `asm` stmt.
`asmSyntax` pragma allowing specify target inline assembler syntax in `asm` stmt.
It prevents compiling code with different of the target CC inline asm syntax, i.e. it will not allow gcc inline asm code to be compiled with vcc.
```nim
proc nothing() =
asm {.inlineAsmSyntax: "gcc".}"""
asm {.asmSyntax: "gcc".}"""
nop
"""
```
The current C(C++) backend implementation cannot generate code for gcc and for vcc at the same time. For example, `{.inlineAsmSyntax: "vcc".}` with the ICC compiler will not generate code with intel asm syntax, even though ICC can use both gcc-like asm and vcc-like.
The current C(C++) backend implementation cannot generate code for gcc and for vcc at the same time. For example, `{.asmSyntax: "vcc".}` with the ICC compiler will not generate code with intel asm syntax, even though ICC can use both gcc-like asm and vcc-like.

0 comments on commit eec8edd

Please sign in to comment.